summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/launcherview.cpp23
-rw-r--r--core/launcher/launcherview.h2
2 files changed, 17 insertions, 8 deletions
diff --git a/core/launcher/launcherview.cpp b/core/launcher/launcherview.cpp
index 42704ba..72313e3 100644
--- a/core/launcher/launcherview.cpp
+++ b/core/launcher/launcherview.cpp
@@ -368,169 +368,176 @@ void LauncherIconView::setBusy(bool on)
368 busyPix.convertFromImage( Resource::loadImage( "busy" ).smoothScale( size * 16, size ) ); 368 busyPix.convertFromImage( Resource::loadImage( "busy" ).smoothScale( size * 16, size ) );
369 } 369 }
370#endif 370#endif
371 371
372 if ( on ) { 372 if ( on ) {
373 busyTimer = startTimer( 100 ); 373 busyTimer = startTimer( 100 );
374 } else { 374 } else {
375 if ( busyTimer ) { 375 if ( busyTimer ) {
376 killTimer( busyTimer ); 376 killTimer( busyTimer );
377 busyTimer = 0; 377 busyTimer = 0;
378 } 378 }
379 } 379 }
380 380
381 LauncherItem *c = on ? (LauncherItem*)currentItem() : 0; 381 LauncherItem *c = on ? (LauncherItem*)currentItem() : 0;
382 382
383 if ( bsy != c ) { 383 if ( bsy != c ) {
384 LauncherItem *oldBusy = bsy; 384 LauncherItem *oldBusy = bsy;
385 bsy = c; 385 bsy = c;
386 if ( oldBusy ) { 386 if ( oldBusy ) {
387 oldBusy->resetIcon(); 387 oldBusy->resetIcon();
388 } 388 }
389 if ( bsy ) { 389 if ( bsy ) {
390 bsy->setBusyIndicatorType( busyType ) ; 390 bsy->setBusyIndicatorType( busyType ) ;
391 bsy->animateIcon(); 391 bsy->animateIcon();
392 } 392 }
393 } 393 }
394} 394}
395 395
396void LauncherIconView::clear() 396void LauncherIconView::clear()
397{ 397{
398 mimes.clear(); 398 mimes.clear();
399 cats.clear(); 399 cats.clear();
400 QIconView::clear(); 400 QIconView::clear();
401 hidden.clear(); 401 hidden.clear();
402} 402}
403 403
404QStringList LauncherIconView::mimeTypes() const 404QStringList LauncherIconView::mimeTypes() const
405{ 405{
406 QStringList r; 406 QStringList r;
407 QDictIterator<void> it(mimes); 407 QDictIterator<void> it(mimes);
408 while (it.current()) { 408 while (it.current()) {
409 r.append(it.currentKey()); 409 r.append(it.currentKey());
410 ++it; 410 ++it;
411 } 411 }
412 r.sort(); 412 r.sort();
413 return r; 413 return r;
414} 414}
415 415
416LauncherItem*LauncherIconView::findDocItem(const QString&fname) 416LauncherItem*LauncherIconView::findDocItem(const QString&fname)
417{ 417{
418 LauncherItem* item = (LauncherItem*)firstItem(); 418 LauncherItem* item = (LauncherItem*)firstItem();
419 while (item) { 419 while (item) {
420 if (item->appLnk()->file()==fname) { 420 if (item->appLnk()->file()==fname) {
421 break; 421 break;
422 } 422 }
423 item = (LauncherItem*)item->nextItem(); 423 item = (LauncherItem*)item->nextItem();
424 } 424 }
425 return item; 425 return item;
426} 426}
427 427
428void LauncherIconView::setEyePixmap(const QPixmap&aPixmap,const QString&aFile,int width) 428void LauncherIconView::setEyePixmap(const QPixmap&aPixmap,const QString&aFile,int width)
429{ 429{
430 int s = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize(); 430 int s = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize();
431 if (s!=width) return; 431 if (s!=width) return;
432 LauncherItem*item = findDocItem(aFile); 432 LauncherItem*item = 0;
433 QMap<QString,LauncherItem*>::Iterator it;
434 if ( ( it = m_itemCache.find(aFile))!=m_itemCache.end()) {
435 item = it.data();
436 m_itemCache.remove(it);
437 } else {
438 item = findDocItem(aFile);
439 }
433 if (!item||!item->isEyeImage()) return; 440 if (!item||!item->isEyeImage()) return;
434 item->setEyePixmap(aPixmap); 441 item->setEyePixmap(aPixmap);
435} 442}
436 443
437void LauncherIconView::checkCallback() 444void LauncherIconView::checkCallback()
438{ 445{
439 if (m_EyeCallBack) { 446 if (!m_EyeCallBack) {
440 return; 447 m_EyeCallBack = new LauncherThumbReceiver();
448 connect(m_EyeCallBack,SIGNAL(sig_Thumbnail(const QPixmap&,const QString&,int)),
449 this,SLOT(setEyePixmap(const QPixmap&,const QString&,int)));
450 m_eyeTimer.changeInterval(600000);
441 } 451 }
442 m_EyeCallBack = new LauncherThumbReceiver();
443 connect(m_EyeCallBack,SIGNAL(sig_Thumbnail(const QPixmap&,const QString&,int)),
444 this,SLOT(setEyePixmap(const QPixmap&,const QString&,int)));
445} 452}
446 453
447void LauncherIconView::addCheckItem(AppLnk* app) 454void LauncherIconView::addCheckItem(AppLnk* app)
448{ 455{
449 LauncherItem*item = new LauncherItem( this, app, bigIcns ); 456 LauncherItem*item = new LauncherItem( this, app, bigIcns );
450 if (item->isEyeImage()) { 457 if (item->isEyeImage()) {
451 checkCallback(); 458 checkCallback();
452 } 459 }
453} 460}
454 461
455void LauncherIconView::requestEyePix(const LauncherItem*item) 462void LauncherIconView::requestEyePix(const LauncherItem*item)
456{ 463{
457 if (!item) return; 464 if (!item) return;
458 if (item->isEyeImage()) { 465 if (item->isEyeImage()) {
459 m_eyeTimer.changeInterval(600000);
460 checkCallback(); 466 checkCallback();
461 int s = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize(); 467 int s = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize();
468 m_itemCache[item->appLnk()->file()]=(LauncherItem*)item;
462 m_EyeCallBack->requestThumb(item->appLnk()->file(),s,s); 469 m_EyeCallBack->requestThumb(item->appLnk()->file(),s,s);
463 } 470 }
464} 471}
465 472
466void LauncherIconView::stopEyeTimer() 473void LauncherIconView::stopEyeTimer()
467{ 474{
468 odebug << "Launcherview: delete opie-eye handle" << oendl;
469 if (m_EyeCallBack) { 475 if (m_EyeCallBack) {
470 delete m_EyeCallBack; 476 delete m_EyeCallBack;
471 m_EyeCallBack=0; 477 m_EyeCallBack=0;
472 } 478 }
479 m_itemCache.clear();
473 m_eyeTimer.stop(); 480 m_eyeTimer.stop();
474} 481}
475 482
476void LauncherIconView::addItem(AppLnk* app, bool resort) 483void LauncherIconView::addItem(AppLnk* app, bool resort)
477{ 484{
478 addCatsAndMimes(app); 485 addCatsAndMimes(app);
479 if ( (tf.isEmpty() || tf.match(app->type()) >= 0) 486 if ( (tf.isEmpty() || tf.match(app->type()) >= 0)
480 && (cf == 0 || app->categories().contains(cf) 487 && (cf == 0 || app->categories().contains(cf)
481 || cf == -1 && app->categories().count() == 0 ) ) { 488 || cf == -1 && app->categories().count() == 0 ) ) {
482 addCheckItem(app); 489 addCheckItem(app);
483 } else { 490 } else {
484 hidden.append(app); 491 hidden.append(app);
485 } 492 }
486 if ( resort ){ 493 if ( resort ){
487 sort(); 494 sort();
488 } 495 }
489} 496}
490 497
491void LauncherIconView::updateCategoriesAndMimeTypes() 498void LauncherIconView::updateCategoriesAndMimeTypes()
492{ 499{
493 mimes.clear(); 500 mimes.clear();
494 cats.clear(); 501 cats.clear();
495 LauncherItem* item = (LauncherItem*)firstItem(); 502 LauncherItem* item = (LauncherItem*)firstItem();
496 while (item) { 503 while (item) {
497 addCatsAndMimes(item->appLnk()); 504 addCatsAndMimes(item->appLnk());
498 item = (LauncherItem*)item->nextItem(); 505 item = (LauncherItem*)item->nextItem();
499 } 506 }
500 QListIterator<AppLnk> it(hidden); 507 QListIterator<AppLnk> it(hidden);
501 AppLnk* l; 508 AppLnk* l;
502 while ((l=it.current())) { 509 while ((l=it.current())) {
503 addCatsAndMimes(l); 510 addCatsAndMimes(l);
504 ++it; 511 ++it;
505 } 512 }
506} 513}
507 514
508void LauncherIconView::hideOrShowItems(bool resort) 515void LauncherIconView::hideOrShowItems(bool resort)
509{ 516{
510 viewport()->setUpdatesEnabled( FALSE ); 517 viewport()->setUpdatesEnabled( FALSE );
511 hidden.setAutoDelete(FALSE); 518 hidden.setAutoDelete(FALSE);
512 QList<AppLnk> links=hidden; 519 QList<AppLnk> links=hidden;
513 hidden.clear(); 520 hidden.clear();
514 hidden.setAutoDelete(TRUE); 521 hidden.setAutoDelete(TRUE);
515 LauncherItem* item = (LauncherItem*)firstItem(); 522 LauncherItem* item = (LauncherItem*)firstItem();
516 while (item) { 523 while (item) {
517 links.append(item->takeAppLnk()); 524 links.append(item->takeAppLnk());
518 item = (LauncherItem*)item->nextItem(); 525 item = (LauncherItem*)item->nextItem();
519 } 526 }
520 clear(); 527 clear();
521 QListIterator<AppLnk> it(links); 528 QListIterator<AppLnk> it(links);
522 AppLnk* l; 529 AppLnk* l;
523 while ((l=it.current())) { 530 while ((l=it.current())) {
524 addItem(l,FALSE); 531 addItem(l,FALSE);
525 ++it; 532 ++it;
526 } 533 }
527 if ( resort && !autoArrange() ) 534 if ( resort && !autoArrange() )
528 sort(); 535 sort();
529 viewport()->setUpdatesEnabled( TRUE ); 536 viewport()->setUpdatesEnabled( TRUE );
530} 537}
531 538
532bool LauncherIconView::removeLink(const QString& linkfile) 539bool LauncherIconView::removeLink(const QString& linkfile)
533{ 540{
534 LauncherItem* item = (LauncherItem*)firstItem(); 541 LauncherItem* item = (LauncherItem*)firstItem();
535 AppLnk* l; 542 AppLnk* l;
536 bool did = FALSE; 543 bool did = FALSE;
diff --git a/core/launcher/launcherview.h b/core/launcher/launcherview.h
index ebb1362..94c367c 100644
--- a/core/launcher/launcherview.h
+++ b/core/launcher/launcherview.h
@@ -1,92 +1,93 @@
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 30
30class CategorySelect; 31class CategorySelect;
31class LauncherIconView; 32class LauncherIconView;
32class LauncherItem; 33class LauncherItem;
33class QIconViewItem; 34class QIconViewItem;
34class QLabel; 35class QLabel;
35class QWidgetStack; 36class QWidgetStack;
36class MenuButton; 37class MenuButton;
37class QComboBox; 38class QComboBox;
38 39
39 40
40 41
41enum BusyIndicatorType { 42enum BusyIndicatorType {
42 BIT_Normal = 0, 43 BIT_Normal = 0,
43 BIT_Animated 44 BIT_Animated
44}; 45};
45 46
46class LauncherView : public QVBox 47class LauncherView : public QVBox
47{ 48{
48 Q_OBJECT 49 Q_OBJECT
49 50
50public: 51public:
51 LauncherView( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); 52 LauncherView( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
52 ~LauncherView(); 53 ~LauncherView();
53 54
54 void hideIcons(); 55 void hideIcons();
55 56
56 bool removeLink(const QString& linkfile); 57 bool removeLink(const QString& linkfile);
57 void addItem(AppLnk* app, bool resort=TRUE); 58 void addItem(AppLnk* app, bool resort=TRUE);
58 void removeAllItems(); 59 void removeAllItems();
59 void setSortEnabled(bool); 60 void setSortEnabled(bool);
60 void setUpdatesEnabled(bool); 61 void setUpdatesEnabled(bool);
61 void sort(); 62 void sort();
62 63
63 void setToolsEnabled(bool); 64 void setToolsEnabled(bool);
64 void updateTools(); 65 void updateTools();
65 66
66 void setBusy(bool); 67 void setBusy(bool);
67 void setBusyIndicatorType( const QString& ); 68 void setBusyIndicatorType( const QString& );
68 69
69 enum ViewMode { Icon, List }; 70 enum ViewMode { Icon, List };
70 void setViewMode( ViewMode m ); 71 void setViewMode( ViewMode m );
71 ViewMode viewMode() const { return vmode; } 72 ViewMode viewMode() const { return vmode; }
72 73
73 enum BackgroundType { Ruled, SolidColor, Image }; 74 enum BackgroundType { Ruled, SolidColor, Image };
74 void setBackgroundType( BackgroundType t, const QString & ); 75 void setBackgroundType( BackgroundType t, const QString & );
75 BackgroundType backgroundType() const { return bgType; } 76 BackgroundType backgroundType() const { return bgType; }
76 77
77 void setTextColor( const QColor & ); 78 void setTextColor( const QColor & );
78 QColor textColor() const { return textCol; } 79 QColor textColor() const { return textCol; }
79 80
80 void setViewFont( const QFont & ); 81 void setViewFont( const QFont & );
81 void clearViewFont(); 82 void clearViewFont();
82 83
83 void relayout(void); 84 void relayout(void);
84 85
85signals: 86signals:
86 void clicked( const AppLnk * ); 87 void clicked( const AppLnk * );
87 void rightPressed( AppLnk * ); 88 void rightPressed( AppLnk * );
88 89
89protected slots: 90protected slots:
90 void selectionChanged(); 91 void selectionChanged();
91 void returnPressed( QIconViewItem *item ); 92 void returnPressed( QIconViewItem *item );
92 void itemClicked( int, QIconViewItem * ); 93 void itemClicked( int, QIconViewItem * );
@@ -178,67 +179,68 @@ public:
178 bool removeLink(const QString& linkfile); 179 bool removeLink(const QString& linkfile);
179 180
180 QStringList mimeTypes() const; 181 QStringList mimeTypes() const;
181 QStringList categories() const; 182 QStringList categories() const;
182 void clear(); 183 void clear();
183 void addCatsAndMimes(AppLnk* app); 184 void addCatsAndMimes(AppLnk* app);
184 185
185 void setBackgroundOrigin( QWidget::BackgroundOrigin ) {} 186 void setBackgroundOrigin( QWidget::BackgroundOrigin ) {}
186 187
187 void setBackgroundPixmap( const QPixmap &pm ) { 188 void setBackgroundPixmap( const QPixmap &pm ) {
188 bgPixmap = pm; 189 bgPixmap = pm;
189 } 190 }
190 191
191 void setBackgroundColor( const QColor &c ) { 192 void setBackgroundColor( const QColor &c ) {
192 bgColor = c; 193 bgColor = c;
193 } 194 }
194 195
195 void drawBackground( QPainter *p, const QRect &r ); 196 void drawBackground( QPainter *p, const QRect &r );
196 void setItemTextPos( ItemTextPos pos ); 197 void setItemTextPos( ItemTextPos pos );
197 void hideOrShowItems(bool resort); 198 void hideOrShowItems(bool resort);
198 199
199 void setTypeFilter(const QString& typefilter, bool resort); 200 void setTypeFilter(const QString& typefilter, bool resort);
200 void setCategoryFilter( int catfilter, bool resort ); 201 void setCategoryFilter( int catfilter, bool resort );
201 202
202 enum SortMethod { Name, Date, Type }; 203 enum SortMethod { Name, Date, Type };
203 204
204 void setSortMethod( SortMethod m ); 205 void setSortMethod( SortMethod m );
205 int compare(const AppLnk* a, const AppLnk* b); 206 int compare(const AppLnk* a, const AppLnk* b);
206 void requestEyePix(const LauncherItem*which); 207 void requestEyePix(const LauncherItem*which);
207 208
208protected: 209protected:
209 virtual void timerEvent( QTimerEvent *te ); 210 virtual void timerEvent( QTimerEvent *te );
210 void styleChange( QStyle &old ); 211 void styleChange( QStyle &old );
211 void calculateGrid( ItemTextPos pos ); 212 void calculateGrid( ItemTextPos pos );
212 void focusInEvent( QFocusEvent * ) {} 213 void focusInEvent( QFocusEvent * ) {}
213 void focusOutEvent( QFocusEvent * ) {} 214 void focusOutEvent( QFocusEvent * ) {}
214 LauncherItem*findDocItem(const QString&); 215 LauncherItem*findDocItem(const QString&);
215 void addCheckItem(AppLnk* app); 216 void addCheckItem(AppLnk* app);
216 void checkCallback(); 217 void checkCallback();
217 virtual void keyPressEvent(QKeyEvent* e); 218 virtual void keyPressEvent(QKeyEvent* e);
218 219
219protected slots: 220protected slots:
220 void setEyePixmap(const QPixmap&,const QString&,int width); 221 void setEyePixmap(const QPixmap&,const QString&,int width);
221 void stopEyeTimer(); 222 void stopEyeTimer();
222 223
223private: 224private:
224 QList<AppLnk> hidden; 225 QList<AppLnk> hidden;
225 QDict<void> mimes; 226 QDict<void> mimes;
226 QDict<void> cats; 227 QDict<void> cats;
227 SortMethod sortmeth; 228 SortMethod sortmeth;
228 QRegExp tf; 229 QRegExp tf;
229 int cf; 230 int cf;
230 LauncherItem* bsy; 231 LauncherItem* bsy;
231 int busyTimer; 232 int busyTimer;
232 bool ike; 233 bool ike;
233 bool bigIcns; 234 bool bigIcns;
234 QPixmap bgPixmap; 235 QPixmap bgPixmap;
235 QColor bgColor; 236 QColor bgColor;
236 LauncherThumbReceiver*m_EyeCallBack; 237 LauncherThumbReceiver*m_EyeCallBack;
237#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY 238#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY
238 QPixmap busyPix; 239 QPixmap busyPix;
239#endif 240#endif
240 BusyIndicatorType busyType; 241 BusyIndicatorType busyType;
241 QTimer m_eyeTimer; 242 QTimer m_eyeTimer;
243 QMap<QString,LauncherItem*> m_itemCache;
242}; 244};
243 245
244#endif // LAUNCHERVIEW_H 246#endif // LAUNCHERVIEW_H