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