From c3bda12e16d1e5120b25f4236be84ef9136892cb Mon Sep 17 00:00:00 2001 From: =?utf8?q?Michal=20Mal=C3=BD?= Date: Wed, 4 Mar 2015 01:14:00 +0100 Subject: [PATCH] Optimize graph redrawing. --- gui/graphview.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/gui/graphview.cpp b/gui/graphview.cpp index da77da8..36b60e4 100644 --- a/gui/graphview.cpp +++ b/gui/graphview.cpp @@ -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 &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) -- 2.43.5