]> Devoid-pointer.net GitWeb - anyanka.git/commitdiff
Optimize graph redrawing.
authorMichal Malý <madcatxster@devoid-pointer.net>
Wed, 4 Mar 2015 00:14:00 +0000 (01:14 +0100)
committerMichal Malý <madcatxster@devoid-pointer.net>
Wed, 4 Mar 2015 00:14:00 +0000 (01:14 +0100)
gui/graphview.cpp

index da77da8993736834deaaf8e2ff3b56d49b74c6f5..36b60e4320806729bc6182d6bed37ad9bbb80724 100644 (file)
@@ -162,11 +162,18 @@ void GraphView::mousePressEvent(QMouseEvent* ev)
 
 void GraphView::paintEvent(QPaintEvent* ev)
 {
-  Q_UNUSED(ev);
-
-  QPainter p(this);
-  if (m_pixmap != nullptr)
-    p.drawPixmap(0, 0, dwidth(), dheight(), *m_pixmap);
+  if (m_pixmap != nullptr) {
+    QPainter p(this);
+    const QVector<QRect> &rects = ev->region().rects();
+
+    for (const QRect& r : rects) {
+      const int l = r.left();
+      const int t = r.top();
+      const int w = r.width();
+      const int h = r.height();
+      p.drawPixmap(l, t, w, h, *m_pixmap, l, t, w, h);
+    }
+  }
 }
 
 void GraphView::resizeEvent(QResizeEvent* ev)