Improve how element editor is opened to edit an element in a diagram.

Before this commit :
ElementPropertiesWidget emit a signal of Diagram to edit an element, and
the signal goes up from Diagram -> DiagramView -> ProjectView ->
QetDiagramEditor and QetDiagramEditor call a static function.
Now :
ElementPropertiesWidget call the static function itself and that all.
All unnecessary signals are removed.
This commit is contained in:
Claveau Joshua 2020-10-02 19:28:52 +02:00
parent e263264752
commit 8507040aa2
8 changed files with 3 additions and 35 deletions

View File

@ -282,9 +282,6 @@ class Diagram : public QGraphicsScene
/// from the diagram within elements collection
void findElementRequired(const ElementsLocation &);
/// Signal emitted when users wish to edit an element from the diagram
void editElementRequired(const ElementsLocation &);
void diagramActivated();
};
Q_DECLARE_METATYPE(Diagram *)

View File

@ -91,7 +91,6 @@ DiagramView::DiagramView(Diagram *diagram, QWidget *parent) :
connect(m_diagram, SIGNAL(showDiagram(Diagram*)), this, SIGNAL(showDiagram(Diagram*)));
connect(m_diagram, SIGNAL(sceneRectChanged(QRectF)), this, SLOT(adjustSceneRect()));
connect(&(m_diagram -> border_and_titleblock), SIGNAL(diagramTitleChanged(const QString &)), this, SLOT(updateWindowTitle()));
connect(diagram, SIGNAL(editElementRequired(ElementsLocation)), this, SIGNAL(editElementRequired(ElementsLocation)));
connect(diagram, SIGNAL(findElementRequired(ElementsLocation)), this, SIGNAL(findElementRequired(ElementsLocation)));
QShortcut *edit_conductor_color_shortcut = new QShortcut(QKeySequence(Qt::Key_F2), this);

View File

@ -108,8 +108,6 @@ class DiagramView : public QGraphicsView
void titleChanged(DiagramView *, const QString &);
/// Signal emitted when users wish to locate an element from the diagram within elements collection
void findElementRequired(const ElementsLocation &);
/// Signal emitted when users wish to edit an element from the diagram
void editElementRequired(const ElementsLocation &);
/// Signal emmitted when diagram must be show
void showDiagram (Diagram *);
/// Signal emmtted when free rubberband changed.

View File

@ -888,7 +888,6 @@ void ProjectView::diagramAdded(Diagram *diagram)
connect(dv, &DiagramView::showDiagram, this, QOverload<Diagram*>::of(&ProjectView::showDiagram));
connect(dv, &DiagramView::titleChanged, this, &ProjectView::updateTabTitle);
connect(dv, &DiagramView::findElementRequired, this, &ProjectView::findElementRequired);
connect(dv, &DiagramView::editElementRequired, this, &ProjectView::editElementRequired);
connect(&dv->diagram()->border_and_titleblock , &BorderTitleBlock::titleBlockFolioChanged, [this, dv]() {this->updateTabTitle(dv);});
// signal diagram view was added

View File

@ -135,7 +135,6 @@ class ProjectView : public QWidget
void errorEncountered(const QString &);
// relayed signals
void findElementRequired(const ElementsLocation &);
void editElementRequired(const ElementsLocation &);
private:
void initActions();

View File

@ -1757,8 +1757,6 @@ void QETDiagramEditor::addProjectView(ProjectView *project_view)
//Manage request for edit or find element and titleblock
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)),
@ -2260,27 +2258,6 @@ void QETDiagramEditor::findElementInPanel(const ElementsLocation &location)
m_element_collection_widget->setCurrentLocation(location);
}
/**
Lance l'editeur d'element pour l'element filename
@param location Emplacement de l'element a editer
*/
void QETDiagramEditor::editElementInEditor(const ElementsLocation &location)
{
QETApp::instance() -> openElementLocations(QList<ElementsLocation>()
<< location);
}
/**
Launch an element editor to edit the selected element in the current
diagram view.
*/
void QETDiagramEditor::editSelectedElementInEditor()
{
if (Element *selected_element = currentElement()) {
editElementInEditor(selected_element -> location());
}
}
/**
Show the error message contained in \a result.
*/
@ -2306,7 +2283,7 @@ void QETDiagramEditor::showError(const QString &error)
*/
void QETDiagramEditor::subWindowActivated(QMdiSubWindow *subWindows)
{
Q_UNUSED(subWindows);
Q_UNUSED(subWindows)
slot_updateActions();
slot_updateWindowsMenu();

View File

@ -134,8 +134,6 @@ class QETDiagramEditor : public QETMainWindow
void reloadOldElementPanel();
void diagramWasAdded(DiagramView *);
void findElementInPanel(const ElementsLocation &);
void editElementInEditor(const ElementsLocation &);
void editSelectedElementInEditor();
void showError(const QETResult &);
void showError(const QString &);
void subWindowActivated(QMdiSubWindow *subWindows);

View File

@ -26,6 +26,7 @@
#include "dynamicelementtextitemeditor.h"
#include "dynamicelementtextitem.h"
#include "elementtextitemgroup.h"
#include "qetapp.h"
#include <QVBoxLayout>
#include <QLabel>
@ -245,7 +246,7 @@ void ElementPropertiesWidget::editElement()
if (m_element && m_diagram)
{
m_diagram->findElementRequired(m_element.data()->location());
m_diagram->editElementRequired(m_element.data()->location());
QETApp::instance()->openElementLocations(QList<ElementsLocation>() << m_element.data()->location());
emit findEditClicked();
}
}