Mercurial > hg > easyhg
changeset 132:16ceeee30e2a
* Ensure panned rect stays current when size changes; update panner cache when scene changes
author | Chris Cannam |
---|---|
date | Tue, 30 Nov 2010 11:41:46 +0000 |
parents | 2550aaa09240 |
children | aaeab914f2a3 |
files | changesetitem.cpp panned.cpp panner.cpp panner.h |
diffstat | 4 files changed, 23 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/changesetitem.cpp Tue Nov 30 11:17:30 2010 +0000 +++ b/changesetitem.cpp Tue Nov 30 11:41:46 2010 +0000 @@ -24,6 +24,7 @@ #include <QPainter> #include <QGraphicsScene> +#include <QGraphicsSceneMouseEvent> ChangesetItem::ChangesetItem(Changeset *cs) : m_changeset(cs), m_detail(0), @@ -74,10 +75,12 @@ ChangesetItem::mousePressEvent(QGraphicsSceneMouseEvent *e) { DEBUG << "ChangesetItem::mousePressEvent" << endl; - if (m_detail) { - hideDetail(); - } else { - showDetail(); + if (e->button() == Qt::LeftButton) { + if (m_detail) { + hideDetail(); + } else { + showDetail(); + } } }
--- a/panned.cpp Tue Nov 30 11:17:30 2010 +0000 +++ b/panned.cpp Tue Nov 30 11:41:46 2010 +0000 @@ -39,12 +39,13 @@ QSizeF sz(farpt.x()-nearpt.x(), farpt.y()-nearpt.y()); QRectF pr(nearpt, sz); + QGraphicsView::resizeEvent(ev); + if (pr != m_pannedRect) { + DEBUG << "Panned: setting panned rect to " << pr << endl; m_pannedRect = pr; emit pannedRectChanged(pr); } - - QGraphicsView::resizeEvent(ev); } void
--- a/panner.cpp Tue Nov 30 11:17:30 2010 +0000 +++ b/panner.cpp Tue Nov 30 11:41:46 2010 +0000 @@ -66,6 +66,8 @@ Panner::setScene(QGraphicsScene *s) { if (scene()) { + disconnect(scene(), SIGNAL(sceneChanged(const QList<QRectF> &)), + this, SLOT(slotSceneChanged(const QList<QRectF> &))); disconnect(scene(), SIGNAL(sceneRectChanged(const QRectF &)), this, SLOT(slotSceneRectChanged(const QRectF &))); } @@ -76,6 +78,8 @@ fit(r); } m_cache = QPixmap(); + connect(scene(), SIGNAL(sceneChanged(const QList<QRectF> &)), + this, SLOT(slotSceneChanged(const QList<QRectF> &))); connect(scene(), SIGNAL(sceneRectChanged(const QRectF &)), this, SLOT(slotSceneRectChanged(const QRectF &))); } @@ -120,6 +124,14 @@ } void +Panner::slotSceneChanged(const QList<QRectF> &) +{ + if (!scene()) return; // spurious + m_cache = QPixmap(); + viewport()->update(); +} + +void Panner::paintEvent(QPaintEvent *e) { QPaintEvent *e2 = new QPaintEvent(e->region().boundingRect());