summaryrefslogtreecommitdiff
authorharlekin <harlekin>2002-02-23 10:05:09 (UTC)
committer harlekin <harlekin>2002-02-23 10:05:09 (UTC)
commitcb8381a2969b3a51697ec2034a919fffa9a9c022 (patch) (unidiff)
tree5e6728d9e757c32884951bb3c2f9254f7ca057b7
parent30ff9056e2632ce4c3cd8b3d0fbf94dcd6b5dafb (diff)
downloadopie-cb8381a2969b3a51697ec2034a919fffa9a9c022.zip
opie-cb8381a2969b3a51697ec2034a919fffa9a9c022.tar.gz
opie-cb8381a2969b3a51697ec2034a919fffa9a9c022.tar.bz2
change to Documents tab, it now shows only existing files
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/launcherview.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/core/launcher/launcherview.cpp b/core/launcher/launcherview.cpp
index e8741a2..7b20fdc 100644
--- a/core/launcher/launcherview.cpp
+++ b/core/launcher/launcherview.cpp
@@ -322,282 +322,291 @@ void LauncherIconView::addItem(AppLnk* app, bool resort)
322{ 322{
323 addCatsAndMimes(app); 323 addCatsAndMimes(app);
324 324
325 if ( (tf.isEmpty() || tf.match(app->type()) >= 0) 325 if ( (tf.isEmpty() || tf.match(app->type()) >= 0)
326 && (cf == 0 || app->categories().contains(cf) 326 && (cf == 0 || app->categories().contains(cf)
327 || cf == -1 && app->categories().count() == 0 ) ) 327 || cf == -1 && app->categories().count() == 0 ) )
328 (void) new LauncherItem( this, app ); 328 (void) new LauncherItem( this, app );
329 else 329 else
330 hidden.append(app); 330 hidden.append(app);
331 if ( resort ) 331 if ( resort )
332 sort(); 332 sort();
333} 333}
334 334
335void LauncherIconView::updateCategoriesAndMimeTypes() 335void LauncherIconView::updateCategoriesAndMimeTypes()
336{ 336{
337 mimes.clear(); 337 mimes.clear();
338 cats.clear(); 338 cats.clear();
339 LauncherItem* item = (LauncherItem*)firstItem(); 339 LauncherItem* item = (LauncherItem*)firstItem();
340 while (item) { 340 while (item) {
341 addCatsAndMimes(item->appLnk()); 341 addCatsAndMimes(item->appLnk());
342 item = (LauncherItem*)item->nextItem(); 342 item = (LauncherItem*)item->nextItem();
343 } 343 }
344 QListIterator<AppLnk> it(hidden); 344 QListIterator<AppLnk> it(hidden);
345 AppLnk* l; 345 AppLnk* l;
346 while ((l=it.current())) { 346 while ((l=it.current())) {
347 addCatsAndMimes(l); 347 addCatsAndMimes(l);
348 ++it; 348 ++it;
349 } 349 }
350} 350}
351 351
352void LauncherIconView::hideOrShowItems(bool resort) 352void LauncherIconView::hideOrShowItems(bool resort)
353{ 353{
354 hidden.setAutoDelete(FALSE); 354 hidden.setAutoDelete(FALSE);
355 QList<AppLnk> links=hidden; 355 QList<AppLnk> links=hidden;
356 hidden.clear(); 356 hidden.clear();
357 hidden.setAutoDelete(TRUE); 357 hidden.setAutoDelete(TRUE);
358 LauncherItem* item = (LauncherItem*)firstItem(); 358 LauncherItem* item = (LauncherItem*)firstItem();
359 while (item) { 359 while (item) {
360 links.append(item->takeAppLnk()); 360 links.append(item->takeAppLnk());
361 item = (LauncherItem*)item->nextItem(); 361 item = (LauncherItem*)item->nextItem();
362 } 362 }
363 bool oldAutoArrange = autoArrange(); 363 bool oldAutoArrange = autoArrange();
364 setAutoArrange( FALSE ); 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 setAutoArrange( oldAutoArrange );
375} 375}
376 376
377bool LauncherIconView::removeLink(const QString& linkfile) 377bool LauncherIconView::removeLink(const QString& linkfile)
378{ 378{
379 LauncherItem* item = (LauncherItem*)firstItem(); 379 LauncherItem* item = (LauncherItem*)firstItem();
380 AppLnk* l; 380 AppLnk* l;
381 bool did = FALSE; 381 bool did = FALSE;
382 DocLnk dl(linkfile); 382 DocLnk dl(linkfile);
383 while (item) { 383 while (item) {
384 l = item->appLnk(); 384 l = item->appLnk();
385 if ( l->linkFileKnown() && l->linkFile() == linkfile || l->file() == linkfile 385 if ( l->linkFileKnown() && l->linkFile() == linkfile || l->file() == linkfile
386 || dl.isValid() && dl.file() == l->file() ) { 386 || dl.isValid() && dl.file() == l->file() ) {
387 delete item; 387 delete item;
388 did = TRUE; 388 did = TRUE;
389 } 389 }
390 item = (LauncherItem*)item->nextItem(); 390 item = (LauncherItem*)item->nextItem();
391 } 391 }
392 QListIterator<AppLnk> it(hidden); 392 QListIterator<AppLnk> it(hidden);
393 while ((l=it.current())) { 393 while ((l=it.current())) {
394 ++it; 394 ++it;
395 if ( l->linkFileKnown() && l->linkFile() == linkfile 395 if ( l->linkFileKnown() && l->linkFile() == linkfile
396 || l->file() == linkfile 396 || l->file() == linkfile
397 || dl.isValid() && dl.file() == l->file() ) { 397 || dl.isValid() && dl.file() == l->file() ) {
398 hidden.removeRef(l); 398 hidden.removeRef(l);
399 did = TRUE; 399 did = TRUE;
400 } 400 }
401 } 401 }
402 return did; 402 return did;
403} 403}
404 404
405LauncherView::LauncherView( QWidget* parent, const char* name, WFlags fl ) 405LauncherView::LauncherView( QWidget* parent, const char* name, WFlags fl )
406 : QVBox( parent, name, fl ) 406 : QVBox( parent, name, fl )
407{ 407{
408 icons = new LauncherIconView( this ); 408 icons = new LauncherIconView( this );
409 setFocusProxy(icons); 409 setFocusProxy(icons);
410 QPEApplication::setStylusOperation( icons->viewport(), QPEApplication::RightOnHold ); 410 QPEApplication::setStylusOperation( icons->viewport(), QPEApplication::RightOnHold );
411 411
412 int dw = QApplication::desktop()->width(); 412 int dw = QApplication::desktop()->width();
413 icons->setItemsMovable( FALSE ); 413 icons->setItemsMovable( FALSE );
414 icons->setAutoArrange( TRUE ); 414 icons->setAutoArrange( TRUE );
415 icons->setSorting( TRUE ); 415 icons->setSorting( TRUE );
416 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
417 icons->setGridY( fontMetrics().height()*2+24 ); 417 icons->setGridY( fontMetrics().height()*2+24 );
418 icons->setFrameStyle( QFrame::NoFrame ); 418 icons->setFrameStyle( QFrame::NoFrame );
419 icons->setSpacing( 4 ); 419 icons->setSpacing( 4 );
420 icons->setMargin( 0 ); 420 icons->setMargin( 0 );
421 icons->setSelectionMode( QIconView::Multi ); 421 icons->setSelectionMode( QIconView::Multi );
422 icons->setBackgroundMode( PaletteBase ); 422 icons->setBackgroundMode( PaletteBase );
423 423
424 connect( icons, SIGNAL(mouseButtonClicked(int, QIconViewItem *, const QPoint&)), 424 connect( icons, SIGNAL(mouseButtonClicked(int, QIconViewItem *, const QPoint&)),
425 SLOT(itemClicked(int, QIconViewItem *)) ); 425 SLOT(itemClicked(int, QIconViewItem *)) );
426 connect( icons, SIGNAL(selectionChanged()), 426 connect( icons, SIGNAL(selectionChanged()),
427 SLOT(selectionChanged()) ); 427 SLOT(selectionChanged()) );
428 connect( icons, SIGNAL(returnPressed(QIconViewItem *)), 428 connect( icons, SIGNAL(returnPressed(QIconViewItem *)),
429 SLOT(returnPressed(QIconViewItem *)) ); 429 SLOT(returnPressed(QIconViewItem *)) );
430 connect( icons, SIGNAL(mouseButtonPressed(int, QIconViewItem *, const QPoint&)), 430 connect( icons, SIGNAL(mouseButtonPressed(int, QIconViewItem *, const QPoint&)),
431 SLOT(itemPressed(int, QIconViewItem *)) ); 431 SLOT(itemPressed(int, QIconViewItem *)) );
432 432
433 tools = 0; 433 tools = 0;
434} 434}
435 435
436LauncherView::~LauncherView() 436LauncherView::~LauncherView()
437{ 437{
438} 438}
439 439
440void LauncherView::setToolsEnabled(bool y) 440void LauncherView::setToolsEnabled(bool y)
441{ 441{
442 if ( !y != !tools ) { 442 if ( !y != !tools ) {
443 if ( y ) { 443 if ( y ) {
444 tools = new QHBox(this); 444 tools = new QHBox(this);
445 445
446 // Type filter 446 // Type filter
447 typemb = new MenuButton(tools); 447 typemb = new MenuButton(tools);
448 typemb->setLabel(tr("Type: %1")); 448 typemb->setLabel(tr("Type: %1"));
449 449
450 // Category filter 450 // Category filter
451 catmb = new CategorySelect(tools); 451 catmb = new CategorySelect(tools);
452 452
453 updateTools(); 453 updateTools();
454 tools->show(); 454 tools->show();
455 } else { 455 } else {
456 delete tools; 456 delete tools;
457 tools = 0; 457 tools = 0;
458 } 458 }
459 } 459 }
460} 460}
461 461
462void LauncherView::updateTools() 462void LauncherView::updateTools()
463{ 463{
464 disconnect( typemb, SIGNAL(selected(const QString&)), 464 disconnect( typemb, SIGNAL(selected(const QString&)),
465 this, SLOT(showType(const QString&)) ); 465 this, SLOT(showType(const QString&)) );
466 disconnect( catmb, SIGNAL(signalSelected(int)), 466 disconnect( catmb, SIGNAL(signalSelected(int)),
467 this, SLOT(showCategory(int)) ); 467 this, SLOT(showCategory(int)) );
468 468
469 icons->updateCategoriesAndMimeTypes(); 469 icons->updateCategoriesAndMimeTypes();
470 470
471 QString prev; 471 QString prev;
472 472
473 // Type filter 473 // Type filter
474 QStringList types; 474 QStringList types;
475 types << tr("All"); 475 types << tr("All");
476 types << "--"; 476 types << "--";
477 types += icons->mimeTypes(); 477 types += icons->mimeTypes();
478 prev = typemb->currentText(); 478 prev = typemb->currentText();
479 typemb->clear(); 479 typemb->clear();
480 typemb->insertItems(types); 480 typemb->insertItems(types);
481 typemb->select(prev); 481 typemb->select(prev);
482 482
483 Categories cats( 0 ); 483 Categories cats( 0 );
484 cats.load( categoryFileName() ); 484 cats.load( categoryFileName() );
485 QArray<int> vl( 0 ); 485 QArray<int> vl( 0 );
486 catmb->setCategories( vl, "Document View", tr("Document View") ); 486 catmb->setCategories( vl, "Document View", tr("Document View") );
487 catmb->setRemoveCategoryEdit( TRUE ); 487 catmb->setRemoveCategoryEdit( TRUE );
488 catmb->setAllCategories( TRUE ); 488 catmb->setAllCategories( TRUE );
489 489
490 connect(typemb, SIGNAL(selected(const QString&)), this, SLOT(showType(const QString&))); 490 connect(typemb, SIGNAL(selected(const QString&)), this, SLOT(showType(const QString&)));
491 connect(catmb, SIGNAL(signalSelected(int)), this, SLOT(showCategory(int))); 491 connect(catmb, SIGNAL(signalSelected(int)), this, SLOT(showCategory(int)));
492} 492}
493 493
494void LauncherView::sortBy(int s) 494void LauncherView::sortBy(int s)
495{ 495{
496 icons->setSortMethod((LauncherIconView::SortMethod)s); 496 icons->setSortMethod((LauncherIconView::SortMethod)s);
497} 497}
498 498
499void LauncherView::showType(const QString& t) 499void LauncherView::showType(const QString& t)
500{ 500{
501 if ( t == tr("All") ) { 501 if ( t == tr("All") ) {
502 icons->setTypeFilter("",TRUE); 502 icons->setTypeFilter("",TRUE);
503 } else { 503 } else {
504 icons->setTypeFilter(t+"/*",TRUE); 504 icons->setTypeFilter(t+"/*",TRUE);
505 } 505 }
506} 506}
507 507
508void LauncherView::showCategory( int c ) 508void LauncherView::showCategory( int c )
509{ 509{
510 icons->setCategoryFilter( c, TRUE ); 510 icons->setCategoryFilter( c, TRUE );
511} 511}
512 512
513void LauncherView::resizeEvent(QResizeEvent *e) 513void LauncherView::resizeEvent(QResizeEvent *e)
514{ 514{
515 QVBox::resizeEvent( e ); 515 QVBox::resizeEvent( e );
516 if ( e->size().width() != e->oldSize().width() ) 516 if ( e->size().width() != e->oldSize().width() )
517 sort(); 517 sort();
518} 518}
519 519
520void LauncherView::populate( AppLnkSet *folder, const QString& typefilter ) 520void LauncherView::populate( AppLnkSet *folder, const QString& typefilter )
521{ 521{
522 icons->clear(); 522 icons->clear();
523 internalPopulate( folder, typefilter ); 523 internalPopulate( folder, typefilter );
524} 524}
525 525
526void LauncherView::selectionChanged() 526void LauncherView::selectionChanged()
527{ 527{
528 QIconViewItem* item = icons->currentItem(); 528 QIconViewItem* item = icons->currentItem();
529 if ( item && item->isSelected() ) { 529 if ( item && item->isSelected() ) {
530 AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); 530 AppLnk *appLnk = ((LauncherItem *)item)->appLnk();
531 if ( icons->inKeyEvent() ) // not for mouse press 531 if ( icons->inKeyEvent() ) // not for mouse press
532 emit clicked( appLnk ); 532 emit clicked( appLnk );
533 item->setSelected(FALSE); 533 item->setSelected(FALSE);
534 } 534 }
535} 535}
536 536
537void LauncherView::returnPressed( QIconViewItem *item ) 537void LauncherView::returnPressed( QIconViewItem *item )
538{ 538{
539 if ( item ) { 539 if ( item ) {
540 AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); 540 AppLnk *appLnk = ((LauncherItem *)item)->appLnk();
541 emit clicked( appLnk ); 541 emit clicked( appLnk );
542 } 542 }
543} 543}
544 544
545void LauncherView::itemClicked( int btn, QIconViewItem *item ) 545void LauncherView::itemClicked( int btn, QIconViewItem *item )
546{ 546{
547 if ( item ) { 547 if ( item ) {
548 AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); 548 AppLnk *appLnk = ((LauncherItem *)item)->appLnk();
549 if ( btn == LeftButton ) { 549 if ( btn == LeftButton ) {
550 // Make sure it's the item we execute that gets highlighted 550 // Make sure it's the item we execute that gets highlighted
551 icons->setCurrentItem( item ); 551 icons->setCurrentItem( item );
552 emit clicked( appLnk ); 552 emit clicked( appLnk );
553 } 553 }
554 item->setSelected(FALSE); 554 item->setSelected(FALSE);
555 } 555 }
556} 556}
557 557
558void LauncherView::itemPressed( int btn, QIconViewItem *item ) 558void LauncherView::itemPressed( int btn, QIconViewItem *item )
559{ 559{
560 if ( item ) { 560 if ( item ) {
561 AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); 561 AppLnk *appLnk = ((LauncherItem *)item)->appLnk();
562 if ( btn == RightButton ) 562 if ( btn == RightButton )
563 emit rightPressed( appLnk ); 563 emit rightPressed( appLnk );
564/* 564/*
565 else if ( btn == LeftButton ) 565 else if ( btn == LeftButton )
566 emit clicked( appLnk ); 566 emit clicked( appLnk );
567*/ 567*/
568 item->setSelected(FALSE); 568 item->setSelected(FALSE);
569 } 569 }
570} 570}
571 571
572void LauncherView::internalPopulate( AppLnkSet *folder, const QString& typefilter ) 572void LauncherView::internalPopulate( AppLnkSet *folder, const QString& typefilter )
573{ 573{
574 QListIterator<AppLnk> it( folder->children() ); 574 QListIterator<AppLnk> it( folder->children() );
575 icons->setTypeFilter(typefilter,FALSE); 575 icons->setTypeFilter(typefilter,FALSE);
576 576
577 while ( it.current() ) { 577 while ( it.current() ) {
578 icons->addItem(*it,FALSE); 578 // show only the icons for existing files
579 if (!QFile(it.current()->file()).exists() )
580 {
581 //maybe insert some .desktop file deletion code later
582 //maybe dir specific
583 }
584 else
585 {
586 icons->addItem(*it,FALSE);
587 }
579 ++it; 588 ++it;
580 } 589 }
581 590
582 icons->sort(); 591 icons->sort();
583} 592}
584 593
585bool LauncherView::removeLink(const QString& linkfile) 594bool LauncherView::removeLink(const QString& linkfile)
586{ 595{
587 return icons->removeLink(linkfile); 596 return icons->removeLink(linkfile);
588} 597}
589 598
590void LauncherView::sort() 599void LauncherView::sort()
591{ 600{
592 icons->sort(); 601 icons->sort();
593} 602}
594 603
595void LauncherView::addItem(AppLnk* app, bool resort) 604void LauncherView::addItem(AppLnk* app, bool resort)
596{ 605{
597 icons->addItem(app,resort); 606 icons->addItem(app,resort);
598} 607}
599 608
600void LauncherView::setFileSystems(const QList<FileSystem> &) 609void LauncherView::setFileSystems(const QList<FileSystem> &)
601{ 610{
602 // ### does nothing now... 611 // ### does nothing now...
603} 612}