mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 20:50:34 +01:00
element editor and diagram view, now can move view by holding wheel click and drag mouse
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@2153 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -409,7 +409,7 @@ void DiagramView::pasteHere() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Manage the events click mouse :
|
Manage the events press click mouse :
|
||||||
* click to add an independent text field
|
* click to add an independent text field
|
||||||
*/
|
*/
|
||||||
void DiagramView::mousePressEvent(QMouseEvent *e) {
|
void DiagramView::mousePressEvent(QMouseEvent *e) {
|
||||||
@@ -423,20 +423,43 @@ void DiagramView::mousePressEvent(QMouseEvent *e) {
|
|||||||
is_adding_text = false;
|
is_adding_text = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Select visualisation or selection mode
|
// workaround for drag view with hold wheel click and drag mouse
|
||||||
|
// see also mouseMoveEvent() and mouseReleaseEvent()
|
||||||
if (e -> buttons() == Qt::MidButton) {
|
if (e -> buttons() == Qt::MidButton) {
|
||||||
if (!is_moving_view_) {
|
setCursor(Qt::ClosedHandCursor);
|
||||||
setVisualisationMode();
|
reference_view_ = mapToScene(e -> pos());
|
||||||
is_moving_view_ = true;
|
center_view_ = mapToScene(this -> viewport() -> rect()).boundingRect().center();
|
||||||
}
|
return;
|
||||||
else{
|
|
||||||
setSelectionMode();
|
|
||||||
is_moving_view_ = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
QGraphicsView::mousePressEvent(e);
|
QGraphicsView::mousePressEvent(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief DiagramView::mouseMoveEvent
|
||||||
|
* Manage the event move mouse
|
||||||
|
*/
|
||||||
|
void DiagramView::mouseMoveEvent(QMouseEvent *e) {
|
||||||
|
if ((e -> buttons() & Qt::MidButton) == Qt::MidButton) {
|
||||||
|
QPointF move = reference_view_ - mapToScene(e -> pos());
|
||||||
|
this -> centerOn(center_view_ + move);
|
||||||
|
center_view_ = mapToScene(this -> viewport() -> rect()).boundingRect().center();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QGraphicsView::mouseMoveEvent(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief DiagramView::mouseReleaseEvent
|
||||||
|
* Manage event release click mouse
|
||||||
|
*/
|
||||||
|
void DiagramView::mouseReleaseEvent(QMouseEvent *e) {
|
||||||
|
if (e -> button() == Qt::MidButton) {
|
||||||
|
setCursor(Qt::ArrowCursor);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QGraphicsView::mouseReleaseEvent(e);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Manage wheel event of mouse
|
Manage wheel event of mouse
|
||||||
@param e QWheelEvent
|
@param e QWheelEvent
|
||||||
|
|||||||
@@ -52,6 +52,8 @@ class DiagramView : public QGraphicsView {
|
|||||||
bool fresh_focus_in_; ///< Indicate the focus was freshly gained
|
bool fresh_focus_in_; ///< Indicate the focus was freshly gained
|
||||||
ElementsLocation next_location_;
|
ElementsLocation next_location_;
|
||||||
QPoint next_position_;
|
QPoint next_position_;
|
||||||
|
QPointF reference_view_;
|
||||||
|
QPointF center_view_;
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
public:
|
public:
|
||||||
@@ -86,6 +88,8 @@ class DiagramView : public QGraphicsView {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void mousePressEvent(QMouseEvent *);
|
void mousePressEvent(QMouseEvent *);
|
||||||
|
void mouseMoveEvent(QMouseEvent *);
|
||||||
|
void mouseReleaseEvent(QMouseEvent *);
|
||||||
void dragEnterEvent(QDragEnterEvent *);
|
void dragEnterEvent(QDragEnterEvent *);
|
||||||
void dragLeaveEvent(QDragLeaveEvent *);
|
void dragLeaveEvent(QDragLeaveEvent *);
|
||||||
void dragMoveEvent(QDragMoveEvent *);
|
void dragMoveEvent(QDragMoveEvent *);
|
||||||
|
|||||||
@@ -336,18 +336,40 @@ ElementContent ElementView::pasteWithOffset(const QDomDocument &xml_document) {
|
|||||||
void ElementView::mousePressEvent(QMouseEvent *e) {
|
void ElementView::mousePressEvent(QMouseEvent *e) {
|
||||||
// Select visualisation or selection mode
|
// Select visualisation or selection mode
|
||||||
if (e -> buttons() == Qt::MidButton) {
|
if (e -> buttons() == Qt::MidButton) {
|
||||||
if (!is_moving_view_) {
|
setCursor(Qt::ClosedHandCursor);
|
||||||
setVisualisationMode();
|
reference_view_ = mapToScene(e -> pos());
|
||||||
is_moving_view_ = true;
|
center_view_ = mapToScene(this -> viewport() -> rect()).boundingRect().center();
|
||||||
}
|
return;
|
||||||
else{
|
|
||||||
setSelectionMode();
|
|
||||||
is_moving_view_ = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
QGraphicsView::mousePressEvent(e);
|
QGraphicsView::mousePressEvent(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief ElementView::mouseMoveEvent
|
||||||
|
* Manage the event move mouse
|
||||||
|
*/
|
||||||
|
void ElementView::mouseMoveEvent(QMouseEvent *e) {
|
||||||
|
if ((e -> buttons() & Qt::MidButton) == Qt::MidButton) {
|
||||||
|
QPointF move = reference_view_ - mapToScene(e -> pos());
|
||||||
|
this -> centerOn(center_view_ + move);
|
||||||
|
center_view_ = mapToScene(this -> viewport() -> rect()).boundingRect().center();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QGraphicsView::mouseMoveEvent(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief ElementView::mouseReleaseEvent
|
||||||
|
* Manage event release click mouse
|
||||||
|
*/
|
||||||
|
void ElementView::mouseReleaseEvent(QMouseEvent *e) {
|
||||||
|
if (e -> button() == Qt::MidButton) {
|
||||||
|
setCursor(Qt::ArrowCursor);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QGraphicsView::mouseReleaseEvent(e);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Gere les actions liees a la rollette de la souris
|
Gere les actions liees a la rollette de la souris
|
||||||
@param e QWheelEvent decrivant l'evenement rollette
|
@param e QWheelEvent decrivant l'evenement rollette
|
||||||
|
|||||||
@@ -43,6 +43,8 @@ class ElementView : public QGraphicsView {
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
void mousePressEvent(QMouseEvent *);
|
void mousePressEvent(QMouseEvent *);
|
||||||
|
void mouseMoveEvent(QMouseEvent *);
|
||||||
|
void mouseReleaseEvent(QMouseEvent *);
|
||||||
void wheelEvent(QWheelEvent *);
|
void wheelEvent(QWheelEvent *);
|
||||||
virtual void drawBackground(QPainter *, const QRectF &);
|
virtual void drawBackground(QPainter *, const QRectF &);
|
||||||
|
|
||||||
@@ -79,6 +81,8 @@ class ElementView : public QGraphicsView {
|
|||||||
QString to_paste_in_area_;
|
QString to_paste_in_area_;
|
||||||
int offset_paste_count_;
|
int offset_paste_count_;
|
||||||
QPointF start_top_left_corner_;
|
QPointF start_top_left_corner_;
|
||||||
|
QPointF reference_view_;
|
||||||
|
QPointF center_view_;
|
||||||
bool is_moving_view_; ///< Indicate whether the visualisation mode has been enabled due to mouse/keyboard interactions
|
bool is_moving_view_; ///< Indicate whether the visualisation mode has been enabled due to mouse/keyboard interactions
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user