Changeset View
Changeset View
Standalone View
Standalone View
krusader/DiskUsage/radialMap/map.cpp
Show All 34 Lines | |||||
35 | #include "Config.h" | 35 | #include "Config.h" | ||
36 | #include "fileTree.h" | 36 | #include "fileTree.h" | ||
37 | #include "sincos.h" | 37 | #include "sincos.h" | ||
38 | #include "widget.h" | 38 | #include "widget.h" | ||
39 | 39 | | |||
40 | #define COLOR_GREY QColor::fromHsv( 0, 0, 140 ) | 40 | #define COLOR_GREY QColor::fromHsv( 0, 0, 140 ) | ||
41 | 41 | | |||
42 | RadialMap::Map::Map() | 42 | RadialMap::Map::Map() | ||
43 | : m_signature(0) | 43 | : m_signature(nullptr) | ||
44 | , m_ringBreadth(MIN_RING_BREADTH) | 44 | , m_ringBreadth(MIN_RING_BREADTH) | ||
45 | , m_innerRadius(0) | 45 | , m_innerRadius(0) | ||
46 | , m_visibleDepth(DEFAULT_RING_DEPTH) | 46 | , m_visibleDepth(DEFAULT_RING_DEPTH) | ||
47 | { | 47 | { | ||
48 | //FIXME this is all broken. No longer is a maximum depth! | 48 | //FIXME this is all broken. No longer is a maximum depth! | ||
49 | const int fmh = QFontMetrics(QFont()).height(); | 49 | const int fmh = QFontMetrics(QFont()).height(); | ||
50 | const int fmhD4 = fmh / 4; | 50 | const int fmhD4 = fmh / 4; | ||
51 | MAP_2MARGIN = 2 * (fmh - (fmhD4 - LABEL_MAP_SPACER)); //margin is dependent on fitting in labels at top and bottom | 51 | MAP_2MARGIN = 2 * (fmh - (fmhD4 - LABEL_MAP_SPACER)); //margin is dependent on fitting in labels at top and bottom | ||
52 | } | 52 | } | ||
53 | 53 | | |||
54 | RadialMap::Map::~Map() | 54 | RadialMap::Map::~Map() | ||
55 | { | 55 | { | ||
56 | delete [] m_signature; | 56 | delete [] m_signature; | ||
57 | } | 57 | } | ||
58 | 58 | | |||
59 | void | 59 | void | ||
60 | RadialMap::Map::invalidate(const bool desaturateTheImage) | 60 | RadialMap::Map::invalidate(const bool desaturateTheImage) | ||
61 | { | 61 | { | ||
62 | delete [] m_signature; | 62 | delete [] m_signature; | ||
63 | m_signature = 0; | 63 | m_signature = nullptr; | ||
64 | 64 | | |||
65 | if (desaturateTheImage) { | 65 | if (desaturateTheImage) { | ||
66 | QImage img = this->toImage(); | 66 | QImage img = this->toImage(); | ||
67 | 67 | | |||
68 | KIconEffect::deSaturate(img, 0.7); | 68 | KIconEffect::deSaturate(img, 0.7); | ||
69 | KIconEffect::toGray(img, true); | 69 | KIconEffect::toGray(img, true); | ||
70 | 70 | | |||
71 | this->QPixmap::operator=(fromImage(img, Qt::AutoColor)); | 71 | this->QPixmap::operator=(fromImage(img, Qt::AutoColor)); | ||
▲ Show 20 Lines • Show All 72 Lines • ▼ Show 20 Line(s) | 138 | { | |||
144 | //this QRect is used by paint() | 144 | //this QRect is used by paint() | ||
145 | m_rect.setRect(mD2, mD2, size, size); | 145 | m_rect.setRect(mD2, mD2, size, size); | ||
146 | } | 146 | } | ||
147 | 147 | | |||
148 | //resize the pixmap | 148 | //resize the pixmap | ||
149 | size += MAP_2MARGIN; | 149 | size += MAP_2MARGIN; | ||
150 | this->QPixmap::operator=(QPixmap(size, size)); | 150 | this->QPixmap::operator=(QPixmap(size, size)); | ||
151 | 151 | | |||
152 | if (m_signature != NULL) { | 152 | if (m_signature != nullptr) { | ||
153 | setRingBreadth(); | 153 | setRingBreadth(); | ||
154 | paint(); | 154 | paint(); | ||
155 | } else fill(); //FIXME I don't like having to do this.. | 155 | } else fill(); //FIXME I don't like having to do this.. | ||
156 | 156 | | |||
157 | return true; | 157 | return true; | ||
158 | } | 158 | } | ||
159 | 159 | | |||
160 | #undef mw | 160 | #undef mw | ||
▲ Show 20 Lines • Show All 127 Lines • ▼ Show 20 Line(s) | 259 | { | |||
288 | 288 | | |||
289 | paint.begin(this); | 289 | paint.begin(this); | ||
290 | 290 | | |||
291 | fill(); //erase background | 291 | fill(); //erase background | ||
292 | 292 | | |||
293 | for (int x = m_visibleDepth; x >= 0; --x) { | 293 | for (int x = m_visibleDepth; x >= 0; --x) { | ||
294 | int width = rect.width() / 2; | 294 | int width = rect.width() / 2; | ||
295 | //clever geometric trick to find largest angle that will give biggest arrow head | 295 | //clever geometric trick to find largest angle that will give biggest arrow head | ||
296 | int a_max = int(acos((double)width / double((width + 5) * scaleFactor)) * (180 * 16 / M_PI)); | 296 | auto a_max = int(acos((double)width / double((width + 5) * scaleFactor)) * (180 * 16 / M_PI)); | ||
297 | 297 | | |||
298 | for (ConstIterator<Segment> it = m_signature[x].constIterator(); it != m_signature[x].end(); ++it) { | 298 | for (ConstIterator<Segment> it = m_signature[x].constIterator(); it != m_signature[x].end(); ++it) { | ||
299 | //draw the pie segments, most of this code is concerned with drawing the little | 299 | //draw the pie segments, most of this code is concerned with drawing the little | ||
300 | //arrows on the ends of segments when they have hidden files | 300 | //arrows on the ends of segments when they have hidden files | ||
301 | 301 | | |||
302 | paint.setPen((*it)->pen()); | 302 | paint.setPen((*it)->pen()); | ||
303 | 303 | | |||
304 | if ((*it)->hasHiddenChildren()) { | 304 | if ((*it)->hasHiddenChildren()) { | ||
▲ Show 20 Lines • Show All 103 Lines • Show Last 20 Lines |