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:
blacksun
2015-03-24 22:21:58 +00:00
parent 9072d3de04
commit 2f9fd79371
4 changed files with 31 additions and 27 deletions

View File

@@ -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
*/
void DiagramView::mousePressEvent(QMouseEvent *e) {
@@ -491,10 +491,10 @@ void DiagramView::mousePressEvent(QMouseEvent *e) {
}
//Start drag view when hold the middle button
if (e -> button() == Qt::MidButton) {
rubber_band_origin = mapToScene(e -> pos());
if (e->button() == Qt::MidButton)
{
rubber_band_origin = e->pos();
setCursor(Qt::ClosedHandCursor);
center_view_ = mapToScene(this -> viewport() -> rect().center());
}
else QGraphicsView::mousePressEvent(e);
@@ -515,11 +515,16 @@ void DiagramView::mouseMoveEvent(QMouseEvent *e) {
return;
}
}
//Drag the view
if (e -> buttons() == Qt::MidButton) {
QPointF move = rubber_band_origin - mapToScene(e -> pos());
this -> centerOn(center_view_ + move);
center_view_ = mapToScene( this -> viewport() -> rect().center() );
if (e->buttons() == Qt::MidButton)
{
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);

View File

@@ -50,7 +50,6 @@ class DiagramView : public QGraphicsView {
QAction *find_element_;
QPoint paste_here_pos;
QPoint next_position_;
QPointF center_view_;
QPointF rubber_band_origin;
bool fresh_focus_in_; ///< Indicate the focus was freshly gained
ElementsLocation next_location_;

View File

@@ -360,13 +360,12 @@ ElementContent ElementView::pasteWithOffset(const QDomDocument &xml_document) {
@param e QMouseEvent decrivant l'evenement souris
*/
void ElementView::mousePressEvent(QMouseEvent *e) {
// Select visualisation or selection mode
if (e -> buttons() == Qt::MidButton) {
setCursor(Qt::ClosedHandCursor);
reference_view_ = mapToScene(e -> pos());
center_view_ = mapToScene(this -> viewport() -> rect()).boundingRect().center();
return;
if (e->buttons() == Qt::MidButton)
{
setCursor( (Qt::ClosedHandCursor));
reference_view_ = e->pos();
}
else
QGraphicsView::mousePressEvent(e);
}
@@ -375,13 +374,16 @@ void ElementView::mousePressEvent(QMouseEvent *e) {
* 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();
adjustSceneRect();
return;
if (e->buttons() == Qt::MidButton)
{
QScrollBar *h = horizontalScrollBar();
QScrollBar *v = verticalScrollBar();
QPointF pos = reference_view_ - e -> pos();
reference_view_ = e -> pos();
h -> setValue(h -> value() + pos.x());
v -> setValue(v -> value() + pos.y());
}
else
QGraphicsView::mouseMoveEvent(e);
}

View File

@@ -89,8 +89,6 @@ class ElementView : public QGraphicsView {
int offset_paste_count_;
QPointF start_top_left_corner_;
QPointF reference_view_;
QPointF center_view_;
bool gestures() const;
bool is_moving_view_; ///< Indicate whether the visualisation mode has been enabled due to mouse/keyboard interactions
};
#endif