From a12198294f5028ed734bf82e79c6dbbdb100a403 Mon Sep 17 00:00:00 2001 From: blacksun Date: Mon, 1 May 2017 11:42:55 +0000 Subject: [PATCH] Re-enable the button "find element in panel". git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4953 bfdf4180-ca20-0410-9c96-a3a8aa849046 --- .../elementscollectionwidget.cpp | 13 +++++++++++++ .../elementscollectionwidget.h | 1 + sources/qetdiagrameditor.cpp | 17 +++++++++-------- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/sources/ElementsCollection/elementscollectionwidget.cpp b/sources/ElementsCollection/elementscollectionwidget.cpp index 2310aaf65..fc98f7eb1 100644 --- a/sources/ElementsCollection/elementscollectionwidget.cpp +++ b/sources/ElementsCollection/elementscollectionwidget.cpp @@ -115,6 +115,19 @@ void ElementsCollectionWidget::highlightUnusedElement() m_model->highlightUnusedElement(); } +/** + * @brief ElementsCollectionWidget::setCurrentLocation + * Set the current item to be the item for @location + * @param location + */ +void ElementsCollectionWidget::setCurrentLocation(const ElementsLocation &location) +{ + if (!location.exist()) + return; + + m_tree_view->setCurrentIndex(m_model->indexFromLocation(location)); +} + bool ElementsCollectionWidget::event(QEvent *event) { if (m_first_show && event->type() == QEvent::WindowActivate) { diff --git a/sources/ElementsCollection/elementscollectionwidget.h b/sources/ElementsCollection/elementscollectionwidget.h index f5c59e795..53df8a050 100644 --- a/sources/ElementsCollection/elementscollectionwidget.h +++ b/sources/ElementsCollection/elementscollectionwidget.h @@ -51,6 +51,7 @@ class ElementsCollectionWidget : public QWidget void addProject (QETProject *project); void removeProject (QETProject *project); void highlightUnusedElement(); + void setCurrentLocation(const ElementsLocation &location); protected: virtual bool event(QEvent *event); diff --git a/sources/qetdiagrameditor.cpp b/sources/qetdiagrameditor.cpp index 604b3e6cb..0ab13b22b 100644 --- a/sources/qetdiagrameditor.cpp +++ b/sources/qetdiagrameditor.cpp @@ -1516,8 +1516,8 @@ void QETDiagramEditor::addProjectView(ProjectView *project_view) connect(project, SIGNAL(readOnlyChanged(QETProject *, bool)), this, SLOT(slot_updateActions())); //Manage request for edit or find element and titleblock - connect(project_view, SIGNAL(findElementRequired(const ElementsLocation &)), this, SLOT(findElementInPanel(const ElementsLocation &))); - connect(project_view, SIGNAL(editElementRequired(const ElementsLocation &)), this, SLOT(editElementInEditor(const ElementsLocation &))); + connect (project_view, &ProjectView::findElementRequired, this, &QETDiagramEditor::findElementInPanel); + connect (project_view, &ProjectView::editElementRequired, this, &QETDiagramEditor::editElementInEditor); // display error messages sent by the project view connect(project_view, SIGNAL(errorEncountered(QString)), this, SLOT(showError(const QString &))); @@ -2065,12 +2065,13 @@ void QETDiagramEditor::diagramWasAdded(DiagramView *dv) } /** - @param location Emplacement de l'element a retrouver dans le panel - d'elements. -*/ -void QETDiagramEditor::findElementInPanel(const ElementsLocation &location) { - //@TODO implement this method for the new element panel - Q_UNUSED (location); + * @brief QETDiagramEditor::findElementInPanel + * Find the item for @location in the element panel + * @param location + */ +void QETDiagramEditor::findElementInPanel(const ElementsLocation &location) +{ + m_element_collection_widget->setCurrentLocation(location); } /**