summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/launcherview.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/core/launcher/launcherview.cpp b/core/launcher/launcherview.cpp
index 0df949e..764f088 100644
--- a/core/launcher/launcherview.cpp
+++ b/core/launcher/launcherview.cpp
@@ -267,356 +267,358 @@ class LauncherItem : public QIconViewItem
267public: 267public:
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; }
278 AppLnk* takeAppLnk() { AppLnk* r=app; app=0; return r; } 278 AppLnk* takeAppLnk() { AppLnk* r=app; app=0; return r; }
279 279
280 virtual int compare ( QIconViewItem * i ) const; 280 virtual int compare ( QIconViewItem * i ) const;
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:
303 AppLnk* app; 303 AppLnk* app;
304}; 304};
305 305
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
313int LauncherItem::compare ( QIconViewItem * i ) const 313int LauncherItem::compare ( QIconViewItem * i ) const
314{ 314{
315 LauncherIconView* view = (LauncherIconView*)iconView(); 315 LauncherIconView* view = (LauncherIconView*)iconView();
316 return view->compare(app,((LauncherItem *)i)->appLnk()); 316 return view->compare(app,((LauncherItem *)i)->appLnk());
317} 317}
318 318
319QStringList LauncherIconView::mimeTypes() const 319QStringList LauncherIconView::mimeTypes() const
320{ 320{
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;
329} 329}
330 330
331void LauncherIconView::addItem(AppLnk* app, bool resort) 331void LauncherIconView::addItem(AppLnk* app, bool resort)
332{ 332{
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()
346{ 346{
347 mimes.clear(); 347 mimes.clear();
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
362void LauncherIconView::hideOrShowItems(bool resort) 362void LauncherIconView::hideOrShowItems(bool resort)
363{ 363{
364 hidden.setAutoDelete(FALSE); 364 hidden.setAutoDelete(FALSE);
365 QList<AppLnk> links=hidden; 365 QList<AppLnk> links=hidden;
366 hidden.clear(); 366 hidden.clear();
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 );
375 clear(); 375 clear();
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
387bool LauncherIconView::removeLink(const QString& linkfile) 387bool LauncherIconView::removeLink(const QString& linkfile)
388{ 388{
389 LauncherItem* item = (LauncherItem*)firstItem(); 389 LauncherItem* item = (LauncherItem*)firstItem();
390 AppLnk* l; 390 AppLnk* l;
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
396 || dl.isValid() && dl.file() == l->file() ) { 396 || dl.isValid() && dl.file() == l->file() ) {
397 delete item; 397 delete item;
398 did = TRUE; 398 did = TRUE;
399 } 399 }
400 item = (LauncherItem*)item->nextItem(); 400 item = (LauncherItem*)item->nextItem();
401 } 401 }
402 QListIterator<AppLnk> it(hidden); 402 QListIterator<AppLnk> it(hidden);
403 while ((l=it.current())) { 403 while ((l=it.current())) {
404 ++it; 404 ++it;
405 if ( l->linkFileKnown() && l->linkFile() == linkfile 405 if ( l->linkFileKnown() && l->linkFile() == linkfile
406 || l->file() == linkfile 406 || l->file() == linkfile
407 || dl.isValid() && dl.file() == l->file() ) { 407 || dl.isValid() && dl.file() == l->file() ) {
408 hidden.removeRef(l); 408 hidden.removeRef(l);
409 did = TRUE; 409 did = TRUE;
410 } 410 }
411 } 411 }
412 return did; 412 return did;
413} 413}
414 414
415LauncherView::LauncherView( QWidget* parent, const char* name, WFlags fl ) 415LauncherView::LauncherView( QWidget* parent, const char* name, WFlags fl )
416 : QVBox( parent, name, fl ) 416 : QVBox( parent, name, fl )
417{ 417{
418 icons = new LauncherIconView( this ); 418 icons = new LauncherIconView( this );
419 setFocusProxy(icons); 419 setFocusProxy(icons);
420 QPEApplication::setStylusOperation( icons->viewport(), QPEApplication::RightOnHold ); 420 QPEApplication::setStylusOperation( icons->viewport(), QPEApplication::RightOnHold );
421 421
422 int dw = QApplication::desktop()->width(); 422 int dw = QApplication::desktop()->width();
423 icons->setItemsMovable( FALSE ); 423 icons->setItemsMovable( FALSE );
424 icons->setAutoArrange( TRUE ); 424 icons->setAutoArrange( TRUE );
425 icons->setSorting( TRUE ); 425 icons->setSorting( TRUE );
426 icons->setGridX( (dw-13-style().scrollBarExtent().width())/3 ); // tweaked for 8pt+dw=176 and 10pt+dw=240 426 icons->setGridX( (dw-13-style().scrollBarExtent().width())/3 ); // tweaked for 8pt+dw=176 and 10pt+dw=240
427 icons->setGridY( fontMetrics().height()*2+24 ); 427 icons->setGridY( fontMetrics().height()*2+24 );
428 icons->setFrameStyle( QFrame::NoFrame ); 428 icons->setFrameStyle( QFrame::NoFrame );
429 icons->setSpacing( 4 ); 429 icons->setSpacing( 4 );
430 icons->setMargin( 0 ); 430 icons->setMargin( 0 );
431 icons->setSelectionMode( QIconView::Multi ); 431 icons->setSelectionMode( QIconView::Multi );
432 icons->setBackgroundMode( PaletteBase ); 432 icons->setBackgroundMode( PaletteBase );
433 433
434 connect( icons, SIGNAL(mouseButtonClicked(int, QIconViewItem *, const QPoint&)), 434 connect( icons, SIGNAL(mouseButtonClicked(int, QIconViewItem *, const QPoint&)),
435 SLOT(itemClicked(int, QIconViewItem *)) ); 435 SLOT(itemClicked(int, QIconViewItem *)) );
436 connect( icons, SIGNAL(selectionChanged()), 436 connect( icons, SIGNAL(selectionChanged()),
437 SLOT(selectionChanged()) ); 437 SLOT(selectionChanged()) );
438 connect( icons, SIGNAL(returnPressed(QIconViewItem *)), 438 connect( icons, SIGNAL(returnPressed(QIconViewItem *)),
439 SLOT(returnPressed(QIconViewItem *)) ); 439 SLOT(returnPressed(QIconViewItem *)) );
440 connect( icons, SIGNAL(mouseButtonPressed(int, QIconViewItem *, const QPoint&)), 440 connect( icons, SIGNAL(mouseButtonPressed(int, QIconViewItem *, const QPoint&)),
441 SLOT(itemPressed(int, QIconViewItem *)) ); 441 SLOT(itemPressed(int, QIconViewItem *)) );
442 442
443 tools = 0; 443 tools = 0;
444} 444}
445 445
446LauncherView::~LauncherView() 446LauncherView::~LauncherView()
447{ 447{
448} 448}
449 449
450void LauncherView::setToolsEnabled(bool y) 450void LauncherView::setToolsEnabled(bool y)
451{ 451{
452 if ( !y != !tools ) { 452 if ( !y != !tools ) {
453 if ( y ) { 453 if ( y ) {
454 tools = new QHBox(this); 454 tools = new QHBox(this);
455 455
456 // Type filter 456 // Type filter
457 typemb = new MenuButton(tools); 457 typemb = new MenuButton(tools);
458 typemb->setLabel(tr("Type: %1")); 458 typemb->setLabel(tr("Type: %1"));
459 459 typemb->setFixedHeight ( 20 );
460
460 // Category filter 461 // Category filter
461 catmb = new CategorySelect(tools); 462 catmb = new CategorySelect(tools);
462 463 catmb->setFixedHeight ( 20 );
464
463 updateTools(); 465 updateTools();
464 tools->show(); 466 tools->show();
465 } else { 467 } else {
466 delete tools; 468 delete tools;
467 tools = 0; 469 tools = 0;
468 } 470 }
469 } 471 }
470} 472}
471 473
472void LauncherView::updateTools() 474void LauncherView::updateTools()
473{ 475{
474 disconnect( typemb, SIGNAL(selected(const QString&)), 476 disconnect( typemb, SIGNAL(selected(const QString&)),
475 this, SLOT(showType(const QString&)) ); 477 this, SLOT(showType(const QString&)) );
476 disconnect( catmb, SIGNAL(signalSelected(int)), 478 disconnect( catmb, SIGNAL(signalSelected(int)),
477 this, SLOT(showCategory(int)) ); 479 this, SLOT(showCategory(int)) );
478 480
479 icons->updateCategoriesAndMimeTypes(); 481 icons->updateCategoriesAndMimeTypes();
480 482
481 QString prev; 483 QString prev;
482 484
483 // Type filter 485 // Type filter
484 QStringList types; 486 QStringList types;
485 types << tr("All"); 487 types << tr("All");
486 types << "--"; 488 types << "--";
487 types += icons->mimeTypes(); 489 types += icons->mimeTypes();
488 prev = typemb->currentText(); 490 prev = typemb->currentText();
489 typemb->clear(); 491 typemb->clear();
490 typemb->insertItems(types); 492 typemb->insertItems(types);
491 typemb->select(prev); 493 typemb->select(prev);
492 494
493 Categories cats( 0 ); 495 Categories cats( 0 );
494 cats.load( categoryFileName() ); 496 cats.load( categoryFileName() );
495 QArray<int> vl( 0 ); 497 QArray<int> vl( 0 );
496 catmb->setCategories( vl, "Document View", tr("Document View") ); 498 catmb->setCategories( vl, "Document View", tr("Document View") );
497 catmb->setRemoveCategoryEdit( TRUE ); 499 catmb->setRemoveCategoryEdit( TRUE );
498 catmb->setAllCategories( TRUE ); 500 catmb->setAllCategories( TRUE );
499 501
500 connect(typemb, SIGNAL(selected(const QString&)), this, SLOT(showType(const QString&))); 502 connect(typemb, SIGNAL(selected(const QString&)), this, SLOT(showType(const QString&)));
501 connect(catmb, SIGNAL(signalSelected(int)), this, SLOT(showCategory(int))); 503 connect(catmb, SIGNAL(signalSelected(int)), this, SLOT(showCategory(int)));
502} 504}
503 505
504void LauncherView::sortBy(int s) 506void LauncherView::sortBy(int s)
505{ 507{
506 icons->setSortMethod((LauncherIconView::SortMethod)s); 508 icons->setSortMethod((LauncherIconView::SortMethod)s);
507} 509}
508 510
509void LauncherView::showType(const QString& t) 511void LauncherView::showType(const QString& t)
510{ 512{
511 if ( t == tr("All") ) { 513 if ( t == tr("All") ) {
512 icons->setTypeFilter("",TRUE); 514 icons->setTypeFilter("",TRUE);
513 } else { 515 } else {
514 icons->setTypeFilter(t+"/*",TRUE); 516 icons->setTypeFilter(t+"/*",TRUE);
515 } 517 }
516} 518}
517 519
518void LauncherView::showCategory( int c ) 520void LauncherView::showCategory( int c )
519{ 521{
520 icons->setCategoryFilter( c, TRUE ); 522 icons->setCategoryFilter( c, TRUE );
521} 523}
522 524
523void LauncherView::resizeEvent(QResizeEvent *e) 525void LauncherView::resizeEvent(QResizeEvent *e)
524{ 526{
525 QVBox::resizeEvent( e ); 527 QVBox::resizeEvent( e );
526 if ( e->size().width() != e->oldSize().width() ) 528 if ( e->size().width() != e->oldSize().width() )
527 sort(); 529 sort();
528} 530}
529 531
530void LauncherView::populate( AppLnkSet *folder, const QString& typefilter ) 532void LauncherView::populate( AppLnkSet *folder, const QString& typefilter )
531{ 533{
532 icons->clear(); 534 icons->clear();
533 internalPopulate( folder, typefilter ); 535 internalPopulate( folder, typefilter );
534} 536}
535 537
536void LauncherView::selectionChanged() 538void LauncherView::selectionChanged()
537{ 539{
538 QIconViewItem* item = icons->currentItem(); 540 QIconViewItem* item = icons->currentItem();
539 if ( item && item->isSelected() ) { 541 if ( item && item->isSelected() ) {
540 AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); 542 AppLnk *appLnk = ((LauncherItem *)item)->appLnk();
541 if ( icons->inKeyEvent() ) // not for mouse press 543 if ( icons->inKeyEvent() ) // not for mouse press
542 emit clicked( appLnk ); 544 emit clicked( appLnk );
543 item->setSelected(FALSE); 545 item->setSelected(FALSE);
544 } 546 }
545} 547}
546 548
547void LauncherView::returnPressed( QIconViewItem *item ) 549void LauncherView::returnPressed( QIconViewItem *item )
548{ 550{
549 if ( item ) { 551 if ( item ) {
550 AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); 552 AppLnk *appLnk = ((LauncherItem *)item)->appLnk();
551 emit clicked( appLnk ); 553 emit clicked( appLnk );
552 } 554 }
553} 555}
554 556
555void LauncherView::itemClicked( int btn, QIconViewItem *item ) 557void LauncherView::itemClicked( int btn, QIconViewItem *item )
556{ 558{
557 if ( item ) { 559 if ( item ) {
558 AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); 560 AppLnk *appLnk = ((LauncherItem *)item)->appLnk();
559 if ( btn == LeftButton ) { 561 if ( btn == LeftButton ) {
560 // Make sure it's the item we execute that gets highlighted 562 // Make sure it's the item we execute that gets highlighted
561 icons->setCurrentItem( item ); 563 icons->setCurrentItem( item );
562 emit clicked( appLnk ); 564 emit clicked( appLnk );
563 } 565 }
564 item->setSelected(FALSE); 566 item->setSelected(FALSE);
565 } 567 }
566} 568}
567 569
568void LauncherView::itemPressed( int btn, QIconViewItem *item ) 570void LauncherView::itemPressed( int btn, QIconViewItem *item )
569{ 571{
570 if ( item ) { 572 if ( item ) {
571 AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); 573 AppLnk *appLnk = ((LauncherItem *)item)->appLnk();
572 if ( btn == RightButton ) 574 if ( btn == RightButton )
573 emit rightPressed( appLnk ); 575 emit rightPressed( appLnk );
574/* 576/*
575 else if ( btn == LeftButton ) 577 else if ( btn == LeftButton )
576 emit clicked( appLnk ); 578 emit clicked( appLnk );
577*/ 579*/
578 item->setSelected(FALSE); 580 item->setSelected(FALSE);
579 } 581 }
580} 582}
581 583
582void LauncherView::internalPopulate( AppLnkSet *folder, const QString& typefilter ) 584void LauncherView::internalPopulate( AppLnkSet *folder, const QString& typefilter )
583{ 585{
584 QListIterator<AppLnk> it( folder->children() ); 586 QListIterator<AppLnk> it( folder->children() );
585 icons->setTypeFilter(typefilter,FALSE); 587 icons->setTypeFilter(typefilter,FALSE);
586 588
587 while ( it.current() ) { 589 while ( it.current() ) {
588 // show only the icons for existing files 590 // show only the icons for existing files
589 if (!QFile(it.current()->file()).exists() ) 591 if (!QFile(it.current()->file()).exists() )
590 { 592 {
591 //maybe insert some .desktop file deletion code later 593 //maybe insert some .desktop file deletion code later
592 //maybe dir specific 594 //maybe dir specific
593 } 595 }
594 else 596 else
595 { 597 {
596 icons->addItem(*it,FALSE); 598 icons->addItem(*it,FALSE);
597 } 599 }
598 ++it; 600 ++it;
599 } 601 }
600 602
601 icons->sort(); 603 icons->sort();
602} 604}
603 605
604bool LauncherView::removeLink(const QString& linkfile) 606bool LauncherView::removeLink(const QString& linkfile)
605{ 607{
606 return icons->removeLink(linkfile); 608 return icons->removeLink(linkfile);
607} 609}
608 610
609void LauncherView::sort() 611void LauncherView::sort()
610{ 612{
611 icons->sort(); 613 icons->sort();
612} 614}
613 615
614void LauncherView::addItem(AppLnk* app, bool resort) 616void LauncherView::addItem(AppLnk* app, bool resort)
615{ 617{
616 icons->addItem(app,resort); 618 icons->addItem(app,resort);
617} 619}
618 620
619void LauncherView::setFileSystems(const QList<FileSystem> &) 621void LauncherView::setFileSystems(const QList<FileSystem> &)
620{ 622{
621 // ### does nothing now... 623 // ### does nothing now...
622} 624}