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
This commit is contained in:
blacksun
2015-08-10 08:02:40 +00:00
parent 3e2c4af95a
commit d1fbcda34b
2 changed files with 8 additions and 86 deletions

View File

@@ -94,7 +94,6 @@ DiagramView::DiagramView(Diagram *diagram, QWidget *parent) :
connect(diagram, SIGNAL(editElementRequired(ElementsLocation)), this, SIGNAL(editElementRequired(ElementsLocation))); connect(diagram, SIGNAL(editElementRequired(ElementsLocation)), this, SIGNAL(editElementRequired(ElementsLocation)));
connect(diagram, SIGNAL(findElementRequired(ElementsLocation)), this, SIGNAL(findElementRequired(ElementsLocation))); connect(diagram, SIGNAL(findElementRequired(ElementsLocation)), this, SIGNAL(findElementRequired(ElementsLocation)));
connect(this, SIGNAL(aboutToAddElement()), this, SLOT(addDroppedElement()), Qt::QueuedConnection);
connect( connect(
this, SIGNAL(aboutToSetDroppedTitleBlockTemplate(const TitleBlockTemplateLocation &)), this, SIGNAL(aboutToSetDroppedTitleBlockTemplate(const TitleBlockTemplateLocation &)),
this, SLOT(setDroppedTitleBlockTemplate(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()))); diagram()->setEventInterface(new DiagramEventAddElement(location, diagram(), mapToScene(e->pos())));
//Set focus to the view to get event //Set focus to the view to get event
this->setFocus(); 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)); 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 @param tbt_loc A title block template location
@return true if the title block template needs to be integrated in the @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()); 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<Element *>(el, diagram(), mapToScene(pos)));
return(true);
}
/** /**
Fait en sorte que le schema ne soit editable que s'il n'est pas en lecture Fait en sorte que le schema ne soit editable que s'il n'est pas en lecture
seule seule
@@ -1210,32 +1159,6 @@ void DiagramView::mouseDoubleClickEvent(QMouseEvent *e) {
QGraphicsView::mouseDoubleClickEvent(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 @param tbt TitleBlockTemplateLocation
*/ */

View File

@@ -17,7 +17,9 @@
*/ */
#ifndef DIAGRAMVIEW_H #ifndef DIAGRAMVIEW_H
#define DIAGRAMVIEW_H #define DIAGRAMVIEW_H
#include <QtWidgets>
#include <QGraphicsView>
#include <QClipboard>
#include "elementslocation.h" #include "elementslocation.h"
#include "templatelocation.h" #include "templatelocation.h"
@@ -25,12 +27,16 @@ class Conductor;
class Diagram; class Diagram;
class QETDiagramEditor; class QETDiagramEditor;
class DVEventInterface; class DVEventInterface;
class QMenu;
class QInputEvent;
class QGestureEvent;
/** /**
This class provides a widget to render an electric diagram in an editable, This class provides a widget to render an electric diagram in an editable,
interactive way. interactive way.
*/ */
class DiagramView : public QGraphicsView { class DiagramView : public QGraphicsView
{
Q_OBJECT Q_OBJECT
// constructors, destructor // constructors, destructor
@@ -49,10 +55,8 @@ class DiagramView : public QGraphicsView {
QAction *paste_here; QAction *paste_here;
QAction *find_element_; QAction *find_element_;
QPoint paste_here_pos; QPoint paste_here_pos;
QPoint next_position_;
QPointF rubber_band_origin; QPointF rubber_band_origin;
bool fresh_focus_in_; ///< Indicate the focus was freshly gained bool fresh_focus_in_; ///< Indicate the focus was freshly gained
ElementsLocation next_location_;
bool m_first_activation; bool m_first_activation;
@@ -99,9 +103,7 @@ class DiagramView : public QGraphicsView {
void handleTextDrop(QDropEvent *); void handleTextDrop(QDropEvent *);
bool gestureEvent(QGestureEvent *event); bool gestureEvent(QGestureEvent *event);
QRectF viewedSceneRect() const; QRectF viewedSceneRect() const;
bool mustIntegrateElement(const ElementsLocation &) const;
bool mustIntegrateTitleBlockTemplate(const TitleBlockTemplateLocation &) const; bool mustIntegrateTitleBlockTemplate(const TitleBlockTemplateLocation &) const;
bool addElementAtPos(const ElementsLocation &, const QPoint &);
bool gestures() const; bool gestures() const;
signals: signals:
@@ -111,8 +113,6 @@ class DiagramView : public QGraphicsView {
void modeChanged(); void modeChanged();
/// Signal emitted after the diagram title changed /// Signal emitted after the diagram title changed
void titleChanged(DiagramView *, const QString &); void titleChanged(DiagramView *, const QString &);
/// Signal emitted before integrating an element
void aboutToAddElement();
/// Signal emitted before integrating a title block template /// Signal emitted before integrating a title block template
void aboutToSetDroppedTitleBlockTemplate(const TitleBlockTemplateLocation &); void aboutToSetDroppedTitleBlockTemplate(const TitleBlockTemplateLocation &);
/// Signal emitted when users wish to locate an element from the diagram within elements collection /// 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(); void resetConductors();
private slots: private slots:
void addDroppedElement();
void setDroppedTitleBlockTemplate(const TitleBlockTemplateLocation &); void setDroppedTitleBlockTemplate(const TitleBlockTemplateLocation &);
void adjustGridToZoom(); void adjustGridToZoom();
void applyReadOnly(); void applyReadOnly();