diff panner.cpp @ 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
line wrap: on
line diff
--- 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());