mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-04-06 21:39:59 +02:00
Add highlight current page in ProjectView
- on clicking project tab - on moving diagram tab - on adding project - on adding diagram
This commit is contained in:
@@ -139,15 +139,26 @@ QTreeWidgetItem *ElementsPanel::addProject(QETProject *project,
|
|||||||
Q_UNUSED(options)
|
Q_UNUSED(options)
|
||||||
|
|
||||||
bool first_add = (first_reload_ || !projects_to_display_.contains(project));
|
bool first_add = (first_reload_ || !projects_to_display_.contains(project));
|
||||||
|
clearSelection();
|
||||||
|
|
||||||
// create the QTreeWidgetItem representing the project
|
// create the QTreeWidgetItem representing the project
|
||||||
QTreeWidgetItem *qtwi_project = GenericPanel::addProject(project, nullptr, GenericPanel::All);
|
QTreeWidgetItem *qtwi_project = GenericPanel::addProject(project, nullptr, GenericPanel::All);
|
||||||
// the project will be inserted right before the common tb templates collection
|
// the project will be inserted right before the common tb templates collection
|
||||||
invisibleRootItem() -> insertChild(
|
invisibleRootItem() -> insertChild(
|
||||||
indexOfTopLevelItem(common_tbt_collection_item_),
|
indexOfTopLevelItem(common_tbt_collection_item_),
|
||||||
qtwi_project
|
qtwi_project
|
||||||
);
|
);
|
||||||
if (first_add) qtwi_project -> setExpanded(true);
|
if (first_add){
|
||||||
|
qtwi_project -> setExpanded(true);
|
||||||
|
// on adding an project select first diagram
|
||||||
|
setCurrentItem(qtwi_project -> child(0));
|
||||||
|
qtwi_project -> child(0)->setSelected(true);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// on adding an diagram to project select the last diagram
|
||||||
|
setCurrentItem(qtwi_project->child(qtwi_project->childCount()-2));
|
||||||
|
qtwi_project->child(qtwi_project->childCount()-2)->setSelected(true);
|
||||||
|
}
|
||||||
|
|
||||||
if (TitleBlockTemplatesCollection *tbt_collection = project -> embeddedTitleBlockTemplatesCollection()) {
|
if (TitleBlockTemplatesCollection *tbt_collection = project -> embeddedTitleBlockTemplatesCollection()) {
|
||||||
if (QTreeWidgetItem *tbt_collection_qtwi = itemForTemplatesCollection(tbt_collection)) {
|
if (QTreeWidgetItem *tbt_collection_qtwi = itemForTemplatesCollection(tbt_collection)) {
|
||||||
|
|||||||
@@ -766,7 +766,6 @@ void GenericPanel::projectDiagramsOrderChanged(QETProject *project,
|
|||||||
if (!moved_qtwi_diagram) return;
|
if (!moved_qtwi_diagram) return;
|
||||||
|
|
||||||
// remove the QTWI then insert it back at the adequate location
|
// remove the QTWI then insert it back at the adequate location
|
||||||
bool was_selected = moved_qtwi_diagram -> isSelected();
|
|
||||||
qtwi_project -> removeChild (moved_qtwi_diagram);
|
qtwi_project -> removeChild (moved_qtwi_diagram);
|
||||||
qtwi_project -> insertChild (to, moved_qtwi_diagram);
|
qtwi_project -> insertChild (to, moved_qtwi_diagram);
|
||||||
|
|
||||||
@@ -781,8 +780,8 @@ void GenericPanel::projectDiagramsOrderChanged(QETProject *project,
|
|||||||
updateDiagramItem(qtwi_diagram, diagram);
|
updateDiagramItem(qtwi_diagram, diagram);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (was_selected)
|
// select the moved diagram
|
||||||
setCurrentItem(moved_qtwi_diagram);
|
setCurrentItem(qtwi_project -> child(from));
|
||||||
|
|
||||||
emit(panelContentChanged());
|
emit(panelContentChanged());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1841,6 +1841,18 @@ void QETDiagramEditor::addProjectView(ProjectView *project_view)
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//Highlight the current page in projectView on project activation
|
||||||
|
connect(this, &QETDiagramEditor::syncElementsPanel, this, [this]() {
|
||||||
|
if (pa && currentDiagramView()) {
|
||||||
|
// In the tree, find the element that corresponds to the diagram of the selected project.
|
||||||
|
QTreeWidgetItem *item = pa->elementsPanel().getItemForDiagram(currentDiagramView()->diagram());
|
||||||
|
if (item) {
|
||||||
|
// select the diagram
|
||||||
|
pa->elementsPanel().setCurrentItem(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
//We maximise the new window if the current window is inexistent or maximized
|
//We maximise the new window if the current window is inexistent or maximized
|
||||||
QWidget *current_window = m_workspace.activeSubWindow();
|
QWidget *current_window = m_workspace.activeSubWindow();
|
||||||
bool maximise = ((!current_window)
|
bool maximise = ((!current_window)
|
||||||
@@ -2349,6 +2361,7 @@ void QETDiagramEditor::subWindowActivated(QMdiSubWindow *subWindows)
|
|||||||
|
|
||||||
slot_updateActions();
|
slot_updateActions();
|
||||||
slot_updateWindowsMenu();
|
slot_updateWindowsMenu();
|
||||||
|
emit syncElementsPanel();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -98,6 +98,9 @@ class QETDiagramEditor : public QETMainWindow
|
|||||||
ProjectView *findProject(const QString &) const;
|
ProjectView *findProject(const QString &) const;
|
||||||
QMdiSubWindow *subWindowForWidget(QWidget *) const;
|
QMdiSubWindow *subWindowForWidget(QWidget *) const;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void syncElementsPanel();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void save();
|
void save();
|
||||||
void saveAs();
|
void saveAs();
|
||||||
|
|||||||
Reference in New Issue
Block a user