Changeset View
Changeset View
Standalone View
Standalone View
krusader/DiskUsage/radialMap/widget.cpp
Show All 34 Lines | |||||
35 | #include <KWidgetsAddons/KCursor> //ctor | 35 | #include <KWidgetsAddons/KCursor> //ctor | ||
36 | 36 | | |||
37 | #include "fileTree.h" | 37 | #include "fileTree.h" | ||
38 | #include "Config.h" | 38 | #include "Config.h" | ||
39 | #include "radialMap.h" //constants | 39 | #include "radialMap.h" //constants | ||
40 | 40 | | |||
41 | RadialMap::Widget::Widget(QWidget *parent) | 41 | RadialMap::Widget::Widget(QWidget *parent) | ||
42 | : QWidget(parent) | 42 | : QWidget(parent) | ||
43 | , m_tree(0) | 43 | , m_tree(nullptr) | ||
44 | , m_focus(0) | 44 | , m_focus(nullptr) | ||
45 | , m_tip(QFontMetrics(font()).height()) //needs to know cursor height | 45 | , m_tip(QFontMetrics(font()).height()) //needs to know cursor height | ||
46 | , m_rootSegment(0) //TODO we don't delete it, *shrug* | 46 | , m_rootSegment(nullptr) //TODO we don't delete it, *shrug* | ||
47 | { | 47 | { | ||
48 | QPalette pal = palette(); | 48 | QPalette pal = palette(); | ||
49 | pal.setColor(backgroundRole(), Qt::white); | 49 | pal.setColor(backgroundRole(), Qt::white); | ||
50 | setPalette(pal); | 50 | setPalette(pal); | ||
51 | 51 | | |||
52 | connect(this, SIGNAL(created(const Directory*)), SLOT(sendFakeMouseEvent())); | 52 | connect(this, SIGNAL(created(const Directory*)), SLOT(sendFakeMouseEvent())); | ||
53 | connect(this, SIGNAL(created(const Directory*)), SLOT(update())); | 53 | connect(this, SIGNAL(created(const Directory*)), SLOT(update())); | ||
54 | connect(&m_timer, SIGNAL(timeout()), SLOT(resizeTimeout())); | 54 | connect(&m_timer, SIGNAL(timeout()), SLOT(resizeTimeout())); | ||
55 | } | 55 | } | ||
56 | 56 | | |||
57 | QString | 57 | QString | ||
58 | RadialMap::Widget::path() const | 58 | RadialMap::Widget::path() const | ||
59 | { | 59 | { | ||
60 | if (m_tree == 0) | 60 | if (m_tree == nullptr) | ||
61 | return QString(); | 61 | return QString(); | ||
62 | return m_tree->fullPath(); | 62 | return m_tree->fullPath(); | ||
63 | } | 63 | } | ||
64 | 64 | | |||
65 | QUrl | 65 | QUrl | ||
66 | RadialMap::Widget::url(File const * const file) const | 66 | RadialMap::Widget::url(File const * const file) const | ||
67 | { | 67 | { | ||
68 | if (file == 0 && m_tree == 0) | 68 | if (file == nullptr && m_tree == nullptr) | ||
69 | return QUrl(); | 69 | return QUrl(); | ||
70 | 70 | | |||
71 | return QUrl::fromLocalFile(file ? file->fullPath() : m_tree->fullPath()); | 71 | return QUrl::fromLocalFile(file ? file->fullPath() : m_tree->fullPath()); | ||
72 | } | 72 | } | ||
73 | 73 | | |||
74 | void | 74 | void | ||
75 | RadialMap::Widget::invalidate(const bool b) | 75 | RadialMap::Widget::invalidate(const bool b) | ||
76 | { | 76 | { | ||
77 | if (isValid()) { | 77 | if (isValid()) { | ||
78 | //**** have to check that only way to invalidate is this function frankly | 78 | //**** have to check that only way to invalidate is this function frankly | ||
79 | //**** otherwise you may get bugs.. | 79 | //**** otherwise you may get bugs.. | ||
80 | 80 | | |||
81 | //disable mouse tracking | 81 | //disable mouse tracking | ||
82 | setMouseTracking(false); | 82 | setMouseTracking(false); | ||
83 | 83 | | |||
84 | QUrl urlInv = url(); | 84 | QUrl urlInv = url(); | ||
85 | 85 | | |||
86 | //ensure this class won't think we have a map still | 86 | //ensure this class won't think we have a map still | ||
87 | m_tree = 0; | 87 | m_tree = nullptr; | ||
88 | m_focus = 0; | 88 | m_focus = nullptr; | ||
89 | 89 | | |||
90 | delete m_rootSegment; | 90 | delete m_rootSegment; | ||
91 | m_rootSegment = 0; | 91 | m_rootSegment = nullptr; | ||
92 | 92 | | |||
93 | //FIXME move this disablement thing no? | 93 | //FIXME move this disablement thing no? | ||
94 | // it is confusing in other areas, like the whole createFromCache() thing | 94 | // it is confusing in other areas, like the whole createFromCache() thing | ||
95 | m_map.invalidate(b); //b signifies whether the pixmap is made to look disabled or not | 95 | m_map.invalidate(b); //b signifies whether the pixmap is made to look disabled or not | ||
96 | if (b) | 96 | if (b) | ||
97 | update(); | 97 | update(); | ||
98 | 98 | | |||
99 | //tell rest of Filelight | 99 | //tell rest of Filelight | ||
100 | emit invalidated(urlInv); | 100 | emit invalidated(urlInv); | ||
101 | } | 101 | } | ||
102 | } | 102 | } | ||
103 | 103 | | |||
104 | void | 104 | void | ||
105 | RadialMap::Widget::create(const Directory *tree) | 105 | RadialMap::Widget::create(const Directory *tree) | ||
106 | { | 106 | { | ||
107 | //it is not the responsibility of create() to invalidate first | 107 | //it is not the responsibility of create() to invalidate first | ||
108 | //skip invalidation at your own risk | 108 | //skip invalidation at your own risk | ||
109 | 109 | | |||
110 | //FIXME make it the responsibility of create to invalidate first | 110 | //FIXME make it the responsibility of create to invalidate first | ||
111 | 111 | | |||
112 | if (tree) { | 112 | if (tree) { | ||
113 | m_focus = 0; | 113 | m_focus = nullptr; | ||
114 | //generate the filemap image | 114 | //generate the filemap image | ||
115 | m_map.make(tree); | 115 | m_map.make(tree); | ||
116 | 116 | | |||
117 | //this is the inner circle in the center | 117 | //this is the inner circle in the center | ||
118 | m_rootSegment = new Segment(tree, 0, 16*360); | 118 | m_rootSegment = new Segment(tree, 0, 16*360); | ||
119 | 119 | | |||
120 | setMouseTracking(true); | 120 | setMouseTracking(true); | ||
121 | } | 121 | } | ||
Show All 19 Lines | 139 | { | |||
141 | QApplication::sendEvent(this, &me); | 141 | QApplication::sendEvent(this, &me); | ||
142 | } | 142 | } | ||
143 | 143 | | |||
144 | void | 144 | void | ||
145 | RadialMap::Widget::resizeTimeout() //slot | 145 | RadialMap::Widget::resizeTimeout() //slot | ||
146 | { | 146 | { | ||
147 | // the segments are about to erased! | 147 | // the segments are about to erased! | ||
148 | // this was a horrid bug, and proves the OO programming should be obeyed always! | 148 | // this was a horrid bug, and proves the OO programming should be obeyed always! | ||
149 | m_focus = 0; | 149 | m_focus = nullptr; | ||
150 | if (m_tree) | 150 | if (m_tree) | ||
151 | m_map.make(m_tree, true); | 151 | m_map.make(m_tree, true); | ||
152 | update(); | 152 | update(); | ||
153 | } | 153 | } | ||
154 | 154 | | |||
155 | void | 155 | void | ||
156 | RadialMap::Widget::refresh(int filth) | 156 | RadialMap::Widget::refresh(int filth) | ||
157 | { | 157 | { | ||
158 | //TODO consider a more direct connection | 158 | //TODO consider a more direct connection | ||
159 | 159 | | |||
160 | if (!m_map.isNull()) { | 160 | if (!m_map.isNull()) { | ||
161 | switch (filth) { | 161 | switch (filth) { | ||
162 | case 1: | 162 | case 1: | ||
163 | m_focus = 0; | 163 | m_focus = nullptr; | ||
164 | if (m_tree) | 164 | if (m_tree) | ||
165 | m_map.make(m_tree, true); //true means refresh only | 165 | m_map.make(m_tree, true); //true means refresh only | ||
166 | break; | 166 | break; | ||
167 | 167 | | |||
168 | case 2: | 168 | case 2: | ||
169 | m_map.aaPaint(); | 169 | m_map.aaPaint(); | ||
170 | break; | 170 | break; | ||
171 | 171 | | |||
Show All 9 Lines | |||||
181 | update(); | 181 | update(); | ||
182 | } | 182 | } | ||
183 | } | 183 | } | ||
184 | 184 | | |||
185 | void | 185 | void | ||
186 | RadialMap::Widget::zoomIn() //slot | 186 | RadialMap::Widget::zoomIn() //slot | ||
187 | { | 187 | { | ||
188 | if (m_map.m_visibleDepth > MIN_RING_DEPTH) { | 188 | if (m_map.m_visibleDepth > MIN_RING_DEPTH) { | ||
189 | m_focus = 0; | 189 | m_focus = nullptr; | ||
190 | --m_map.m_visibleDepth; | 190 | --m_map.m_visibleDepth; | ||
191 | if (m_tree) | 191 | if (m_tree) | ||
192 | m_map.make(m_tree); | 192 | m_map.make(m_tree); | ||
193 | Config::defaultRingDepth = m_map.m_visibleDepth; | 193 | Config::defaultRingDepth = m_map.m_visibleDepth; | ||
194 | update(); | 194 | update(); | ||
195 | } | 195 | } | ||
196 | } | 196 | } | ||
197 | 197 | | |||
198 | void | 198 | void | ||
199 | RadialMap::Widget::zoomOut() //slot | 199 | RadialMap::Widget::zoomOut() //slot | ||
200 | { | 200 | { | ||
201 | m_focus = 0; | 201 | m_focus = nullptr; | ||
202 | ++m_map.m_visibleDepth; | 202 | ++m_map.m_visibleDepth; | ||
203 | if (m_tree) | 203 | if (m_tree) | ||
204 | m_map.make(m_tree); | 204 | m_map.make(m_tree); | ||
205 | if (m_map.m_visibleDepth > Config::defaultRingDepth) | 205 | if (m_map.m_visibleDepth > Config::defaultRingDepth) | ||
206 | Config::defaultRingDepth = m_map.m_visibleDepth; | 206 | Config::defaultRingDepth = m_map.m_visibleDepth; | ||
207 | update(); | 207 | update(); | ||
208 | } | 208 | } | ||
209 | 209 | | |||
210 | 210 | | |||
211 | RadialMap::Segment::~Segment() | 211 | RadialMap::Segment::~Segment() | ||
212 | { | 212 | { | ||
213 | if (isFake()) | 213 | if (isFake()) | ||
214 | delete m_file; //created by us in Builder::build() | 214 | delete m_file; //created by us in Builder::build() | ||
215 | } | 215 | } | ||
216 | 216 | |