Clean diagram view code

This commit is contained in:
Claveau Joshua
2020-10-02 18:38:24 +02:00
parent e0201a8027
commit 7038e6f796
3 changed files with 14 additions and 50 deletions

View File

@@ -16,32 +16,20 @@
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "diagramview.h" #include "diagramview.h"
#include "diagram.h"
#include "qetgraphicsitem/conductor.h"
#include "diagramcommands.h" #include "diagramcommands.h"
#include "diagramposition.h"
#include "conductorpropertieswidget.h"
#include "qetgraphicsitem/conductortextitem.h" #include "qetgraphicsitem/conductortextitem.h"
#include "qetgraphicsitem/independenttextitem.h" #include "qetgraphicsitem/independenttextitem.h"
#include "qetgraphicsitem/diagramimageitem.h" #include "qetgraphicsitem/conductor.h"
#include "templatelocation.h"
#include "qetproject.h"
#include "projectview.h" #include "projectview.h"
#include "integrationmovetemplateshandler.h" #include "integrationmovetemplateshandler.h"
#include "qetdiagrameditor.h" #include "qetdiagrameditor.h"
#include "qeticons.h" #include "qeticons.h"
#include "qetmessagebox.h"
#include <QGraphicsObject>
#include <QGraphicsPixmapItem>
#include <QGraphicsSceneMouseEvent>
#include "factory/elementfactory.h"
#include "diagrampropertiesdialog.h" #include "diagrampropertiesdialog.h"
#include "dveventinterface.h" #include "dveventinterface.h"
#include "diagrameventaddelement.h" #include "diagrameventaddelement.h"
#include "QPropertyUndoCommand/qpropertyundocommand.h" #include "QPropertyUndoCommand/qpropertyundocommand.h"
#include "qetshapeitem.h"
#include "undocommand/deleteqgraphicsitemcommand.h"
#include "dynamicelementtextitem.h"
#include "multipastedialog.h" #include "multipastedialog.h"
#include "changetitleblockcommand.h" #include "changetitleblockcommand.h"
#include "conductorcreator.h" #include "conductorcreator.h"
@@ -114,32 +102,7 @@ DiagramView::DiagramView(Diagram *diagram, QWidget *parent) :
Destructeur Destructeur
*/ */
DiagramView::~DiagramView() DiagramView::~DiagramView()
{ {}
}
/**
Selectionne tous les objets du schema
*/
void DiagramView::selectAll()
{
m_diagram -> selectAll();
}
/**
Deslectionne tous les objets selectionnes
*/
void DiagramView::selectNothing()
{
m_diagram -> deselectAll();
}
/**
Inverse l'etat de selection de tous les objets du schema
*/
void DiagramView::selectInvert()
{
m_diagram -> invertSelection();
}
/** /**
Accepte ou refuse le drag'n drop en fonction du type de donnees entrant Accepte ou refuse le drag'n drop en fonction du type de donnees entrant

View File

@@ -117,9 +117,6 @@ class DiagramView : public QGraphicsView
void freeRubberBandChanged(QPolygonF polygon); void freeRubberBandChanged(QPolygonF polygon);
public slots: public slots:
void selectNothing();
void selectAll();
void selectInvert();
void setVisualisationMode(); void setVisualisationMode();
void setSelectionMode(); void setSelectionMode();
void zoom(const qreal zoom_factor); void zoom(const qreal zoom_factor);

View File

@@ -1338,17 +1338,21 @@ void QETDiagramEditor::zoomGroupTriggered(QAction *action)
*/ */
void QETDiagramEditor::selectGroupTriggered(QAction *action) void QETDiagramEditor::selectGroupTriggered(QAction *action)
{ {
QString value = action->data().toString(); if (!currentDiagramView() || !currentDiagramView()->diagram())
DiagramView *dv = currentDiagramView(); return;
if (!dv || value.isEmpty()) return; auto value = action->data().toString();
if (value.isEmpty())
return;
auto diagram = currentDiagramView()->diagram();
if (value == "select_all") if (value == "select_all")
dv->selectAll(); diagram->selectAll();
else if (value == "deselect") else if (value == "deselect")
dv->selectNothing(); diagram->deselectAll();
else if (value == "invert_selection") else if (value == "invert_selection")
dv->selectInvert(); diagram->invertSelection();
} }
/** /**