• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeutils API Reference
  • KDE Home
  • Contact Us
 

filelight

  • sources
  • kde-4.12
  • kdeutils
  • filelight
  • src
  • part
  • radialMap
widget.cpp
Go to the documentation of this file.
1 /***********************************************************************
2 * Copyright 2003-2004 Max Howell <max.howell@methylblue.com>
3 * Copyright 2008-2009 Martin Sandsmark <martin.sandsmark@kde.org>
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of
8 * the License or (at your option) version 3 or any later version
9 * accepted by the membership of KDE e.V. (or its successor approved
10 * by the membership of KDE e.V.), which shall act as a proxy
11 * defined in Section 14 of version 3 of the license.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 ***********************************************************************/
21 
22 #include "widget.h"
23 
24 #include "part/Config.h"
25 #include "part/fileTree.h"
26 #include "radialMap.h" //constants
27 #include "map.h"
28 
29 #include <KCursor> //ctor
30 #include <KUrl>
31 
32 #include <QtGui/QApplication> //sendEvent
33 #include <QtGui/QBitmap> //ctor - finding cursor size
34 #include <QtGui/QCursor> //slotPostMouseEvent()
35 #include <QtCore/QTimer> //member
36 #include <QtGui/QWidget>
37 
38 
39 RadialMap::Widget::Widget(QWidget *parent, bool isSummary)
40  : QWidget(parent)
41  , m_tree(0)
42  , m_focus(0)
43  , m_map(isSummary)
44  , m_rootSegment(0) //TODO we don't delete it, *shrug*
45  , m_isSummary(isSummary)
46  , m_toBeDeleted(0)
47 {
48  setAcceptDrops(true);
49  setMinimumSize(350, 250);
50 
51  connect(this, SIGNAL(created(const Folder*)), SLOT(sendFakeMouseEvent()));
52  connect(this, SIGNAL(created(const Folder*)), SLOT(update()));
53  connect(&m_timer, SIGNAL(timeout()), SLOT(resizeTimeout()));
54 }
55 
56 RadialMap::Widget::~Widget()
57 {
58  delete m_rootSegment;
59 }
60 
61 
62 QString
63 RadialMap::Widget::path() const
64 {
65  return m_tree->fullPath();
66 }
67 
68 KUrl
69 RadialMap::Widget::url(File const * const file) const
70 {
71  return KUrl(file ? file->fullPath() : m_tree->fullPath());
72 }
73 
74 void
75 RadialMap::Widget::invalidate()
76 {
77  if (isValid())
78  {
79  //**** have to check that only way to invalidate is this function frankly
80  //**** otherwise you may get bugs..
81 
82  //disable mouse tracking
83  setMouseTracking(false);
84 
85  //ensure this class won't think we have a map still
86  m_tree = 0;
87  m_focus = 0;
88 
89  delete m_rootSegment;
90  m_rootSegment = 0;
91 
92  //FIXME move this disablement thing no?
93  // it is confusing in other areas, like the whole createFromCache() thing
94  m_map.invalidate();
95  update();
96 
97  //tell rest of Filelight
98  emit invalidated(url());
99  }
100 }
101 
102 void
103 RadialMap::Widget::create(const Folder *tree)
104 {
105  //it is not the responsibility of create() to invalidate first
106  //skip invalidation at your own risk
107 
108  //FIXME make it the responsibility of create to invalidate first
109 
110  if (tree)
111  {
112  m_focus = 0;
113  //generate the filemap image
114  m_map.make(tree);
115 
116  //this is the inner circle in the center
117  m_rootSegment = new Segment(tree, 0, 16*360);
118 
119  setMouseTracking(true);
120  }
121 
122  m_tree = tree;
123 
124  //tell rest of Filelight
125  emit created(tree);
126 }
127 
128 void
129 RadialMap::Widget::createFromCache(const Folder *tree)
130 {
131  //no scan was necessary, use cached tree, however we MUST still emit invalidate
132  invalidate();
133  create(tree);
134 }
135 
136 void
137 RadialMap::Widget::sendFakeMouseEvent() //slot
138 {
139  QMouseEvent me(QEvent::MouseMove, mapFromGlobal(QCursor::pos()), Qt::NoButton, Qt::NoButton, Qt::NoModifier);
140  QApplication::sendEvent(this, &me);
141 }
142 
143 void
144 RadialMap::Widget::resizeTimeout() //slot
145 {
146  // the segments are about to erased!
147  // this was a horrid bug, and proves the OO programming should be obeyed always!
148  m_focus = 0;
149  if (m_tree)
150  m_map.make(m_tree, true);
151  update();
152 }
153 
154 void
155 RadialMap::Widget::refresh(int filth)
156 {
157  //TODO consider a more direct connection
158 
159  if (!m_map.isNull())
160  {
161  switch (filth)
162  {
163  case 1:
164  m_focus=0;
165  m_map.make(m_tree, true); //true means refresh only
166  break;
167 
168  case 2:
169  m_map.paint(true); //antialiased painting
170  break;
171 
172  case 3:
173  m_map.colorise(); //FALL THROUGH!
174  case 4:
175  m_map.paint();
176 
177  default:
178  break;
179  }
180 
181  update();
182  }
183 }
184 
185 void
186 RadialMap::Widget::zoomIn() //slot
187 {
188  if (m_map.m_visibleDepth > MIN_RING_DEPTH)
189  {
190  --m_map.m_visibleDepth;
191  m_focus = 0;
192  m_map.make(m_tree);
193  Config::defaultRingDepth = m_map.m_visibleDepth;
194  update();
195  }
196 }
197 
198 void
199 RadialMap::Widget::zoomOut() //slot
200 {
201  m_focus = 0;
202  ++m_map.m_visibleDepth;
203  m_map.make(m_tree);
204  if (m_map.m_visibleDepth > Config::defaultRingDepth)
205  Config::defaultRingDepth = m_map.m_visibleDepth;
206  update();
207 }
208 
209 
210 RadialMap::Segment::~Segment()
211 {
212  if (isFake())
213  delete m_file; //created by us in Builder::build()
214 }
215 
216 #include "widget.moc"
RadialMap::Widget::Widget
Widget(QWidget *=0, bool=false)
Definition: widget.cpp:39
RadialMap::Widget::created
void created(const Folder *)
RadialMap::Widget::refresh
void refresh(int)
Definition: widget.cpp:155
RadialMap::Widget::invalidate
void invalidate()
Definition: widget.cpp:75
RadialMap::Widget::zoomOut
void zoomOut()
Definition: widget.cpp:199
QWidget
Config.h
RadialMap::Widget::~Widget
virtual ~Widget()
Definition: widget.cpp:56
File::fullPath
QString fullPath(const Folder *=0) const
Definition: fileTree.cpp:28
MIN_RING_DEPTH
#define MIN_RING_DEPTH
Definition: radialMap.h:100
radialMap.h
RadialMap::Widget::path
QString path() const
Definition: widget.cpp:63
Folder
Definition: fileTree.h:271
fileTree.h
RadialMap::Widget::create
void create(const Folder *)
Definition: widget.cpp:103
Filelight::parent
http QObject * parent
Definition: part.cpp:74
widget.h
RadialMap::Segment::~Segment
~Segment()
Definition: widget.cpp:210
map.h
RadialMap::Widget::url
KUrl url(File const *const =0) const
Definition: widget.cpp:69
RadialMap::Widget::zoomIn
void zoomIn()
Definition: widget.cpp:186
RadialMap::Segment
Definition: radialMap.h:31
File
Definition: fileTree.h:225
Filelight::m_map
http QObject const QList< QVariant > m_map(0)
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:08:08 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

filelight

Skip menu "filelight"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdeutils API Reference

Skip menu "kdeutils API Reference"
  • ark
  • filelight
  • kcalc
  • kcharselect
  • kdf
  • kfloppy
  • kgpg
  • kremotecontrol
  • ktimer
  • kwallet
  • superkaramba
  • sweeper

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal