[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: playground/utils/filelight/src/part/radialMap
From: Martin Tobias Holmedahl Sandsmark <sandsmark () samfundet ! no>
Date: 2009-05-29 18:35:07
Message-ID: 1243622107.456952.22264.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 974936 by sandsmark:
go back to drawing on a pixmap, massive performance improvement. lesson of the day: never doubt mxcl.
M +9 -16 map.cpp
M +12 -11 map.h
M +2 -2 widget.cpp
M +0 -2 widget.h
M +5 -6 widgetEvents.cpp
--- trunk/playground/utils/filelight/src/part/radialMap/map.cpp #974935:974936
@@ -38,13 +38,15 @@
#include "sincos.h"
#include "widget.h"
-RadialMap::Map::Map(Widget* widget)
+RadialMap::Map::Map(bool summary)
: m_signature(NULL)
, m_visibleDepth(DEFAULT_RING_DEPTH)
- , m_widget(widget)
, m_ringBreadth(MIN_RING_BREADTH)
, m_innerRadius(0)
+ , m_summary(summary)
{
+
+ m_pixmap.fill(Qt::transparent);
//FIXME this is all broken. No longer is a maximum depth!
const int fmh = QFontMetrics(QFont()).height();
const int fmhD4 = fmh / 4;
@@ -134,6 +136,8 @@
//this QRect is used by paint()
m_rect.setRect(0,0,size,size);
}
+ m_pixmap = QPixmap(m_rect.size());
+ m_pixmap.fill(Qt::transparent);
//resize the pixmap
size += MAP_2MARGIN;
@@ -141,7 +145,7 @@
if (m_signature != NULL)
{
setRingBreadth();
- //paint();
+ paint();
}
return true;
@@ -172,7 +176,7 @@
{
for (Iterator<Segment> it = m_signature[i].iterator(); it != m_signature[i].end(); ++it)
{
- if (m_widget->isSummary()){ // Summary view has its own colors.
+ if (m_summary){ // Summary view has its own colors.
if ((*it)->file()->name() == "Used") {
cb = QApplication::palette().highlight().color();
cb.getHsv(&h, &s1, &v1);
@@ -267,25 +271,15 @@
}
}
-void RadialMap::Map::aaPaint()
-{
- //paint() is called during continuous processes
- //aaPaint() is not and is slower so set overidecursor (make sets it too)
- QApplication::setOverrideCursor(Qt::WaitCursor);
- paint(true);
- QApplication::restoreOverrideCursor();
-}
-
void RadialMap::Map::paint(bool antialias)
{
-
QPainter paint;
QRect rect = m_rect;
//**** best option you can think of is to make the circles slightly less perfect,
// ** i.e. slightly eliptic when resizing inbetween
- paint.begin(m_widget);
+ paint.begin(&m_pixmap);
if (antialias && Config::antialias)
paint.setRenderHint(QPainter::Antialiasing);
@@ -300,7 +294,6 @@
}
- rect.moveTo(m_widget->offset());
for (int x = m_visibleDepth; x >= 0; --x)
{
int width = rect.width() / 2;
--- trunk/playground/utils/filelight/src/part/radialMap/map.h #974935:974936
@@ -23,7 +23,6 @@
#define MAP_H
#include "part/fileTree.h"
-#include "widget.h"
#include <QPixmap>
#include <QRect>
@@ -31,12 +30,11 @@
namespace RadialMap {
class Segment;
-class Widget;
class Map
{
public:
- Map(Widget*);
+ Map(bool summary);
~Map();
void make(const Directory *, bool = false);
@@ -53,24 +51,27 @@
int width() const {
return m_rect.width();
}
+ QPixmap pixmap() {
+ return m_pixmap;
+ }
friend class Builder;
friend class Widget;
private:
- void paint(bool = false);
- void aaPaint();
+ void paint(bool antialias = true);
void colorise();
void setRingBreadth();
Chain<Segment> *m_signature;
- QRect m_rect;
- uint m_visibleDepth; ///visible level depth of system
- Widget* m_widget;
- uint m_ringBreadth; ///ring breadth
- uint m_innerRadius; ///radius of inner circle
- QString m_centerText;
+ QRect m_rect;
+ uint m_visibleDepth; ///visible level depth of system
+ QPixmap m_pixmap;
+ uint m_ringBreadth; ///ring breadth
+ uint m_innerRadius; ///radius of inner circle
+ QString m_centerText;
+ bool m_summary;
uint MAP_2MARGIN;
};
--- trunk/playground/utils/filelight/src/part/radialMap/widget.cpp #974935:974936
@@ -40,7 +40,7 @@
: QWidget(parent)
, m_tree(0)
, m_focus(0)
- , m_map(this)
+ , m_map(isSummary)
, m_rootSegment(0) //TODO we don't delete it, *shrug*
, m_isSummary(isSummary)
{
@@ -160,7 +160,7 @@
break;
case 2:
- m_map.aaPaint();
+ m_map.paint(true); //antialiased painting
break;
case 3:
--- trunk/playground/utils/filelight/src/part/radialMap/widget.h #974935:974936
@@ -69,8 +69,6 @@
return m_isSummary;
}
- QPoint offset() { return m_offset; }
-
friend class Label; //FIXME badness
public slots:
--- trunk/playground/utils/filelight/src/part/radialMap/widgetEvents.cpp #974935:974936
@@ -64,21 +64,20 @@
void
RadialMap::Widget::paintEvent(QPaintEvent*)
{
+ QPainter paint;
+ paint.begin(this);
+
if (!m_map.isNull())
- m_map.paint(this);
+ paint.drawPixmap(m_offset, m_map.pixmap());
else
{
- QPainter paint;
- paint.begin(this);
paint.drawText(rect(), 0, i18n("Internal representation is invalid,\nplease reload."));
- paint.end();
return;
}
//exploded labels
if (!m_map.isNull() && !m_timer.isActive())
{
- QPainter paint(this);
if (Config::antialias) paint.setRenderHint(QPainter::Antialiasing);
paintExplodedLabels(paint);
}
@@ -150,7 +149,7 @@
m_tip->updateTip(m_focus->file(), m_tree);
emit mouseHover(m_focus->file()->fullPath());
- m_tip->update();
+ update();
}
m_tip->moveTo(e->globalPos(), (p.y() < 0));
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic