mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-20 16:20:52 +01:00
Minor change about how drag view work (diagram editor and element editor)
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3849 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -470,7 +470,7 @@ void DiagramView::pasteHere() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Manage the events press click mouse :
|
Manage the events press click :
|
||||||
* click to add an independent text field
|
* click to add an independent text field
|
||||||
*/
|
*/
|
||||||
void DiagramView::mousePressEvent(QMouseEvent *e) {
|
void DiagramView::mousePressEvent(QMouseEvent *e) {
|
||||||
@@ -490,11 +490,11 @@ void DiagramView::mousePressEvent(QMouseEvent *e) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Start drag view when hold the middle button
|
//Start drag view when hold the middle button
|
||||||
if (e -> button() == Qt::MidButton) {
|
if (e->button() == Qt::MidButton)
|
||||||
rubber_band_origin = mapToScene(e -> pos());
|
{
|
||||||
|
rubber_band_origin = e->pos();
|
||||||
setCursor(Qt::ClosedHandCursor);
|
setCursor(Qt::ClosedHandCursor);
|
||||||
center_view_ = mapToScene(this -> viewport() -> rect().center());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else QGraphicsView::mousePressEvent(e);
|
else QGraphicsView::mousePressEvent(e);
|
||||||
@@ -515,11 +515,16 @@ void DiagramView::mouseMoveEvent(QMouseEvent *e) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//Drag the view
|
|
||||||
if (e -> buttons() == Qt::MidButton) {
|
//Drag the view
|
||||||
QPointF move = rubber_band_origin - mapToScene(e -> pos());
|
if (e->buttons() == Qt::MidButton)
|
||||||
this -> centerOn(center_view_ + move);
|
{
|
||||||
center_view_ = mapToScene( this -> viewport() -> rect().center() );
|
QScrollBar *h = horizontalScrollBar();
|
||||||
|
QScrollBar *v = verticalScrollBar();
|
||||||
|
QPointF pos = rubber_band_origin - e -> pos();
|
||||||
|
rubber_band_origin = e -> pos();
|
||||||
|
h -> setValue(h -> value() + pos.x());
|
||||||
|
v -> setValue(v -> value() + pos.y());
|
||||||
}
|
}
|
||||||
|
|
||||||
else QGraphicsView::mouseMoveEvent(e);
|
else QGraphicsView::mouseMoveEvent(e);
|
||||||
|
|||||||
@@ -50,7 +50,6 @@ class DiagramView : public QGraphicsView {
|
|||||||
QAction *find_element_;
|
QAction *find_element_;
|
||||||
QPoint paste_here_pos;
|
QPoint paste_here_pos;
|
||||||
QPoint next_position_;
|
QPoint next_position_;
|
||||||
QPointF center_view_;
|
|
||||||
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_;
|
ElementsLocation next_location_;
|
||||||
|
|||||||
@@ -360,14 +360,13 @@ ElementContent ElementView::pasteWithOffset(const QDomDocument &xml_document) {
|
|||||||
@param e QMouseEvent decrivant l'evenement souris
|
@param e QMouseEvent decrivant l'evenement souris
|
||||||
*/
|
*/
|
||||||
void ElementView::mousePressEvent(QMouseEvent *e) {
|
void ElementView::mousePressEvent(QMouseEvent *e) {
|
||||||
// Select visualisation or selection mode
|
if (e->buttons() == Qt::MidButton)
|
||||||
if (e -> buttons() == Qt::MidButton) {
|
{
|
||||||
setCursor(Qt::ClosedHandCursor);
|
setCursor( (Qt::ClosedHandCursor));
|
||||||
reference_view_ = mapToScene(e -> pos());
|
reference_view_ = e->pos();
|
||||||
center_view_ = mapToScene(this -> viewport() -> rect()).boundingRect().center();
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
QGraphicsView::mousePressEvent(e);
|
else
|
||||||
|
QGraphicsView::mousePressEvent(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -375,14 +374,17 @@ void ElementView::mousePressEvent(QMouseEvent *e) {
|
|||||||
* Manage the event move mouse
|
* Manage the event move mouse
|
||||||
*/
|
*/
|
||||||
void ElementView::mouseMoveEvent(QMouseEvent *e) {
|
void ElementView::mouseMoveEvent(QMouseEvent *e) {
|
||||||
if ((e -> buttons() & Qt::MidButton) == Qt::MidButton) {
|
if (e->buttons() == Qt::MidButton)
|
||||||
QPointF move = reference_view_ - mapToScene(e -> pos());
|
{
|
||||||
this -> centerOn(center_view_ + move);
|
QScrollBar *h = horizontalScrollBar();
|
||||||
center_view_ = mapToScene(this -> viewport() -> rect()).boundingRect().center();
|
QScrollBar *v = verticalScrollBar();
|
||||||
adjustSceneRect();
|
QPointF pos = reference_view_ - e -> pos();
|
||||||
return;
|
reference_view_ = e -> pos();
|
||||||
|
h -> setValue(h -> value() + pos.x());
|
||||||
|
v -> setValue(v -> value() + pos.y());
|
||||||
}
|
}
|
||||||
QGraphicsView::mouseMoveEvent(e);
|
else
|
||||||
|
QGraphicsView::mouseMoveEvent(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -89,8 +89,6 @@ class ElementView : public QGraphicsView {
|
|||||||
int offset_paste_count_;
|
int offset_paste_count_;
|
||||||
QPointF start_top_left_corner_;
|
QPointF start_top_left_corner_;
|
||||||
QPointF reference_view_;
|
QPointF reference_view_;
|
||||||
QPointF center_view_;
|
|
||||||
bool gestures() const;
|
bool gestures() const;
|
||||||
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