summaryrefslogtreecommitdiff
path: root/core/launcher/launcherview.cpp
authorbipolar <bipolar>2002-03-09 03:09:15 (UTC)
committer bipolar <bipolar>2002-03-09 03:09:15 (UTC)
commitcb1d684a68565ff70fedd184eedf1ef4f2b71079 (patch) (unidiff)
tree51dc13c1eaa2408b6e753de751bcb7ac2d02f7e8 /core/launcher/launcherview.cpp
parentbc79d3f4a7503c4298a5396b80c65a3e268f4be3 (diff)
downloadopie-cb1d684a68565ff70fedd184eedf1ef4f2b71079.zip
opie-cb1d684a68565ff70fedd184eedf1ef4f2b71079.tar.gz
opie-cb1d684a68565ff70fedd184eedf1ef4f2b71079.tar.bz2
ljp: hopefully took care of doclnk creating zero size files, while maintaining what was going on.
Diffstat (limited to 'core/launcher/launcherview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/launcherview.cpp449
1 files changed, 223 insertions, 226 deletions
diff --git a/core/launcher/launcherview.cpp b/core/launcher/launcherview.cpp
index 764f088..538ad79 100644
--- a/core/launcher/launcherview.cpp
+++ b/core/launcher/launcherview.cpp
@@ -43,25 +43,25 @@
43class LauncherIconView : public QIconView { 43class LauncherIconView : public QIconView {
44public: 44public:
45 LauncherIconView( QWidget* parent, const char* name=0 ) : 45 LauncherIconView( QWidget* parent, const char* name=0 ) :
46 QIconView(parent,name), 46 QIconView(parent,name),
47 tf(""), 47 tf(""),
48 cf(0), 48 cf(0),
49 bsy(0) 49 bsy(0)
50 { 50 {
51 sortmeth = Name; 51 sortmeth = Name;
52 hidden.setAutoDelete(TRUE); 52 hidden.setAutoDelete(TRUE);
53 ike = FALSE; 53 ike = FALSE;
54 } 54 }
55 55
56 ~LauncherIconView() 56 ~LauncherIconView()
57 { 57 {
58#if 0 // debuggery 58#if 0 // debuggery
59 QListIterator<AppLnk> it(hidden); 59 QListIterator<AppLnk> it(hidden);
60 AppLnk* l; 60 AppLnk* l;
61 while ((l=it.current())) { 61 while ((l=it.current())) {
62 ++it; 62 ++it;
63 //qDebug("%p: hidden (should remove)",l); 63 //qDebug("%p: hidden (should remove)",l);
64 } 64 }
65#endif 65#endif
66 } 66 }
67 67
@@ -71,30 +71,30 @@ public:
71 71
72 void doAutoScroll() 72 void doAutoScroll()
73 { 73 {
74 // We don't want rubberbanding (yet) 74 // We don't want rubberbanding (yet)
75 } 75 }
76 76
77 void setBusy(bool on) 77 void setBusy(bool on)
78 { 78 {
79 QIconViewItem *c = on ? currentItem() : 0; 79 QIconViewItem *c = on ? currentItem() : 0;
80 if ( bsy != c ) { 80 if ( bsy != c ) {
81 QIconViewItem* o = bsy; 81 QIconViewItem* o = bsy;
82 bsy = c; 82 bsy = c;
83 if ( o ) o->repaint(); 83 if ( o ) o->repaint();
84 if ( c ) c->repaint(); 84 if ( c ) c->repaint();
85 } 85 }
86 } 86 }
87 87
88 bool inKeyEvent() const { return ike; } 88 bool inKeyEvent() const { return ike; }
89 void keyPressEvent(QKeyEvent* e) 89 void keyPressEvent(QKeyEvent* e)
90 { 90 {
91 ike = TRUE; 91 ike = TRUE;
92 if ( e->key() == Key_F33 ) { 92 if ( e->key() == Key_F33 ) {
93 // "OK" button 93 // "OK" button
94 returnPressed(currentItem()); 94 returnPressed(currentItem());
95 } 95 }
96 QIconView::keyPressEvent(e); 96 QIconView::keyPressEvent(e);
97 ike = FALSE; 97 ike = FALSE;
98 } 98 }
99 99
100 void addItem(AppLnk* app, bool resort=TRUE); 100 void addItem(AppLnk* app, bool resort=TRUE);
@@ -105,141 +105,141 @@ public:
105 105
106 void clear() 106 void clear()
107 { 107 {
108 mimes.clear(); 108 mimes.clear();
109 cats.clear(); 109 cats.clear();
110 QIconView::clear(); 110 QIconView::clear();
111 hidden.clear(); 111 hidden.clear();
112 } 112 }
113 113
114 void addCatsAndMimes(AppLnk* app) 114 void addCatsAndMimes(AppLnk* app)
115 { 115 {
116 // QStringList c = app->categories(); 116 // QStringList c = app->categories();
117 // for (QStringList::ConstIterator cit=c.begin(); cit!=c.end(); ++cit) { 117 // for (QStringList::ConstIterator cit=c.begin(); cit!=c.end(); ++cit) {
118 // cats.replace(*cit,(void*)1); 118 // cats.replace(*cit,(void*)1);
119 // } 119 // }
120 QString maj=app->type(); 120 QString maj=app->type();
121 int sl=maj.find('/'); 121 int sl=maj.find('/');
122 if (sl>=0) { 122 if (sl>=0) {
123 QString k = maj.left(sl); 123 QString k = maj.left(sl);
124 mimes.replace(k,(void*)1); 124 mimes.replace(k,(void*)1);
125 } 125 }
126 } 126 }
127 127
128 void drawBackground( QPainter *p, const QRect &r ) 128 void drawBackground( QPainter *p, const QRect &r )
129 { 129 {
130 Config config("qpe"); 130 Config config("qpe");
131 config.setGroup("Appearance"); 131 config.setGroup("Appearance");
132 QString backgroundImage = config.readEntry("BackgroundImage"); 132 QString backgroundImage = config.readEntry("BackgroundImage");
133 133
134 if (backgroundImage.isNull()) backgroundImage="qpe-background"; 134 if (backgroundImage.isNull()) backgroundImage="qpe-background";
135 int backgroundMode = QPixmap::defaultDepth() >= 12 ? 1 : 0; 135 int backgroundMode = QPixmap::defaultDepth() >= 12 ? 1 : 0;
136 //int backgroundMode = 2; 136 //int backgroundMode = 2;
137 137
138 if ( backgroundMode == 1 ) { 138 if ( backgroundMode == 1 ) {
139 139
140 // Double buffer the background 140 // Double buffer the background
141 static QPixmap *bg = NULL; 141 static QPixmap *bg = NULL;
142 static QColor bgColor; 142 static QColor bgColor;
143 143
144 if ( (bg == NULL) || (bgColor != colorGroup().button()) ) { 144 if ( (bg == NULL) || (bgColor != colorGroup().button()) ) {
145 // Create a new background double buffer 145 // Create a new background double buffer
146 if (bg == NULL) 146 if (bg == NULL)
147 bg = new QPixmap( width(), height() ); 147 bg = new QPixmap( width(), height() );
148 bgColor = colorGroup().button(); 148 bgColor = colorGroup().button();
149 QPainter painter( bg ); 149 QPainter painter( bg );
150 150
151 painter.fillRect( QRect( 0, 0, width(), height() ), colorGroup().background().light(110)); 151 painter.fillRect( QRect( 0, 0, width(), height() ), colorGroup().background().light(110));
152 // Overlay the Qtopia logo in the center 152 // Overlay the Qtopia logo in the center
153 QImage logo; 153 QImage logo;
154 if (QFile::exists(backgroundImage)) { 154 if (QFile::exists(backgroundImage)) {
155 logo = QImage(backgroundImage); 155 logo = QImage(backgroundImage);
156 } else { 156 } else {
157 logo = Resource::loadImage(backgroundImage ); 157 logo = Resource::loadImage(backgroundImage );
158 } 158 }
159 if ( !logo.isNull() ) 159 if ( !logo.isNull() )
160 painter.drawImage( (width() - logo.width()) / 2, 160 painter.drawImage( (width() - logo.width()) / 2,
161 (height() - logo.height()) / 2, logo ); 161 (height() - logo.height()) / 2, logo );
162 } 162 }
163 163
164 // Draw the double buffer to the widget (it is tiled for when the icon view is large) 164 // Draw the double buffer to the widget (it is tiled for when the icon view is large)
165 p->drawTiledPixmap( r, *bg, QPoint( (r.x() + contentsX()) % bg->width(), 165 p->drawTiledPixmap( r, *bg, QPoint( (r.x() + contentsX()) % bg->width(),
166 (r.y() + contentsY()) % bg->height() ) ); 166 (r.y() + contentsY()) % bg->height() ) );
167 } else if ( backgroundMode == 2 ) { 167 } else if ( backgroundMode == 2 ) {
168 static QPixmap *bg = 0; 168 static QPixmap *bg = 0;
169 static QColor bgColor; 169 static QColor bgColor;
170 if ( !bg || (bgColor != colorGroup().background()) ) { 170 if ( !bg || (bgColor != colorGroup().background()) ) {
171 bgColor = colorGroup().background(); 171 bgColor = colorGroup().background();
172 bg = new QPixmap( width(), 9 ); 172 bg = new QPixmap( width(), 9 );
173 QPainter painter( bg ); 173 QPainter painter( bg );
174 for ( int i = 0; i < 3; i++ ) { 174 for ( int i = 0; i < 3; i++ ) {
175 painter.setPen( colorGroup().background().light(130) ); 175 painter.setPen( colorGroup().background().light(130) );
176 painter.drawLine( 0, i*3, width()-1, i*3 ); 176 painter.drawLine( 0, i*3, width()-1, i*3 );
177 painter.drawLine( 0, i*3+1, width()-1, i*3+1 ); 177 painter.drawLine( 0, i*3+1, width()-1, i*3+1 );
178 painter.setPen( colorGroup().background().light(105) ); 178 painter.setPen( colorGroup().background().light(105) );
179 painter.drawLine( 0, i*3+2, width()-1, i*3+2 ); 179 painter.drawLine( 0, i*3+2, width()-1, i*3+2 );
180 } 180 }
181 } 181 }
182 p->drawTiledPixmap( r, *bg, QPoint( (r.x() + contentsX()) % bg->width(), 182 p->drawTiledPixmap( r, *bg, QPoint( (r.x() + contentsX()) % bg->width(),
183 (r.y() + contentsY()) % bg->height() ) ); 183 (r.y() + contentsY()) % bg->height() ) );
184 } else { 184 } else {
185 p->fillRect( r, QBrush( colorGroup().background().light(110) ) ); 185 p->fillRect( r, QBrush( colorGroup().background().light(110) ) );
186 } 186 }
187 } 187 }
188 188
189 void hideOrShowItems(bool resort); 189 void hideOrShowItems(bool resort);
190 190
191 void setTypeFilter(const QString& typefilter, bool resort) 191 void setTypeFilter(const QString& typefilter, bool resort)
192 { 192 {
193 tf = QRegExp(typefilter,FALSE,TRUE); 193 tf = QRegExp(typefilter,FALSE,TRUE);
194 hideOrShowItems(resort); 194 hideOrShowItems(resort);
195 } 195 }
196 196
197 void setCategoryFilter( int catfilter, bool resort ) 197 void setCategoryFilter( int catfilter, bool resort )
198 { 198 {
199 Categories cat; 199 Categories cat;
200 cat.load( categoryFileName() ); 200 cat.load( categoryFileName() );
201 QString str; 201 QString str;
202 if ( catfilter == -2 ) 202 if ( catfilter == -2 )
203 cf = 0; 203 cf = 0;
204 else 204 else
205 cf = catfilter; 205 cf = catfilter;
206 hideOrShowItems(resort); 206 hideOrShowItems(resort);
207 } 207 }
208 208
209 enum SortMethod { Name, Date, Type }; 209 enum SortMethod { Name, Date, Type };
210 210
211 void setSortMethod( SortMethod m ) 211 void setSortMethod( SortMethod m )
212 { 212 {
213 if ( sortmeth != m ) { 213 if ( sortmeth != m ) {
214 sortmeth = m; 214 sortmeth = m;
215 sort(); 215 sort();
216 } 216 }
217 } 217 }
218 218
219 int compare(const AppLnk* a, const AppLnk* b) 219 int compare(const AppLnk* a, const AppLnk* b)
220 { 220 {
221 switch (sortmeth) { 221 switch (sortmeth) {
222 case Name: 222 case Name:
223 return a->name().compare(b->name()); 223 return a->name().compare(b->name());
224 case Date: { 224 case Date: {
225 QFileInfo fa(a->linkFileKnown() ? a->linkFile() : a->file()); 225 QFileInfo fa(a->linkFileKnown() ? a->linkFile() : a->file());
226 QFileInfo fb(b->linkFileKnown() ? b->linkFile() : b->file()); 226 QFileInfo fb(b->linkFileKnown() ? b->linkFile() : b->file());
227 return fa.lastModified().secsTo(fb.lastModified()); 227 return fa.lastModified().secsTo(fb.lastModified());
228 } 228 }
229 case Type: 229 case Type:
230 return a->type().compare(b->type()); 230 return a->type().compare(b->type());
231 } 231 }
232 return 0; 232 return 0;
233 } 233 }
234 234
235protected: 235protected:
236 236
237 void styleChange( QStyle &old ) 237 void styleChange( QStyle &old )
238 { 238 {
239 QIconView::styleChange( old ); 239 QIconView::styleChange( old );
240 //### duplicated code from LauncherView constructor 240 //### duplicated code from LauncherView constructor
241 int dw = QApplication::desktop()->width(); 241 int dw = QApplication::desktop()->width();
242 setGridX( (dw-13-style().scrollBarExtent().width())/3 ); // tweaked for 8pt+dw=176 and 10pt+dw=240 242 setGridX( (dw-13-style().scrollBarExtent().width())/3 ); // tweaked for 8pt+dw=176 and 10pt+dw=240
243 } 243 }
244 244
245private: 245private:
@@ -268,10 +268,10 @@ public:
268 LauncherItem( QIconView *parent, AppLnk* applnk ); 268 LauncherItem( QIconView *parent, AppLnk* applnk );
269 ~LauncherItem() 269 ~LauncherItem()
270 { 270 {
271 LauncherIconView* liv = (LauncherIconView*)iconView(); 271 LauncherIconView* liv = (LauncherIconView*)iconView();
272 if ( liv->busyItem() == this ) 272 if ( liv->busyItem() == this )
273 liv->setBusy(FALSE); 273 liv->setBusy(FALSE);
274 delete app; 274 delete app;
275 } 275 }
276 276
277 AppLnk* appLnk() const { return app; } 277 AppLnk* appLnk() const { return app; }
@@ -281,22 +281,22 @@ public:
281 281
282 void paintItem( QPainter *p, const QColorGroup &cg ) 282 void paintItem( QPainter *p, const QColorGroup &cg )
283 { 283 {
284 LauncherIconView* liv = (LauncherIconView*)iconView(); 284 LauncherIconView* liv = (LauncherIconView*)iconView();
285 QBrush oldBrush( liv->itemTextBackground() ); 285 QBrush oldBrush( liv->itemTextBackground() );
286 QColorGroup mycg( cg ); 286 QColorGroup mycg( cg );
287 if ( liv->currentItem() == this ) { 287 if ( liv->currentItem() == this ) {
288 liv->setItemTextBackground( cg.brush( QColorGroup::Highlight ) ); 288 liv->setItemTextBackground( cg.brush( QColorGroup::Highlight ) );
289 mycg.setColor( QColorGroup::Text, cg.color( QColorGroup::HighlightedText ) ); 289 mycg.setColor( QColorGroup::Text, cg.color( QColorGroup::HighlightedText ) );
290 } 290 }
291 QIconViewItem::paintItem(p,mycg); 291 QIconViewItem::paintItem(p,mycg);
292 if ( liv->currentItem() == this ) 292 if ( liv->currentItem() == this )
293 liv->setItemTextBackground( oldBrush ); 293 liv->setItemTextBackground( oldBrush );
294 if ( liv->busyItem() == this ) { 294 if ( liv->busyItem() == this ) {
295 static QPixmap* busypm=0; 295 static QPixmap* busypm=0;
296 if ( !busypm ) 296 if ( !busypm )
297 busypm = new QPixmap(Resource::loadPixmap("launching")); 297 busypm = new QPixmap(Resource::loadPixmap("launching"));
298 p->drawPixmap(x()+(width()-busypm->width())/2, y(),*busypm); 298 p->drawPixmap(x()+(width()-busypm->width())/2, y(),*busypm);
299 } 299 }
300 } 300 }
301 301
302protected: 302protected:
@@ -306,7 +306,7 @@ protected:
306 306
307LauncherItem::LauncherItem( QIconView *parent, AppLnk *applnk ) 307LauncherItem::LauncherItem( QIconView *parent, AppLnk *applnk )
308 : QIconViewItem( parent, applnk->name(), applnk->bigPixmap() ), 308 : QIconViewItem( parent, applnk->name(), applnk->bigPixmap() ),
309 app(applnk) // Takes ownership 309 app(applnk) // Takes ownership
310{ 310{
311} 311}
312 312
@@ -321,8 +321,8 @@ QStringList LauncherIconView::mimeTypes() const
321 QStringList r; 321 QStringList r;
322 QDictIterator<void> it(mimes); 322 QDictIterator<void> it(mimes);
323 while (it.current()) { 323 while (it.current()) {
324 r.append(it.currentKey()); 324 r.append(it.currentKey());
325 ++it; 325 ++it;
326 } 326 }
327 r.sort(); 327 r.sort();
328 return r; 328 return r;
@@ -333,13 +333,13 @@ void LauncherIconView::addItem(AppLnk* app, bool resort)
333 addCatsAndMimes(app); 333 addCatsAndMimes(app);
334 334
335 if ( (tf.isEmpty() || tf.match(app->type()) >= 0) 335 if ( (tf.isEmpty() || tf.match(app->type()) >= 0)
336 && (cf == 0 || app->categories().contains(cf) 336 && (cf == 0 || app->categories().contains(cf)
337 || cf == -1 && app->categories().count() == 0 ) ) 337 || cf == -1 && app->categories().count() == 0 ) )
338 (void) new LauncherItem( this, app ); 338 (void) new LauncherItem( this, app );
339 else 339 else
340 hidden.append(app); 340 hidden.append(app);
341 if ( resort ) 341 if ( resort )
342 sort(); 342 sort();
343} 343}
344 344
345void LauncherIconView::updateCategoriesAndMimeTypes() 345void LauncherIconView::updateCategoriesAndMimeTypes()
@@ -348,14 +348,14 @@ void LauncherIconView::updateCategoriesAndMimeTypes()
348 cats.clear(); 348 cats.clear();
349 LauncherItem* item = (LauncherItem*)firstItem(); 349 LauncherItem* item = (LauncherItem*)firstItem();
350 while (item) { 350 while (item) {
351 addCatsAndMimes(item->appLnk()); 351 addCatsAndMimes(item->appLnk());
352 item = (LauncherItem*)item->nextItem(); 352 item = (LauncherItem*)item->nextItem();
353 } 353 }
354 QListIterator<AppLnk> it(hidden); 354 QListIterator<AppLnk> it(hidden);
355 AppLnk* l; 355 AppLnk* l;
356 while ((l=it.current())) { 356 while ((l=it.current())) {
357 addCatsAndMimes(l); 357 addCatsAndMimes(l);
358 ++it; 358 ++it;
359 } 359 }
360} 360}
361 361
@@ -367,8 +367,8 @@ void LauncherIconView::hideOrShowItems(bool resort)
367 hidden.setAutoDelete(TRUE); 367 hidden.setAutoDelete(TRUE);
368 LauncherItem* item = (LauncherItem*)firstItem(); 368 LauncherItem* item = (LauncherItem*)firstItem();
369 while (item) { 369 while (item) {
370 links.append(item->takeAppLnk()); 370 links.append(item->takeAppLnk());
371 item = (LauncherItem*)item->nextItem(); 371 item = (LauncherItem*)item->nextItem();
372 } 372 }
373 bool oldAutoArrange = autoArrange(); 373 bool oldAutoArrange = autoArrange();
374 setAutoArrange( FALSE ); 374 setAutoArrange( FALSE );
@@ -376,11 +376,11 @@ void LauncherIconView::hideOrShowItems(bool resort)
376 QListIterator<AppLnk> it(links); 376 QListIterator<AppLnk> it(links);
377 AppLnk* l; 377 AppLnk* l;
378 while ((l=it.current())) { 378 while ((l=it.current())) {
379 addItem(l,FALSE); 379 addItem(l,FALSE);
380 ++it; 380 ++it;
381 } 381 }
382 if ( resort ) 382 if ( resort )
383 sort(); 383 sort();
384 setAutoArrange( oldAutoArrange ); 384 setAutoArrange( oldAutoArrange );
385} 385}
386 386
@@ -391,23 +391,20 @@ bool LauncherIconView::removeLink(const QString& linkfile)
391 bool did = FALSE; 391 bool did = FALSE;
392 DocLnk dl(linkfile); 392 DocLnk dl(linkfile);
393 while (item) { 393 while (item) {
394 l = item->appLnk(); 394 l = item->appLnk();
395 if ( l->linkFileKnown() && l->linkFile() == linkfile || l->file() == linkfile 395 if ( l->linkFileKnown() && l->linkFile() == linkfile/* || l->file() == linkfile || dl.isValid() && dl.file() == l->file()*/ ) {
396 || dl.isValid() && dl.file() == l->file() ) { 396 delete item;
397 delete item; 397 did = TRUE;
398 did = TRUE; 398 }
399 } 399 item = (LauncherItem*)item->nextItem();
400 item = (LauncherItem*)item->nextItem();
401 } 400 }
402 QListIterator<AppLnk> it(hidden); 401 QListIterator<AppLnk> it(hidden);
403 while ((l=it.current())) { 402 while ((l=it.current())) {
404 ++it; 403 ++it;
405 if ( l->linkFileKnown() && l->linkFile() == linkfile 404 if ( l->linkFileKnown() && l->linkFile() == linkfile/* || l->file() == linkfile || dl.isValid() && dl.file() == l->file()*/ ) {
406 || l->file() == linkfile 405 hidden.removeRef(l);
407 || dl.isValid() && dl.file() == l->file() ) { 406 did = TRUE;
408 hidden.removeRef(l); 407 }
409 did = TRUE;
410 }
411 } 408 }
412 return did; 409 return did;
413} 410}
@@ -432,13 +429,13 @@ LauncherView::LauncherView( QWidget* parent, const char* name, WFlags fl )
432 icons->setBackgroundMode( PaletteBase ); 429 icons->setBackgroundMode( PaletteBase );
433 430
434 connect( icons, SIGNAL(mouseButtonClicked(int, QIconViewItem *, const QPoint&)), 431 connect( icons, SIGNAL(mouseButtonClicked(int, QIconViewItem *, const QPoint&)),
435 SLOT(itemClicked(int, QIconViewItem *)) ); 432 SLOT(itemClicked(int, QIconViewItem *)) );
436 connect( icons, SIGNAL(selectionChanged()), 433 connect( icons, SIGNAL(selectionChanged()),
437 SLOT(selectionChanged()) ); 434 SLOT(selectionChanged()) );
438 connect( icons, SIGNAL(returnPressed(QIconViewItem *)), 435 connect( icons, SIGNAL(returnPressed(QIconViewItem *)),
439 SLOT(returnPressed(QIconViewItem *)) ); 436 SLOT(returnPressed(QIconViewItem *)) );
440 connect( icons, SIGNAL(mouseButtonPressed(int, QIconViewItem *, const QPoint&)), 437 connect( icons, SIGNAL(mouseButtonPressed(int, QIconViewItem *, const QPoint&)),
441 SLOT(itemPressed(int, QIconViewItem *)) ); 438 SLOT(itemPressed(int, QIconViewItem *)) );
442 439
443 tools = 0; 440 tools = 0;
444} 441}
@@ -450,33 +447,33 @@ LauncherView::~LauncherView()
450void LauncherView::setToolsEnabled(bool y) 447void LauncherView::setToolsEnabled(bool y)
451{ 448{
452 if ( !y != !tools ) { 449 if ( !y != !tools ) {
453 if ( y ) { 450 if ( y ) {
454 tools = new QHBox(this); 451 tools = new QHBox(this);
455 452
456 // Type filter 453 // Type filter
457 typemb = new MenuButton(tools); 454 typemb = new MenuButton(tools);
458 typemb->setLabel(tr("Type: %1")); 455 typemb->setLabel(tr("Type: %1"));
459 typemb->setFixedHeight ( 20 ); 456 typemb->setFixedHeight ( 20 );
460 457
461 // Category filter 458 // Category filter
462 catmb = new CategorySelect(tools); 459 catmb = new CategorySelect(tools);
463 catmb->setFixedHeight ( 20 ); 460 catmb->setFixedHeight ( 20 );
464 461
465 updateTools(); 462 updateTools();
466 tools->show(); 463 tools->show();
467 } else { 464 } else {
468 delete tools; 465 delete tools;
469 tools = 0; 466 tools = 0;
470 } 467 }
471 } 468 }
472} 469}
473 470
474void LauncherView::updateTools() 471void LauncherView::updateTools()
475{ 472{
476 disconnect( typemb, SIGNAL(selected(const QString&)), 473 disconnect( typemb, SIGNAL(selected(const QString&)),
477 this, SLOT(showType(const QString&)) ); 474 this, SLOT(showType(const QString&)) );
478 disconnect( catmb, SIGNAL(signalSelected(int)), 475 disconnect( catmb, SIGNAL(signalSelected(int)),
479 this, SLOT(showCategory(int)) ); 476 this, SLOT(showCategory(int)) );
480 477
481 icons->updateCategoriesAndMimeTypes(); 478 icons->updateCategoriesAndMimeTypes();
482 479
@@ -511,9 +508,9 @@ void LauncherView::sortBy(int s)
511void LauncherView::showType(const QString& t) 508void LauncherView::showType(const QString& t)
512{ 509{
513 if ( t == tr("All") ) { 510 if ( t == tr("All") ) {
514 icons->setTypeFilter("",TRUE); 511 icons->setTypeFilter("",TRUE);
515 } else { 512 } else {
516 icons->setTypeFilter(t+"/*",TRUE); 513 icons->setTypeFilter(t+"/*",TRUE);
517 } 514 }
518} 515}
519 516
@@ -526,7 +523,7 @@ void LauncherView::resizeEvent(QResizeEvent *e)
526{ 523{
527 QVBox::resizeEvent( e ); 524 QVBox::resizeEvent( e );
528 if ( e->size().width() != e->oldSize().width() ) 525 if ( e->size().width() != e->oldSize().width() )
529 sort(); 526 sort();
530} 527}
531 528
532void LauncherView::populate( AppLnkSet *folder, const QString& typefilter ) 529void LauncherView::populate( AppLnkSet *folder, const QString& typefilter )
@@ -539,45 +536,45 @@ void LauncherView::selectionChanged()
539{ 536{
540 QIconViewItem* item = icons->currentItem(); 537 QIconViewItem* item = icons->currentItem();
541 if ( item && item->isSelected() ) { 538 if ( item && item->isSelected() ) {
542 AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); 539 AppLnk *appLnk = ((LauncherItem *)item)->appLnk();
543 if ( icons->inKeyEvent() ) // not for mouse press 540 if ( icons->inKeyEvent() ) // not for mouse press
544 emit clicked( appLnk ); 541 emit clicked( appLnk );
545 item->setSelected(FALSE); 542 item->setSelected(FALSE);
546 } 543 }
547} 544}
548 545
549void LauncherView::returnPressed( QIconViewItem *item ) 546void LauncherView::returnPressed( QIconViewItem *item )
550{ 547{
551 if ( item ) { 548 if ( item ) {
552 AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); 549 AppLnk *appLnk = ((LauncherItem *)item)->appLnk();
553 emit clicked( appLnk ); 550 emit clicked( appLnk );
554 } 551 }
555} 552}
556 553
557void LauncherView::itemClicked( int btn, QIconViewItem *item ) 554void LauncherView::itemClicked( int btn, QIconViewItem *item )
558{ 555{
559 if ( item ) { 556 if ( item ) {
560 AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); 557 AppLnk *appLnk = ((LauncherItem *)item)->appLnk();
561 if ( btn == LeftButton ) { 558 if ( btn == LeftButton ) {
562 // Make sure it's the item we execute that gets highlighted 559 // Make sure it's the item we execute that gets highlighted
563 icons->setCurrentItem( item ); 560 icons->setCurrentItem( item );
564 emit clicked( appLnk ); 561 emit clicked( appLnk );
565 } 562 }
566 item->setSelected(FALSE); 563 item->setSelected(FALSE);
567 } 564 }
568} 565}
569 566
570void LauncherView::itemPressed( int btn, QIconViewItem *item ) 567void LauncherView::itemPressed( int btn, QIconViewItem *item )
571{ 568{
572 if ( item ) { 569 if ( item ) {
573 AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); 570 AppLnk *appLnk = ((LauncherItem *)item)->appLnk();
574 if ( btn == RightButton ) 571 if ( btn == RightButton )
575 emit rightPressed( appLnk ); 572 emit rightPressed( appLnk );
576/* 573/*
577 else if ( btn == LeftButton ) 574 else if ( btn == LeftButton )
578 emit clicked( appLnk ); 575 emit clicked( appLnk );
579*/ 576*/
580 item->setSelected(FALSE); 577 item->setSelected(FALSE);
581 } 578 }
582} 579}
583 580
@@ -589,15 +586,15 @@ void LauncherView::internalPopulate( AppLnkSet *folder, const QString& typefilte
589 while ( it.current() ) { 586 while ( it.current() ) {
590 // show only the icons for existing files 587 // show only the icons for existing files
591 if (!QFile(it.current()->file()).exists() ) 588 if (!QFile(it.current()->file()).exists() )
592 { 589 {
593 //maybe insert some .desktop file deletion code later 590 //maybe insert some .desktop file deletion code later
594 //maybe dir specific 591 //maybe dir specific
595 } 592 }
596 else 593 else
597 { 594 {
598 icons->addItem(*it,FALSE); 595 icons->addItem(*it,FALSE);
599 } 596 }
600 ++it; 597 ++it;
601 } 598 }
602 599
603 icons->sort(); 600 icons->sort();