From d1fbcda34bf76bb28b6cf93abc2e1adda55e33bd Mon Sep 17 00:00:00 2001 From: blacksun Date: Mon, 10 Aug 2015 08:02:40 +0000 Subject: [PATCH] Diagram view : remove old code about drop element. git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4094 bfdf4180-ca20-0410-9c96-a3a8aa849046 --- sources/diagramview.cpp | 77 ----------------------------------------- sources/diagramview.h | 17 +++++---- 2 files changed, 8 insertions(+), 86 deletions(-) diff --git a/sources/diagramview.cpp b/sources/diagramview.cpp index b8d202cb6..97097ade0 100644 --- a/sources/diagramview.cpp +++ b/sources/diagramview.cpp @@ -94,7 +94,6 @@ DiagramView::DiagramView(Diagram *diagram, QWidget *parent) : connect(diagram, SIGNAL(editElementRequired(ElementsLocation)), this, SIGNAL(editElementRequired(ElementsLocation))); connect(diagram, SIGNAL(findElementRequired(ElementsLocation)), this, SIGNAL(findElementRequired(ElementsLocation))); - connect(this, SIGNAL(aboutToAddElement()), this, SLOT(addDroppedElement()), Qt::QueuedConnection); connect( this, SIGNAL(aboutToSetDroppedTitleBlockTemplate(const TitleBlockTemplateLocation &)), this, SLOT(setDroppedTitleBlockTemplate(const TitleBlockTemplateLocation &)), @@ -293,11 +292,6 @@ void DiagramView::handleElementDrop(QDropEvent *e) { diagram()->setEventInterface(new DiagramEventAddElement(location, diagram(), mapToScene(e->pos()))); //Set focus to the view to get event this->setFocus(); - -// next_location_ = location; -// next_position_ = e-> pos(); - -// emit(aboutToAddElement()); } /** @@ -822,33 +816,6 @@ QRectF DiagramView::viewedSceneRect() const { return(QRectF(scene_left_top, scene_right_bottom)); } -/** - Cette methode permet de determiner s'il faut ou non integrer au projet un - element dont on connait l'emplacement. - L'element droppe est integre a la collection du projet : - * s'il appartient a un autre projet, quelque soit la specification de - l'utilisateur a ce propos ; - * s'il appartient a la collection commune ou a la collection - personnelle ET que l'utilisateur a autorise l'integration automatique - des elements dans les projets. - @param location Emplacement de l'element - @return true si l'element doit etre integre, false sinon - -*/ -bool DiagramView::mustIntegrateElement(const ElementsLocation &location) const { - // l'utilisateur a-t-il autorise l'integration automatique des elements dans les projets ? - bool auto_integration_enabled = QETApp::settings().value("diagrameditor/integrate-elements", true).toBool(); - - // l'element appartient-il a un projet et si oui, est-ce un autre projet ? - bool elmt_from_project = location.project(); - bool elmt_from_another_project = elmt_from_project && location.project() != scene -> project(); - - // faut-il integrer l'element ? - bool must_integrate_element = (elmt_from_another_project || (auto_integration_enabled && !elmt_from_project)); - - return(must_integrate_element); -} - /** @param tbt_loc A title block template location @return true if the title block template needs to be integrated in the @@ -863,24 +830,6 @@ bool DiagramView::mustIntegrateTitleBlockTemplate(const TitleBlockTemplateLocati return(tbt_parent_project != scene -> project()); } -/** - @param location Emplacement de l'element a ajouter sur le schema - @param pos Position (dans les coordonnees de la vue) a laquelle l'element sera ajoute -*/ -bool DiagramView::addElementAtPos(const ElementsLocation &location, const QPoint &pos) { - // construit une instance de l'element correspondant a l'emplacement - int state; - Element *el = ElementFactory::Instance()->createElement(location, 0, &state); - if (state) { - delete el; - return(false); - } - - //Add element to diagram - diagram() -> undoStack().push (new AddItemCommand(el, diagram(), mapToScene(pos))); - return(true); -} - /** Fait en sorte que le schema ne soit editable que s'il n'est pas en lecture seule @@ -1210,32 +1159,6 @@ void DiagramView::mouseDoubleClickEvent(QMouseEvent *e) { QGraphicsView::mouseDoubleClickEvent(e); } -/** - Cette methode ajoute l'element designe par l'emplacement location a la - position pos. Si necessaire, elle demande l'integration de l'element au - projet. - @see mustIntegrateElement -*/ -void DiagramView::addDroppedElement() { - ElementsLocation location = next_location_; - QPoint pos = next_position_; - - if (!mustIntegrateElement(location)) { - addElementAtPos(location, pos); - } else { - QString error_msg; - IntegrationMoveElementsHandler *integ_handler = new IntegrationMoveElementsHandler(this); - QString integ_path = scene -> project() -> integrateElement(location.toString(), integ_handler, error_msg); - delete integ_handler; - if (integ_path.isEmpty()) { - qDebug() << "DiagramView::addDroppedElement : Impossible d'ajouter l'element. Motif : " << qPrintable(error_msg); - return; - } - addElementAtPos(ElementsLocation::locationFromString(integ_path), pos); - } - adjustSceneRect(); -} - /** @param tbt TitleBlockTemplateLocation */ diff --git a/sources/diagramview.h b/sources/diagramview.h index 793047a90..348f2e339 100644 --- a/sources/diagramview.h +++ b/sources/diagramview.h @@ -17,7 +17,9 @@ */ #ifndef DIAGRAMVIEW_H #define DIAGRAMVIEW_H -#include + +#include +#include #include "elementslocation.h" #include "templatelocation.h" @@ -25,12 +27,16 @@ class Conductor; class Diagram; class QETDiagramEditor; class DVEventInterface; +class QMenu; +class QInputEvent; +class QGestureEvent; /** This class provides a widget to render an electric diagram in an editable, interactive way. */ -class DiagramView : public QGraphicsView { +class DiagramView : public QGraphicsView +{ Q_OBJECT // constructors, destructor @@ -49,10 +55,8 @@ class DiagramView : public QGraphicsView { QAction *paste_here; QAction *find_element_; QPoint paste_here_pos; - QPoint next_position_; QPointF rubber_band_origin; bool fresh_focus_in_; ///< Indicate the focus was freshly gained - ElementsLocation next_location_; bool m_first_activation; @@ -99,9 +103,7 @@ class DiagramView : public QGraphicsView { void handleTextDrop(QDropEvent *); bool gestureEvent(QGestureEvent *event); QRectF viewedSceneRect() const; - bool mustIntegrateElement(const ElementsLocation &) const; bool mustIntegrateTitleBlockTemplate(const TitleBlockTemplateLocation &) const; - bool addElementAtPos(const ElementsLocation &, const QPoint &); bool gestures() const; signals: @@ -111,8 +113,6 @@ class DiagramView : public QGraphicsView { void modeChanged(); /// Signal emitted after the diagram title changed void titleChanged(DiagramView *, const QString &); - /// Signal emitted before integrating an element - void aboutToAddElement(); /// Signal emitted before integrating a title block template void aboutToSetDroppedTitleBlockTemplate(const TitleBlockTemplateLocation &); /// Signal emitted when users wish to locate an element from the diagram within elements collection @@ -154,7 +154,6 @@ class DiagramView : public QGraphicsView { void resetConductors(); private slots: - void addDroppedElement(); void setDroppedTitleBlockTemplate(const TitleBlockTemplateLocation &); void adjustGridToZoom(); void applyReadOnly();