comparison 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
comparison
equal deleted inserted replaced
131:2550aaa09240 132:16ceeee30e2a
64 64
65 void 65 void
66 Panner::setScene(QGraphicsScene *s) 66 Panner::setScene(QGraphicsScene *s)
67 { 67 {
68 if (scene()) { 68 if (scene()) {
69 disconnect(scene(), SIGNAL(sceneChanged(const QList<QRectF> &)),
70 this, SLOT(slotSceneChanged(const QList<QRectF> &)));
69 disconnect(scene(), SIGNAL(sceneRectChanged(const QRectF &)), 71 disconnect(scene(), SIGNAL(sceneRectChanged(const QRectF &)),
70 this, SLOT(slotSceneRectChanged(const QRectF &))); 72 this, SLOT(slotSceneRectChanged(const QRectF &)));
71 } 73 }
72 QGraphicsView::setScene(s); 74 QGraphicsView::setScene(s);
73 if (scene()) { 75 if (scene()) {
74 QRectF r = sceneRect(); 76 QRectF r = sceneRect();
75 DEBUG << "scene rect: " << r << ", my rect " << rect() << endl; 77 DEBUG << "scene rect: " << r << ", my rect " << rect() << endl;
76 fit(r); 78 fit(r);
77 } 79 }
78 m_cache = QPixmap(); 80 m_cache = QPixmap();
81 connect(scene(), SIGNAL(sceneChanged(const QList<QRectF> &)),
82 this, SLOT(slotSceneChanged(const QList<QRectF> &)));
79 connect(scene(), SIGNAL(sceneRectChanged(const QRectF &)), 83 connect(scene(), SIGNAL(sceneRectChanged(const QRectF &)),
80 this, SLOT(slotSceneRectChanged(const QRectF &))); 84 this, SLOT(slotSceneRectChanged(const QRectF &)));
81 } 85 }
82 86
83 void 87 void
113 void 117 void
114 Panner::slotSceneRectChanged(const QRectF &newRect) 118 Panner::slotSceneRectChanged(const QRectF &newRect)
115 { 119 {
116 if (!scene()) return; // spurious 120 if (!scene()) return; // spurious
117 fit(newRect); 121 fit(newRect);
122 m_cache = QPixmap();
123 viewport()->update();
124 }
125
126 void
127 Panner::slotSceneChanged(const QList<QRectF> &)
128 {
129 if (!scene()) return; // spurious
118 m_cache = QPixmap(); 130 m_cache = QPixmap();
119 viewport()->update(); 131 viewport()->update();
120 } 132 }
121 133
122 void 134 void