mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-18 22:00:35 +01:00
element editor : clean some code
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3477 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -48,6 +48,7 @@ ElementScene::ElementScene(QETElementEditor *editor, QObject *parent) :
|
|||||||
element_editor(editor),
|
element_editor(editor),
|
||||||
decorator_(0)
|
decorator_(0)
|
||||||
{
|
{
|
||||||
|
behavior = Normal;
|
||||||
setItemIndexMethod(NoIndex);
|
setItemIndexMethod(NoIndex);
|
||||||
setGrid(1, 1);
|
setGrid(1, 1);
|
||||||
initPasteArea();
|
initPasteArea();
|
||||||
@@ -63,14 +64,6 @@ ElementScene::~ElementScene() {
|
|||||||
if (m_event_interface) delete m_event_interface;
|
if (m_event_interface) delete m_event_interface;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
Passe la scene en mode "selection et deplacement de parties"
|
|
||||||
*/
|
|
||||||
void ElementScene::slot_move() {
|
|
||||||
behavior = Normal;
|
|
||||||
if (m_event_interface) delete m_event_interface; m_event_interface = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief ElementScene::mouseMoveEvent
|
* @brief ElementScene::mouseMoveEvent
|
||||||
* @param e
|
* @param e
|
||||||
@@ -87,7 +80,8 @@ void ElementScene::mouseMoveEvent(QGraphicsSceneMouseEvent *e) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
QPointF event_pos = e -> scenePos();
|
QPointF event_pos = e -> scenePos();
|
||||||
if (mustSnapToGrid(e)) event_pos = snapToGrid(event_pos);
|
if (!e -> modifiers() & Qt::ControlModifier)
|
||||||
|
event_pos = snapToGrid(event_pos);
|
||||||
|
|
||||||
if (behavior == PasteArea) {
|
if (behavior == PasteArea) {
|
||||||
QRectF current_rect(paste_area_ -> rect());
|
QRectF current_rect(paste_area_ -> rect());
|
||||||
@@ -957,16 +951,6 @@ QPointF ElementScene::snapToGrid(QPointF point) {
|
|||||||
return point;
|
return point;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
@param e Evenement souris
|
|
||||||
@return true s'il faut utiliser le snap-to-grid
|
|
||||||
Typiquement, cette methode retourne true si l'evenement souris se produit
|
|
||||||
sans la touche Ctrl enfoncee.
|
|
||||||
*/
|
|
||||||
bool ElementScene::mustSnapToGrid(QGraphicsSceneMouseEvent *e) {
|
|
||||||
return(!(e -> modifiers() & Qt::ControlModifier));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@return true if \a item1's zValue() is less than \a item2's.
|
@return true if \a item1's zValue() is less than \a item2's.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -151,13 +151,11 @@ class ElementScene : public QGraphicsScene {
|
|||||||
ElementContent addContentAtPos(const ElementContent &, const QPointF &, QString * = 0);
|
ElementContent addContentAtPos(const ElementContent &, const QPointF &, QString * = 0);
|
||||||
void addPrimitive(QGraphicsItem *);
|
void addPrimitive(QGraphicsItem *);
|
||||||
void initPasteArea();
|
void initPasteArea();
|
||||||
bool mustSnapToGrid(QGraphicsSceneMouseEvent *);
|
|
||||||
static bool zValueLessThan(QGraphicsItem *, QGraphicsItem *);
|
static bool zValueLessThan(QGraphicsItem *, QGraphicsItem *);
|
||||||
QMutex *decorator_lock_;
|
QMutex *decorator_lock_;
|
||||||
void centerElementToOrigine();
|
void centerElementToOrigine();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void slot_move();
|
|
||||||
void slot_select(const ElementContent &);
|
void slot_select(const ElementContent &);
|
||||||
void slot_selectAll();
|
void slot_selectAll();
|
||||||
void slot_deselectAll();
|
void slot_deselectAll();
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ ElementView::ElementView(ElementScene *scene, QWidget *parent) :
|
|||||||
setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
|
setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
|
||||||
zoomReset();
|
zoomReset();
|
||||||
connect(scene_, SIGNAL(pasteAreaDefined(const QRectF &)), this, SLOT(pasteAreaDefined(const QRectF &)));
|
connect(scene_, SIGNAL(pasteAreaDefined(const QRectF &)), this, SLOT(pasteAreaDefined(const QRectF &)));
|
||||||
connect(scene_, SIGNAL(partsAdded()), this, SLOT(adjustSceneRect()));
|
|
||||||
connect(scene_, SIGNAL(needZoomFit()), this, SLOT(zoomFit()));
|
connect(scene_, SIGNAL(needZoomFit()), this, SLOT(zoomFit()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -486,7 +486,6 @@ void QETElementEditor::slot_updateTitle() {
|
|||||||
void QETElementEditor::setupInterface() {
|
void QETElementEditor::setupInterface() {
|
||||||
// editeur
|
// editeur
|
||||||
ce_scene = new ElementScene(this, this);
|
ce_scene = new ElementScene(this, this);
|
||||||
ce_scene -> slot_move();
|
|
||||||
ce_view = new ElementView(ce_scene, this);
|
ce_view = new ElementView(ce_scene, this);
|
||||||
slot_setRubberBandToView();
|
slot_setRubberBandToView();
|
||||||
setCentralWidget(ce_view);
|
setCentralWidget(ce_view);
|
||||||
|
|||||||
Reference in New Issue
Block a user