mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-19 23:20:52 +01:00
Clean wheelEvent in diagramview and add the same system to element Editor
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@2115 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -293,7 +293,7 @@ void DiagramView::handleTitleBlockDrop(QDropEvent *e) {
|
||||
}
|
||||
|
||||
/**
|
||||
Passe le Diagram en mode visualisation
|
||||
Set the Diagram in visualisation mode
|
||||
*/
|
||||
void DiagramView::setVisualisationMode() {
|
||||
setDragMode(ScrollHandDrag);
|
||||
@@ -303,7 +303,7 @@ void DiagramView::setVisualisationMode() {
|
||||
}
|
||||
|
||||
/**
|
||||
Passe le Diagram en mode Selection
|
||||
Set the Diagram in Selection mode
|
||||
*/
|
||||
void DiagramView::setSelectionMode() {
|
||||
setDragMode(RubberBandDrag);
|
||||
@@ -457,17 +457,6 @@ void DiagramView::wheelEvent(QWheelEvent *e) {
|
||||
QAbstractScrollArea::wheelEvent(e);
|
||||
}
|
||||
}
|
||||
// Or select visualisation or selection mode
|
||||
else{
|
||||
if (!is_moving_view_) {
|
||||
setVisualisationMode();
|
||||
is_moving_view_ = true;
|
||||
}
|
||||
else{
|
||||
setSelectionMode();
|
||||
is_moving_view_ = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -74,6 +74,24 @@ void ElementView::setScene(ElementScene *s) {
|
||||
scene_ = s;
|
||||
}
|
||||
|
||||
/**
|
||||
Set the Diagram in visualisation mode
|
||||
*/
|
||||
void ElementView::setVisualisationMode() {
|
||||
setDragMode(ScrollHandDrag);
|
||||
setInteractive(false);
|
||||
emit(modeChanged());
|
||||
}
|
||||
|
||||
/**
|
||||
Set the Diagram in Selection mode
|
||||
*/
|
||||
void ElementView::setSelectionMode() {
|
||||
setDragMode(RubberBandDrag);
|
||||
setInteractive(true);
|
||||
emit(modeChanged());
|
||||
}
|
||||
|
||||
/**
|
||||
Agrandit le schema (+33% = inverse des -25 % de zoomMoins())
|
||||
*/
|
||||
@@ -316,8 +334,16 @@ ElementContent ElementView::pasteWithOffset(const QDomDocument &xml_document) {
|
||||
@param e QMouseEvent decrivant l'evenement souris
|
||||
*/
|
||||
void ElementView::mousePressEvent(QMouseEvent *e) {
|
||||
if (e -> buttons() & Qt::MidButton) {
|
||||
paste(mapToScene(e -> pos()));
|
||||
// Select visualisation or selection mode
|
||||
if (e -> buttons() == Qt::MidButton) {
|
||||
if (!is_moving_view_) {
|
||||
setVisualisationMode();
|
||||
is_moving_view_ = true;
|
||||
}
|
||||
else{
|
||||
setSelectionMode();
|
||||
is_moving_view_ = false;
|
||||
}
|
||||
}
|
||||
QGraphicsView::mousePressEvent(e);
|
||||
}
|
||||
@@ -327,16 +353,20 @@ void ElementView::mousePressEvent(QMouseEvent *e) {
|
||||
@param e QWheelEvent decrivant l'evenement rollette
|
||||
*/
|
||||
void ElementView::wheelEvent(QWheelEvent *e) {
|
||||
// si la touche Ctrl est enfoncee, on zoome / dezoome
|
||||
if (e -> modifiers() & Qt::ControlModifier) {
|
||||
if (e -> delta() > 0) {
|
||||
//Zoom and scrolling
|
||||
if (e->buttons() != Qt::MidButton) {
|
||||
if (!(e -> modifiers() & Qt::ControlModifier)) {
|
||||
if (e -> delta() > 0){
|
||||
zoomIn();
|
||||
} else {
|
||||
}
|
||||
else{
|
||||
zoomOut();
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
QAbstractScrollArea::wheelEvent(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -50,6 +50,8 @@ class ElementView : public QGraphicsView {
|
||||
QRectF applyMovement(const QRectF &, const QET::OrientedMovement &, const QPointF &);
|
||||
|
||||
public slots:
|
||||
void setVisualisationMode();
|
||||
void setSelectionMode();
|
||||
void zoomIn();
|
||||
void zoomOut();
|
||||
void zoomFit();
|
||||
@@ -60,6 +62,10 @@ class ElementView : public QGraphicsView {
|
||||
void paste();
|
||||
void pasteInArea();
|
||||
|
||||
signals:
|
||||
/// Signal emitted after the mode changed
|
||||
void modeChanged();
|
||||
|
||||
private slots:
|
||||
void getPasteArea(const QRectF &);
|
||||
ElementContent pasteAreaDefined(const QRectF &);
|
||||
@@ -73,5 +79,6 @@ class ElementView : public QGraphicsView {
|
||||
QString to_paste_in_area_;
|
||||
int offset_paste_count_;
|
||||
QPointF start_top_left_corner_;
|
||||
bool is_moving_view_; ///< Indicate whether the visualisation mode has been enabled due to mouse/keyboard interactions
|
||||
};
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user