summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/launcherview.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/core/launcher/launcherview.cpp b/core/launcher/launcherview.cpp
index 047fe45..c2bde53 100644
--- a/core/launcher/launcherview.cpp
+++ b/core/launcher/launcherview.cpp
@@ -1,865 +1,865 @@
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#include <qpe/qpeapplication.h> 23#include <qpe/qpeapplication.h>
24#include <qpe/applnk.h> 24#include <qpe/applnk.h>
25#include <qpe/qpedebug.h> 25#include <qpe/qpedebug.h>
26#include <qpe/categories.h> 26#include <qpe/categories.h>
27#include <qpe/categoryselect.h> 27#include <qpe/categoryselect.h>
28#include <qpe/menubutton.h> 28#include <qpe/menubutton.h>
29#include <qpe/mimetype.h> 29#include <qpe/mimetype.h>
30#include <qpe/resource.h> 30#include <qpe/resource.h>
31#include <qpe/qpetoolbar.h> 31#include <qpe/qpetoolbar.h>
32//#include <qtopia/private/palmtoprecord.h> 32//#include <qtopia/private/palmtoprecord.h>
33 33
34#include <qtimer.h> 34#include <qtimer.h>
35#include <qtextstream.h> 35#include <qtextstream.h>
36#include <qdict.h> 36#include <qdict.h>
37#include <qfile.h> 37#include <qfile.h>
38#include <qfileinfo.h> 38#include <qfileinfo.h>
39#include <qhbox.h> 39#include <qhbox.h>
40#include <qiconview.h> 40#include <qiconview.h>
41#include <qpainter.h> 41#include <qpainter.h>
42#include <qregexp.h> 42#include <qregexp.h>
43#include <qtoolbutton.h> 43#include <qtoolbutton.h>
44#include <qimage.h> 44#include <qimage.h>
45 45
46 46
47class BgPixmap 47class BgPixmap
48{ 48{
49public: 49public:
50 BgPixmap( const QPixmap &p ) : pm(p), ref(1) {} 50 BgPixmap( const QPixmap &p ) : pm(p), ref(1) {}
51 QPixmap pm; 51 QPixmap pm;
52 int ref; 52 int ref;
53}; 53};
54 54
55static QMap<QString,BgPixmap*> *bgCache = 0; 55static QMap<QString,BgPixmap*> *bgCache = 0;
56 56
57class LauncherIconView : public QIconView { 57class LauncherIconView : public QIconView {
58public: 58public:
59 LauncherIconView( QWidget* parent, const char* name=0 ) : 59 LauncherIconView( QWidget* parent, const char* name=0 ) :
60 QIconView(parent,name), 60 QIconView(parent,name),
61 tf(""), 61 tf(""),
62 cf(0), 62 cf(0),
63 bsy(0), 63 bsy(0),
64 bigIcns(TRUE), 64 bigIcns(TRUE),
65 bgColor(white) 65 bgColor(white)
66 { 66 {
67 sortmeth = Name; 67 sortmeth = Name;
68 hidden.setAutoDelete(TRUE); 68 hidden.setAutoDelete(TRUE);
69 ike = FALSE; 69 ike = FALSE;
70 calculateGrid( Bottom ); 70 calculateGrid( Bottom );
71 } 71 }
72 72
73 ~LauncherIconView() 73 ~LauncherIconView()
74 { 74 {
75#if 0 // debuggery 75#if 0 // debuggery
76 QListIterator<AppLnk> it(hidden); 76 QListIterator<AppLnk> it(hidden);
77 AppLnk* l; 77 AppLnk* l;
78 while ((l=it.current())) { 78 while ((l=it.current())) {
79 ++it; 79 ++it;
80 //qDebug("%p: hidden (should remove)",l); 80 //qDebug("%p: hidden (should remove)",l);
81 } 81 }
82#endif 82#endif
83 } 83 }
84 84
85 QPixmap* busyPixmap() const { return (QPixmap*)&bpm; } 85 QPixmap* busyPixmap() const { return (QPixmap*)&bpm; }
86 QIconViewItem* busyItem() const { return bsy; } 86 QIconViewItem* busyItem() const { return bsy; }
87 void setBigIcons( bool bi ) { bigIcns = bi; } 87 void setBigIcons( bool bi ) { bigIcns = bi; }
88 88
89 void updateCategoriesAndMimeTypes(); 89 void updateCategoriesAndMimeTypes();
90 90
91 void doAutoScroll() 91 void doAutoScroll()
92 { 92 {
93 // We don't want rubberbanding (yet) 93 // We don't want rubberbanding (yet)
94 } 94 }
95 95
96 void setBusy(bool on) 96 void setBusy(bool on)
97 { 97 {
98 QIconViewItem *c = on ? currentItem() : 0; 98 QIconViewItem *c = on ? currentItem() : 0;
99 if ( bsy != c ) { 99 if ( bsy != c ) {
100 if ( c ) { 100 if ( c ) {
101 QPixmap *src = c->pixmap(); 101 QPixmap *src = c->pixmap();
102 QImage img = src->convertToImage(); 102 QImage img = src->convertToImage();
103 QRgb* rgb; 103 QRgb* rgb;
104 int count; 104 int count;
105 if ( img.depth() == 32 ) { 105 if ( img.depth() == 32 ) {
106 rgb = (QRgb*)img.bits(); 106 rgb = (QRgb*)img.bits();
107 count = img.bytesPerLine()/sizeof(QRgb)*img.height(); 107 count = img.bytesPerLine()/sizeof(QRgb)*img.height();
108 } else { 108 } else {
109 rgb = img.colorTable(); 109 rgb = img.colorTable();
110 count = img.numColors(); 110 count = img.numColors();
111 } 111 }
112 int rc, gc, bc; 112 int rc, gc, bc;
113 colorGroup().highlight().rgb( &rc, &gc, &bc ); 113 colorGroup().highlight().rgb( &rc, &gc, &bc );
114 int ri, gi, bi; 114 int ri, gi, bi;
115 for ( int r = 0; r < count; r++, rgb++ ) { 115 for ( int r = 0; r < count; r++, rgb++ ) {
116 int ri = (rc+qRed(*rgb))/2; 116 int ri = (rc+qRed(*rgb))/2;
117 int gi = (gc+qGreen(*rgb))/2; 117 int gi = (gc+qGreen(*rgb))/2;
118 int bi = (bc+qBlue(*rgb))/2; 118 int bi = (bc+qBlue(*rgb))/2;
119 int ai = qAlpha(*rgb); 119 int ai = qAlpha(*rgb);
120 *rgb = qRgba(ri,gi,bi,ai); 120 *rgb = qRgba(ri,gi,bi,ai);
121 } 121 }
122 122
123 bpm.convertFromImage( img ); 123 bpm.convertFromImage( img );
124 } 124 }
125 QIconViewItem* o = bsy; 125 QIconViewItem* o = bsy;
126 bsy = c; 126 bsy = c;
127 if ( o ) o->repaint(); 127 if ( o ) o->repaint();
128 if ( c ) c->repaint(); 128 if ( c ) c->repaint();
129 } 129 }
130 } 130 }
131 131
132 bool inKeyEvent() const { return ike; } 132 bool inKeyEvent() const { return ike; }
133 void keyPressEvent(QKeyEvent* e) 133 void keyPressEvent(QKeyEvent* e)
134 { 134 {
135 ike = TRUE; 135 ike = TRUE;
136 if ( e->key() == Key_F33 /* OK button */ || e->key() == Key_Space ) 136 if ( e->key() == Key_F33 /* OK button */ || e->key() == Key_Space )
137 returnPressed(currentItem()); 137 returnPressed(currentItem());
138 QIconView::keyPressEvent(e); 138 QIconView::keyPressEvent(e);
139 ike = FALSE; 139 ike = FALSE;
140 } 140 }
141 141
142 void addItem(AppLnk* app, bool resort=TRUE); 142 void addItem(AppLnk* app, bool resort=TRUE);
143 bool removeLink(const QString& linkfile); 143 bool removeLink(const QString& linkfile);
144 144
145 QStringList mimeTypes() const; 145 QStringList mimeTypes() const;
146 QStringList categories() const; 146 QStringList categories() const;
147 147
148 void clear() 148 void clear()
149 { 149 {
150 mimes.clear(); 150 mimes.clear();
151 cats.clear(); 151 cats.clear();
152 QIconView::clear(); 152 QIconView::clear();
153 hidden.clear(); 153 hidden.clear();
154 } 154 }
155 155
156 void addCatsAndMimes(AppLnk* app) 156 void addCatsAndMimes(AppLnk* app)
157 { 157 {
158 // QStringList c = app->categories(); 158 // QStringList c = app->categories();
159 // for (QStringList::ConstIterator cit=c.begin(); cit!=c.end(); ++cit) { 159 // for (QStringList::ConstIterator cit=c.begin(); cit!=c.end(); ++cit) {
160 // cats.replace(*cit,(void*)1); 160 // cats.replace(*cit,(void*)1);
161 // } 161 // }
162 QString maj=app->type(); 162 QString maj=app->type();
163 int sl=maj.find('/'); 163 int sl=maj.find('/');
164 if (sl>=0) { 164 if (sl>=0) {
165 QString k; 165 QString k;
166 k = maj.left(12) == "application/" ? maj : maj.left(sl); 166 k = maj.left(12) == "application/" ? maj : maj.left(sl);
167 mimes.replace(k,(void*)1); 167 mimes.replace(k,(void*)1);
168 } 168 }
169 } 169 }
170 170
171 void setBackgroundPixmap( const QPixmap &pm ) { 171 void setBackgroundPixmap( const QPixmap &pm ) {
172 bgPixmap = pm; 172 bgPixmap = pm;
173 } 173 }
174 174
175 void setBackgroundColor( const QColor &c ) { 175 void setBackgroundColor( const QColor &c ) {
176 bgColor = c; 176 bgColor = c;
177 } 177 }
178 178
179 void drawBackground( QPainter *p, const QRect &r ) 179 void drawBackground( QPainter *p, const QRect &r )
180 { 180 {
181 if ( !bgPixmap.isNull() ) { 181 if ( !bgPixmap.isNull() ) {
182 p->drawTiledPixmap( r, bgPixmap, 182 p->drawTiledPixmap( r, bgPixmap,
183 QPoint( (r.x() + contentsX()) % bgPixmap.width(), 183 QPoint( (r.x() + contentsX()) % bgPixmap.width(),
184 (r.y() + contentsY()) % bgPixmap.height() ) ); 184 (r.y() + contentsY()) % bgPixmap.height() ) );
185 } else { 185 } else {
186 p->fillRect( r, bgColor ); 186 p->fillRect( r, bgColor );
187 } 187 }
188 } 188 }
189 189
190 void setItemTextPos( ItemTextPos pos ) 190 void setItemTextPos( ItemTextPos pos )
191 { 191 {
192 calculateGrid( pos ); 192 calculateGrid( pos );
193 QIconView::setItemTextPos( pos ); 193 QIconView::setItemTextPos( pos );
194 } 194 }
195 195
196 void hideOrShowItems(bool resort); 196 void hideOrShowItems(bool resort);
197 197
198 void setTypeFilter(const QString& typefilter, bool resort) 198 void setTypeFilter(const QString& typefilter, bool resort)
199 { 199 {
200 tf = QRegExp(typefilter,FALSE,TRUE); 200 tf = QRegExp(typefilter,FALSE,TRUE);
201 hideOrShowItems(resort); 201 hideOrShowItems(resort);
202 } 202 }
203 203
204 void setCategoryFilter( int catfilter, bool resort ) 204 void setCategoryFilter( int catfilter, bool resort )
205 { 205 {
206 Categories cat; 206 Categories cat;
207 cat.load( categoryFileName() ); 207 cat.load( categoryFileName() );
208 QString str; 208 QString str;
209 if ( catfilter == -2 ) 209 if ( catfilter == -2 )
210 cf = 0; 210 cf = 0;
211 else 211 else
212 cf = catfilter; 212 cf = catfilter;
213 hideOrShowItems(resort); 213 hideOrShowItems(resort);
214 } 214 }
215 215
216 enum SortMethod { Name, Date, Type }; 216 enum SortMethod { Name, Date, Type };
217 217
218 void setSortMethod( SortMethod m ) 218 void setSortMethod( SortMethod m )
219 { 219 {
220 if ( sortmeth != m ) { 220 if ( sortmeth != m ) {
221 sortmeth = m; 221 sortmeth = m;
222 sort(); 222 sort();
223 } 223 }
224 } 224 }
225 225
226 int compare(const AppLnk* a, const AppLnk* b) 226 int compare(const AppLnk* a, const AppLnk* b)
227 { 227 {
228 switch (sortmeth) { 228 switch (sortmeth) {
229 case Name: 229 case Name:
230 return a->name().compare(b->name()); 230 return a->name().compare(b->name());
231 case Date: { 231 case Date: {
232 QFileInfo fa(a->linkFileKnown() ? a->linkFile() : a->file()); 232 QFileInfo fa(a->linkFileKnown() ? a->linkFile() : a->file());
233 QFileInfo fb(b->linkFileKnown() ? b->linkFile() : b->file()); 233 QFileInfo fb(b->linkFileKnown() ? b->linkFile() : b->file());
234 return fa.lastModified().secsTo(fb.lastModified()); 234 return fa.lastModified().secsTo(fb.lastModified());
235 } 235 }
236 case Type: 236 case Type:
237 return a->type().compare(b->type()); 237 return a->type().compare(b->type());
238 } 238 }
239 return 0; 239 return 0;
240 } 240 }
241 241
242 QString getAllDocLinkInfo() const; 242 QString getAllDocLinkInfo() const;
243 243
244protected: 244protected:
245 245
246 void styleChange( QStyle &old ) 246 void styleChange( QStyle &old )
247 { 247 {
248 QIconView::styleChange( old ); 248 QIconView::styleChange( old );
249 calculateGrid( itemTextPos() ); 249 calculateGrid( itemTextPos() );
250 } 250 }
251 251
252 void calculateGrid( ItemTextPos pos ) 252 void calculateGrid( ItemTextPos pos )
253 { 253 {
254 int dw = QApplication::desktop()->width(); 254 int dw = QApplication::desktop()->width();
255 int viewerWidth = dw-style().scrollBarExtent().width(); 255 int viewerWidth = dw-style().scrollBarExtent().width();
256 if ( pos == Bottom ) { 256 if ( pos == Bottom ) {
257 int cols = 3; 257 int cols = 3;
258 if ( viewerWidth <= 200 ) 258 if ( viewerWidth <= 200 )
259 cols = 2; 259 cols = 2;
260 else if ( viewerWidth >= 400 ) 260 else if ( viewerWidth >= 400 )
261 cols = viewerWidth/96; 261 cols = viewerWidth/96;
262 setSpacing( 4 ); 262 setSpacing( 4 );
263 setGridX( (viewerWidth-(cols+1)*spacing())/cols ); 263 setGridX( (viewerWidth-(cols+1)*spacing())/cols );
264 setGridY( fontMetrics().height()*2+24 ); 264 setGridY( fontMetrics().height()*2+24 );
265 } else { 265 } else {
266 int cols = 2; 266 int cols = 2;
267 if ( viewerWidth < 150 ) 267 if ( viewerWidth < 150 )
268 cols = 1; 268 cols = 1;
269 else if ( viewerWidth >= 400 ) 269 else if ( viewerWidth >= 400 )
270 cols = viewerWidth/150; 270 cols = viewerWidth/150;
271 setSpacing( 2 ); 271 setSpacing( 2 );
272 setGridX( (viewerWidth-(cols+1)*spacing())/cols ); 272 setGridX( (viewerWidth-(cols+1)*spacing())/cols );
273 setGridY( fontMetrics().height()+2 ); 273 setGridY( fontMetrics().height()+2 );
274 } 274 }
275 } 275 }
276 276
277private: 277private:
278 QList<AppLnk> hidden; 278 QList<AppLnk> hidden;
279 QDict<void> mimes; 279 QDict<void> mimes;
280 QDict<void> cats; 280 QDict<void> cats;
281 SortMethod sortmeth; 281 SortMethod sortmeth;
282 QRegExp tf; 282 QRegExp tf;
283 int cf; 283 int cf;
284 QIconViewItem* bsy; 284 QIconViewItem* bsy;
285 bool ike; 285 bool ike;
286 bool bigIcns; 286 bool bigIcns;
287 QPixmap bgPixmap; 287 QPixmap bgPixmap;
288 QPixmap bpm; 288 QPixmap bpm;
289 QColor bgColor; 289 QColor bgColor;
290}; 290};
291 291
292 292
293bool LauncherView::bsy=FALSE; 293bool LauncherView::bsy=FALSE;
294 294
295void LauncherView::setBusy(bool on) 295void LauncherView::setBusy(bool on)
296{ 296{
297 icons->setBusy(on); 297 icons->setBusy(on);
298} 298}
299 299
300class LauncherItem : public QIconViewItem 300class LauncherItem : public QIconViewItem
301{ 301{
302public: 302public:
303 LauncherItem( QIconView *parent, AppLnk* applnk, bool bigIcon=TRUE ); 303 LauncherItem( QIconView *parent, AppLnk* applnk, bool bigIcon=TRUE );
304 ~LauncherItem() 304 ~LauncherItem()
305 { 305 {
306 LauncherIconView* liv = (LauncherIconView*)iconView(); 306 LauncherIconView* liv = (LauncherIconView*)iconView();
307 if ( liv->busyItem() == this ) 307 if ( liv->busyItem() == this )
308 liv->setBusy(FALSE); 308 liv->setBusy(FALSE);
309 delete app; 309 delete app;
310 } 310 }
311 311
312 AppLnk* appLnk() const { return app; } 312 AppLnk* appLnk() const { return app; }
313 AppLnk* takeAppLnk() { AppLnk* r=app; app=0; return r; } 313 AppLnk* takeAppLnk() { AppLnk* r=app; app=0; return r; }
314 314
315 virtual int compare ( QIconViewItem * i ) const; 315 virtual int compare ( QIconViewItem * i ) const;
316 316
317 void paintItem( QPainter *p, const QColorGroup &cg ) 317 void paintItem( QPainter *p, const QColorGroup &cg )
318 { 318 {
319 LauncherIconView* liv = (LauncherIconView*)iconView(); 319 LauncherIconView* liv = (LauncherIconView*)iconView();
320 QBrush oldBrush( liv->itemTextBackground() ); 320 QBrush oldBrush( liv->itemTextBackground() );
321 QColorGroup mycg( cg ); 321 QColorGroup mycg( cg );
322 if ( liv->currentItem() == this ) { 322 if ( liv->currentItem() == this ) {
323 liv->setItemTextBackground( cg.brush( QColorGroup::Highlight ) ); 323 liv->setItemTextBackground( cg.brush( QColorGroup::Highlight ) );
324 mycg.setColor( QColorGroup::Text, cg.color( QColorGroup::HighlightedText ) ); 324 mycg.setColor( QColorGroup::Text, cg.color( QColorGroup::HighlightedText ) );
325 } 325 }
326 QIconViewItem::paintItem(p,mycg); 326 QIconViewItem::paintItem(p,mycg);
327 if ( liv->currentItem() == this ) 327 if ( liv->currentItem() == this )
328 liv->setItemTextBackground( oldBrush ); 328 liv->setItemTextBackground( oldBrush );
329 } 329 }
330 330
331 virtual QPixmap* pixmap () const 331 virtual QPixmap* pixmap () const
332 { 332 {
333 const LauncherIconView* liv = (LauncherIconView*)iconView(); 333 const LauncherIconView* liv = (LauncherIconView*)iconView();
334 if ( (const LauncherItem *)liv->busyItem() == this ) 334 if ( (const LauncherItem *)liv->busyItem() == this )
335 return liv->busyPixmap(); 335 return liv->busyPixmap();
336 return QIconViewItem::pixmap(); 336 return QIconViewItem::pixmap();
337 } 337 }
338 338
339protected: 339protected:
340 AppLnk* app; 340 AppLnk* app;
341}; 341};
342 342
343 343
344LauncherItem::LauncherItem( QIconView *parent, AppLnk *applnk, bool bigIcon ) 344LauncherItem::LauncherItem( QIconView *parent, AppLnk *applnk, bool bigIcon )
345 : QIconViewItem( parent, applnk->name(), 345 : QIconViewItem( parent, applnk->name(),
346 bigIcon ? applnk->bigPixmap() :applnk->pixmap() ), 346 bigIcon ? applnk->bigPixmap() :applnk->pixmap() ),
347 app(applnk) // Takes ownership 347 app(applnk) // Takes ownership
348{ 348{
349} 349}
350 350
351int LauncherItem::compare ( QIconViewItem * i ) const 351int LauncherItem::compare ( QIconViewItem * i ) const
352{ 352{
353 LauncherIconView* view = (LauncherIconView*)iconView(); 353 LauncherIconView* view = (LauncherIconView*)iconView();
354 return view->compare(app,((LauncherItem *)i)->appLnk()); 354 return view->compare(app,((LauncherItem *)i)->appLnk());
355} 355}
356 356
357QStringList LauncherIconView::mimeTypes() const 357QStringList LauncherIconView::mimeTypes() const
358{ 358{
359 QStringList r; 359 QStringList r;
360 QDictIterator<void> it(mimes); 360 QDictIterator<void> it(mimes);
361 while (it.current()) { 361 while (it.current()) {
362 r.append(it.currentKey()); 362 r.append(it.currentKey());
363 ++it; 363 ++it;
364 } 364 }
365 r.sort(); 365 r.sort();
366 return r; 366 return r;
367} 367}
368 368
369void LauncherIconView::addItem(AppLnk* app, bool resort) 369void LauncherIconView::addItem(AppLnk* app, bool resort)
370{ 370{
371 addCatsAndMimes(app); 371 addCatsAndMimes(app);
372 372
373 if ( (tf.isEmpty() || tf.match(app->type()) >= 0) 373 if ( (tf.isEmpty() || tf.match(app->type()) >= 0)
374 && (cf == 0 || app->categories().contains(cf) 374 && (cf == 0 || app->categories().contains(cf)
375 || cf == -1 && app->categories().count() == 0 ) ) 375 || cf == -1 && app->categories().count() == 0 ) )
376 (void) new LauncherItem( this, app, bigIcns ); 376 (void) new LauncherItem( this, app, bigIcns );
377 else 377 else
378 hidden.append(app); 378 hidden.append(app);
379 if ( resort ) 379 if ( resort )
380 sort(); 380 sort();
381} 381}
382 382
383void LauncherIconView::updateCategoriesAndMimeTypes() 383void LauncherIconView::updateCategoriesAndMimeTypes()
384{ 384{
385 mimes.clear(); 385 mimes.clear();
386 cats.clear(); 386 cats.clear();
387 LauncherItem* item = (LauncherItem*)firstItem(); 387 LauncherItem* item = (LauncherItem*)firstItem();
388 while (item) { 388 while (item) {
389 addCatsAndMimes(item->appLnk()); 389 addCatsAndMimes(item->appLnk());
390 item = (LauncherItem*)item->nextItem(); 390 item = (LauncherItem*)item->nextItem();
391 } 391 }
392 QListIterator<AppLnk> it(hidden); 392 QListIterator<AppLnk> it(hidden);
393 AppLnk* l; 393 AppLnk* l;
394 while ((l=it.current())) { 394 while ((l=it.current())) {
395 addCatsAndMimes(l); 395 addCatsAndMimes(l);
396 ++it; 396 ++it;
397 } 397 }
398} 398}
399 399
400void LauncherIconView::hideOrShowItems(bool resort) 400void LauncherIconView::hideOrShowItems(bool resort)
401{ 401{
402 hidden.setAutoDelete(FALSE); 402 hidden.setAutoDelete(FALSE);
403 QList<AppLnk> links=hidden; 403 QList<AppLnk> links=hidden;
404 hidden.clear(); 404 hidden.clear();
405 hidden.setAutoDelete(TRUE); 405 hidden.setAutoDelete(TRUE);
406 LauncherItem* item = (LauncherItem*)firstItem(); 406 LauncherItem* item = (LauncherItem*)firstItem();
407 while (item) { 407 while (item) {
408 links.append(item->takeAppLnk()); 408 links.append(item->takeAppLnk());
409 item = (LauncherItem*)item->nextItem(); 409 item = (LauncherItem*)item->nextItem();
410 } 410 }
411 viewport()->setUpdatesEnabled( FALSE ); 411 viewport()->setUpdatesEnabled( FALSE );
412 clear(); 412 clear();
413 QListIterator<AppLnk> it(links); 413 QListIterator<AppLnk> it(links);
414 AppLnk* l; 414 AppLnk* l;
415 while ((l=it.current())) { 415 while ((l=it.current())) {
416 addItem(l,FALSE); 416 addItem(l,FALSE);
417 ++it; 417 ++it;
418 } 418 }
419 viewport()->setUpdatesEnabled( TRUE ); 419 viewport()->setUpdatesEnabled( TRUE );
420 if ( resort && !autoArrange() ) 420 if ( resort && !autoArrange() )
421 sort(); 421 sort();
422} 422}
423 423
424bool LauncherIconView::removeLink(const QString& linkfile) 424bool LauncherIconView::removeLink(const QString& linkfile)
425{ 425{
426 LauncherItem* item = (LauncherItem*)firstItem(); 426 LauncherItem* item = (LauncherItem*)firstItem();
427 AppLnk* l; 427 AppLnk* l;
428 bool did = FALSE; 428 bool did = FALSE;
429 DocLnk dl(linkfile); 429 DocLnk dl(linkfile);
430 while (item) { 430 while (item) {
431 l = item->appLnk(); 431 l = item->appLnk();
432 if ( l->linkFileKnown() && l->linkFile() == linkfile 432 if ( l->linkFileKnown() && l->linkFile() == linkfile
433 || l->fileKnown() && ( 433 || l->fileKnown() && (
434 l->file() == linkfile 434 l->file() == linkfile
435 || dl.isValid() && dl.file() == l->file() ) ) { 435 || dl.isValid() && dl.file() == l->file() ) ) {
436 delete item; 436 delete item;
437 did = TRUE; 437 did = TRUE;
438 } 438 }
439 item = (LauncherItem*)item->nextItem(); 439 item = (LauncherItem*)item->nextItem();
440 } 440 }
441 QListIterator<AppLnk> it(hidden); 441 QListIterator<AppLnk> it(hidden);
442 while ((l=it.current())) { 442 while ((l=it.current())) {
443 ++it; 443 ++it;
444 if ( l->linkFileKnown() && l->linkFile() == linkfile 444 if ( l->linkFileKnown() && l->linkFile() == linkfile
445 || l->file() == linkfile 445 || l->file() == linkfile
446 || dl.isValid() && dl.file() == l->file() ) { 446 || dl.isValid() && dl.file() == l->file() ) {
447 hidden.removeRef(l); 447 hidden.removeRef(l);
448 did = TRUE; 448 did = TRUE;
449 } 449 }
450 } 450 }
451 return did; 451 return did;
452} 452}
453 453
454static QString docLinkInfo(const Categories& cats, DocLnk* doc) 454static QString docLinkInfo(const Categories& cats, DocLnk* doc)
455{ 455{
456 QString contents; 456 QString contents;
457 457
458 QFileInfo fi( doc->file() ); 458 QFileInfo fi( doc->file() );
459 if ( !fi.exists() ) 459 if ( !fi.exists() )
460 return contents; 460 return contents;
461 461
462 if ( doc->linkFileKnown() ) { 462 if ( doc->linkFileKnown() ) {
463 QString lfn = doc->linkFile(); 463 QString lfn = doc->linkFile();
464 QFile f( lfn ); 464 QFile f( lfn );
465 if ( f.open( IO_ReadOnly ) ) { 465 if ( f.open( IO_ReadOnly ) ) {
466 QTextStream ts( &f ); 466 QTextStream ts( &f );
467 ts.setEncoding( QTextStream::UnicodeUTF8 ); 467 ts.setEncoding( QTextStream::UnicodeUTF8 );
468 contents += ts.read(); 468 contents += ts.read();
469 f.close(); 469 f.close();
470 goto calcsize; 470 goto calcsize;
471 } 471 }
472 } 472 }
473 473
474 contents += "[Desktop Entry]\n"; 474 contents += "[Desktop Entry]\n";
475 contents += "Categories = " // No tr 475 contents += "Categories = " // No tr
476 + cats.labels("Document View", doc->categories()).join(";") + "\n"; // No tr 476 + cats.labels("Document View", doc->categories()).join(";") + "\n"; // No tr
477 contents += "File = "+doc->file()+"\n"; // No tr 477 contents += "File = "+doc->file()+"\n"; // No tr
478 contents += "Name = "+doc->name()+"\n"; // No tr 478 contents += "Name = "+doc->name()+"\n"; // No tr
479 contents += "Type = "+doc->type()+"\n"; // No tr 479 contents += "Type = "+doc->type()+"\n"; // No tr
480 480
481calcsize: 481calcsize:
482 contents += QString("Size = %1\n").arg( fi.size() ); // No tr 482 contents += QString("Size = %1\n").arg( fi.size() ); // No tr
483 return contents; 483 return contents;
484} 484}
485 485
486QString LauncherIconView::getAllDocLinkInfo() const 486QString LauncherIconView::getAllDocLinkInfo() const
487{ 487{
488 QString contents; 488 QString contents;
489 LauncherItem* item = (LauncherItem*)firstItem(); 489 LauncherItem* item = (LauncherItem*)firstItem();
490 Categories cats; 490 Categories cats;
491 while (item) { 491 while (item) {
492 DocLnk* doc = (DocLnk*)item->appLnk(); 492 DocLnk* doc = (DocLnk*)item->appLnk();
493 contents += docLinkInfo(cats,doc); 493 contents += docLinkInfo(cats,doc);
494 item = (LauncherItem*)item->nextItem(); 494 item = (LauncherItem*)item->nextItem();
495 } 495 }
496 QListIterator<AppLnk> it(hidden); 496 QListIterator<AppLnk> it(hidden);
497 DocLnk* doc; 497 DocLnk* doc;
498 while ((doc=(DocLnk*)it.current())) { 498 while ((doc=(DocLnk*)it.current())) {
499 contents += docLinkInfo(cats,doc); 499 contents += docLinkInfo(cats,doc);
500 ++it; 500 ++it;
501 } 501 }
502 return contents; 502 return contents;
503} 503}
504 504
505//=========================================================================== 505//===========================================================================
506 506
507LauncherView::LauncherView( QWidget* parent, const char* name, WFlags fl ) 507LauncherView::LauncherView( QWidget* parent, const char* name, WFlags fl )
508 : QVBox( parent, name, fl ) 508 : QVBox( parent, name, fl )
509{ 509{
510 icons = new LauncherIconView( this ); 510 icons = new LauncherIconView( this );
511 setFocusProxy(icons); 511 setFocusProxy(icons);
512 QPEApplication::setStylusOperation( icons->viewport(), QPEApplication::RightOnHold ); 512 QPEApplication::setStylusOperation( icons->viewport(), QPEApplication::RightOnHold );
513 513
514 icons->setItemsMovable( FALSE ); 514 icons->setItemsMovable( FALSE );
515 icons->setAutoArrange( TRUE ); 515 icons->setAutoArrange( TRUE );
516 icons->setSorting( TRUE ); 516 icons->setSorting( TRUE );
517 icons->setFrameStyle( QFrame::NoFrame ); 517 icons->setFrameStyle( QFrame::NoFrame );
518 icons->setMargin( 0 ); 518 icons->setMargin( 0 );
519 icons->setSelectionMode( QIconView::NoSelection ); 519 icons->setSelectionMode( QIconView::NoSelection );
520 icons->setBackgroundMode( PaletteBase ); 520 icons->setBackgroundMode( PaletteBase );
521 icons->setResizeMode( QIconView::Fixed ); 521 icons->setResizeMode( QIconView::Fixed );
522 vmode = (ViewMode)-1; 522 vmode = (ViewMode)-1;
523 setViewMode( Icon ); 523 setViewMode( Icon );
524 524
525 connect( icons, SIGNAL(mouseButtonClicked(int, QIconViewItem *, const QPoint&)), 525 connect( icons, SIGNAL(mouseButtonClicked(int, QIconViewItem *, const QPoint&)),
526 SLOT(itemClicked(int, QIconViewItem *)) ); 526 SLOT(itemClicked(int, QIconViewItem *)) );
527 connect( icons, SIGNAL(selectionChanged()), 527 connect( icons, SIGNAL(selectionChanged()),
528 SLOT(selectionChanged()) ); 528 SLOT(selectionChanged()) );
529 connect( icons, SIGNAL(returnPressed(QIconViewItem *)), 529 connect( icons, SIGNAL(returnPressed(QIconViewItem *)),
530 SLOT(returnPressed(QIconViewItem *)) ); 530 SLOT(returnPressed(QIconViewItem *)) );
531 connect( icons, SIGNAL(mouseButtonPressed(int, QIconViewItem *, const QPoint&)), 531 connect( icons, SIGNAL(mouseButtonPressed(int, QIconViewItem *, const QPoint&)),
532 SLOT(itemPressed(int, QIconViewItem *)) ); 532 SLOT(itemPressed(int, QIconViewItem *)) );
533 533
534 tools = 0; 534 tools = 0;
535 setBackgroundType( Ruled, QString::null ); 535 setBackgroundType( Ruled, QString::null );
536} 536}
537 537
538LauncherView::~LauncherView() 538LauncherView::~LauncherView()
539{ 539{
540} 540}
541 541
542void LauncherView::setToolsEnabled(bool y) 542void LauncherView::setToolsEnabled(bool y)
543{ 543{
544 if ( !y != !tools ) { 544 if ( !y != !tools ) {
545 if ( y ) { 545 if ( y ) {
546 tools = new QHBox(this); 546 tools = new QHBox(this);
547 547
548 // Type filter 548 // Type filter
549 typemb = new QComboBox(tools); 549 typemb = new QComboBox(tools);
550 550
551 // Category filter 551 // Category filter
552 catmb = new CategorySelect(tools); 552 catmb = new CategorySelect(tools);
553 553
554 updateTools(); 554 updateTools();
555 tools->show(); 555 tools->show();
556 } else { 556 } else {
557 delete tools; 557 delete tools;
558 tools = 0; 558 tools = 0;
559 } 559 }
560 } 560 }
561} 561}
562 562
563void LauncherView::updateTools() 563void LauncherView::updateTools()
564{ 564{
565 disconnect( typemb, SIGNAL(activated(int)), 565 disconnect( typemb, SIGNAL(activated(int)),
566 this, SLOT(showType(int)) ); 566 this, SLOT(showType(int)) );
567 disconnect( catmb, SIGNAL(signalSelected(int)), 567 disconnect( catmb, SIGNAL(signalSelected(int)),
568 this, SLOT(showCategory(int)) ); 568 this, SLOT(showCategory(int)) );
569 569
570 icons->updateCategoriesAndMimeTypes(); 570 icons->updateCategoriesAndMimeTypes();
571 571
572 QString prev; 572 QString prev;
573 573
574 // Type filter 574 // Type filter
575 QStringList types; 575 QStringList types;
576 typelist = icons->mimeTypes(); 576 typelist = icons->mimeTypes();
577 for (QStringList::ConstIterator it = typelist.begin(); it!=typelist.end(); ++it) { 577 for (QStringList::ConstIterator it = typelist.begin(); it!=typelist.end(); ++it) {
578 QString t = *it; 578 QString t = *it;
579 if ( t.left(12) == "application/" ) { 579 if ( t.left(12) == "application/" ) {
580 MimeType mt(t); 580 MimeType mt(t);
581 const AppLnk* app = mt.application(); 581 const AppLnk* app = mt.application();
582 if ( app ) 582 if ( app )
583 t = app->name(); 583 t = app->name();
584 else 584 else
585 t = t.mid(12); 585 t = t.mid(12);
586 } else { 586 } else {
587 t[0] = t[0].upper(); 587 t[0] = t[0].upper();
588 } 588 }
589 types += tr("%1 files").arg(t); 589 types += tr("%1 files").arg(t);
590 } 590 }
591 types << tr("All types of file"); 591 types << tr("All types of file");
592 prev = typemb->currentText(); 592 prev = typemb->currentText();
593 typemb->clear(); 593 typemb->clear();
594 typemb->insertStringList(types); 594 typemb->insertStringList(types);
595 for (int i=0; i<typemb->count(); i++) { 595 for (int i=0; i<typemb->count(); i++) {
596 if ( typemb->text(i) == prev ) { 596 if ( typemb->text(i) == prev ) {
597 typemb->setCurrentItem(i); 597 typemb->setCurrentItem(i);
598 break; 598 break;
599 } 599 }
600 } 600 }
601 if ( prev.isNull() ) 601 if ( prev.isNull() )
602 typemb->setCurrentItem(typemb->count()-1); 602 typemb->setCurrentItem(typemb->count()-1);
603 603
604 Categories cats( 0 ); 604 Categories cats( 0 );
605 cats.load( categoryFileName() ); 605 cats.load( categoryFileName() );
606 QArray<int> vl( 0 ); 606 QArray<int> vl( 0 );
607 catmb->setCategories( vl, "Document View", // No tr 607 catmb->setCategories( vl, "Document View", // No tr
608 tr("Document View") ); 608 tr("Document View") );
609 catmb->setRemoveCategoryEdit( TRUE ); 609 catmb->setRemoveCategoryEdit( TRUE );
610 catmb->setAllCategories( TRUE ); 610 catmb->setAllCategories( TRUE );
611 611
612 connect(typemb, SIGNAL(activated(int)), this, SLOT(showType(int))); 612 connect(typemb, SIGNAL(activated(int)), this, SLOT(showType(int)));
613 connect(catmb, SIGNAL(signalSelected(int)), this, SLOT(showCategory(int))); 613 connect(catmb, SIGNAL(signalSelected(int)), this, SLOT(showCategory(int)));
614} 614}
615 615
616void LauncherView::sortBy(int s) 616void LauncherView::sortBy(int s)
617{ 617{
618 icons->setSortMethod((LauncherIconView::SortMethod)s); 618 icons->setSortMethod((LauncherIconView::SortMethod)s);
619} 619}
620 620
621void LauncherView::showType(int t) 621void LauncherView::showType(int t)
622{ 622{
623 if ( t >= (int)typelist.count() ) { 623 if ( t >= (int)typelist.count() ) {
624 icons->setTypeFilter("",TRUE); 624 icons->setTypeFilter("",TRUE);
625 } else { 625 } else {
626 QString ty = typelist[t]; 626 QString ty = typelist[t];
627 if ( !ty.contains('/') ) 627 if ( !ty.contains('/') )
628 ty += "/*"; 628 ty += "/*";
629 icons->setTypeFilter(ty,TRUE); 629 icons->setTypeFilter(ty,TRUE);
630 } 630 }
631} 631}
632 632
633void LauncherView::showCategory( int c ) 633void LauncherView::showCategory( int c )
634{ 634{
635 icons->setCategoryFilter( c, TRUE ); 635 icons->setCategoryFilter( c, TRUE );
636} 636}
637 637
638void LauncherView::setViewMode( ViewMode m ) 638void LauncherView::setViewMode( ViewMode m )
639{ 639{
640 if ( vmode != m ) { 640 if ( vmode != m ) {
641 bool bigIcons = m == Icon; 641 bool bigIcons = m == Icon;
642 icons->viewport()->setUpdatesEnabled( FALSE ); 642 icons->viewport()->setUpdatesEnabled( FALSE );
643 icons->setBigIcons( bigIcons ); 643 icons->setBigIcons( bigIcons );
644 switch ( m ) { 644 switch ( m ) {
645 case List: 645 case List:
646 icons->setItemTextPos( QIconView::Right ); 646 icons->setItemTextPos( QIconView::Right );
647 break; 647 break;
648 case Icon: 648 case Icon:
649 icons->setItemTextPos( QIconView::Bottom ); 649 icons->setItemTextPos( QIconView::Bottom );
650 break; 650 break;
651 } 651 }
652 icons->hideOrShowItems( FALSE ); 652 icons->hideOrShowItems( FALSE );
653 icons->viewport()->setUpdatesEnabled( TRUE ); 653 icons->viewport()->setUpdatesEnabled( TRUE );
654 vmode = m; 654 vmode = m;
655 } 655 }
656} 656}
657 657
658void LauncherView::setBackgroundType( BackgroundType t, const QString &val ) 658void LauncherView::setBackgroundType( BackgroundType t, const QString &val )
659{ 659{
660 if ( !bgCache ) 660 if ( !bgCache )
661 bgCache = new QMap<QString,BgPixmap*>; 661 bgCache = new QMap<QString,BgPixmap*>;
662 if ( bgCache->contains( bgName ) ) 662 if ( bgCache->contains( bgName ) )
663 (*bgCache)[bgName]->ref--; 663 (*bgCache)[bgName]->ref--;
664 664
665 switch ( t ) { 665 switch ( t ) {
666 case Ruled: { 666 case Ruled: {
667 bgName = QString("Ruled_%1").arg(colorGroup().background().name()); // No tr 667 bgName = QString("Ruled_%1").arg(colorGroup().background().name()); // No tr
668 QPixmap bg; 668 QPixmap bg;
669 if ( bgCache->contains( bgName ) ) { 669 if ( bgCache->contains( bgName ) ) {
670 (*bgCache)[bgName]->ref++; 670 (*bgCache)[bgName]->ref++;
671 bg = (*bgCache)[bgName]->pm; 671 bg = (*bgCache)[bgName]->pm;
672 } else { 672 } else {
673 bg.resize( width(), 9 ); 673 bg.resize( width(), 9 );
674 QPainter painter( &bg ); 674 QPainter painter( &bg );
675 for ( int i = 0; i < 3; i++ ) { 675 for ( int i = 0; i < 3; i++ ) {
676 painter.setPen( white ); 676 painter.setPen( white );
677 painter.drawLine( 0, i*3, width()-1, i*3 ); 677 painter.drawLine( 0, i*3, width()-1, i*3 );
678 painter.drawLine( 0, i*3+1, width()-1, i*3+1 ); 678 painter.drawLine( 0, i*3+1, width()-1, i*3+1 );
679 painter.setPen( colorGroup().background().light(105) ); 679 painter.setPen( colorGroup().background().light(105) );
680 painter.drawLine( 0, i*3+2, width()-1, i*3+2 ); 680 painter.drawLine( 0, i*3+2, width()-1, i*3+2 );
681 } 681 }
682 painter.end(); 682 painter.end();
683 bgCache->insert( bgName, new BgPixmap(bg) ); 683 bgCache->insert( bgName, new BgPixmap(bg) );
684 } 684 }
685 icons->setBackgroundPixmap( bg ); 685 icons->setBackgroundPixmap( bg );
686 break; 686 break;
687 } 687 }
688 688
689 case SolidColor: 689 case SolidColor:
690 icons->setBackgroundPixmap( QPixmap() ); 690 icons->setBackgroundPixmap( QPixmap() );
691 if ( val.isEmpty() ) { 691 if ( val.isEmpty() ) {
692 icons->setBackgroundColor( colorGroup().base() ); 692 icons->setBackgroundColor( colorGroup().base() );
693 } else { 693 } else {
694 icons->setBackgroundColor( val ); 694 icons->setBackgroundColor( val );
695 } 695 }
696 bgName = ""; 696 bgName = "";
697 break; 697 break;
698 698
699 case Image: 699 case Image:
700 bgName = val; 700 bgName = val;
701 if ( bgCache->contains( bgName ) ) { 701 if ( bgCache->contains( bgName ) ) {
702 (*bgCache)[bgName]->ref++; 702 (*bgCache)[bgName]->ref++;
703 icons->setBackgroundPixmap( (*bgCache)[bgName]->pm ); 703 icons->setBackgroundPixmap( (*bgCache)[bgName]->pm );
704 } else { 704 } else {
705 qDebug( "Loading image: %s", val.latin1() ); 705 qDebug( "Loading image: %s", val.latin1() );
706 QPixmap bg( Resource::loadPixmap( "wallpaper/" + val ) ); 706 QPixmap bg( Resource::loadPixmap( val ) );
707 if ( bg.isNull() ) { 707 if ( bg.isNull() ) {
708 QImageIO imgio; 708 QImageIO imgio;
709 imgio.setFileName( bgName ); 709 imgio.setFileName( bgName );
710 QSize ds = qApp->desktop()->size(); 710 QSize ds = qApp->desktop()->size();
711 QString param( "Scale( %1, %2, ScaleMin )" ); // No tr 711 QString param( "Scale( %1, %2, ScaleMin )" ); // No tr
712 imgio.setParameters( param.arg(ds.width()).arg(ds.height()).latin1() ); 712 imgio.setParameters( param.arg(ds.width()).arg(ds.height()).latin1() );
713 imgio.read(); 713 imgio.read();
714 bg = imgio.image(); 714 bg = imgio.image();
715 } 715 }
716 bgCache->insert( bgName, new BgPixmap(bg) ); 716 bgCache->insert( bgName, new BgPixmap(bg) );
717 icons->setBackgroundPixmap( bg ); 717 icons->setBackgroundPixmap( bg );
718 } 718 }
719 break; 719 break;
720 } 720 }
721 721
722 // remove unreferenced backgrounds. 722 // remove unreferenced backgrounds.
723 QMap<QString,BgPixmap*>::Iterator it = bgCache->begin(); 723 QMap<QString,BgPixmap*>::Iterator it = bgCache->begin();
724 while ( it != bgCache->end() ) { 724 while ( it != bgCache->end() ) {
725 QMap<QString,BgPixmap*>::Iterator curr = it; 725 QMap<QString,BgPixmap*>::Iterator curr = it;
726 ++it; 726 ++it;
727 if ( (*curr)->ref == 0 ) { 727 if ( (*curr)->ref == 0 ) {
728 delete (*curr); 728 delete (*curr);
729 bgCache->remove( curr ); 729 bgCache->remove( curr );
730 } 730 }
731 } 731 }
732 732
733 bgType = t; 733 bgType = t;
734 icons->viewport()->update(); 734 icons->viewport()->update();
735} 735}
736 736
737void LauncherView::setTextColor( const QColor &tc ) 737void LauncherView::setTextColor( const QColor &tc )
738{ 738{
739 textCol = tc; 739 textCol = tc;
740 QColorGroup cg = icons->colorGroup(); 740 QColorGroup cg = icons->colorGroup();
741 cg.setColor( QColorGroup::Text, tc ); 741 cg.setColor( QColorGroup::Text, tc );
742 icons->setPalette( QPalette(cg,cg,cg) ); 742 icons->setPalette( QPalette(cg,cg,cg) );
743 icons->viewport()->update(); 743 icons->viewport()->update();
744} 744}
745 745
746void LauncherView::setViewFont( const QFont &f ) 746void LauncherView::setViewFont( const QFont &f )
747{ 747{
748 icons->setFont( f ); 748 icons->setFont( f );
749} 749}
750 750
751void LauncherView::resizeEvent(QResizeEvent *e) 751void LauncherView::resizeEvent(QResizeEvent *e)
752{ 752{
753 QVBox::resizeEvent( e ); 753 QVBox::resizeEvent( e );
754 if ( e->size().width() != e->oldSize().width() ) 754 if ( e->size().width() != e->oldSize().width() )
755 sort(); 755 sort();
756} 756}
757 757
758void LauncherView::populate( AppLnkSet *folder, const QString& typefilter ) 758void LauncherView::populate( AppLnkSet *folder, const QString& typefilter )
759{ 759{
760 icons->clear(); 760 icons->clear();
761 internalPopulate( folder, typefilter ); 761 internalPopulate( folder, typefilter );
762} 762}
763 763
764QString LauncherView::getAllDocLinkInfo() const 764QString LauncherView::getAllDocLinkInfo() const
765{ 765{
766 return icons->getAllDocLinkInfo(); 766 return icons->getAllDocLinkInfo();
767} 767}
768 768
769void LauncherView::selectionChanged() 769void LauncherView::selectionChanged()
770{ 770{
771 QIconViewItem* item = icons->currentItem(); 771 QIconViewItem* item = icons->currentItem();
772 if ( item && item->isSelected() ) { 772 if ( item && item->isSelected() ) {
773 AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); 773 AppLnk *appLnk = ((LauncherItem *)item)->appLnk();
774 if ( icons->inKeyEvent() ) // not for mouse press 774 if ( icons->inKeyEvent() ) // not for mouse press
775 emit clicked( appLnk ); 775 emit clicked( appLnk );
776 item->setSelected(FALSE); 776 item->setSelected(FALSE);
777 } 777 }
778} 778}
779 779
780void LauncherView::returnPressed( QIconViewItem *item ) 780void LauncherView::returnPressed( QIconViewItem *item )
781{ 781{
782 if ( item ) { 782 if ( item ) {
783 AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); 783 AppLnk *appLnk = ((LauncherItem *)item)->appLnk();
784 emit clicked( appLnk ); 784 emit clicked( appLnk );
785 } 785 }
786} 786}
787 787
788void LauncherView::itemClicked( int btn, QIconViewItem *item ) 788void LauncherView::itemClicked( int btn, QIconViewItem *item )
789{ 789{
790 if ( item ) { 790 if ( item ) {
791 AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); 791 AppLnk *appLnk = ((LauncherItem *)item)->appLnk();
792 if ( btn == LeftButton ) { 792 if ( btn == LeftButton ) {
793 // Make sure it's the item we execute that gets highlighted 793 // Make sure it's the item we execute that gets highlighted
794 icons->setCurrentItem( item ); 794 icons->setCurrentItem( item );
795 emit clicked( appLnk ); 795 emit clicked( appLnk );
796 } 796 }
797 item->setSelected(FALSE); 797 item->setSelected(FALSE);
798 } 798 }
799} 799}
800 800
801void LauncherView::itemPressed( int btn, QIconViewItem *item ) 801void LauncherView::itemPressed( int btn, QIconViewItem *item )
802{ 802{
803 if ( item ) { 803 if ( item ) {
804 AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); 804 AppLnk *appLnk = ((LauncherItem *)item)->appLnk();
805 if ( btn == RightButton ) 805 if ( btn == RightButton )
806 emit rightPressed( appLnk ); 806 emit rightPressed( appLnk );
807/* 807/*
808 else if ( btn == LeftButton ) 808 else if ( btn == LeftButton )
809 emit clicked( appLnk ); 809 emit clicked( appLnk );
810*/ 810*/
811 item->setSelected(FALSE); 811 item->setSelected(FALSE);
812 } 812 }
813} 813}
814 814
815void LauncherView::internalPopulate( AppLnkSet *folder, const QString& typefilter ) 815void LauncherView::internalPopulate( AppLnkSet *folder, const QString& typefilter )
816{ 816{
817 QListIterator<AppLnk> it( folder->children() ); 817 QListIterator<AppLnk> it( folder->children() );
818 icons->setTypeFilter(typefilter,FALSE); 818 icons->setTypeFilter(typefilter,FALSE);
819 819
820 while ( it.current() ) { 820 while ( it.current() ) {
821 // show only the icons for existing files 821 // show only the icons for existing files
822 if (QFile(it.current()->file()).exists() || ( it.current()->file().left(4) == "http" )) { 822 if (QFile(it.current()->file()).exists() || ( it.current()->file().left(4) == "http" )) {
823 icons->addItem(*it,FALSE); 823 icons->addItem(*it,FALSE);
824 } 824 }
825 else { 825 else {
826 //maybe insert some .desktop file deletion code later 826 //maybe insert some .desktop file deletion code later
827 //maybe dir specific 827 //maybe dir specific
828 } 828 }
829 ++it; 829 ++it;
830 } 830 }
831 831
832 icons->sort(); 832 icons->sort();
833} 833}
834 834
835bool LauncherView::removeLink(const QString& linkfile) 835bool LauncherView::removeLink(const QString& linkfile)
836{ 836{
837 return icons->removeLink(linkfile); 837 return icons->removeLink(linkfile);
838} 838}
839 839
840void LauncherView::sort() 840void LauncherView::sort()
841{ 841{
842 icons->sort(); 842 icons->sort();
843} 843}
844 844
845void LauncherView::addItem(AppLnk* app, bool resort) 845void LauncherView::addItem(AppLnk* app, bool resort)
846{ 846{
847 icons->addItem(app,resort); 847 icons->addItem(app,resort);
848} 848}
849 849
850void LauncherView::setFileSystems(const QList<FileSystem> &) 850void LauncherView::setFileSystems(const QList<FileSystem> &)
851{ 851{
852 // ### does nothing now... 852 // ### does nothing now...
853} 853}
854 854
855void LauncherView::paletteChange( const QPalette &p ) 855void LauncherView::paletteChange( const QPalette &p )
856{ 856{
857 icons->unsetPalette(); 857 icons->unsetPalette();
858 QVBox::paletteChange( p ); 858 QVBox::paletteChange( p );
859 if ( bgType == Ruled ) 859 if ( bgType == Ruled )
860 setBackgroundType( Ruled, QString::null ); 860 setBackgroundType( Ruled, QString::null );
861 QColorGroup cg = icons->colorGroup(); 861 QColorGroup cg = icons->colorGroup();
862 cg.setColor( QColorGroup::Text, textCol ); 862 cg.setColor( QColorGroup::Text, textCol );
863 icons->setPalette( QPalette(cg,cg,cg) ); 863 icons->setPalette( QPalette(cg,cg,cg) );
864} 864}
865 865