mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-03-30 06:39:58 +02:00
Merge pull request #443 from Kellermorph/master
Feature: Auto-select active diagram in the elements panel tree
This commit is contained in:
@@ -95,8 +95,8 @@ class GenericPanel : public QTreeWidget {
|
||||
virtual QTreeWidgetItem *addDiagram(Diagram *,
|
||||
QTreeWidgetItem * = nullptr,
|
||||
PanelOptions = AddAllChild);
|
||||
protected:
|
||||
virtual QTreeWidgetItem *getItemForDiagram(Diagram *, bool * = nullptr);
|
||||
protected:
|
||||
virtual QTreeWidgetItem *updateDiagramItem(QTreeWidgetItem *,
|
||||
Diagram *,
|
||||
PanelOptions = AddAllChild,
|
||||
|
||||
@@ -1168,6 +1168,18 @@ bool QETDiagramEditor::addProject(QETProject *project, bool update_panel)
|
||||
|
||||
// cree un ProjectView pour visualiser le projet
|
||||
ProjectView *project_view = new ProjectView(project);
|
||||
//Highlight the current page
|
||||
connect(project_view, &ProjectView::diagramActivated, this, [this](DiagramView *dv) {
|
||||
if (dv && dv->diagram() && pa) {
|
||||
// 1. Find the item in the tree that corresponds to this diagram
|
||||
QTreeWidgetItem *item = pa->elementsPanel().getItemForDiagram(dv->diagram());
|
||||
|
||||
// 2. If you find it, select it
|
||||
if (item) {
|
||||
pa->elementsPanel().setCurrentItem(item);
|
||||
}
|
||||
}
|
||||
});
|
||||
addProjectView(project_view);
|
||||
|
||||
undo_group.addStack(project -> undoStack());
|
||||
|
||||
Reference in New Issue
Block a user