summaryrefslogtreecommitdiff
path: root/core/launcher/launcherview.cpp
Unidiff
Diffstat (limited to 'core/launcher/launcherview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/launcherview.cpp27
1 files changed, 17 insertions, 10 deletions
diff --git a/core/launcher/launcherview.cpp b/core/launcher/launcherview.cpp
index ed39720..e8741a2 100644
--- a/core/launcher/launcherview.cpp
+++ b/core/launcher/launcherview.cpp
@@ -191,52 +191,50 @@ public:
191 QString str; 191 QString str;
192 if ( catfilter == -2 ) 192 if ( catfilter == -2 )
193 cf = 0; 193 cf = 0;
194 else 194 else
195 cf = catfilter; 195 cf = catfilter;
196 hideOrShowItems(resort); 196 hideOrShowItems(resort);
197 } 197 }
198 198
199 enum SortMethod { Name, Date, Type }; 199 enum SortMethod { Name, Date, Type };
200 200
201 void setSortMethod( SortMethod m ) 201 void setSortMethod( SortMethod m )
202 { 202 {
203 if ( sortmeth != m ) { 203 if ( sortmeth != m ) {
204 sortmeth = m; 204 sortmeth = m;
205 sort(); 205 sort();
206 } 206 }
207 } 207 }
208 208
209 int compare(const AppLnk* a, const AppLnk* b) 209 int compare(const AppLnk* a, const AppLnk* b)
210 { 210 {
211 switch (sortmeth) { 211 switch (sortmeth) {
212 case Name: 212 case Name:
213 return a->name().compare(b->name()); 213 return a->name().compare(b->name());
214 case Date: { 214 case Date: {
215 QFileInfo fa(a->linkFile()); 215 QFileInfo fa(a->linkFileKnown() ? a->linkFile() : a->file());
216 if ( !fa.exists() ) fa.setFile(a->file()); 216 QFileInfo fb(b->linkFileKnown() ? b->linkFile() : b->file());
217 QFileInfo fb(b->linkFile());
218 if ( !fb.exists() ) fb.setFile(b->file());
219 return fa.lastModified().secsTo(fb.lastModified()); 217 return fa.lastModified().secsTo(fb.lastModified());
220 } 218 }
221 case Type: 219 case Type:
222 return a->type().compare(b->type()); 220 return a->type().compare(b->type());
223 } 221 }
224 return 0; 222 return 0;
225 } 223 }
226 224
227protected: 225protected:
228 226
229 void styleChange( QStyle &old ) 227 void styleChange( QStyle &old )
230 { 228 {
231 QIconView::styleChange( old ); 229 QIconView::styleChange( old );
232 //### duplicated code from LauncherView constructor 230 //### duplicated code from LauncherView constructor
233 int dw = QApplication::desktop()->width(); 231 int dw = QApplication::desktop()->width();
234 setGridX( (dw-13-style().scrollBarExtent().width())/3 ); // tweaked for 8pt+dw=176 and 10pt+dw=240 232 setGridX( (dw-13-style().scrollBarExtent().width())/3 ); // tweaked for 8pt+dw=176 and 10pt+dw=240
235 } 233 }
236 234
237private: 235private:
238 QList<AppLnk> hidden; 236 QList<AppLnk> hidden;
239 QDict<void> mimes; 237 QDict<void> mimes;
240 QDict<void> cats; 238 QDict<void> cats;
241 SortMethod sortmeth; 239 SortMethod sortmeth;
242 QRegExp tf; 240 QRegExp tf;
@@ -341,79 +339,88 @@ void LauncherIconView::updateCategoriesAndMimeTypes()
341 LauncherItem* item = (LauncherItem*)firstItem(); 339 LauncherItem* item = (LauncherItem*)firstItem();
342 while (item) { 340 while (item) {
343 addCatsAndMimes(item->appLnk()); 341 addCatsAndMimes(item->appLnk());
344 item = (LauncherItem*)item->nextItem(); 342 item = (LauncherItem*)item->nextItem();
345 } 343 }
346 QListIterator<AppLnk> it(hidden); 344 QListIterator<AppLnk> it(hidden);
347 AppLnk* l; 345 AppLnk* l;
348 while ((l=it.current())) { 346 while ((l=it.current())) {
349 addCatsAndMimes(l); 347 addCatsAndMimes(l);
350 ++it; 348 ++it;
351 } 349 }
352} 350}
353 351
354void LauncherIconView::hideOrShowItems(bool resort) 352void LauncherIconView::hideOrShowItems(bool resort)
355{ 353{
356 hidden.setAutoDelete(FALSE); 354 hidden.setAutoDelete(FALSE);
357 QList<AppLnk> links=hidden; 355 QList<AppLnk> links=hidden;
358 hidden.clear(); 356 hidden.clear();
359 hidden.setAutoDelete(TRUE); 357 hidden.setAutoDelete(TRUE);
360 LauncherItem* item = (LauncherItem*)firstItem(); 358 LauncherItem* item = (LauncherItem*)firstItem();
361 while (item) { 359 while (item) {
362 links.append(item->takeAppLnk()); 360 links.append(item->takeAppLnk());
363 item = (LauncherItem*)item->nextItem(); 361 item = (LauncherItem*)item->nextItem();
364 } 362 }
363 bool oldAutoArrange = autoArrange();
364 setAutoArrange( FALSE );
365 clear(); 365 clear();
366 QListIterator<AppLnk> it(links); 366 QListIterator<AppLnk> it(links);
367 AppLnk* l; 367 AppLnk* l;
368 while ((l=it.current())) { 368 while ((l=it.current())) {
369 addItem(l,FALSE); 369 addItem(l,FALSE);
370 ++it; 370 ++it;
371 } 371 }
372 if ( resort ) 372 if ( resort )
373 sort(); 373 sort();
374 setAutoArrange( oldAutoArrange );
374} 375}
375 376
376bool LauncherIconView::removeLink(const QString& linkfile) 377bool LauncherIconView::removeLink(const QString& linkfile)
377{ 378{
378 LauncherItem* item = (LauncherItem*)firstItem(); 379 LauncherItem* item = (LauncherItem*)firstItem();
380 AppLnk* l;
381 bool did = FALSE;
382 DocLnk dl(linkfile);
379 while (item) { 383 while (item) {
380 if ( item->appLnk()->linkFile() == linkfile ) { 384 l = item->appLnk();
385 if ( l->linkFileKnown() && l->linkFile() == linkfile || l->file() == linkfile
386 || dl.isValid() && dl.file() == l->file() ) {
381 delete item; 387 delete item;
382 return TRUE; 388 did = TRUE;
383 } 389 }
384 item = (LauncherItem*)item->nextItem(); 390 item = (LauncherItem*)item->nextItem();
385 } 391 }
386 QListIterator<AppLnk> it(hidden); 392 QListIterator<AppLnk> it(hidden);
387 AppLnk* l;
388 while ((l=it.current())) { 393 while ((l=it.current())) {
389 ++it; 394 ++it;
390 if ( l->linkFile() == linkfile ) { 395 if ( l->linkFileKnown() && l->linkFile() == linkfile
396 || l->file() == linkfile
397 || dl.isValid() && dl.file() == l->file() ) {
391 hidden.removeRef(l); 398 hidden.removeRef(l);
392 return TRUE; 399 did = TRUE;
393 } 400 }
394 } 401 }
395 return FALSE; 402 return did;
396} 403}
397 404
398LauncherView::LauncherView( QWidget* parent, const char* name, WFlags fl ) 405LauncherView::LauncherView( QWidget* parent, const char* name, WFlags fl )
399 : QVBox( parent, name, fl ) 406 : QVBox( parent, name, fl )
400{ 407{
401 icons = new LauncherIconView( this ); 408 icons = new LauncherIconView( this );
402 setFocusProxy(icons); 409 setFocusProxy(icons);
403 QPEApplication::setStylusOperation( icons->viewport(), QPEApplication::RightOnHold ); 410 QPEApplication::setStylusOperation( icons->viewport(), QPEApplication::RightOnHold );
404 411
405 int dw = QApplication::desktop()->width(); 412 int dw = QApplication::desktop()->width();
406 icons->setItemsMovable( FALSE ); 413 icons->setItemsMovable( FALSE );
407 icons->setAutoArrange( TRUE ); 414 icons->setAutoArrange( TRUE );
408 icons->setSorting( TRUE ); 415 icons->setSorting( TRUE );
409 icons->setGridX( (dw-13-style().scrollBarExtent().width())/3 ); // tweaked for 8pt+dw=176 and 10pt+dw=240 416 icons->setGridX( (dw-13-style().scrollBarExtent().width())/3 ); // tweaked for 8pt+dw=176 and 10pt+dw=240
410 icons->setGridY( fontMetrics().height()*2+24 ); 417 icons->setGridY( fontMetrics().height()*2+24 );
411 icons->setFrameStyle( QFrame::NoFrame ); 418 icons->setFrameStyle( QFrame::NoFrame );
412 icons->setSpacing( 4 ); 419 icons->setSpacing( 4 );
413 icons->setMargin( 0 ); 420 icons->setMargin( 0 );
414 icons->setSelectionMode( QIconView::Multi ); 421 icons->setSelectionMode( QIconView::Multi );
415 icons->setBackgroundMode( PaletteBase ); 422 icons->setBackgroundMode( PaletteBase );
416 423
417 connect( icons, SIGNAL(mouseButtonClicked(int, QIconViewItem *, const QPoint&)), 424 connect( icons, SIGNAL(mouseButtonClicked(int, QIconViewItem *, const QPoint&)),
418 SLOT(itemClicked(int, QIconViewItem *)) ); 425 SLOT(itemClicked(int, QIconViewItem *)) );
419 connect( icons, SIGNAL(selectionChanged()), 426 connect( icons, SIGNAL(selectionChanged()),