summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin T. H. Sandsmark <martin.sandsmark@kde.org>2016-08-21 18:39:39 (GMT)
committerMartin T. H. Sandsmark <martin.sandsmark@kde.org>2016-08-27 13:02:43 (GMT)
commit6175850d0195bccf362d19ea7a874c6a81252c6a (patch)
treeadbd7fd3a4b01ae7156f99e1fc9b4fe2a05d4708
parent4de788b10cf2753dc341d6d34c2a9190505640f0 (diff)
Port radial map from Chain to QList
-rw-r--r--src/part/radialMap/labels.cpp28
-rw-r--r--src/part/radialMap/map.cpp40
-rw-r--r--src/part/radialMap/map.h2
-rw-r--r--src/part/radialMap/widgetEvents.cpp9
4 files changed, 34 insertions, 45 deletions
diff --git a/src/part/radialMap/labels.cpp b/src/part/radialMap/labels.cpp
index 71b0dd6..d46e82d 100644
--- a/src/part/radialMap/labels.cpp
+++ b/src/part/radialMap/labels.cpp
@@ -102,34 +102,26 @@ RadialMap::Widget::paintExplodedLabels(QPainter &paint) const
minAngle = int(m_focus->length() * LABEL_MIN_ANGLE_FACTOR);
-#define segment (*it)
-#define ring (m_map.m_signature + i)
-
//**** Levels should be on a scale starting with 0
//**** range is a useless parameter
//**** keep a topblock var which is the lowestLevel OR startLevel for identation purposes
- for (unsigned int i = startLevel; i <= m_map.m_visibleDepth; ++i)
- for (Iterator<Segment> it = ring->iterator(); it != ring->end(); ++it)
- if (segment->start() >= start && segment->end() <= end)
+ for (unsigned int i = startLevel; i <= m_map.m_visibleDepth; ++i) {
+ for (const Segment *segment : m_map.m_signature[i]) {
+ if (segment->start() >= start && segment->end() <= end) {
if (segment->length() > minAngle) {
list.append(new Label(segment, i));
}
-
-#undef ring
-#undef segment
-
+ }
+ }
+ }
} else {
-#define ring m_map.m_signature
-
- for (Iterator<Segment> it = ring->iterator(); it != ring->end(); ++it)
- if ((*it)->length() > 288) {
- list.append(new Label((*it), 0));
+ for (Segment *segment : *m_map.m_signature) {
+ if (segment->length() > 288) {
+ list.append(new Label(segment, 0));
}
-
-#undef ring
-
+ }
}
qSort(list.begin(), list.end(), compareAndSortLabels);
diff --git a/src/part/radialMap/map.cpp b/src/part/radialMap/map.cpp
index cc67ebc..0401692 100644
--- a/src/part/radialMap/map.cpp
+++ b/src/part/radialMap/map.cpp
@@ -76,7 +76,7 @@ void RadialMap::Map::make(const Folder *tree, bool refresh)
//**** this is a mess
delete [] m_signature;
- m_signature = new Chain<Segment>[m_visibleDepth + 1];
+ m_signature = new QList<Segment*>[m_visibleDepth + 1];
m_root = tree;
@@ -265,10 +265,9 @@ void RadialMap::Map::colorise()
for (uint i = 0; i <= m_visibleDepth; ++i, darkness += 0.04)
{
- for (Iterator<Segment> it = m_signature[i].iterator(); it != m_signature[i].end(); ++it)
- {
+ for (Segment *segment : m_signature[i]) {
if (m_summary){ // Summary view has its own colors, special cased.
- if ((*it)->file()->name() == QLatin1String("Used")) {
+ if (segment->file()->name() == QLatin1String("Used")) {
cb = QApplication::palette().highlight().color();
cb.getHsv(&h, &s1, &v1);
@@ -287,7 +286,7 @@ void RadialMap::Map::colorise()
cb = Qt::white;
}
- (*it)->setPalette(cp, cb);
+ segment->setPalette(cp, cb);
}
else
{
@@ -298,7 +297,7 @@ void RadialMap::Map::colorise()
//gradient will work by figuring out rgb delta values for 360 degrees
//then each component is angle*delta
- int a = (*it)->start();
+ int a = segment->start();
if (a > 2880) a = 2880 - (a - 2880);
@@ -315,11 +314,11 @@ void RadialMap::Map::colorise()
case Filelight::HighContrast:
cp.setHsv(0, 0, 0); //values of h, s and v are irrelevant
cb.setHsv(180, 0, int(255.0 * contrast));
- (*it)->setPalette(cp, cb);
+ segment->setPalette(cp, cb);
continue;
default:
- h = int((*it)->start() / 16);
+ h = int(segment->start() / 16);
s1 = 160;
v1 = (int)(255.0 / darkness); //****doing this more often than once seems daft!
}
@@ -329,12 +328,12 @@ void RadialMap::Map::colorise()
if (s1 < 80) s1 = 80; //can fall too low and makes contrast between the files hard to discern
- if ((*it)->isFake()) //multi-file
+ if (segment->isFake()) //multi-file
{
cb.setHsv(h, s2, (v2 < 90) ? 90 : v2); //too dark if < 100
cp.setHsv(h, 17, v1);
}
- else if (!(*it)->file()->isFolder()) //file
+ else if (!segment->file()->isFolder()) //file
{
cb.setHsv(h, 17, v1);
cp.setHsv(h, 17, v2);
@@ -345,7 +344,7 @@ void RadialMap::Map::colorise()
cp.setHsv(h, s2, v2); //v was 225 - delta
}
- (*it)->setPalette(cp, cb);
+ segment->setPalette(cp, cb);
//TODO:
//**** may be better to store KDE colours as H and S and vary V as others
@@ -406,19 +405,18 @@ void RadialMap::Map::paint(bool antialias)
//clever geometric trick to find largest angle that will give biggest arrow head
uint a_max = int(acos((double)width / double((width + 5))) * (180*16 / M_PI));
- for (ConstIterator<Segment> it = m_signature[x].constIterator(); it != m_signature[x].end(); ++it)
- {
+ for (Segment *segment : m_signature[x]) {
//draw the pie segments, most of this code is concerned with drawing the little
//arrows on the ends of segments when they have hidden files
- paint.setPen((*it)->pen());
+ paint.setPen(segment->pen());
- if ((*it)->hasHiddenChildren())
+ if (segment->hasHiddenChildren())
{
//draw arrow head to indicate undisplayed files/directories
QPolygon pts(3);
QPoint pos, cpos = rect.center();
- uint a[3] = { (*it)->start(), (*it)->length(), 0 };
+ uint a[3] = { segment->start(), segment->length(), 0 };
a[2] = a[0] + (a[1] / 2); //assign to halfway between
if (a[1] > a_max)
@@ -441,14 +439,14 @@ void RadialMap::Map::paint(bool antialias)
pts.setPoint(i, pos);
}
- paint.setBrush((*it)->pen());
+ paint.setBrush(segment->pen());
paint.drawPolygon(pts);
}
- paint.setBrush((*it)->brush());
- paint.drawPie(rect, (*it)->start(), (*it)->length());
+ paint.setBrush(segment->brush());
+ paint.drawPie(rect, segment->start(), segment->length());
- if ((*it)->hasHiddenChildren())
+ if (segment->hasHiddenChildren())
{
//**** code is bloated!
paint.save();
@@ -459,7 +457,7 @@ void RadialMap::Map::paint(bool antialias)
QRect rect2 = rect;
width /= 2;
rect2.adjust(width, width, -width, -width);
- paint.drawArc(rect2, (*it)->start(), (*it)->length());
+ paint.drawArc(rect2, segment->start(), segment->length());
paint.restore();
}
}
diff --git a/src/part/radialMap/map.h b/src/part/radialMap/map.h
index 2bf29fa..708d90b 100644
--- a/src/part/radialMap/map.h
+++ b/src/part/radialMap/map.h
@@ -67,7 +67,7 @@ private:
void findVisibleDepth(const Folder *dir, uint currentDepth = 0);
bool build(const Folder* const dir, const uint depth =0, uint a_start =0, const uint a_end =5760);
- Chain<Segment> *m_signature;
+ QList<Segment*> *m_signature;
const Folder *m_root;
uint m_minSize;
diff --git a/src/part/radialMap/widgetEvents.cpp b/src/part/radialMap/widgetEvents.cpp
index 1c7b244..f92184e 100644
--- a/src/part/radialMap/widgetEvents.cpp
+++ b/src/part/radialMap/widgetEvents.cpp
@@ -121,11 +121,10 @@ const RadialMap::Segment* RadialMap::Widget::segmentAt(QPoint &e) const
//acos only understands 0-180 degrees
if (e.y() < 0) a = 5760 - a;
-#define ring (m_map.m_signature + depth)
- for (ConstIterator<Segment> it = ring->constIterator(); it != ring->end(); ++it)
- if ((*it)->intersects(a))
- return *it;
-#undef ring
+ for (Segment *segment : m_map.m_signature[depth]) {
+ if (segment->intersects(a))
+ return segment;
+ }
}
}
else return m_rootSegment; //hovering over inner circle