-rw-r--r-- | library/applnk.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/library/applnk.cpp b/library/applnk.cpp index 4adf1bd..8763eb2 100644 --- a/library/applnk.cpp +++ b/library/applnk.cpp | |||
@@ -373,193 +373,193 @@ AppLnk::AppLnk( const QString &file ) | |||
373 | Config config( file, Config::File ); | 373 | Config config( file, Config::File ); |
374 | 374 | ||
375 | if ( config.isValid() ) { | 375 | if ( config.isValid() ) { |
376 | config.setGroup( "Desktop Entry" ); | 376 | config.setGroup( "Desktop Entry" ); |
377 | 377 | ||
378 | mName = config.readEntry( "Name", file ); | 378 | mName = config.readEntry( "Name", file ); |
379 | mExec = config.readEntry( "Exec" ); | 379 | mExec = config.readEntry( "Exec" ); |
380 | mType = config.readEntry( "Type", QString::null ); | 380 | mType = config.readEntry( "Type", QString::null ); |
381 | mIconFile = config.readEntry( "Icon", QString::null ); | 381 | mIconFile = config.readEntry( "Icon", QString::null ); |
382 | mRotation = config.readEntry( "Rotation", "" ); | 382 | mRotation = config.readEntry( "Rotation", "" ); |
383 | mComment = config.readEntry( "Comment", QString::null ); | 383 | mComment = config.readEntry( "Comment", QString::null ); |
384 | // MIME types are case-insensitive. | 384 | // MIME types are case-insensitive. |
385 | mMimeTypes = config.readListEntry( "MimeType", ';' ); | 385 | mMimeTypes = config.readListEntry( "MimeType", ';' ); |
386 | for (QStringList::Iterator it=mMimeTypes.begin(); it!=mMimeTypes.end(); ++it) | 386 | for (QStringList::Iterator it=mMimeTypes.begin(); it!=mMimeTypes.end(); ++it) |
387 | *it = (*it).lower(); | 387 | *it = (*it).lower(); |
388 | mMimeTypeIcons = config.readListEntry( "MimeTypeIcons", ';' ); | 388 | mMimeTypeIcons = config.readListEntry( "MimeTypeIcons", ';' ); |
389 | mLinkFile = file; | 389 | mLinkFile = file; |
390 | mFile = config.readEntry("File", QString::null); | 390 | mFile = config.readEntry("File", QString::null); |
391 | if ( !mExec. isEmpty ( )) { | 391 | if ( !mExec. isEmpty ( )) { |
392 | mFile = QString::null; | 392 | mFile = QString::null; |
393 | } | 393 | } |
394 | else if ( mFile[0] != '/' ) { | 394 | else if ( mFile[0] != '/' ) { |
395 | int slash = file.findRev('/'); | 395 | int slash = file.findRev('/'); |
396 | if ( slash >= 0 ) { | 396 | if ( slash >= 0 ) { |
397 | mFile = file.left(slash) + '/' + mFile; | 397 | mFile = file.left(slash) + '/' + mFile; |
398 | } | 398 | } |
399 | } | 399 | } |
400 | d->mCatList = config.readListEntry("Categories", ';'); | 400 | d->mCatList = config.readListEntry("Categories", ';'); |
401 | if ( d->mCatList[0].toInt() < -1 ) { | 401 | if ( d->mCatList[0].toInt() < -1 ) { |
402 | // numeric cats in file! convert to text | 402 | // numeric cats in file! convert to text |
403 | Categories cat( 0 ); | 403 | Categories cat( 0 ); |
404 | cat.load( categoryFileName() ); | 404 | cat.load( categoryFileName() ); |
405 | d->mCat.resize( d->mCatList.count() ); | 405 | d->mCat.resize( d->mCatList.count() ); |
406 | int i; | 406 | int i; |
407 | QStringList::ConstIterator it; | 407 | QStringList::ConstIterator it; |
408 | for ( i = 0, it = d->mCatList.begin(); it != d->mCatList.end(); | 408 | for ( i = 0, it = d->mCatList.begin(); it != d->mCatList.end(); |
409 | ++it, i++ ) { | 409 | ++it, i++ ) { |
410 | bool number; | 410 | bool number; |
411 | int id = (*it).toInt( &number ); | 411 | int id = (*it).toInt( &number ); |
412 | if ( !number ) { | 412 | if ( !number ) { |
413 | // convert from text | 413 | // convert from text |
414 | id = cat.id( "Document View", *it ); | 414 | id = cat.id( "Document View", *it ); |
415 | if ( id == 0 ) | 415 | if ( id == 0 ) |
416 | id = cat.addCategory( "Document View", *it ); | 416 | id = cat.addCategory( "Document View", *it ); |
417 | } | 417 | } |
418 | d->mCat[i] = id; | 418 | d->mCat[i] = id; |
419 | } | 419 | } |
420 | d->updateCatListFromArray(); | 420 | d->updateCatListFromArray(); |
421 | } | 421 | } |
422 | } | 422 | } |
423 | } | 423 | } |
424 | mId = 0; | 424 | mId = 0; |
425 | } | 425 | } |
426 | 426 | ||
427 | AppLnk& AppLnk::operator=(const AppLnk ©) | 427 | AppLnk& AppLnk::operator=(const AppLnk ©) |
428 | { | 428 | { |
429 | if ( this == © ) return *this; | 429 | if ( this == © ) return *this; |
430 | if ( mId ) | 430 | if ( mId ) |
431 | qWarning("Deleting AppLnk that is in an AppLnkSet"); | 431 | qWarning("Deleting AppLnk that is in an AppLnkSet"); |
432 | if ( d ) | 432 | if ( d ) |
433 | delete d; | 433 | delete d; |
434 | 434 | ||
435 | 435 | ||
436 | mName = copy.mName; | 436 | mName = copy.mName; |
437 | 437 | ||
438 | /* remove for Qtopia 3.0 -zecke */ | 438 | /* remove for Qtopia 3.0 -zecke */ |
439 | mPixmap = copy.mPixmap; | 439 | mPixmap = copy.mPixmap; |
440 | mBigPixmap = copy.mBigPixmap; | 440 | mBigPixmap = copy.mBigPixmap; |
441 | 441 | ||
442 | mExec = copy.mExec; | 442 | mExec = copy.mExec; |
443 | mType = copy.mType; | 443 | mType = copy.mType; |
444 | mRotation = copy.mRotation; | 444 | mRotation = copy.mRotation; |
445 | mComment = copy.mComment; | 445 | mComment = copy.mComment; |
446 | mFile = copy.mFile; | 446 | mFile = copy.mFile; |
447 | mLinkFile = copy.mLinkFile; | 447 | mLinkFile = copy.mLinkFile; |
448 | mIconFile = copy.mIconFile; | 448 | mIconFile = copy.mIconFile; |
449 | mMimeTypes = copy.mMimeTypes; | 449 | mMimeTypes = copy.mMimeTypes; |
450 | mMimeTypeIcons = copy.mMimeTypeIcons; | 450 | mMimeTypeIcons = copy.mMimeTypeIcons; |
451 | mId = 0; | 451 | mId = 0; |
452 | d = new AppLnkPrivate(); | 452 | d = new AppLnkPrivate(); |
453 | d->mCat = copy.d->mCat; | 453 | d->mCat = copy.d->mCat; |
454 | d->mCatList = copy.d->mCatList; | 454 | d->mCatList = copy.d->mCatList; |
455 | d->mPixmaps = copy.d->mPixmaps; | 455 | d->mPixmaps = copy.d->mPixmaps; |
456 | 456 | ||
457 | return *this; | 457 | return *this; |
458 | } | 458 | } |
459 | /*! | 459 | /*! |
460 | protected internally to share code | 460 | protected internally to share code |
461 | should I document that at all? | 461 | should I document that at all? |
462 | I don't know the TT style for that | 462 | I don't know the TT style for that |
463 | */ | 463 | */ |
464 | const QPixmap& AppLnk::pixmap( int pos, int size ) const { | 464 | const QPixmap& AppLnk::pixmap( int pos, int size ) const { |
465 | if ( d->mPixmaps[pos].isNull() ) { | 465 | if ( d->mPixmaps[pos].isNull() ) { |
466 | AppLnk* that = (AppLnk*)this; | 466 | AppLnk* that = (AppLnk*)this; |
467 | if ( mIconFile.isEmpty() ) { | 467 | if ( mIconFile.isEmpty() ) { |
468 | MimeType mt(type()); | 468 | MimeType mt(type()); |
469 | that->d->mPixmaps[pos] = mt.pixmap(); | 469 | that->d->mPixmaps[pos] = pos ? mt.bigPixmap() : mt.pixmap(); |
470 | if ( that->d->mPixmaps[pos].isNull() ) | 470 | if ( that->d->mPixmaps[pos].isNull() ) |
471 | that->d->mPixmaps[pos].convertFromImage( | 471 | that->d->mPixmaps[pos].convertFromImage( |
472 | Resource::loadImage("UnknownDocument") | 472 | Resource::loadImage("UnknownDocument") |
473 | .smoothScale( size, size ) ); | 473 | .smoothScale( size, size ) ); |
474 | return that->d->mPixmaps[pos]; | 474 | return that->d->mPixmaps[pos]; |
475 | } | 475 | } |
476 | QImage unscaledIcon = Resource::loadImage( that->mIconFile ); | 476 | QImage unscaledIcon = Resource::loadImage( that->mIconFile ); |
477 | if ( unscaledIcon.isNull() ) { | 477 | if ( unscaledIcon.isNull() ) { |
478 | // qDebug( "Cannot find icon: %s", that->mIconFile.latin1() ); | 478 | // qDebug( "Cannot find icon: %s", that->mIconFile.latin1() ); |
479 | that->d->mPixmaps[pos].convertFromImage( | 479 | that->d->mPixmaps[pos].convertFromImage( |
480 | Resource::loadImage("UnknownDocument") | 480 | Resource::loadImage("UnknownDocument") |
481 | .smoothScale( size, size ) ); | 481 | .smoothScale( size, size ) ); |
482 | } else { | 482 | } else { |
483 | that->d->mPixmaps[0].convertFromImage( unscaledIcon.smoothScale( smallSize, smallSize ) ); | 483 | that->d->mPixmaps[0].convertFromImage( unscaledIcon.smoothScale( smallSize, smallSize ) ); |
484 | that->d->mPixmaps[1].convertFromImage( unscaledIcon.smoothScale( bigSize, bigSize ) ); | 484 | that->d->mPixmaps[1].convertFromImage( unscaledIcon.smoothScale( bigSize, bigSize ) ); |
485 | } | 485 | } |
486 | return that->d->mPixmaps[pos]; | 486 | return that->d->mPixmaps[pos]; |
487 | } | 487 | } |
488 | return d->mPixmaps[pos]; | 488 | return d->mPixmaps[pos]; |
489 | } | 489 | } |
490 | 490 | ||
491 | /*! | 491 | /*! |
492 | Returns a small pixmap associated with the application. | 492 | Returns a small pixmap associated with the application. |
493 | 493 | ||
494 | \sa bigPixmap() setIcon() | 494 | \sa bigPixmap() setIcon() |
495 | */ | 495 | */ |
496 | const QPixmap& AppLnk::pixmap() const | 496 | const QPixmap& AppLnk::pixmap() const |
497 | { | 497 | { |
498 | if ( d->mPixmaps[0].isNull() ) { | 498 | if ( d->mPixmaps[0].isNull() ) { |
499 | return pixmap(AppLnkPrivate::Normal, smallSize ); | 499 | return pixmap(AppLnkPrivate::Normal, smallSize ); |
500 | } | 500 | } |
501 | return d->mPixmaps[0]; | 501 | return d->mPixmaps[0]; |
502 | } | 502 | } |
503 | 503 | ||
504 | /*! | 504 | /*! |
505 | Returns a large pixmap associated with the application. | 505 | Returns a large pixmap associated with the application. |
506 | 506 | ||
507 | \sa pixmap() setIcon() | 507 | \sa pixmap() setIcon() |
508 | */ | 508 | */ |
509 | const QPixmap& AppLnk::bigPixmap() const | 509 | const QPixmap& AppLnk::bigPixmap() const |
510 | { | 510 | { |
511 | if ( d->mPixmaps[1].isNull() ) { | 511 | if ( d->mPixmaps[1].isNull() ) { |
512 | return pixmap( AppLnkPrivate::Big, bigSize ); | 512 | return pixmap( AppLnkPrivate::Big, bigSize ); |
513 | } | 513 | } |
514 | return d->mPixmaps[1]; | 514 | return d->mPixmaps[1]; |
515 | } | 515 | } |
516 | 516 | ||
517 | /*! | 517 | /*! |
518 | Returns the type of the AppLnk. For applications, games and | 518 | Returns the type of the AppLnk. For applications, games and |
519 | settings the type is \c Application; for documents the type is the | 519 | settings the type is \c Application; for documents the type is the |
520 | document's MIME type. | 520 | document's MIME type. |
521 | */ | 521 | */ |
522 | QString AppLnk::type() const | 522 | QString AppLnk::type() const |
523 | { | 523 | { |
524 | if ( mType.isNull() ) { | 524 | if ( mType.isNull() ) { |
525 | AppLnk* that = (AppLnk*)this; | 525 | AppLnk* that = (AppLnk*)this; |
526 | QString f = file(); | 526 | QString f = file(); |
527 | if ( !f.isNull() ) { | 527 | if ( !f.isNull() ) { |
528 | MimeType mt(f); | 528 | MimeType mt(f); |
529 | that->mType = mt.id(); | 529 | that->mType = mt.id(); |
530 | return that->mType; | 530 | return that->mType; |
531 | } | 531 | } |
532 | } | 532 | } |
533 | return mType; | 533 | return mType; |
534 | } | 534 | } |
535 | 535 | ||
536 | /*! | 536 | /*! |
537 | Returns the file associated with the AppLnk. | 537 | Returns the file associated with the AppLnk. |
538 | 538 | ||
539 | \sa exec() name() | 539 | \sa exec() name() |
540 | */ | 540 | */ |
541 | QString AppLnk::file() const | 541 | QString AppLnk::file() const |
542 | { | 542 | { |
543 | if ( mExec.isEmpty ( ) && mFile.isNull() ) { | 543 | if ( mExec.isEmpty ( ) && mFile.isNull() ) { |
544 | AppLnk* that = (AppLnk*)this; | 544 | AppLnk* that = (AppLnk*)this; |
545 | QString ext = MimeType(mType).extension(); | 545 | QString ext = MimeType(mType).extension(); |
546 | if ( !ext.isEmpty() ) | 546 | if ( !ext.isEmpty() ) |
547 | ext = "." + ext; | 547 | ext = "." + ext; |
548 | if ( !mLinkFile.isEmpty() ) { | 548 | if ( !mLinkFile.isEmpty() ) { |
549 | that->mFile = | 549 | that->mFile = |
550 | mLinkFile.right(8)==".desktop" // 8 = strlen(".desktop") | 550 | mLinkFile.right(8)==".desktop" // 8 = strlen(".desktop") |
551 | ? mLinkFile.left(mLinkFile.length()-8) : mLinkFile; | 551 | ? mLinkFile.left(mLinkFile.length()-8) : mLinkFile; |
552 | qDebug("mFile now == %s", mFile.latin1()); | 552 | qDebug("mFile now == %s", mFile.latin1()); |
553 | } else if ( mType.contains('/') ) { | 553 | } else if ( mType.contains('/') ) { |
554 | that->mFile = | 554 | that->mFile = |
555 | QString(getenv("HOME"))+"/Documents/"+mType+"/"+safeFileName(that->mName); | 555 | QString(getenv("HOME"))+"/Documents/"+mType+"/"+safeFileName(that->mName); |
556 | /* | 556 | /* |
557 | * A file with the same name or a .desktop file already exists | 557 | * A file with the same name or a .desktop file already exists |
558 | */ | 558 | */ |
559 | if ( QFile::exists(that->mFile+ext) || QFile::exists(that->mFile+".desktop") ) { | 559 | if ( QFile::exists(that->mFile+ext) || QFile::exists(that->mFile+".desktop") ) { |
560 | int n=1; | 560 | int n=1; |
561 | QString nn; | 561 | QString nn; |
562 | while (QFile::exists((nn=(that->mFile+"_"+QString::number(n)))+ext) | 562 | while (QFile::exists((nn=(that->mFile+"_"+QString::number(n)))+ext) |
563 | || QFile::exists(nn+".desktop")) | 563 | || QFile::exists(nn+".desktop")) |
564 | n++; | 564 | n++; |
565 | that->mFile = nn; | 565 | that->mFile = nn; |