summaryrefslogtreecommitdiff
authoralwin <alwin>2005-03-12 02:13:52 (UTC)
committer alwin <alwin>2005-03-12 02:13:52 (UTC)
commitcd1b9f7c11c73ef0df0ce66c53466c979a3a4d42 (patch) (unidiff)
treed4ed9b082abe2aa645fbd58b86d65f5ce9c48348
parent84af289057291a49a52a60b390bc5320c02b5a55 (diff)
downloadopie-cd1b9f7c11c73ef0df0ce66c53466c979a3a4d42.zip
opie-cd1b9f7c11c73ef0df0ce66c53466c979a3a4d42.tar.gz
opie-cd1b9f7c11c73ef0df0ce66c53466c979a3a4d42.tar.bz2
And I'm wondering why opie sometimes is that slow. Hopefully reduced
the calls to opie-eye for images in documenttab when changing layout and so on.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/launcherview.cpp34
-rw-r--r--core/launcher/launcherview.h4
2 files changed, 31 insertions, 7 deletions
diff --git a/core/launcher/launcherview.cpp b/core/launcher/launcherview.cpp
index a4c7561..d960908 100644
--- a/core/launcher/launcherview.cpp
+++ b/core/launcher/launcherview.cpp
@@ -1,1260 +1,1280 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "launcherview.h" 21#include "launcherview.h"
22 22
23/* OPIE */ 23/* OPIE */
24#include <opie2/odebug.h> 24#include <opie2/odebug.h>
25#include <qpe/config.h> 25#include <qpe/config.h>
26#include <qtopia/qpeapplication.h> 26#include <qtopia/qpeapplication.h>
27#include <qtopia/private/categories.h> 27#include <qtopia/private/categories.h>
28#include <qtopia/categoryselect.h> 28#include <qtopia/categoryselect.h>
29#include <qtopia/mimetype.h> 29#include <qtopia/mimetype.h>
30#include <qtopia/resource.h> 30#include <qtopia/resource.h>
31using namespace Opie::Core; 31using namespace Opie::Core;
32 32
33#include <qpe/qcopenvelope_qws.h> 33#include <qpe/qcopenvelope_qws.h>
34 34
35/* QT */ 35/* QT */
36#include <qtimer.h> 36#include <qtimer.h>
37#include <qfileinfo.h> 37#include <qfileinfo.h>
38#include <qiconview.h> 38#include <qiconview.h>
39#include <qobjectlist.h> 39#include <qobjectlist.h>
40 40
41 41
42// These define how the busy icon is animated and highlighted 42// These define how the busy icon is animated and highlighted
43#define BRIGHTEN_BUSY_ICON 43#define BRIGHTEN_BUSY_ICON
44//#define ALPHA_FADE_BUSY_ICON 44//#define ALPHA_FADE_BUSY_ICON
45//#define USE_ANIMATED_BUSY_ICON_OVERLAY 45//#define USE_ANIMATED_BUSY_ICON_OVERLAY
46#define BOUNCE_BUSY_ICON 46#define BOUNCE_BUSY_ICON
47 47
48typedef QMap<QString,QPixmap>::Iterator pixiter; 48typedef QMap<QString,QPixmap>::Iterator pixiter;
49 49
50class BgPixmap 50class BgPixmap
51{ 51{
52public: 52public:
53 BgPixmap( const QPixmap &p ) : pm(p), ref(1) {} 53 BgPixmap( const QPixmap &p ) : pm(p), ref(1) {}
54 QPixmap pm; 54 QPixmap pm;
55 int ref; 55 int ref;
56}; 56};
57 57
58 58
59static QMap<QString,BgPixmap*> *bgCache = 0; 59static QMap<QString,BgPixmap*> *bgCache = 0;
60 60
61static void cleanup_cache() 61static void cleanup_cache()
62{ 62{
63 QMap<QString,BgPixmap*>::Iterator it = bgCache->begin(); 63 QMap<QString,BgPixmap*>::Iterator it = bgCache->begin();
64 while ( it != bgCache->end() ) { 64 while ( it != bgCache->end() ) {
65 QMap<QString,BgPixmap*>::Iterator curr = it; 65 QMap<QString,BgPixmap*>::Iterator curr = it;
66 ++it; 66 ++it;
67 delete (*curr); 67 delete (*curr);
68 bgCache->remove( curr ); 68 bgCache->remove( curr );
69 } 69 }
70 delete bgCache; 70 delete bgCache;
71 bgCache = 0; 71 bgCache = 0;
72} 72}
73 73
74 74
75class LauncherItem : public QIconViewItem 75class LauncherItem : public QIconViewItem
76{ 76{
77public: 77public:
78 enum iconstate_t { 78 enum iconstate_t {
79 BASE_ICON, 79 BASE_ICON,
80 WAITING_ICON, 80 WAITING_ICON,
81 EYE_ICON 81 EYE_ICON
82 }; 82 };
83 83
84 LauncherItem( QIconView *parent, AppLnk* applnk, bool bigIcon=TRUE ); 84 LauncherItem( QIconView *parent, AppLnk* applnk, bool bigIcon=TRUE );
85 ~LauncherItem(); 85 ~LauncherItem();
86 86
87 AppLnk *appLnk() const { return app; } 87 AppLnk *appLnk() const { return app; }
88 AppLnk *takeAppLnk() { AppLnk* r=app; app=0; return r; } 88 AppLnk *takeAppLnk() { AppLnk* r=app; app=0; return r; }
89 89
90 void animateIcon(); 90 void animateIcon();
91 void resetIcon(); 91 void resetIcon();
92 bool isEyeImage()const{return m_EyeImage;} 92 bool isEyeImage()const{return m_EyeImage;}
93 93
94 virtual int compare ( QIconViewItem * i ) const; 94 virtual int compare ( QIconViewItem * i ) const;
95 void paintItem( QPainter *p, const QColorGroup &cg ); 95 void paintItem( QPainter *p, const QColorGroup &cg );
96 96
97 void setBusyIndicatorType ( BusyIndicatorType t ) { busyType = t; } 97 void setBusyIndicatorType ( BusyIndicatorType t ) { busyType = t; }
98 void setEyePixmap(const QPixmap&aIcon); 98 void setEyePixmap(const QPixmap&aIcon);
99 virtual QPixmap*pixmap()const; 99 virtual QPixmap*pixmap()const;
100 100
101protected: 101protected:
102 bool isBigIcon; 102 bool isBigIcon;
103 int iteration; 103 int iteration;
104 AppLnk* app; 104 AppLnk* app;
105 105
106private: 106private:
107 void paintAnimatedIcon( QPainter *p ); 107 void paintAnimatedIcon( QPainter *p );
108 BusyIndicatorType busyType; 108 BusyIndicatorType busyType;
109 int psize; 109 int psize;
110 bool m_EyeImage; 110 bool m_EyeImage;
111 iconstate_t m_EyeImageSet; 111 iconstate_t m_EyeImageSet;
112}; 112};
113 113
114static bool s_IgnoreNextPix = false;
115
114LauncherItem::LauncherItem( QIconView *parent, AppLnk *applnk, bool bigIcon ) 116LauncherItem::LauncherItem( QIconView *parent, AppLnk *applnk, bool bigIcon )
115 : QIconViewItem( parent, applnk->name(), 117 : QIconViewItem( parent, applnk->name(),
116 bigIcon ? applnk->bigPixmap() :applnk->pixmap() ), 118 bigIcon ? applnk->bigPixmap() :applnk->pixmap() ),
117 isBigIcon( bigIcon ), 119 isBigIcon( bigIcon ),
118 iteration(0), 120 iteration(0),
119 app(applnk), // Takes ownership 121 app(applnk), // Takes ownership
120 psize( (bigIcon ? applnk->bigPixmap().width() :applnk->pixmap().width() ) ), 122 psize( (bigIcon ? applnk->bigPixmap().width() :applnk->pixmap().width() ) ),
121 m_EyeImage(false), 123 m_EyeImage(false),
122 m_EyeImageSet(BASE_ICON) 124 m_EyeImageSet(BASE_ICON)
123{ 125{
124 if (applnk->type().lower().startsWith("image/") && applnk->exec().contains("opie-eye",false)) { 126 if (applnk->type().lower().startsWith("image/") && applnk->exec().contains("opie-eye",false)) {
125 m_EyeImage = true; 127 m_EyeImage = true;
126 QMap<QString,QPixmap>::Iterator it = LauncherIconView::sm_EyeCache->find(applnk->file()); 128 QMap<QString,QPixmap>::Iterator it = LauncherIconView::sm_EyeCache->find(applnk->file());
127 if (it != LauncherIconView::sm_EyeCache->end()) { 129 if (it != LauncherIconView::sm_EyeCache->end()) {
128 m_EyeImageSet = EYE_ICON; 130 m_EyeImageSet = EYE_ICON;
129 setPixmap(*it); 131 setPixmap(*it);
130 } 132 }
131 } 133 }
132} 134}
133 135
134LauncherItem::~LauncherItem() 136LauncherItem::~LauncherItem()
135{ 137{
136 LauncherIconView* liv = (LauncherIconView*)iconView(); 138 LauncherIconView* liv = (LauncherIconView*)iconView();
137 if ( liv->busyItem() == this ) 139 if ( liv->busyItem() == this )
138 liv->setBusy(FALSE); 140 liv->setBusy(FALSE);
139 delete app; 141 delete app;
140} 142}
141 143
142QPixmap*LauncherItem::pixmap()const 144QPixmap*LauncherItem::pixmap()const
143{ 145{
144 if (m_EyeImage && m_EyeImageSet == BASE_ICON) { 146 if (m_EyeImage && m_EyeImageSet == BASE_ICON && s_IgnoreNextPix==false) {
145 LauncherIconView* liv = (LauncherIconView*)iconView(); 147 LauncherIconView* liv = (LauncherIconView*)iconView();
146 liv->requestEyePix(this); 148 liv->requestEyePix(this);
147 } 149 }
148 return QIconViewItem::pixmap(); 150 return QIconViewItem::pixmap();
149} 151}
150 152
151int LauncherItem::compare ( QIconViewItem * i ) const 153int LauncherItem::compare ( QIconViewItem * i ) const
152{ 154{
153 LauncherIconView* view = (LauncherIconView*)iconView(); 155 LauncherIconView* view = (LauncherIconView*)iconView();
154 return view->compare(app,((LauncherItem *)i)->appLnk()); 156 return view->compare(app,((LauncherItem *)i)->appLnk());
155} 157}
156 158
157void LauncherItem::paintItem( QPainter *p, const QColorGroup &cg ) 159void LauncherItem::paintItem( QPainter *p, const QColorGroup &cg )
158{ 160{
159 LauncherIconView* liv = (LauncherIconView*)iconView(); 161 LauncherIconView* liv = (LauncherIconView*)iconView();
160 QBrush oldBrush( liv->itemTextBackground() ); 162 QBrush oldBrush( liv->itemTextBackground() );
161 QColorGroup mycg( cg ); 163 QColorGroup mycg( cg );
162 if ( liv->currentItem() == this ) { 164 if ( liv->currentItem() == this ) {
163 liv->setItemTextBackground( cg.brush( QColorGroup::Highlight ) ); 165 liv->setItemTextBackground( cg.brush( QColorGroup::Highlight ) );
164 mycg.setColor( QColorGroup::Text, cg.color( QColorGroup::HighlightedText ) ); 166 mycg.setColor( QColorGroup::Text, cg.color( QColorGroup::HighlightedText ) );
165 } 167 }
166 168
167 QIconViewItem::paintItem(p,mycg); 169 QIconViewItem::paintItem(p,mycg);
168 170
169 // Paint animation overlay 171 // Paint animation overlay
170 if ( liv->busyItem() == this ) 172 if ( liv->busyItem() == this )
171 paintAnimatedIcon(p); 173 paintAnimatedIcon(p);
172 174
173 if ( liv->currentItem() == this ) 175 if ( liv->currentItem() == this )
174 liv->setItemTextBackground( oldBrush ); 176 liv->setItemTextBackground( oldBrush );
175} 177}
176 178
177void LauncherItem::paintAnimatedIcon( QPainter *p ) 179void LauncherItem::paintAnimatedIcon( QPainter *p )
178{ 180{
179 LauncherIconView* liv = (LauncherIconView*)iconView(); 181 LauncherIconView* liv = (LauncherIconView*)iconView();
180 int pic = iteration % 16; 182 int pic = iteration % 16;
181 int w = pixmap()->width(), h = pixmap()->height(); 183 int w = pixmap()->width(), h = pixmap()->height();
182 QPixmap dblBuf( w, h + 4 ); 184 QPixmap dblBuf( w, h + 4 );
183 QPainter p2( &dblBuf ); 185 QPainter p2( &dblBuf );
184 int x1, y1; 186 int x1, y1;
185 if ( liv->itemTextPos() == QIconView::Bottom ) { 187 if ( liv->itemTextPos() == QIconView::Bottom ) {
186 x1 = x() + (width() - w) / 2 - liv->contentsX(); 188 x1 = x() + (width() - w) / 2 - liv->contentsX();
187 y1 = y() - liv->contentsY(); 189 y1 = y() - liv->contentsY();
188 } else { 190 } else {
189 x1 = x() - liv->contentsX(); 191 x1 = x() - liv->contentsX();
190 y1 = y() + (height() - h) / 2 - liv->contentsY(); 192 y1 = y() + (height() - h) / 2 - liv->contentsY();
191 } 193 }
192 y1 -= 2; 194 y1 -= 2;
193 p2.translate(-x1,-y1); 195 p2.translate(-x1,-y1);
194 liv->drawBackground( &p2, QRect(x1,y1,w,h+4) ); 196 liv->drawBackground( &p2, QRect(x1,y1,w,h+4) );
195 int bounceY = 2; 197 int bounceY = 2;
196#ifdef BOUNCE_BUSY_ICON 198#ifdef BOUNCE_BUSY_ICON
197 if ( busyType == BIT_Animated ) { 199 if ( busyType == BIT_Animated ) {
198 bounceY = 4 - ((iteration+2)%8); 200 bounceY = 4 - ((iteration+2)%8);
199 bounceY = bounceY < 0 ? -bounceY : bounceY; 201 bounceY = bounceY < 0 ? -bounceY : bounceY;
200 } 202 }
201#endif 203#endif
202 p2.drawPixmap( x1, y1 + bounceY, *pixmap() ); 204 p2.drawPixmap( x1, y1 + bounceY, *pixmap() );
203#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY 205#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY
204 p2.drawPixmap( x1, y1 + bounceY, liv->busyPixmap(), w * pic, 0, w, h ); 206 p2.drawPixmap( x1, y1 + bounceY, liv->busyPixmap(), w * pic, 0, w, h );
205#else 207#else
206 Q_UNUSED( pic ) 208 Q_UNUSED( pic )
207#endif 209#endif
208 p->drawPixmap( x1, y1, dblBuf ); 210 p->drawPixmap( x1, y1, dblBuf );
209} 211}
210 212
211void LauncherItem::animateIcon() 213void LauncherItem::animateIcon()
212{ 214{
213 LauncherIconView* liv = (LauncherIconView*)iconView(); 215 LauncherIconView* liv = (LauncherIconView*)iconView();
214 216
215 if ( liv->busyItem() != this || !app ) 217 if ( liv->busyItem() != this || !app )
216 return; 218 return;
217 219
218 // Highlight the icon 220 // Highlight the icon
219 if ( iteration == 0 ) { 221 if ( iteration == 0 ) {
220 QPixmap src; 222 QPixmap src;
221 pixiter it; 223 pixiter it;
222 if (isEyeImage() && (it=LauncherIconView::sm_EyeCache->find(appLnk()->file()))!=LauncherIconView::sm_EyeCache->end()) { 224 if (isEyeImage() && (it=LauncherIconView::sm_EyeCache->find(appLnk()->file()))!=LauncherIconView::sm_EyeCache->end()) {
223 src = (*it); 225 src = (*it);
224 } else { 226 } else {
225 src = ((isBigIcon ? app->bigPixmap() : app->pixmap())); 227 src = ((isBigIcon ? app->bigPixmap() : app->pixmap()));
226 } 228 }
227 QImage img = src.convertToImage(); 229 QImage img = src.convertToImage();
228 QRgb *rgb; 230 QRgb *rgb;
229 int count; 231 int count;
230 if ( img.depth() == 32 ) { 232 if ( img.depth() == 32 ) {
231 rgb = (QRgb*)img.bits(); 233 rgb = (QRgb*)img.bits();
232 count = img.bytesPerLine()/sizeof(QRgb)*img.height(); 234 count = img.bytesPerLine()/sizeof(QRgb)*img.height();
233 } else { 235 } else {
234 rgb = img.colorTable(); 236 rgb = img.colorTable();
235 count = img.numColors(); 237 count = img.numColors();
236 } 238 }
237 for ( int r = 0; r < count; r++, rgb++ ) { 239 for ( int r = 0; r < count; r++, rgb++ ) {
238#if defined(BRIGHTEN_BUSY_ICON) 240#if defined(BRIGHTEN_BUSY_ICON)
239 QColor c(*rgb); 241 QColor c(*rgb);
240 int h, s, v; 242 int h, s, v;
241 c.hsv(&h,&s,&v); 243 c.hsv(&h,&s,&v);
242 c.setHsv(h,QMAX(s-24,0),QMIN(v+48,255)); 244 c.setHsv(h,QMAX(s-24,0),QMIN(v+48,255));
243 *rgb = qRgba(c.red(),c.green(),c.blue(),qAlpha(*rgb)); 245 *rgb = qRgba(c.red(),c.green(),c.blue(),qAlpha(*rgb));
244#elif defined(ALPHA_FADE_BUSY_ICON) 246#elif defined(ALPHA_FADE_BUSY_ICON)
245 *rgb = qRgba(qRed(*rgb),qGreen(*rgb),qBlue(*rgb),qAlpha(*rgb)/2); 247 *rgb = qRgba(qRed(*rgb),qGreen(*rgb),qBlue(*rgb),qAlpha(*rgb)/2);
246#endif 248#endif
247 } 249 }
248 src.convertFromImage( img ); 250 src.convertFromImage( img );
249 setPixmap( src ); 251 setPixmap( src );
250 } 252 }
251 253
252 iteration++; 254 iteration++;
253 255
254 // Paint animation overlay 256 // Paint animation overlay
255 QPainter p( liv->viewport() ); 257 QPainter p( liv->viewport() );
256 paintAnimatedIcon( &p ); 258 paintAnimatedIcon( &p );
257} 259}
258 260
259void LauncherItem::resetIcon() 261void LauncherItem::resetIcon()
260{ 262{
261 iteration = 0; 263 iteration = 0;
262 if (isEyeImage()) { 264 if (isEyeImage()) {
263 QMap<QString,QPixmap>::Iterator it = LauncherIconView::sm_EyeCache->find(appLnk()->file()); 265 QMap<QString,QPixmap>::Iterator it = LauncherIconView::sm_EyeCache->find(appLnk()->file());
264 if (it != LauncherIconView::sm_EyeCache->end()) { 266 if (it != LauncherIconView::sm_EyeCache->end()) {
265 setPixmap(*it); 267 setPixmap(*it);
266 return; 268 return;
267 } 269 }
268 } 270 }
269 setPixmap(isBigIcon ? app->bigPixmap() : app->pixmap()); 271 setPixmap(isBigIcon ? app->bigPixmap() : app->pixmap());
270} 272}
271 273
272void LauncherItem::setEyePixmap(const QPixmap&aIcon) 274void LauncherItem::setEyePixmap(const QPixmap&aIcon)
273{ 275{
274 if (!isEyeImage()) return; 276 if (!isEyeImage()) return;
275 setPixmap(aIcon); 277 setPixmap(aIcon);
276 m_EyeImageSet = EYE_ICON; 278 m_EyeImageSet = EYE_ICON;
277} 279}
278 280
279//=========================================================================== 281//===========================================================================
280// Implemantation of LauncherIconview start 282// Implemantation of LauncherIconview start
281//=========================================================================== 283//===========================================================================
282 284
283QMap<QString,QPixmap>* LauncherIconView::sm_EyeCache=0; 285QMap<QString,QPixmap>* LauncherIconView::sm_EyeCache=0;
284 286
285LauncherIconView::LauncherIconView( QWidget* parent, const char* name ) 287LauncherIconView::LauncherIconView( QWidget* parent, const char* name )
286 : QIconView(parent,name),tf(""),cf(0),bsy(0),busyTimer(0),bigIcns(TRUE),bgColor(white),numColumns(0) 288 : QIconView(parent,name),tf(""),cf(0),bsy(0),busyTimer(0),bigIcns(TRUE),bgColor(white),numColumns(0)
287{ 289{
288 m_EyeCallBack = 0; 290 m_EyeCallBack = 0;
289 if (!sm_EyeCache) sm_EyeCache = new QMap<QString,QPixmap>(); 291 if (!sm_EyeCache) sm_EyeCache = new QMap<QString,QPixmap>();
290 sortmeth = Name; 292 sortmeth = Name;
291 hidden.setAutoDelete(TRUE); 293 hidden.setAutoDelete(TRUE);
292 ike = FALSE; 294 ike = FALSE;
293 calculateGrid( Bottom ); 295 calculateGrid( Bottom );
294 connect(&m_eyeTimer,SIGNAL(timeout()),this,SLOT(stopEyeTimer())); 296 connect(&m_eyeTimer,SIGNAL(timeout()),this,SLOT(stopEyeTimer()));
295 Config config( "Launcher" ); 297 Config config( "Launcher" );
296 config.setGroup( "GUI" ); 298 config.setGroup( "GUI" );
297 setStaticBackgroundPicture( config.readBoolEntry( "StaticBackground", true ) ); 299 setStaticBackgroundPicture( config.readBoolEntry( "StaticBackground", true ) );
298} 300}
299 301
300LauncherIconView::~LauncherIconView() 302LauncherIconView::~LauncherIconView()
301{ 303{
302 odebug << "LauncherIconView::~LauncherIconView()" << oendl; 304 odebug << "LauncherIconView::~LauncherIconView()" << oendl;
303#if 0 // debuggery 305#if 0 // debuggery
304 QListIterator<AppLnk> it(hidden); 306 QListIterator<AppLnk> it(hidden);
305 AppLnk* l; 307 AppLnk* l;
306 while ((l=it.current())) { 308 while ((l=it.current())) {
307 ++it; 309 ++it;
308 //odebug << "" << l << ": hidden (should remove)" << oendl; 310 //odebug << "" << l << ": hidden (should remove)" << oendl;
309 } 311 }
310#endif 312#endif
311} 313}
312 314
315void LauncherIconView::unsetPalette()
316{
317 s_IgnoreNextPix = true;
318 QIconView::unsetPalette();
319 s_IgnoreNextPix = false;
320}
321
322void LauncherIconView::setPalette(const QPalette & palette)
323{
324 s_IgnoreNextPix = true;
325 QIconView::setPalette(palette);
326 s_IgnoreNextPix = false;
327}
328
313void LauncherIconView::setStaticBackgroundPicture( bool enable ) 329void LauncherIconView::setStaticBackgroundPicture( bool enable )
314{ 330{
315 staticBackground = enable; 331 staticBackground = enable;
316 if ( staticBackground ) 332 if ( staticBackground )
317 { 333 {
318 setStaticBackground( true ); 334 setStaticBackground( true );
319 verticalScrollBar()->setTracking( false ); 335 verticalScrollBar()->setTracking( false );
320 } 336 }
321 else 337 else
322 { 338 {
323 setStaticBackground( false ); 339 setStaticBackground( false );
324 verticalScrollBar()->setTracking( true ); 340 verticalScrollBar()->setTracking( true );
325 } 341 }
326} 342}
327 343
328int LauncherIconView::compare(const AppLnk* a, const AppLnk* b) 344int LauncherIconView::compare(const AppLnk* a, const AppLnk* b)
329{ 345{
330 switch (sortmeth) { 346 switch (sortmeth) {
331 case Name: 347 case Name:
332 return a->name().lower().compare(b->name().lower()); 348 return a->name().lower().compare(b->name().lower());
333 case Date: { 349 case Date: {
334 QFileInfo fa(a->linkFileKnown() ? a->linkFile() : a->file()); 350 QFileInfo fa(a->linkFileKnown() ? a->linkFile() : a->file());
335 QFileInfo fb(b->linkFileKnown() ? b->linkFile() : b->file()); 351 QFileInfo fb(b->linkFileKnown() ? b->linkFile() : b->file());
336 return fa.lastModified().secsTo(fb.lastModified()); 352 return fa.lastModified().secsTo(fb.lastModified());
337 } 353 }
338 case Type: 354 case Type:
339 return a->type().compare(b->type()); 355 return a->type().compare(b->type());
340 } 356 }
341 return 0; 357 return 0;
342} 358}
343 359
344void LauncherIconView::setSortMethod( SortMethod m ) 360void LauncherIconView::setSortMethod( SortMethod m )
345{ 361{
346 if ( sortmeth != m ) { 362 if ( sortmeth != m ) {
347 sortmeth = m; 363 sortmeth = m;
348 sort(); 364 sort();
349 } 365 }
350} 366}
351 367
352void LauncherIconView::setCategoryFilter( int catfilter, bool resort ) 368void LauncherIconView::setCategoryFilter( int catfilter, bool resort )
353{ 369{
354 if ( catfilter == -2 ) 370 if ( catfilter == -2 )
355 cf = 0; 371 cf = 0;
356 else 372 else
357 cf = catfilter; 373 cf = catfilter;
358 hideOrShowItems(resort); 374 hideOrShowItems(resort);
359} 375}
360 376
361void LauncherIconView::setTypeFilter(const QString& typefilter, bool resort) 377void LauncherIconView::setTypeFilter(const QString& typefilter, bool resort)
362{ 378{
363 tf = QRegExp(typefilter,FALSE,TRUE); 379 tf = QRegExp(typefilter,FALSE,TRUE);
364 hideOrShowItems(resort); 380 hideOrShowItems(resort);
365} 381}
366 382
367void LauncherIconView::setItemTextPos( ItemTextPos pos ) 383void LauncherIconView::setItemTextPos( ItemTextPos pos )
368{ 384{
369 calculateGrid( pos ); 385 calculateGrid( pos );
370 QIconView::setItemTextPos( pos ); 386 QIconView::setItemTextPos( pos );
371} 387}
372 388
373void LauncherIconView::drawBackground( QPainter *p, const QRect &r ) 389void LauncherIconView::drawBackground( QPainter *p, const QRect &r )
374{ 390{
375 if ( bgPixmap.isNull() ) 391 if ( bgPixmap.isNull() )
376 { 392 {
377 p->fillRect( r, bgColor ); 393 p->fillRect( r, bgColor );
378 } 394 }
379 else 395 else
380 { 396 {
381 if ( staticBackground ) 397 if ( staticBackground )
382 { 398 {
383 p->drawTiledPixmap( r, bgPixmap, QPoint( r.x() % bgPixmap.width(), r.y() % bgPixmap.height() ) ); 399 p->drawTiledPixmap( r, bgPixmap, QPoint( r.x() % bgPixmap.width(), r.y() % bgPixmap.height() ) );
384 } 400 }
385 else 401 else
386 { 402 {
387 p->drawTiledPixmap( r, bgPixmap, QPoint( (r.x() + contentsX()) % bgPixmap.width(), 403 p->drawTiledPixmap( r, bgPixmap, QPoint( (r.x() + contentsX()) % bgPixmap.width(),
388 (r.y() + contentsY()) % bgPixmap.height() ) ); 404 (r.y() + contentsY()) % bgPixmap.height() ) );
389 } 405 }
390 } 406 }
391} 407}
392 408
393void LauncherIconView::addCatsAndMimes(AppLnk* app) 409void LauncherIconView::addCatsAndMimes(AppLnk* app)
394{ 410{
395 // QStringList c = app->categories(); 411 // QStringList c = app->categories();
396 // for (QStringList::ConstIterator cit=c.begin(); cit!=c.end(); ++cit) { 412 // for (QStringList::ConstIterator cit=c.begin(); cit!=c.end(); ++cit) {
397 // cats.replace(*cit,(void*)1); 413 // cats.replace(*cit,(void*)1);
398 // } 414 // }
399 QString maj=app->type(); 415 QString maj=app->type();
400 int sl=maj.find('/'); 416 int sl=maj.find('/');
401 if (sl>=0) { 417 if (sl>=0) {
402 QString k; 418 QString k;
403 k = maj.left(12) == "application/" ? maj : maj.left(sl); 419 k = maj.left(12) == "application/" ? maj : maj.left(sl);
404 mimes.replace(k,(void*)1); 420 mimes.replace(k,(void*)1);
405 } 421 }
406} 422}
407 423
408void LauncherIconView::setBusy(bool on) 424void LauncherIconView::setBusy(bool on)
409{ 425{
410#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY 426#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY
411 if ( busyPix.isNull() ) { 427 if ( busyPix.isNull() ) {
412 int size = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize(); 428 int size = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize();
413 busyPix.convertFromImage( Resource::loadImage( "busy" ).smoothScale( size * 16, size ) ); 429 busyPix.convertFromImage( Resource::loadImage( "busy" ).smoothScale( size * 16, size ) );
414 } 430 }
415#endif 431#endif
416 432
417 if ( on ) { 433 if ( on ) {
418 busyTimer = startTimer( 100 ); 434 busyTimer = startTimer( 100 );
419 } else { 435 } else {
420 if ( busyTimer ) { 436 if ( busyTimer ) {
421 killTimer( busyTimer ); 437 killTimer( busyTimer );
422 busyTimer = 0; 438 busyTimer = 0;
423 } 439 }
424 } 440 }
425 441
426 LauncherItem *c = on ? (LauncherItem*)currentItem() : 0; 442 LauncherItem *c = on ? (LauncherItem*)currentItem() : 0;
427 443
428 if ( bsy != c ) { 444 if ( bsy != c ) {
429 LauncherItem *oldBusy = bsy; 445 LauncherItem *oldBusy = bsy;
430 bsy = c; 446 bsy = c;
431 if ( oldBusy ) { 447 if ( oldBusy ) {
432 oldBusy->resetIcon(); 448 oldBusy->resetIcon();
433 } 449 }
434 if ( bsy ) { 450 if ( bsy ) {
435 bsy->setBusyIndicatorType( busyType ) ; 451 bsy->setBusyIndicatorType( busyType ) ;
436 bsy->animateIcon(); 452 bsy->animateIcon();
437 } 453 }
438 } 454 }
439} 455}
440 456
441void LauncherIconView::clear() 457void LauncherIconView::clear()
442{ 458{
443 mimes.clear(); 459 mimes.clear();
444 cats.clear(); 460 cats.clear();
445 QIconView::clear(); 461 QIconView::clear();
446 hidden.clear(); 462 hidden.clear();
447} 463}
448 464
449QStringList LauncherIconView::mimeTypes() const 465QStringList LauncherIconView::mimeTypes() const
450{ 466{
451 QStringList r; 467 QStringList r;
452 QDictIterator<void> it(mimes); 468 QDictIterator<void> it(mimes);
453 while (it.current()) { 469 while (it.current()) {
454 r.append(it.currentKey()); 470 r.append(it.currentKey());
455 ++it; 471 ++it;
456 } 472 }
457 r.sort(); 473 r.sort();
458 return r; 474 return r;
459} 475}
460 476
461LauncherItem*LauncherIconView::findDocItem(const QString&fname) 477LauncherItem*LauncherIconView::findDocItem(const QString&fname)
462{ 478{
463 LauncherItem* item = (LauncherItem*)firstItem(); 479 LauncherItem* item = (LauncherItem*)firstItem();
464 while (item) { 480 while (item) {
465 if (item->appLnk()->file()==fname) { 481 if (item->appLnk()->file()==fname) {
466 break; 482 break;
467 } 483 }
468 item = (LauncherItem*)item->nextItem(); 484 item = (LauncherItem*)item->nextItem();
469 } 485 }
470 return item; 486 return item;
471} 487}
472 488
473void LauncherIconView::setEyePixmap(const QPixmap&aPixmap,const QString&aFile,int width) 489void LauncherIconView::setEyePixmap(const QPixmap&aPixmap,const QString&aFile,int width)
474{ 490{
475 int s = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize(); 491 int s = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize();
476 if (s!=width) return; 492 if (s!=width) return;
477 LauncherItem*item = findDocItem(aFile); 493 LauncherItem*item = findDocItem(aFile);
478 if (!item||!item->isEyeImage()) return; 494 if (!item||!item->isEyeImage()) return;
479 (*sm_EyeCache)[aFile]=aPixmap; 495 (*sm_EyeCache)[aFile]=aPixmap;
480 item->setEyePixmap(aPixmap); 496 item->setEyePixmap(aPixmap);
481} 497}
482 498
483void LauncherIconView::checkCallback() 499void LauncherIconView::checkCallback()
484{ 500{
485 if (!m_EyeCallBack) { 501 if (!m_EyeCallBack) {
486 m_EyeCallBack = new LauncherThumbReceiver(); 502 m_EyeCallBack = new LauncherThumbReceiver();
487 connect(m_EyeCallBack,SIGNAL(sig_Thumbnail(const QPixmap&,const QString&,int)), 503 connect(m_EyeCallBack,SIGNAL(sig_Thumbnail(const QPixmap&,const QString&,int)),
488 this,SLOT(setEyePixmap(const QPixmap&,const QString&,int))); 504 this,SLOT(setEyePixmap(const QPixmap&,const QString&,int)));
505 m_eyeTimer.changeInterval(600000);
489 } 506 }
490 m_eyeTimer.changeInterval(600000);
491} 507}
492 508
493void LauncherIconView::addCheckItem(AppLnk* app) 509void LauncherIconView::addCheckItem(AppLnk* app)
494{ 510{
495 LauncherItem*item = new LauncherItem( this, app, bigIcns ); 511 LauncherItem*item = new LauncherItem( this, app, bigIcns );
496 if (item->isEyeImage()) { 512 if (item->isEyeImage()) {
497 checkCallback(); 513 checkCallback();
498 } 514 }
499} 515}
500 516
501void LauncherIconView::requestEyePix(const LauncherItem*item) 517void LauncherIconView::requestEyePix(const LauncherItem*item)
502{ 518{
503 if (!item) return; 519 if (!item) return;
504 if (item->isEyeImage()) { 520 if (item->isEyeImage()) {
505 checkCallback(); 521 checkCallback();
506 int s = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize(); 522 int s = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize();
507 m_EyeCallBack->requestThumb(item->appLnk()->file(),s,s); 523 m_EyeCallBack->requestThumb(item->appLnk()->file(),s,s);
508 } 524 }
509} 525}
510 526
511void LauncherIconView::stopEyeTimer() 527void LauncherIconView::stopEyeTimer()
512{ 528{
513 if (m_EyeCallBack) { 529 if (m_EyeCallBack) {
514 disconnect(m_EyeCallBack,SIGNAL(sig_Thumbnail(const QPixmap&,const QString&,int)), 530 disconnect(m_EyeCallBack,SIGNAL(sig_Thumbnail(const QPixmap&,const QString&,int)),
515 this,SLOT(setEyePixmap(const QPixmap&,const QString&,int))); 531 this,SLOT(setEyePixmap(const QPixmap&,const QString&,int)));
516 delete m_EyeCallBack; 532 delete m_EyeCallBack;
517 m_EyeCallBack=0; 533 m_EyeCallBack=0;
518 } 534 }
519 m_eyeTimer.stop(); 535 m_eyeTimer.stop();
520} 536}
521 537
522void LauncherIconView::updateCategoriesAndMimeTypes() 538void LauncherIconView::updateCategoriesAndMimeTypes()
523{ 539{
524 mimes.clear(); 540 mimes.clear();
525 cats.clear(); 541 cats.clear();
526 LauncherItem* item = (LauncherItem*)firstItem(); 542 LauncherItem* item = (LauncherItem*)firstItem();
527 while (item) { 543 while (item) {
528 addCatsAndMimes(item->appLnk()); 544 addCatsAndMimes(item->appLnk());
529 item = (LauncherItem*)item->nextItem(); 545 item = (LauncherItem*)item->nextItem();
530 } 546 }
531 QListIterator<AppLnk> it(hidden); 547 QListIterator<AppLnk> it(hidden);
532 AppLnk* l; 548 AppLnk* l;
533 while ((l=it.current())) { 549 while ((l=it.current())) {
534 addCatsAndMimes(l); 550 addCatsAndMimes(l);
535 ++it; 551 ++it;
536 } 552 }
537} 553}
538 554
539void LauncherIconView::hideOrShowItems(bool resort) 555void LauncherIconView::hideOrShowItems(bool resort)
540{ 556{
541 viewport()->setUpdatesEnabled( FALSE ); 557 viewport()->setUpdatesEnabled( FALSE );
542 hidden.setAutoDelete(FALSE); 558 hidden.setAutoDelete(FALSE);
543 QList<AppLnk> links=hidden; 559 QList<AppLnk> links=hidden;
544 hidden.clear(); 560 hidden.clear();
545 hidden.setAutoDelete(TRUE); 561 hidden.setAutoDelete(TRUE);
546 LauncherItem* item = (LauncherItem*)firstItem(); 562 LauncherItem* item = (LauncherItem*)firstItem();
547 while (item) { 563 while (item) {
548 links.append(item->takeAppLnk()); 564 links.append(item->takeAppLnk());
549 item = (LauncherItem*)item->nextItem(); 565 item = (LauncherItem*)item->nextItem();
550 } 566 }
551 clear(); 567 clear();
552 QListIterator<AppLnk> it(links); 568 QListIterator<AppLnk> it(links);
553 AppLnk* l; 569 AppLnk* l;
554 while ((l=it.current())) { 570 while ((l=it.current())) {
555 addItem(l,FALSE); 571 addItem(l,FALSE);
556 ++it; 572 ++it;
557 } 573 }
558 if ( resort && !autoArrange() ) 574 if ( resort && !autoArrange() )
559 sort(); 575 sort();
560 viewport()->setUpdatesEnabled( TRUE ); 576 viewport()->setUpdatesEnabled( TRUE );
561} 577}
562 578
563bool LauncherIconView::removeLink(const QString& linkfile,bool removeCache) 579bool LauncherIconView::removeLink(const QString& linkfile,bool removeCache)
564{ 580{
565 LauncherItem* item = (LauncherItem*)firstItem(); 581 LauncherItem* item = (LauncherItem*)firstItem();
566 AppLnk* l; 582 AppLnk* l;
567 bool did = FALSE; 583 bool did = FALSE;
568 DocLnk dl(linkfile); 584 DocLnk dl(linkfile);
569 while (item) { 585 while (item) {
570 l = item->appLnk(); 586 l = item->appLnk();
571 LauncherItem *nextItem = (LauncherItem *)item->nextItem(); 587 LauncherItem *nextItem = (LauncherItem *)item->nextItem();
572 if ( l->linkFileKnown() && l->linkFile() == linkfile || l->fileKnown() && 588 if ( l->linkFileKnown() && l->linkFile() == linkfile || l->fileKnown() &&
573 ( l->file() == linkfile || dl.isValid() && dl.file() == l->file() ) ) { 589 ( l->file() == linkfile || dl.isValid() && dl.file() == l->file() ) ) {
574 if (removeCache) sm_EyeCache->remove(l->file()); 590 if (removeCache) sm_EyeCache->remove(l->file());
575 delete item; 591 delete item;
576 did = TRUE; 592 did = TRUE;
577 } 593 }
578 item = nextItem; 594 item = nextItem;
579 } 595 }
580 QListIterator<AppLnk> it(hidden); 596 QListIterator<AppLnk> it(hidden);
581 while ((l=it.current())) { 597 while ((l=it.current())) {
582 ++it; 598 ++it;
583 if ( l->linkFileKnown() && l->linkFile() == linkfile 599 if ( l->linkFileKnown() && l->linkFile() == linkfile
584 || l->file() == linkfile 600 || l->file() == linkfile
585 || dl.isValid() && dl.file() == l->file() ) { 601 || dl.isValid() && dl.file() == l->file() ) {
586 hidden.removeRef(l); 602 hidden.removeRef(l);
587 did = TRUE; 603 did = TRUE;
588 } 604 }
589 } 605 }
590 return did; 606 return did;
591} 607}
592 608
593void LauncherIconView::addItem(AppLnk* app, bool resort) 609void LauncherIconView::addItem(AppLnk* app, bool resort)
594{ 610{
595 addCatsAndMimes(app); 611 addCatsAndMimes(app);
596 if ( (tf.isEmpty() || tf.match(app->type()) >= 0) 612 if ( (tf.isEmpty() || tf.match(app->type()) >= 0)
597 && (cf == 0 || app->categories().contains(cf) 613 && (cf == 0 || app->categories().contains(cf)
598 || cf == -1 && app->categories().count() == 0 ) ) { 614 || cf == -1 && app->categories().count() == 0 ) ) {
599 addCheckItem(app); 615 addCheckItem(app);
600 } else { 616 } else {
601 hidden.append(app); 617 hidden.append(app);
602 } 618 }
603 if ( resort ){ 619 if ( resort ){
604 sort(); 620 sort();
605 } 621 }
606} 622}
607 623
608void LauncherIconView::changeItem(const AppLnk&old,AppLnk*nlink) 624void LauncherIconView::changeItem(const AppLnk&old,AppLnk*nlink)
609{ 625{
610 QString oldfile = old.file(); 626 QString oldfile = old.file();
611 QString newfile = nlink->file(); 627 QString newfile = nlink->file();
612 628
613 if (newfile != oldfile) { 629 if (newfile != oldfile) {
614 QMap<QString,QPixmap>::Iterator it = sm_EyeCache->find(oldfile); 630 QMap<QString,QPixmap>::Iterator it = sm_EyeCache->find(oldfile);
615 if (it != sm_EyeCache->end()) { 631 if (it != sm_EyeCache->end()) {
616 (*sm_EyeCache)[newfile]=(*it); 632 (*sm_EyeCache)[newfile]=(*it);
617 } 633 }
618 removeLink(old.linkFile()); 634 removeLink(old.linkFile());
619 } else { 635 } else {
620 removeLink(old.linkFile(),false); 636 removeLink(old.linkFile(),false);
621 } 637 }
622 addItem(nlink,false); 638 addItem(nlink,false);
623} 639}
624 640
625void LauncherIconView::timerEvent( QTimerEvent *te ) 641void LauncherIconView::timerEvent( QTimerEvent *te )
626{ 642{
627 if ( te->timerId() == busyTimer ) { 643 if ( te->timerId() == busyTimer ) {
628 if ( bsy ) 644 if ( bsy )
629 bsy->animateIcon(); 645 bsy->animateIcon();
630 } else { 646 } else {
631 QIconView::timerEvent( te ); 647 QIconView::timerEvent( te );
632 } 648 }
633} 649}
634 650
635void LauncherIconView::setBigIcons( bool bi ) 651void LauncherIconView::setBigIcons( bool bi )
636{ 652{
637 sm_EyeCache->clear(); 653 sm_EyeCache->clear();
638 bigIcns = bi; 654 bigIcns = bi;
639#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY 655#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY
640 busyPix.resize(0,0); 656 busyPix.resize(0,0);
641#endif 657#endif
642} 658}
643 659
644QIconViewItem* LauncherIconView::busyItem() const 660QIconViewItem* LauncherIconView::busyItem() const
645{ 661{
646 return bsy; 662 return bsy;
647} 663}
648 664
649void LauncherIconView::setBusyIndicatorType ( BusyIndicatorType t ) { busyType = t; } 665void LauncherIconView::setBusyIndicatorType ( BusyIndicatorType t ) { busyType = t; }
650 666
651void LauncherIconView::calculateGrid( ItemTextPos pos ) 667void LauncherIconView::calculateGrid( ItemTextPos pos )
652{ 668{
653 int dw = QApplication::desktop()->width(); 669 int dw = QApplication::desktop()->width();
654 int viewerWidth = dw-style().scrollBarExtent().width(); 670 int viewerWidth = dw-style().scrollBarExtent().width();
655 if ( pos == Bottom ) { 671 if ( pos == Bottom ) {
656 if( !numColumns ) { 672 if( !numColumns ) {
657 if ( viewerWidth <= 200 ) numColumns = 2; 673 if ( viewerWidth <= 200 ) numColumns = 2;
658 else if ( viewerWidth >= 400 ) numColumns = viewerWidth/96; 674 else if ( viewerWidth >= 400 ) numColumns = viewerWidth/96;
659 else numColumns = 3; 675 else numColumns = 3;
660 } 676 }
661 setSpacing( 4 ); 677 setSpacing( 4 );
662 setGridX( (viewerWidth-(numColumns+1)*spacing())/numColumns ); 678 setGridX( (viewerWidth-(numColumns+1)*spacing())/numColumns );
663 setGridY( fontMetrics().height()*2+24 ); 679 setGridY( fontMetrics().height()*2+24 );
664 } else { 680 } else {
665 if( !numColumns ) { 681 if( !numColumns ) {
666 if ( viewerWidth < 150 ) numColumns = 1; 682 if ( viewerWidth < 150 ) numColumns = 1;
667 else if ( viewerWidth >= 400 ) numColumns = viewerWidth/150; 683 else if ( viewerWidth >= 400 ) numColumns = viewerWidth/150;
668 else numColumns = 2; 684 else numColumns = 2;
669 } 685 }
670 setSpacing( 2 ); 686 setSpacing( 2 );
671 setGridX( (viewerWidth-(numColumns+1)*spacing())/numColumns ); 687 setGridX( (viewerWidth-(numColumns+1)*spacing())/numColumns );
672 setGridY( fontMetrics().height()+2 ); 688 setGridY( fontMetrics().height()+2 );
673 } 689 }
674} 690}
675 691
676void LauncherIconView::styleChange( QStyle &old ) 692void LauncherIconView::styleChange( QStyle &old )
677{ 693{
678 QIconView::styleChange( old ); 694 QIconView::styleChange( old );
679 calculateGrid( itemTextPos() ); 695 calculateGrid( itemTextPos() );
680} 696}
681 697
682void LauncherIconView::keyPressEvent(QKeyEvent* e) 698void LauncherIconView::keyPressEvent(QKeyEvent* e)
683{ 699{
684 ike = TRUE; 700 ike = TRUE;
685 if ( e->key() == Key_F33 /* OK button */ || e->key() == Key_Space ) { 701 if ( e->key() == Key_F33 /* OK button */ || e->key() == Key_Space ) {
686 if ( (e->state() & ShiftButton) ) 702 if ( (e->state() & ShiftButton) )
687 emit mouseButtonPressed(ShiftButton, currentItem(), QPoint() ); 703 emit mouseButtonPressed(ShiftButton, currentItem(), QPoint() );
688 else 704 else
689 returnPressed(currentItem()); 705 returnPressed(currentItem());
690 } 706 }
691 707
692 QIconView::keyPressEvent(e); 708 QIconView::keyPressEvent(e);
693 ike = FALSE; 709 ike = FALSE;
694} 710}
695 711
696//=========================================================================== 712//===========================================================================
697// Implemantation of LauncherIconview end 713// Implemantation of LauncherIconview end
698//=========================================================================== 714//===========================================================================
699 715
700 716
701//=========================================================================== 717//===========================================================================
702LauncherView::LauncherView( QWidget* parent, const char* name, WFlags fl ) 718LauncherView::LauncherView( QWidget* parent, const char* name, WFlags fl )
703 : QVBox( parent, name, fl ) 719 : QVBox( parent, name, fl )
704{ 720{
705 catmb = 0; 721 catmb = 0;
706 icons = new LauncherIconView( this ); 722 icons = new LauncherIconView( this );
707 setFocusProxy(icons); 723 setFocusProxy(icons);
708 QPEApplication::setStylusOperation( icons->viewport(), QPEApplication::RightOnHold ); 724 QPEApplication::setStylusOperation( icons->viewport(), QPEApplication::RightOnHold );
709 725
710 icons->setItemsMovable( FALSE ); 726 icons->setItemsMovable( FALSE );
711 icons->setAutoArrange( TRUE ); 727 icons->setAutoArrange( TRUE );
712 icons->setSorting( TRUE ); 728 icons->setSorting( TRUE );
713 icons->setFrameStyle( QFrame::NoFrame ); 729 icons->setFrameStyle( QFrame::NoFrame );
714 icons->setMargin( 0 ); 730 icons->setMargin( 0 );
715 icons->setSelectionMode( QIconView::NoSelection ); 731 icons->setSelectionMode( QIconView::NoSelection );
716 icons->setBackgroundMode( PaletteBase ); 732 icons->setBackgroundMode( PaletteBase );
717 icons->setResizeMode( QIconView::Adjust ); 733 icons->setResizeMode( QIconView::Adjust );
718 vmode = (ViewMode)-1; 734 vmode = (ViewMode)-1;
719 setViewMode( Icon ); 735 setViewMode( Icon );
720 736
721 connect( icons, SIGNAL(mouseButtonClicked(int,QIconViewItem*,const QPoint&)), 737 connect( icons, SIGNAL(mouseButtonClicked(int,QIconViewItem*,const QPoint&)),
722 SLOT(itemClicked(int,QIconViewItem*)) ); 738 SLOT(itemClicked(int,QIconViewItem*)) );
723 connect( icons, SIGNAL(selectionChanged()), 739 connect( icons, SIGNAL(selectionChanged()),
724 SLOT(selectionChanged()) ); 740 SLOT(selectionChanged()) );
725 connect( icons, SIGNAL(returnPressed(QIconViewItem*)), 741 connect( icons, SIGNAL(returnPressed(QIconViewItem*)),
726 SLOT(returnPressed(QIconViewItem*)) ); 742 SLOT(returnPressed(QIconViewItem*)) );
727 connect( icons, SIGNAL(mouseButtonPressed(int,QIconViewItem*,const QPoint&)), 743 connect( icons, SIGNAL(mouseButtonPressed(int,QIconViewItem*,const QPoint&)),
728 SLOT(itemPressed(int,QIconViewItem*)) ); 744 SLOT(itemPressed(int,QIconViewItem*)) );
729 745
730 tools = 0; 746 tools = 0;
731 setBackgroundType( Ruled, QString::null ); 747 setBackgroundType( Ruled, QString::null );
732} 748}
733 749
734LauncherView::~LauncherView() 750LauncherView::~LauncherView()
735{ 751{
736 if ( bgCache && bgCache->contains( bgName ) ) 752 if ( bgCache && bgCache->contains( bgName ) )
737 (*bgCache)[bgName]->ref--; 753 (*bgCache)[bgName]->ref--;
738} 754}
739 755
740 756
741bool LauncherView::bsy=FALSE; 757bool LauncherView::bsy=FALSE;
742 758
743void LauncherView::setBusy(bool on) 759void LauncherView::setBusy(bool on)
744{ 760{
745 icons->setBusy(on); 761 icons->setBusy(on);
746} 762}
747 763
748void LauncherView::setBusyIndicatorType( const QString& type ) { 764void LauncherView::setBusyIndicatorType( const QString& type ) {
749 if ( type. lower ( ) == "animated" ) 765 if ( type. lower ( ) == "animated" )
750 icons->setBusyIndicatorType( BIT_Animated ) ; 766 icons->setBusyIndicatorType( BIT_Animated ) ;
751 else 767 else
752 icons->setBusyIndicatorType( BIT_Normal ) ; 768 icons->setBusyIndicatorType( BIT_Normal ) ;
753} 769}
754 770
755void LauncherView::hideIcons() 771void LauncherView::hideIcons()
756{ 772{
757 icons->hide(); 773 icons->hide();
758} 774}
759 775
760void LauncherView::setToolsEnabled(bool y) 776void LauncherView::setToolsEnabled(bool y)
761{ 777{
762 if ( !y != !tools ) { 778 if ( !y != !tools ) {
763 if ( y ) { 779 if ( y ) {
764 tools = new QHBox(this); 780 tools = new QHBox(this);
765 // Type filter 781 // Type filter
766 typemb = new QComboBox(tools); 782 typemb = new QComboBox(tools);
767 QSizePolicy p = typemb->sizePolicy(); 783 QSizePolicy p = typemb->sizePolicy();
768 p.setHorData(QSizePolicy::Expanding); 784 p.setHorData(QSizePolicy::Expanding);
769 typemb->setSizePolicy(p); 785 typemb->setSizePolicy(p);
770 // Category filter 786 // Category filter
771 updateTools(); 787 updateTools();
772 tools->show(); 788 tools->show();
773 } else { 789 } else {
774 delete tools; 790 delete tools;
775 tools = 0; 791 tools = 0;
776 } 792 }
777 } 793 }
778} 794}
779 795
780void LauncherView::updateTools() 796void LauncherView::updateTools()
781{ 797{
782 disconnect( typemb, SIGNAL(activated(int)), 798 disconnect( typemb, SIGNAL(activated(int)),
783 this, SLOT(showType(int)) ); 799 this, SLOT(showType(int)) );
784 if ( catmb ) { 800 if ( catmb ) {
785 disconnect( catmb, SIGNAL(signalSelected(int)),this,SLOT(showCategory(int))); 801 disconnect( catmb, SIGNAL(signalSelected(int)),this,SLOT(showCategory(int)));
786 } 802 }
787 803
788 // ### I want to remove this 804 // ### I want to remove this
789 icons->updateCategoriesAndMimeTypes(); 805 icons->updateCategoriesAndMimeTypes();
790 806
791 QString prev; 807 QString prev;
792 808
793 // Type filter 809 // Type filter
794 QStringList types; 810 QStringList types;
795 typelist = icons->mimeTypes(); 811 typelist = icons->mimeTypes();
796 for (QStringList::ConstIterator it = typelist.begin(); it!=typelist.end(); ++it) { 812 for (QStringList::ConstIterator it = typelist.begin(); it!=typelist.end(); ++it) {
797 QString t = *it; 813 QString t = *it;
798 if ( t.left(12) == "application/" ) { 814 if ( t.left(12) == "application/" ) {
799 MimeType mt(t); 815 MimeType mt(t);
800 const AppLnk* app = mt.application(); 816 const AppLnk* app = mt.application();
801 if ( app ) 817 if ( app )
802 t = app->name(); 818 t = app->name();
803 else 819 else
804 t = t.mid(12); 820 t = t.mid(12);
805 } else { 821 } else {
806 t[0] = t[0].upper(); 822 t[0] = t[0].upper();
807 } 823 }
808 types += t; 824 types += t;
809 } 825 }
810 types << tr("All types"); 826 types << tr("All types");
811 prev = typemb->currentText(); 827 prev = typemb->currentText();
812 typemb->clear(); 828 typemb->clear();
813 typemb->insertStringList(types); 829 typemb->insertStringList(types);
814 for (int i=0; i<typemb->count(); i++) { 830 for (int i=0; i<typemb->count(); i++) {
815 if ( typemb->text(i) == prev ) { 831 if ( typemb->text(i) == prev ) {
816 typemb->setCurrentItem(i); 832 typemb->setCurrentItem(i);
817 break; 833 break;
818 } 834 }
819 } 835 }
820 if ( prev.isNull() ) { 836 if ( prev.isNull() ) {
821 typemb->setCurrentItem(typemb->count()-1); 837 typemb->setCurrentItem(typemb->count()-1);
822 } 838 }
823 839
824 int pcat = catmb ? catmb->currentCategory() : -2; 840 int pcat = catmb ? catmb->currentCategory() : -2;
825 if ( !catmb ) { 841 if ( !catmb ) {
826 catmb = new CategorySelect(tools); 842 catmb = new CategorySelect(tools);
827 } else if (pcat!=-2) { 843 } else if (pcat!=-2) {
828 844
829 } 845 }
830 Categories cats( 0 ); 846 Categories cats( 0 );
831 cats.load( categoryFileName() ); 847 cats.load( categoryFileName() );
832 QArray<int> vl( 0 ); 848 QArray<int> vl( 0 );
833 catmb->setCategories( vl, "Document View", // No tr 849 catmb->setCategories( vl, "Document View", // No tr
834 tr("Document View") ); 850 tr("Document View") );
835 catmb->setRemoveCategoryEdit( TRUE ); 851 catmb->setRemoveCategoryEdit( TRUE );
836 catmb->setAllCategories( TRUE ); 852 catmb->setAllCategories( TRUE );
837 catmb->setCurrentCategory(pcat); 853 catmb->setCurrentCategory(pcat);
838 854
839 // if type has changed we need to redisplay 855 // if type has changed we need to redisplay
840 if ( typemb->currentText() != prev ) 856 if ( typemb->currentText() != prev )
841 showType( typemb->currentItem() ); 857 showType( typemb->currentItem() );
842 858
843 connect(typemb, SIGNAL(activated(int)), this, SLOT(showType(int))); 859 connect(typemb, SIGNAL(activated(int)), this, SLOT(showType(int)));
844 connect(catmb, SIGNAL(signalSelected(int)), this, SLOT(showCategory(int))); 860 connect(catmb, SIGNAL(signalSelected(int)), this, SLOT(showCategory(int)));
845} 861}
846 862
847void LauncherView::sortBy(int s) 863void LauncherView::sortBy(int s)
848{ 864{
849 icons->setSortMethod((LauncherIconView::SortMethod)s); 865 icons->setSortMethod((LauncherIconView::SortMethod)s);
850} 866}
851 867
852void LauncherView::showType(int t) 868void LauncherView::showType(int t)
853{ 869{
854 if ( t >= (int)typelist.count() ) { 870 if ( t >= (int)typelist.count() ) {
855 icons->setTypeFilter("",TRUE); 871 icons->setTypeFilter("",TRUE);
856 } else { 872 } else {
857 QString ty = typelist[t]; 873 QString ty = typelist[t];
858 if ( !ty.contains('/') ) 874 if ( !ty.contains('/') )
859 ty += "/*"; 875 ty += "/*";
860 icons->setTypeFilter(ty,TRUE); 876 icons->setTypeFilter(ty,TRUE);
861 } 877 }
862} 878}
863 879
864void LauncherView::showCategory( int c ) 880void LauncherView::showCategory( int c )
865{ 881{
866 icons->setCategoryFilter( c, TRUE ); 882 icons->setCategoryFilter( c, TRUE );
867} 883}
868 884
869void LauncherView::setViewMode( ViewMode m ) 885void LauncherView::setViewMode( ViewMode m )
870{ 886{
871 odebug << "LauncherView::setViewMode( ViewMode m )" << oendl; 887 odebug << "LauncherView::setViewMode( ViewMode m )" << oendl;
872 if ( vmode != m ) { 888 if ( vmode != m ) {
873 bool bigIcons = m == Icon; 889 bool bigIcons = m == Icon;
874 icons->viewport()->setUpdatesEnabled( FALSE ); 890 icons->viewport()->setUpdatesEnabled( FALSE );
875 icons->setBigIcons( bigIcons ); 891 icons->setBigIcons( bigIcons );
876 switch ( m ) { 892 switch ( m ) {
877 case List: 893 case List:
878 icons->setItemTextPos( QIconView::Right ); 894 icons->setItemTextPos( QIconView::Right );
879 break; 895 break;
880 case Icon: 896 case Icon:
881 icons->setItemTextPos( QIconView::Bottom ); 897 icons->setItemTextPos( QIconView::Bottom );
882 break; 898 break;
883 } 899 }
884 icons->hideOrShowItems( FALSE ); 900 icons->hideOrShowItems( FALSE );
885 icons->viewport()->setUpdatesEnabled( TRUE ); 901 icons->viewport()->setUpdatesEnabled( TRUE );
886 vmode = m; 902 vmode = m;
887 } 903 }
888} 904}
889 905
890// 906//
891// User images may require scaling. 907// User images may require scaling.
892// 908//
893QImage LauncherView::loadBackgroundImage(QString &bgName) 909QImage LauncherView::loadBackgroundImage(QString &bgName)
894{ 910{
895 QImageIO imgio; 911 QImageIO imgio;
896 QSize ds = qApp->desktop()->size(); // should be launcher, not desktop 912 QSize ds = qApp->desktop()->size(); // should be launcher, not desktop
897 bool further_scaling = TRUE; 913 bool further_scaling = TRUE;
898 914
899 imgio.setFileName( bgName ); 915 imgio.setFileName( bgName );
900 imgio.setParameters("GetHeaderInformation"); 916 imgio.setParameters("GetHeaderInformation");
901 917
902 if (imgio.read() == FALSE) { 918 if (imgio.read() == FALSE) {
903 return imgio.image(); 919 return imgio.image();
904 } 920 }
905 921
906 if (imgio.image().width() < ds.width() && 922 if (imgio.image().width() < ds.width() &&
907 imgio.image().height() < ds.height()) { 923 imgio.image().height() < ds.height()) {
908 further_scaling = FALSE; 924 further_scaling = FALSE;
909 } 925 }
910 926
911 if (!imgio.image().bits()) { 927 if (!imgio.image().bits()) {
912 // 928 //
913 // Scale and load. Note we don't scale up. 929 // Scale and load. Note we don't scale up.
914 // 930 //
915 QString param( "Scale( %1, %2, ScaleMin )" ); // No tr 931 QString param( "Scale( %1, %2, ScaleMin )" ); // No tr
916 imgio.setParameters(further_scaling ? 932 imgio.setParameters(further_scaling ?
917 param.arg(ds.width()).arg(ds.height()).latin1() : 933 param.arg(ds.width()).arg(ds.height()).latin1() :
918 ""); 934 "");
919 imgio.read(); 935 imgio.read();
920 } else { 936 } else {
921 if (further_scaling) { 937 if (further_scaling) {
922 int t1 = imgio.image().width() * ds.height(); 938 int t1 = imgio.image().width() * ds.height();
923 int t2 = imgio.image().height() * ds.width(); 939 int t2 = imgio.image().height() * ds.width();
924 int dsth = ds.height(); 940 int dsth = ds.height();
925 int dstw = ds.width(); 941 int dstw = ds.width();
926 942
927 if (t1 > t2) { 943 if (t1 > t2) {
928 dsth = t2 / imgio.image().width(); 944 dsth = t2 / imgio.image().width();
929 } else { 945 } else {
930 dstw = t1 / imgio.image().height(); 946 dstw = t1 / imgio.image().height();
931 } 947 }
932 948
933 // 949 //
934 // Loader didn't scale for us. Do it manually. 950 // Loader didn't scale for us. Do it manually.
935 // 951 //
936 return imgio.image().smoothScale(dstw, dsth); 952 return imgio.image().smoothScale(dstw, dsth);
937 } 953 }
938 } 954 }
939 955
940 return imgio.image(); 956 return imgio.image();
941} 957}
942 958
943void LauncherView::setBackgroundType( BackgroundType t, const QString &val ) 959void LauncherView::setBackgroundType( BackgroundType t, const QString &val )
944{ 960{
945 if ( !bgCache ) { 961 if ( !bgCache ) {
946 bgCache = new QMap<QString,BgPixmap*>; 962 bgCache = new QMap<QString,BgPixmap*>;
947 qAddPostRoutine( cleanup_cache ); 963 qAddPostRoutine( cleanup_cache );
948 } 964 }
949 965
950 if ( bgCache->contains( bgName ) ) 966 if ( bgCache->contains( bgName ) )
951 (*bgCache)[bgName]->ref--; 967 (*bgCache)[bgName]->ref--;
952 bgName = ""; 968 bgName = "";
953 969
954 QPixmap bg; 970 QPixmap bg;
955 971
956 switch ( t ) { 972 switch ( t ) {
957 case Ruled: { 973 case Ruled: {
958 bgName = QString("Ruled_%1").arg(colorGroup().background().name()); // No tr 974 bgName = QString("Ruled_%1").arg(colorGroup().background().name()); // No tr
959 if ( bgCache->contains( bgName ) ) { 975 if ( bgCache->contains( bgName ) ) {
960 (*bgCache)[bgName]->ref++; 976 (*bgCache)[bgName]->ref++;
961 bg = (*bgCache)[bgName]->pm; 977 bg = (*bgCache)[bgName]->pm;
962 } else { 978 } else {
963 bg.resize( width(), 9 ); 979 bg.resize( width(), 9 );
964 QPainter painter( &bg ); 980 QPainter painter( &bg );
965 for ( int i = 0; i < 3; i++ ) { 981 for ( int i = 0; i < 3; i++ ) {
966 painter.setPen( white ); 982 painter.setPen( white );
967 painter.drawLine( 0, i*3, width()-1, i*3 ); 983 painter.drawLine( 0, i*3, width()-1, i*3 );
968 painter.drawLine( 0, i*3+1, width()-1, i*3+1 ); 984 painter.drawLine( 0, i*3+1, width()-1, i*3+1 );
969 painter.setPen( colorGroup().background().light(105) ); 985 painter.setPen( colorGroup().background().light(105) );
970 painter.drawLine( 0, i*3+2, width()-1, i*3+2 ); 986 painter.drawLine( 0, i*3+2, width()-1, i*3+2 );
971 } 987 }
972 painter.end(); 988 painter.end();
973 bgCache->insert( bgName, new BgPixmap(bg) ); 989 bgCache->insert( bgName, new BgPixmap(bg) );
974 } 990 }
975 break; 991 break;
976 } 992 }
977 993
978 case Image: 994 case Image:
979 if (!val.isEmpty()) { 995 if (!val.isEmpty()) {
980 bgName = val; 996 bgName = val;
981 if ( bgCache->contains( bgName ) ) { 997 if ( bgCache->contains( bgName ) ) {
982 (*bgCache)[bgName]->ref++; 998 (*bgCache)[bgName]->ref++;
983 bg = (*bgCache)[bgName]->pm; 999 bg = (*bgCache)[bgName]->pm;
984 } else { 1000 } else {
985 QString imgFile = bgName; 1001 QString imgFile = bgName;
986 bool tile = FALSE; 1002 bool tile = FALSE;
987 if ( imgFile[0]!='/' || !QFile::exists(imgFile) ) { 1003 if ( imgFile[0]!='/' || !QFile::exists(imgFile) ) {
988 imgFile = Resource::findPixmap( imgFile ); 1004 imgFile = Resource::findPixmap( imgFile );
989 tile = TRUE; 1005 tile = TRUE;
990 } 1006 }
991 QImage img = loadBackgroundImage(imgFile); 1007 QImage img = loadBackgroundImage(imgFile);
992 1008
993 1009
994 if ( img.depth() == 1 ) 1010 if ( img.depth() == 1 )
995 img = img.convertDepth(8); 1011 img = img.convertDepth(8);
996 img.setAlphaBuffer(FALSE); 1012 img.setAlphaBuffer(FALSE);
997 bg.convertFromImage(img); 1013 bg.convertFromImage(img);
998 bgCache->insert( bgName, new BgPixmap(bg) ); 1014 bgCache->insert( bgName, new BgPixmap(bg) );
999 } 1015 }
1000 } 1016 }
1001 break; 1017 break;
1002 1018
1003 case SolidColor: 1019 case SolidColor:
1004 default: 1020 default:
1005 break; 1021 break;
1006 } 1022 }
1007 1023
1008 const QObjectList *list = queryList( "QWidget", 0, FALSE ); 1024 const QObjectList *list = queryList( "QWidget", 0, FALSE );
1009 QObject *obj; 1025 QObject *obj;
1010 for ( QObjectListIt it( *list ); (obj=it.current()); ++it ) { 1026 for ( QObjectListIt it( *list ); (obj=it.current()); ++it ) {
1011 if ( obj->isWidgetType() ) { 1027 if ( obj->isWidgetType() ) {
1012 QWidget *w = (QWidget*)obj; 1028 QWidget *w = (QWidget*)obj;
1013 w->setBackgroundPixmap( bg ); 1029 w->setBackgroundPixmap( bg );
1014 if ( bgName.isEmpty() ) { 1030 if ( bgName.isEmpty() ) {
1015 // Solid Color 1031 // Solid Color
1016 if ( val.isEmpty() ) 1032 if ( val.isEmpty() )
1017 w->setBackgroundColor( colorGroup().base() ); 1033 w->setBackgroundColor( colorGroup().base() );
1018 else 1034 else
1019 w->setBackgroundColor( val ); 1035 w->setBackgroundColor( val );
1020 } else { 1036 } else {
1021 // Ruled or Image pixmap 1037 // Ruled or Image pixmap
1022 w->setBackgroundOrigin( ParentOrigin ); 1038 w->setBackgroundOrigin( ParentOrigin );
1023 } 1039 }
1024 } 1040 }
1025 } 1041 }
1026 delete list; 1042 delete list;
1027 1043
1028 bgType = t; 1044 bgType = t;
1029 icons->viewport()->update(); 1045 icons->viewport()->update();
1030 1046
1031 QTimer::singleShot( 1000, this, SLOT(flushBgCache()) ); 1047 QTimer::singleShot( 1000, this, SLOT(flushBgCache()) );
1032} 1048}
1033 1049
1034void LauncherView::setColNumber( int num ) 1050void LauncherView::setColNumber( int num )
1035{ 1051{
1036 icons->setColNumber( num ); 1052 icons->setColNumber( num );
1037} 1053}
1038 1054
1039void LauncherIconView::setColNumber( int num ) 1055void LauncherIconView::setColNumber( int num )
1040{ 1056{
1041 numColumns = num; 1057 numColumns = num;
1042 calculateGrid( Bottom ); 1058 calculateGrid( Bottom );
1043} 1059}
1044 1060
1045void LauncherView::setTextColor( const QColor &tc ) 1061void LauncherView::setTextColor( const QColor &tc )
1046{ 1062{
1047 textCol = tc; 1063 textCol = tc;
1048 QColorGroup cg = icons->colorGroup(); 1064 QColorGroup cg = icons->colorGroup();
1049 cg.setColor( QColorGroup::Text, tc ); 1065 cg.setColor( QColorGroup::Text, tc );
1050 icons->setPalette( QPalette(cg,cg,cg) ); 1066 icons->setPalette( QPalette(cg,cg,cg) );
1051 icons->viewport()->update(); 1067 icons->viewport()->update();
1052} 1068}
1053 1069
1054void LauncherView::setViewFont( const QFont &f ) 1070void LauncherView::setViewFont( const QFont &f )
1055{ 1071{
1056 icons->setFont( f ); 1072 icons->setFont( f );
1057 icons->hideOrShowItems( FALSE ); 1073 icons->hideOrShowItems( FALSE );
1058} 1074}
1059 1075
1060void LauncherView::clearViewFont() 1076void LauncherView::clearViewFont()
1061{ 1077{
1062 icons->unsetFont(); 1078 icons->unsetFont();
1063 icons->hideOrShowItems( FALSE ); 1079 icons->hideOrShowItems( FALSE );
1064} 1080}
1065 1081
1066void LauncherView::resizeEvent(QResizeEvent *e) 1082void LauncherView::resizeEvent(QResizeEvent *e)
1067{ 1083{
1068// qDebug("LauncherView resize event"); 1084// qDebug("LauncherView resize event");
1069 QVBox::resizeEvent( e ); 1085 QVBox::resizeEvent( e );
1070// commented out for launcherview and qt/e 2.3.8 problems, probably needs real fixing somewhere... 1086// commented out for launcherview and qt/e 2.3.8 problems, probably needs real fixing somewhere...
1071// if ( e->size().width() != e->oldSize().width() ) 1087// if ( e->size().width() != e->oldSize().width() )
1072 sort(); 1088 sort();
1073} 1089}
1074 1090
1075void LauncherView::selectionChanged() 1091void LauncherView::selectionChanged()
1076{ 1092{
1077 QIconViewItem* item = icons->currentItem(); 1093 QIconViewItem* item = icons->currentItem();
1078 if ( item && item->isSelected() ) { 1094 if ( item && item->isSelected() ) {
1079 AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); 1095 AppLnk *appLnk = ((LauncherItem *)item)->appLnk();
1080 if ( icons->inKeyEvent() ) // not for mouse press 1096 if ( icons->inKeyEvent() ) // not for mouse press
1081 emit clicked( appLnk ); 1097 emit clicked( appLnk );
1082 item->setSelected(FALSE); 1098 item->setSelected(FALSE);
1083 } 1099 }
1084} 1100}
1085 1101
1086void LauncherView::returnPressed( QIconViewItem *item ) 1102void LauncherView::returnPressed( QIconViewItem *item )
1087{ 1103{
1088 if ( item ) { 1104 if ( item ) {
1089 AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); 1105 AppLnk *appLnk = ((LauncherItem *)item)->appLnk();
1090 emit clicked( appLnk ); 1106 emit clicked( appLnk );
1091 } 1107 }
1092} 1108}
1093 1109
1094void LauncherView::itemClicked( int btn, QIconViewItem *item ) 1110void LauncherView::itemClicked( int btn, QIconViewItem *item )
1095{ 1111{
1096 if ( item ) { 1112 if ( item ) {
1097 AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); 1113 AppLnk *appLnk = ((LauncherItem *)item)->appLnk();
1098 if ( btn == LeftButton ) { 1114 if ( btn == LeftButton ) {
1099 // Make sure it's the item we execute that gets highlighted 1115 // Make sure it's the item we execute that gets highlighted
1100 icons->setCurrentItem( item ); 1116 icons->setCurrentItem( item );
1101 emit clicked( appLnk ); 1117 emit clicked( appLnk );
1102 } 1118 }
1103 item->setSelected(FALSE); 1119 item->setSelected(FALSE);
1104 } 1120 }
1105} 1121}
1106 1122
1107void LauncherView::itemPressed( int btn, QIconViewItem *item ) 1123void LauncherView::itemPressed( int btn, QIconViewItem *item )
1108{ 1124{
1109 if ( item ) { 1125 if ( item ) {
1110 AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); 1126 AppLnk *appLnk = ((LauncherItem *)item)->appLnk();
1111 if ( btn == RightButton ) 1127 if ( btn == RightButton )
1112 emit rightPressed( appLnk ); 1128 emit rightPressed( appLnk );
1113 else if ( btn == ShiftButton ) 1129 else if ( btn == ShiftButton )
1114 emit rightPressed( appLnk ); 1130 emit rightPressed( appLnk );
1115 item->setSelected(FALSE); 1131 item->setSelected(FALSE);
1116 } 1132 }
1117} 1133}
1118 1134
1119void LauncherView::removeAllItems() 1135void LauncherView::removeAllItems()
1120{ 1136{
1121 odebug << "LauncherView::removeAllItems()" << oendl; 1137 odebug << "LauncherView::removeAllItems()" << oendl;
1122 if (LauncherIconView::sm_EyeCache) LauncherIconView::sm_EyeCache->clear(); 1138 if (LauncherIconView::sm_EyeCache) LauncherIconView::sm_EyeCache->clear();
1123 icons->clear(); 1139 icons->clear();
1124} 1140}
1125 1141
1126bool LauncherView::removeLink(const QString& linkfile) 1142bool LauncherView::removeLink(const QString& linkfile)
1127{ 1143{
1128 return icons->removeLink(linkfile); 1144 return icons->removeLink(linkfile);
1129} 1145}
1130 1146
1131void LauncherView::addItem(AppLnk* app, bool resort) 1147void LauncherView::addItem(AppLnk* app, bool resort)
1132{ 1148{
1133 icons->addItem(app,resort); 1149 icons->addItem(app,resort);
1134} 1150}
1135 1151
1136void LauncherView::changeItem(const AppLnk&old,AppLnk*nlink) 1152void LauncherView::changeItem(const AppLnk&old,AppLnk*nlink)
1137{ 1153{
1138 icons->changeItem(old,nlink); 1154 icons->changeItem(old,nlink);
1139} 1155}
1140 1156
1141void LauncherView::setSortEnabled( bool v ) 1157void LauncherView::setSortEnabled( bool v )
1142{ 1158{
1143 icons->setSorting( v ); 1159 icons->setSorting( v );
1144 if ( v ) 1160 if ( v )
1145 sort(); 1161 sort();
1146} 1162}
1147 1163
1148void LauncherView::setUpdatesEnabled( bool u ) 1164void LauncherView::setUpdatesEnabled( bool u )
1149{ 1165{
1150 icons->setUpdatesEnabled( u ); 1166 icons->setUpdatesEnabled( u );
1151} 1167}
1152 1168
1153void LauncherView::sort() 1169void LauncherView::sort()
1154{ 1170{
1155 icons->sort(); 1171 icons->sort();
1156} 1172}
1157 1173
1158void LauncherView::paletteChange( const QPalette &p ) 1174void LauncherView::paletteChange( const QPalette &p )
1159{ 1175{
1160 icons->unsetPalette(); 1176 icons->unsetPalette();
1161 QVBox::paletteChange( p ); 1177 QVBox::paletteChange( p );
1162 if ( bgType == Ruled ) 1178 if ( bgType == Ruled )
1163 setBackgroundType( Ruled, QString::null ); 1179 setBackgroundType( Ruled, QString::null );
1164 QColorGroup cg = icons->colorGroup(); 1180 QColorGroup cg = icons->colorGroup();
1165 cg.setColor( QColorGroup::Text, textCol ); 1181 cg.setColor( QColorGroup::Text, textCol );
1166 icons->setPalette( QPalette(cg,cg,cg) ); 1182 icons->setPalette( QPalette(cg,cg,cg) );
1167} 1183}
1168 1184
1169void LauncherView::fontChanged(const QFont&) 1185void LauncherView::fontChanged(const QFont&)
1170{ 1186{
1171 odebug << "LauncherView::fontChanged()" << oendl; 1187 odebug << "LauncherView::fontChanged()" << oendl;
1172 icons->hideOrShowItems( FALSE ); 1188 icons->hideOrShowItems( FALSE );
1173} 1189}
1174 1190
1175void LauncherView::relayout(void) 1191void LauncherView::relayout(void)
1176{ 1192{
1177 icons->hideOrShowItems(FALSE); 1193 icons->hideOrShowItems(FALSE);
1178} 1194}
1179 1195
1180void LauncherView::flushBgCache() 1196void LauncherView::flushBgCache()
1181{ 1197{
1182 if ( !bgCache ) 1198 if ( !bgCache )
1183 return; 1199 return;
1184 // remove unreferenced backgrounds. 1200 // remove unreferenced backgrounds.
1185 QMap<QString,BgPixmap*>::Iterator it = bgCache->begin(); 1201 QMap<QString,BgPixmap*>::Iterator it = bgCache->begin();
1186 while ( it != bgCache->end() ) { 1202 while ( it != bgCache->end() ) {
1187 QMap<QString,BgPixmap*>::Iterator curr = it; 1203 QMap<QString,BgPixmap*>::Iterator curr = it;
1188 ++it; 1204 ++it;
1189 if ( (*curr)->ref == 0 ) { 1205 if ( (*curr)->ref == 0 ) {
1190 delete (*curr); 1206 delete (*curr);
1191 bgCache->remove( curr ); 1207 bgCache->remove( curr );
1192 } 1208 }
1193 } 1209 }
1194} 1210}
1195 1211
1196/* 1212/*
1197 * Launcherthumbnail handling for image files 1213 * Launcherthumbnail handling for image files
1198 */ 1214 */
1199 1215
1200/* special image handling - based on opie eye */ 1216/* special image handling - based on opie eye */
1201QDataStream &operator>>( QDataStream& s, PixmapInfo& inf ) { 1217QDataStream &operator>>( QDataStream& s, PixmapInfo& inf ) {
1202 s >> inf.file >> inf.pixmap >> inf.width >> inf.height; 1218 s >> inf.file >> inf.pixmap >> inf.width >> inf.height;
1203 return s; 1219 return s;
1204} 1220}
1205 1221
1206QDataStream &operator<<( QDataStream& s, const PixmapInfo& inf) { 1222QDataStream &operator<<( QDataStream& s, const PixmapInfo& inf) {
1207 return s << inf.file << inf.width << inf.height; 1223 return s << inf.file << inf.width << inf.height;
1208} 1224}
1209 1225
1210LauncherThumbReceiver::LauncherThumbReceiver() 1226LauncherThumbReceiver::LauncherThumbReceiver()
1211 :QObject() 1227 :QObject(),requestTimer(this)
1212{ 1228{
1229
1230 connect(&requestTimer,SIGNAL(timeout()),SLOT(sendRequest()));
1213 QCopChannel * chan = new QCopChannel( "QPE/opie-eye",this ); 1231 QCopChannel * chan = new QCopChannel( "QPE/opie-eye",this );
1214 connect(chan, SIGNAL(received(const QCString&,const QByteArray&)), 1232 connect(chan, SIGNAL(received(const QCString&,const QByteArray&)),
1215 this, SLOT(recieve(const QCString&,const QByteArray&)) ); 1233 this, SLOT(recieve(const QCString&,const QByteArray&)) );
1216 1234
1217 { 1235 {
1218 QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" ); 1236 QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" );
1219 } 1237 }
1220} 1238}
1221 1239
1222LauncherThumbReceiver::~LauncherThumbReceiver() 1240LauncherThumbReceiver::~LauncherThumbReceiver()
1223{ 1241{
1224 { 1242 {
1225 QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" ); 1243 QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" );
1226 } 1244 }
1227} 1245}
1228 1246
1229void LauncherThumbReceiver::recieve( const QCString&str, const QByteArray&at ) 1247void LauncherThumbReceiver::recieve( const QCString&str, const QByteArray&at )
1230{ 1248{
1231 PixmapInfos pixinfos; 1249 PixmapInfos pixinfos;
1232 QDataStream stream( at, IO_ReadOnly ); 1250 QDataStream stream( at, IO_ReadOnly );
1233 1251
1234 /* we are just interested in thumbmails */ 1252 /* we are just interested in thumbmails */
1235 if ( str == "pixmapsHandled(PixmapList)" ) 1253 if ( str == "pixmapsHandled(PixmapList)" )
1236 stream >> pixinfos; 1254 stream >> pixinfos;
1237 1255
1238 for ( PixmapInfos::Iterator it = pixinfos.begin(); it != pixinfos.end(); ++it ) { 1256 for ( PixmapInfos::Iterator it = pixinfos.begin(); it != pixinfos.end(); ++it ) {
1239 emit sig_Thumbnail((*it).pixmap,(*it).file,(*it).width); 1257 emit sig_Thumbnail((*it).pixmap,(*it).file,(*it).width);
1240 } 1258 }
1241} 1259}
1242 1260
1243void LauncherThumbReceiver::requestThumb(const QString&file,int width,int height) 1261void LauncherThumbReceiver::requestThumb(const QString&file,int width,int height)
1244{ 1262{
1245 PixmapInfo rItem; 1263 PixmapInfo rItem;
1246 rItem.file = file; 1264 rItem.file = file;
1247 rItem.width = width; 1265 rItem.width = width;
1248 rItem.height = height; 1266 rItem.height = height;
1249 m_inThumbNail.append(rItem); 1267 m_inThumbNail.append(rItem);
1250 QTimer::singleShot(2, this, SLOT(sendRequest())); 1268 if (!requestTimer.isActive()) {
1269 requestTimer.start(100,true);
1270 }
1251} 1271}
1252 1272
1253void LauncherThumbReceiver::sendRequest() 1273void LauncherThumbReceiver::sendRequest()
1254{ 1274{
1255 if (m_inThumbNail.count()>0) { 1275 if (m_inThumbNail.count()>0) {
1256 QCopEnvelope env("QPE/opie-eye_slave", "pixmapInfos(PixmapInfos)" ); 1276 QCopEnvelope env("QPE/opie-eye_slave", "pixmapInfos(PixmapInfos)" );
1257 env << m_inThumbNail; 1277 env << m_inThumbNail;
1258 m_inThumbNail.clear(); 1278 m_inThumbNail.clear();
1259 } 1279 }
1260} 1280}
diff --git a/core/launcher/launcherview.h b/core/launcher/launcherview.h
index 6a2d197..792c6d1 100644
--- a/core/launcher/launcherview.h
+++ b/core/launcher/launcherview.h
@@ -1,255 +1,259 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#ifndef LAUNCHERVIEW_H 20#ifndef LAUNCHERVIEW_H
21#define LAUNCHERVIEW_H 21#define LAUNCHERVIEW_H
22 22
23#include <qtopia/storage.h> 23#include <qtopia/storage.h>
24#include <qtopia/applnk.h> 24#include <qtopia/applnk.h>
25 25
26#include <qvbox.h> 26#include <qvbox.h>
27#include <qiconview.h> 27#include <qiconview.h>
28#include <qtimer.h> 28#include <qtimer.h>
29#include <qmap.h> 29#include <qmap.h>
30 30
31class CategorySelect; 31class CategorySelect;
32class LauncherIconView; 32class LauncherIconView;
33class LauncherItem; 33class LauncherItem;
34class QIconViewItem; 34class QIconViewItem;
35class QLabel; 35class QLabel;
36class QWidgetStack; 36class QWidgetStack;
37class MenuButton; 37class MenuButton;
38class QComboBox; 38class QComboBox;
39 39
40enum BusyIndicatorType { 40enum BusyIndicatorType {
41 BIT_Normal = 0, 41 BIT_Normal = 0,
42 BIT_Animated 42 BIT_Animated
43}; 43};
44 44
45class LauncherView : public QVBox 45class LauncherView : public QVBox
46{ 46{
47 Q_OBJECT 47 Q_OBJECT
48 48
49public: 49public:
50 LauncherView( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); 50 LauncherView( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
51 ~LauncherView(); 51 ~LauncherView();
52 52
53 void hideIcons(); 53 void hideIcons();
54 54
55 bool removeLink(const QString& linkfile); 55 bool removeLink(const QString& linkfile);
56 void addItem(AppLnk* app, bool resort=TRUE); 56 void addItem(AppLnk* app, bool resort=TRUE);
57 void changeItem(const AppLnk&old,AppLnk*nlink); 57 void changeItem(const AppLnk&old,AppLnk*nlink);
58 58
59 void removeAllItems(); 59 void removeAllItems();
60 void setSortEnabled(bool); 60 void setSortEnabled(bool);
61 void setUpdatesEnabled(bool); 61 void setUpdatesEnabled(bool);
62 void sort(); 62 void sort();
63 63
64 void setToolsEnabled(bool); 64 void setToolsEnabled(bool);
65 void updateTools(); 65 void updateTools();
66 66
67 void setBusy(bool); 67 void setBusy(bool);
68 void setBusyIndicatorType( const QString& ); 68 void setBusyIndicatorType( const QString& );
69 69
70 enum ViewMode { Icon, List }; 70 enum ViewMode { Icon, List };
71 void setViewMode( ViewMode m ); 71 void setViewMode( ViewMode m );
72 ViewMode viewMode() const { return vmode; } 72 ViewMode viewMode() const { return vmode; }
73 73
74 enum BackgroundType { Ruled, SolidColor, Image }; 74 enum BackgroundType { Ruled, SolidColor, Image };
75 void setBackgroundType( BackgroundType t, const QString & ); 75 void setBackgroundType( BackgroundType t, const QString & );
76 BackgroundType backgroundType() const { return bgType; } 76 BackgroundType backgroundType() const { return bgType; }
77 77
78 void setTextColor( const QColor & ); 78 void setTextColor( const QColor & );
79 QColor textColor() const { return textCol; } 79 QColor textColor() const { return textCol; }
80 80
81 void setViewFont( const QFont & ); 81 void setViewFont( const QFont & );
82 void clearViewFont(); 82 void clearViewFont();
83 83
84 void setColNumber( int ); 84 void setColNumber( int );
85 void relayout(void); 85 void relayout(void);
86 LauncherIconView* iconView() { return icons; }; 86 LauncherIconView* iconView() { return icons; };
87 87
88signals: 88signals:
89 void clicked( const AppLnk * ); 89 void clicked( const AppLnk * );
90 void rightPressed( AppLnk * ); 90 void rightPressed( AppLnk * );
91 91
92protected slots: 92protected slots:
93 void selectionChanged(); 93 void selectionChanged();
94 void returnPressed( QIconViewItem *item ); 94 void returnPressed( QIconViewItem *item );
95 void itemClicked( int, QIconViewItem * ); 95 void itemClicked( int, QIconViewItem * );
96 void itemPressed( int, QIconViewItem * ); 96 void itemPressed( int, QIconViewItem * );
97 void sortBy(int); 97 void sortBy(int);
98 void showType(int); 98 void showType(int);
99 void showCategory( int ); 99 void showCategory( int );
100 void resizeEvent(QResizeEvent *); 100 void resizeEvent(QResizeEvent *);
101 void flushBgCache(); 101 void flushBgCache();
102 102
103protected: 103protected:
104 void paletteChange( const QPalette & ); 104 void paletteChange( const QPalette & );
105 105
106 void fontChanged(const QFont &); 106 void fontChanged(const QFont &);
107 107
108private: 108private:
109 static bool bsy; 109 static bool bsy;
110 QWidget* tools; 110 QWidget* tools;
111 LauncherIconView* icons; 111 LauncherIconView* icons;
112 QComboBox *typemb; 112 QComboBox *typemb;
113 QStringList typelist; 113 QStringList typelist;
114 CategorySelect *catmb; 114 CategorySelect *catmb;
115 ViewMode vmode; 115 ViewMode vmode;
116 BackgroundType bgType; 116 BackgroundType bgType;
117 QString bgName; 117 QString bgName;
118 QColor textCol; 118 QColor textCol;
119 119
120 QImage loadBackgroundImage(QString &fname); 120 QImage loadBackgroundImage(QString &fname);
121 121
122}; 122};
123 123
124/* from opie-eye */ 124/* from opie-eye */
125struct PixmapInfo { 125struct PixmapInfo {
126 PixmapInfo() : width( -1 ), height( -1 ) {} 126 PixmapInfo() : width( -1 ), height( -1 ) {}
127 bool operator==( const PixmapInfo& r ) { 127 bool operator==( const PixmapInfo& r ) {
128 if ( width != r.width ) return false; 128 if ( width != r.width ) return false;
129 if ( height != r.height ) return false; 129 if ( height != r.height ) return false;
130 if ( file != r.file ) return false; 130 if ( file != r.file ) return false;
131 return true; 131 return true;
132 } 132 }
133 int width, height; 133 int width, height;
134 QString file; 134 QString file;
135 QPixmap pixmap; 135 QPixmap pixmap;
136}; 136};
137 137
138class LauncherThumbReceiver:public QObject 138class LauncherThumbReceiver:public QObject
139{ 139{
140 Q_OBJECT 140 Q_OBJECT
141 typedef QValueList<PixmapInfo> PixmapInfos; 141 typedef QValueList<PixmapInfo> PixmapInfos;
142public: 142public:
143 LauncherThumbReceiver(); 143 LauncherThumbReceiver();
144 ~LauncherThumbReceiver(); 144 ~LauncherThumbReceiver();
145 void requestThumb(const QString&file,int width,int height); 145 void requestThumb(const QString&file,int width,int height);
146 146
147public slots: 147public slots:
148 void recieve( const QCString&, const QByteArray& ); 148 void recieve( const QCString&, const QByteArray& );
149protected slots: 149protected slots:
150 virtual void sendRequest(); 150 virtual void sendRequest();
151 151
152signals: 152signals:
153 void sig_Thumbnail(const QPixmap&,const QString&,int); 153 void sig_Thumbnail(const QPixmap&,const QString&,int);
154 154
155protected: 155protected:
156 QTimer requestTimer;
156 PixmapInfos m_inThumbNail; 157 PixmapInfos m_inThumbNail;
157}; 158};
158 159
159class LauncherIconView : public QIconView { 160class LauncherIconView : public QIconView {
160 Q_OBJECT 161 Q_OBJECT
161public: 162public:
162 LauncherIconView( QWidget* parent, const char* name=0 ); 163 LauncherIconView( QWidget* parent, const char* name=0 );
163 ~LauncherIconView(); 164 ~LauncherIconView();
164 QIconViewItem* busyItem() const; 165 QIconViewItem* busyItem() const;
165 166
166#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY 167#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY
167 QPixmap busyPixmap() const { return busyPix; } 168 QPixmap busyPixmap() const { return busyPix; }
168#endif 169#endif
169 void setBigIcons( bool bi ); 170 void setBigIcons( bool bi );
170 void updateCategoriesAndMimeTypes(); 171 void updateCategoriesAndMimeTypes();
171 void setBusyIndicatorType ( BusyIndicatorType t ); 172 void setBusyIndicatorType ( BusyIndicatorType t );
172 void setStaticBackgroundPicture( bool enable ); 173 void setStaticBackgroundPicture( bool enable );
173 void doAutoScroll() 174 void doAutoScroll()
174 { 175 {
175 // We don't want rubberbanding (yet) 176 // We don't want rubberbanding (yet)
176 } 177 }
177 178
178 void setBusy(bool on); 179 void setBusy(bool on);
179 bool inKeyEvent() const { return ike; } 180 bool inKeyEvent() const { return ike; }
180 181
181 void addItem(AppLnk* app, bool resort=TRUE); 182 void addItem(AppLnk* app, bool resort=TRUE);
182 bool removeLink(const QString& linkfile,bool removeCache = true); 183 bool removeLink(const QString& linkfile,bool removeCache = true);
183 void changeItem(const AppLnk&old,AppLnk*nlink); 184 void changeItem(const AppLnk&old,AppLnk*nlink);
184 185
185 QStringList mimeTypes() const; 186 QStringList mimeTypes() const;
186 QStringList categories() const; 187 QStringList categories() const;
187 void clear(); 188 void clear();
188 void addCatsAndMimes(AppLnk* app); 189 void addCatsAndMimes(AppLnk* app);
189 190
190 void setBackgroundOrigin( QWidget::BackgroundOrigin ) {} 191 void setBackgroundOrigin( QWidget::BackgroundOrigin ) {}
191 192
192 void setBackgroundPixmap( const QPixmap &pm ) { 193 void setBackgroundPixmap( const QPixmap &pm ) {
193 bgPixmap = pm; 194 bgPixmap = pm;
194 } 195 }
195 196
196 void setBackgroundColor( const QColor &c ) { 197 void setBackgroundColor( const QColor &c ) {
197 bgColor = c; 198 bgColor = c;
198 } 199 }
199 200
200 void setColNumber( int ); 201 void setColNumber( int );
201 202
202 void drawBackground( QPainter *p, const QRect &r ); 203 void drawBackground( QPainter *p, const QRect &r );
203 void setItemTextPos( ItemTextPos pos ); 204 void setItemTextPos( ItemTextPos pos );
204 void hideOrShowItems(bool resort); 205 void hideOrShowItems(bool resort);
205 206
206 void setTypeFilter(const QString& typefilter, bool resort); 207 void setTypeFilter(const QString& typefilter, bool resort);
207 void setCategoryFilter( int catfilter, bool resort ); 208 void setCategoryFilter( int catfilter, bool resort );
208 209
209 enum SortMethod { Name, Date, Type }; 210 enum SortMethod { Name, Date, Type };
210 211
211 void setSortMethod( SortMethod m ); 212 void setSortMethod( SortMethod m );
212 int compare(const AppLnk* a, const AppLnk* b); 213 int compare(const AppLnk* a, const AppLnk* b);
213 void requestEyePix(const LauncherItem*which); 214 void requestEyePix(const LauncherItem*which);
214 215
215 static QMap<QString,QPixmap>* sm_EyeCache; 216 static QMap<QString,QPixmap>* sm_EyeCache;
216 217
218 virtual void setPalette(const QPalette & palette);
219 virtual void unsetPalette();
220
217protected: 221protected:
218 virtual void timerEvent( QTimerEvent *te ); 222 virtual void timerEvent( QTimerEvent *te );
219 void styleChange( QStyle &old ); 223 void styleChange( QStyle &old );
220 void calculateGrid( ItemTextPos pos ); 224 void calculateGrid( ItemTextPos pos );
221 void focusInEvent( QFocusEvent * ) {} 225 void focusInEvent( QFocusEvent * ) {}
222 void focusOutEvent( QFocusEvent * ) {} 226 void focusOutEvent( QFocusEvent * ) {}
223 LauncherItem*findDocItem(const QString&); 227 LauncherItem*findDocItem(const QString&);
224 void addCheckItem(AppLnk* app); 228 void addCheckItem(AppLnk* app);
225 void checkCallback(); 229 void checkCallback();
226 virtual void keyPressEvent(QKeyEvent* e); 230 virtual void keyPressEvent(QKeyEvent* e);
227 231
228protected slots: 232protected slots:
229 void setEyePixmap(const QPixmap&,const QString&,int width); 233 void setEyePixmap(const QPixmap&,const QString&,int width);
230 void stopEyeTimer(); 234 void stopEyeTimer();
231 235
232private: 236private:
233 QList<AppLnk> hidden; 237 QList<AppLnk> hidden;
234 QDict<void> mimes; 238 QDict<void> mimes;
235 QDict<void> cats; 239 QDict<void> cats;
236 SortMethod sortmeth; 240 SortMethod sortmeth;
237 QRegExp tf; 241 QRegExp tf;
238 int cf; 242 int cf;
239 LauncherItem* bsy; 243 LauncherItem* bsy;
240 int busyTimer; 244 int busyTimer;
241 bool ike; 245 bool ike;
242 bool bigIcns; 246 bool bigIcns;
243 QPixmap bgPixmap; 247 QPixmap bgPixmap;
244 QColor bgColor; 248 QColor bgColor;
245 LauncherThumbReceiver*m_EyeCallBack; 249 LauncherThumbReceiver*m_EyeCallBack;
246#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY 250#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY
247 QPixmap busyPix; 251 QPixmap busyPix;
248#endif 252#endif
249 BusyIndicatorType busyType; 253 BusyIndicatorType busyType;
250 QTimer m_eyeTimer; 254 QTimer m_eyeTimer;
251 int numColumns; 255 int numColumns;
252 bool staticBackground; 256 bool staticBackground;
253}; 257};
254 258
255#endif // LAUNCHERVIEW_H 259#endif // LAUNCHERVIEW_H