author | llornkcor <llornkcor> | 2003-05-04 13:12:11 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2003-05-04 13:12:11 (UTC) |
commit | 8409a251d52b59585889e1bcaa278a6b847db2fc (patch) (unidiff) | |
tree | 50f085a116cdb739705aa3c40ceececc99833465 | |
parent | 8489a583d5b762c5530076271ee3c3be7011b9ef (diff) | |
download | opie-8409a251d52b59585889e1bcaa278a6b847db2fc.zip opie-8409a251d52b59585889e1bcaa278a6b847db2fc.tar.gz opie-8409a251d52b59585889e1bcaa278a6b847db2fc.tar.bz2 |
remove debug message - Cannot find icon
-rw-r--r-- | library/applnk.cpp | 712 |
1 files changed, 356 insertions, 356 deletions
diff --git a/library/applnk.cpp b/library/applnk.cpp index 00030e8..4adf1bd 100644 --- a/library/applnk.cpp +++ b/library/applnk.cpp | |||
@@ -46,27 +46,27 @@ int AppLnk::lastId = 5000; | |||
46 | 46 | ||
47 | static int smallSize = 14; | 47 | static int smallSize = 14; |
48 | static int bigSize = 32; | 48 | static int bigSize = 32; |
49 | 49 | ||
50 | static QString safeFileName(const QString& n) | 50 | static QString safeFileName(const QString& n) |
51 | { | 51 | { |
52 | QString safename=n; | 52 | QString safename=n; |
53 | safename.replace(QRegExp("[^0-9A-Za-z.]"),"_"); | 53 | safename.replace(QRegExp("[^0-9A-Za-z.]"),"_"); |
54 | safename.replace(QRegExp("^[^A-Za-z]*"),""); | 54 | safename.replace(QRegExp("^[^A-Za-z]*"),""); |
55 | if ( safename.isEmpty() ) | 55 | if ( safename.isEmpty() ) |
56 | safename = "_"; | 56 | safename = "_"; |
57 | return safename; | 57 | return safename; |
58 | } | 58 | } |
59 | 59 | ||
60 | static bool prepareDirectories(const QString& lf) | 60 | static bool prepareDirectories(const QString& lf) |
61 | { | 61 | { |
62 | if ( !QFile::exists(lf) ) { | 62 | if ( !QFile::exists(lf) ) { |
63 | // May need to create directories | 63 | // May need to create directories |
64 | QFileInfo fi(lf); | 64 | QFileInfo fi(lf); |
65 | if ( system(("mkdir -p "+fi.dirPath(TRUE))) ) | 65 | if ( system(("mkdir -p "+fi.dirPath(TRUE))) ) |
66 | return FALSE; | 66 | return FALSE; |
67 | } | 67 | } |
68 | return TRUE; | 68 | return TRUE; |
69 | } | 69 | } |
70 | 70 | ||
71 | class AppLnkPrivate | 71 | class AppLnkPrivate |
72 | { | 72 | { |
@@ -84,48 +84,48 @@ public: | |||
84 | QStringList mCatList; // always correct | 84 | QStringList mCatList; // always correct |
85 | QArray<int> mCat; // cached value; correct if not empty | 85 | QArray<int> mCat; // cached value; correct if not empty |
86 | QMap<int, QPixmap> mPixmaps; | 86 | QMap<int, QPixmap> mPixmaps; |
87 | 87 | ||
88 | void updateCatListFromArray() | 88 | void updateCatListFromArray() |
89 | { | 89 | { |
90 | Categories cat( 0 ); | 90 | Categories cat( 0 ); |
91 | cat.load( categoryFileName() ); | 91 | cat.load( categoryFileName() ); |
92 | // we need to update the names for the mCat... to mCatList | 92 | // we need to update the names for the mCat... to mCatList |
93 | mCatList.clear(); | 93 | mCatList.clear(); |
94 | for (uint i = 0; i < mCat.count(); i++ ) | 94 | for (uint i = 0; i < mCat.count(); i++ ) |
95 | mCatList << cat.label("Document View", mCat[i] ); | 95 | mCatList << cat.label("Document View", mCat[i] ); |
96 | 96 | ||
97 | } | 97 | } |
98 | 98 | ||
99 | void setCatArrayDirty() | 99 | void setCatArrayDirty() |
100 | { | 100 | { |
101 | mCat.resize(0); | 101 | mCat.resize(0); |
102 | } | 102 | } |
103 | 103 | ||
104 | void ensureCatArray() | 104 | void ensureCatArray() |
105 | { | 105 | { |
106 | if ( mCat.count() > 0 || mCatList.count()==0 ) | 106 | if ( mCat.count() > 0 || mCatList.count()==0 ) |
107 | return; | 107 | return; |
108 | 108 | ||
109 | Categories cat( 0 ); | 109 | Categories cat( 0 ); |
110 | cat.load( categoryFileName() ); | 110 | cat.load( categoryFileName() ); |
111 | mCat.resize( mCatList.count() ); | 111 | mCat.resize( mCatList.count() ); |
112 | int i; | 112 | int i; |
113 | QStringList::ConstIterator it; | 113 | QStringList::ConstIterator it; |
114 | for ( i = 0, it = mCatList.begin(); it != mCatList.end(); | 114 | for ( i = 0, it = mCatList.begin(); it != mCatList.end(); |
115 | ++it, i++ ) { | 115 | ++it, i++ ) { |
116 | 116 | ||
117 | bool number; | 117 | bool number; |
118 | int id = (*it).toInt( &number ); | 118 | int id = (*it).toInt( &number ); |
119 | if ( !number ) { | 119 | if ( !number ) { |
120 | id = cat.id( "Document View", *it ); | 120 | id = cat.id( "Document View", *it ); |
121 | if ( id == 0 ) | 121 | if ( id == 0 ) |
122 | id = cat.addCategory( "Document View", *it ); | 122 | id = cat.addCategory( "Document View", *it ); |
123 | } | 123 | } |
124 | mCat[i] = id; | 124 | mCat[i] = id; |
125 | } | 125 | } |
126 | } | 126 | } |
127 | }; | 127 | }; |
128 | 128 | ||
129 | /*! | 129 | /*! |
130 | \class AppLnk applnk.h | 130 | \class AppLnk applnk.h |
131 | \brief The AppLnk class represents an application available on the system. | 131 | \brief The AppLnk class represents an application available on the system. |
@@ -183,29 +183,29 @@ public: | |||
183 | using isValid(). | 183 | using isValid(). |
184 | 184 | ||
185 | The following functions are used to set or retrieve information | 185 | The following functions are used to set or retrieve information |
186 | about the application: | 186 | about the application: |
187 | \table | 187 | \table |
188 | \header \i Get Function \i Set Function \i Short Description | 188 | \header \i Get Function \i Set Function \i Short Description |
189 | \row \i \l name() \i \l setName() \i application's name | 189 | \row \i \l name() \i \l setName() \i application's name |
190 | \row \i \l pixmap() \i \e none \i application's icon | 190 | \row \i \l pixmap() \i \e none \i application's icon |
191 | \row \i \l bigPixmap() \i \e none \i application's large icon | 191 | \row \i \l bigPixmap() \i \e none \i application's large icon |
192 | \row \i \e none \i setIcon() \i sets the icon's filename | 192 | \row \i \e none \i setIcon() \i sets the icon's filename |
193 | \row \i \l type() \i \l setType() \i see \link #Types Types\endlink above | 193 | \row \i \l type() \i \l setType() \i see \link #Types Types\endlink above |
194 | \row \i \l rotation() \i \e none \i 0, 90, 180 or 270 degrees | 194 | \row \i \l rotation() \i \e none \i 0, 90, 180 or 270 degrees |
195 | \row \i \l comment() \i \l setComment() \i text for the Details dialog | 195 | \row \i \l comment() \i \l setComment() \i text for the Details dialog |
196 | \row \i \l exec() \i \l setExec() \i executable's filename | 196 | \row \i \l exec() \i \l setExec() \i executable's filename |
197 | \row \i \l file() \i \e none \i document's filename | 197 | \row \i \l file() \i \e none \i document's filename |
198 | \row \i \l linkFile() \i \l setLinkFile()\i \e .desktop filename | 198 | \row \i \l linkFile() \i \l setLinkFile() \i \e .desktop filename |
199 | \row \i \l mimeTypes() \i \e none \i the mime types the application can view or edit | 199 | \row \i \l mimeTypes() \i \e none \i the mime types the application can view or edit |
200 | \row \i \l categories() \i \l setCategories()\i \e{see the function descriptions} | 200 | \row \i \l categories() \i \l setCategories() \i \e{see the function descriptions} |
201 | \row \i \l fileKnown() \i \e none \i see \link | 201 | \row \i \l fileKnown() \i \e none \i see \link |
202 | #files-and-links Files and Links\endlink above | 202 | #files-and-links Files and Links\endlink above |
203 | \row \i \l linkFileKnown() \i \e none \i see \link | 203 | \row \i \l linkFileKnown() \i \e none \i see \link |
204 | #files-and-links Files and Links\endlink above | 204 | #files-and-links Files and Links\endlink above |
205 | \row \i \l property() \i \l setProperty()\i any AppLnk property | 205 | \row \i \l property() \i \l setProperty() \i any AppLnk property |
206 | can be retrieved or set (if writeable) using these | 206 | can be retrieved or set (if writeable) using these |
207 | \endtable | 207 | \endtable |
208 | 208 | ||
209 | To save an AppLnk to disk use writeLink(). To execute the | 209 | To save an AppLnk to disk use writeLink(). To execute the |
210 | application that the AppLnk object refers to, use execute(). | 210 | application that the AppLnk object refers to, use execute(). |
211 | 211 | ||
@@ -367,73 +367,73 @@ AppLnk::AppLnk() | |||
367 | */ | 367 | */ |
368 | AppLnk::AppLnk( const QString &file ) | 368 | AppLnk::AppLnk( const QString &file ) |
369 | { | 369 | { |
370 | QStringList sl; | 370 | QStringList sl; |
371 | d = new AppLnkPrivate(); | 371 | d = new AppLnkPrivate(); |
372 | if ( !file.isNull() ) { | 372 | if ( !file.isNull() ) { |
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; |
@@ -460,33 +460,33 @@ AppLnk& AppLnk::operator=(const AppLnk ©) | |||
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] = 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. |
@@ -519,91 +519,91 @@ const QPixmap& AppLnk::bigPixmap() const | |||
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; |
566 | } | 566 | } |
567 | that->mLinkFile = that->mFile+".desktop"; | 567 | that->mLinkFile = that->mFile+".desktop"; |
568 | that->mFile += ext; | 568 | that->mFile += ext; |
569 | } | 569 | } |
570 | prepareDirectories(that->mFile); | 570 | prepareDirectories(that->mFile); |
571 | if ( !that->mFile.isEmpty() ) { | 571 | if ( !that->mFile.isEmpty() ) { |
572 | QFile f(that->mFile); | 572 | QFile f(that->mFile); |
573 | if ( !f.open(IO_WriteOnly) ) | 573 | if ( !f.open(IO_WriteOnly) ) |
574 | that->mFile = QString::null; | 574 | that->mFile = QString::null; |
575 | return that->mFile; | 575 | return that->mFile; |
576 | } | 576 | } |
577 | } | 577 | } |
578 | return mFile; | 578 | return mFile; |
579 | } | 579 | } |
580 | 580 | ||
581 | /*! | 581 | /*! |
582 | Returns the desktop file corresponding to this AppLnk. | 582 | Returns the desktop file corresponding to this AppLnk. |
583 | 583 | ||
584 | \sa file() exec() name() | 584 | \sa file() exec() name() |
585 | */ | 585 | */ |
586 | QString AppLnk::linkFile() const | 586 | QString AppLnk::linkFile() const |
587 | { | 587 | { |
588 | if ( mLinkFile.isNull() ) { | 588 | if ( mLinkFile.isNull() ) { |
589 | AppLnk* that = (AppLnk*)this; | 589 | AppLnk* that = (AppLnk*)this; |
590 | if ( type().contains('/') ) { | 590 | if ( type().contains('/') ) { |
591 | StorageInfo storage; | 591 | StorageInfo storage; |
592 | const FileSystem *fs = storage.fileSystemOf( that->mFile ); | 592 | const FileSystem *fs = storage.fileSystemOf( that->mFile ); |
593 | /* tmpfs + and ramfs are available too but not removable | 593 | /* tmpfs + and ramfs are available too but not removable |
594 | * either we fix storage or add this | 594 | * either we fix storage or add this |
595 | */ | 595 | */ |
596 | if ( fs && ( fs->isRemovable() || fs->disk() == "/dev/mtdblock6" || fs->disk() == "tmpfs") ) { | 596 | if ( fs && ( fs->isRemovable() || fs->disk() == "/dev/mtdblock6" || fs->disk() == "tmpfs") ) { |
597 | that->mLinkFile = fs->path(); | 597 | that->mLinkFile = fs->path(); |
598 | } else | 598 | } else |
599 | that->mLinkFile = getenv( "HOME" ); | 599 | that->mLinkFile = getenv( "HOME" ); |
600 | that->mLinkFile += "/Documents/"+type()+"/"+safeFileName(that->mName); | 600 | that->mLinkFile += "/Documents/"+type()+"/"+safeFileName(that->mName); |
601 | 601 | ||
602 | /* the desktop file exists make sure we don't point to the same file */ | 602 | /* the desktop file exists make sure we don't point to the same file */ |
603 | if ( QFile::exists(that->mLinkFile+".desktop") ) { | 603 | if ( QFile::exists(that->mLinkFile+".desktop") ) { |
604 | AppLnk lnk( that->mLinkFile + ".desktop" ); | 604 | AppLnk lnk( that->mLinkFile + ".desktop" ); |
605 | 605 | ||
606 | /* the linked is different */ | 606 | /* the linked is different */ |
607 | if(that->file() != lnk.file() ) { | 607 | if(that->file() != lnk.file() ) { |
608 | int n = 1; | 608 | int n = 1; |
609 | QString nn; | 609 | QString nn; |
@@ -613,17 +613,17 @@ QString AppLnk::linkFile() const | |||
613 | AppLnk lnk(nn ); | 613 | AppLnk lnk(nn ); |
614 | if (lnk.file() == that->file() ) | 614 | if (lnk.file() == that->file() ) |
615 | break; | 615 | break; |
616 | } | 616 | } |
617 | that->mLinkFile = nn; | 617 | that->mLinkFile = nn; |
618 | } | 618 | } |
619 | } | 619 | } |
620 | that->mLinkFile += ".desktop"; | 620 | that->mLinkFile += ".desktop"; |
621 | storeLink(); | 621 | storeLink(); |
622 | } | 622 | } |
623 | return that->mLinkFile; | 623 | return that->mLinkFile; |
624 | } | 624 | } |
625 | return mLinkFile; | 625 | return mLinkFile; |
626 | } | 626 | } |
627 | 627 | ||
628 | /*! | 628 | /*! |
629 | Copies \a copy. | 629 | Copies \a copy. |
@@ -655,15 +655,15 @@ AppLnk::AppLnk( const AppLnk © ) | |||
655 | 655 | ||
656 | \sa AppLnkSet::add() AppLnkSet::remove() | 656 | \sa AppLnkSet::add() AppLnkSet::remove() |
657 | */ | 657 | */ |
658 | AppLnk::~AppLnk() | 658 | AppLnk::~AppLnk() |
659 | { | 659 | { |
660 | if ( mId ) | 660 | if ( mId ) |
661 | qWarning("Deleting AppLnk that is in an AppLnkSet"); | 661 | qWarning("Deleting AppLnk that is in an AppLnkSet"); |
662 | if ( d ) | 662 | if ( d ) |
663 | delete d; | 663 | delete d; |
664 | } | 664 | } |
665 | 665 | ||
666 | /*! | 666 | /*! |
667 | \overload | 667 | \overload |
668 | Executes the application associated with this AppLnk. | 668 | Executes the application associated with this AppLnk. |
669 | 669 | ||
@@ -681,22 +681,22 @@ void AppLnk::execute() const | |||
681 | \sa exec() | 681 | \sa exec() |
682 | */ | 682 | */ |
683 | void AppLnk::execute(const QStringList& args) const | 683 | void AppLnk::execute(const QStringList& args) const |
684 | { | 684 | { |
685 | #ifdef Q_WS_QWS | 685 | #ifdef Q_WS_QWS |
686 | if ( !mRotation.isEmpty() ) { | 686 | if ( !mRotation.isEmpty() ) { |
687 | // ######## this will only work in the server | 687 | // ######## this will only work in the server |
688 | int rot = QPEApplication::defaultRotation(); | 688 | int rot = QPEApplication::defaultRotation(); |
689 | rot = (rot+mRotation.toInt())%360; | 689 | rot = (rot+mRotation.toInt())%360; |
690 | QCString old = getenv("QWS_DISPLAY"); | 690 | QCString old = getenv("QWS_DISPLAY"); |
691 | setenv("QWS_DISPLAY", QString("Transformed:Rot%1:0").arg(rot), 1); | 691 | setenv("QWS_DISPLAY", QString("Transformed:Rot%1:0").arg(rot), 1); |
692 | invoke(args); | 692 | invoke(args); |
693 | setenv("QWS_DISPLAY", old.data(), 1); | 693 | setenv("QWS_DISPLAY", old.data(), 1); |
694 | } else | 694 | } else |
695 | #endif | 695 | #endif |
696 | invoke(args); | 696 | invoke(args); |
697 | } | 697 | } |
698 | 698 | ||
699 | /*! | 699 | /*! |
700 | Invokes the application associated with this AppLnk, with | 700 | Invokes the application associated with this AppLnk, with |
701 | \a args as arguments. Rotation is not taken into account by | 701 | \a args as arguments. Rotation is not taken into account by |
702 | this function, so you should not call it directly. | 702 | this function, so you should not call it directly. |
@@ -723,13 +723,13 @@ void AppLnk::setExec( const QString& exec ) | |||
723 | Sets the Rotation property to \a rot. | 723 | Sets the Rotation property to \a rot. |
724 | 724 | ||
725 | \sa rotation() | 725 | \sa rotation() |
726 | */ | 726 | */ |
727 | void AppLnk::setRotation ( const QString &rot ) | 727 | void AppLnk::setRotation ( const QString &rot ) |
728 | { | 728 | { |
729 | mRotation = rot; | 729 | mRotation = rot; |
730 | } | 730 | } |
731 | #endif | 731 | #endif |
732 | 732 | ||
733 | /*! | 733 | /*! |
734 | Sets the Name property to \a docname. | 734 | Sets the Name property to \a docname. |
735 | 735 | ||
@@ -850,13 +850,13 @@ bool AppLnk::ensureLinkExists() const | |||
850 | */ | 850 | */ |
851 | bool AppLnk::writeLink() const | 851 | bool AppLnk::writeLink() const |
852 | { | 852 | { |
853 | // Only re-writes settable parts | 853 | // Only re-writes settable parts |
854 | QString lf = linkFile(); | 854 | QString lf = linkFile(); |
855 | if ( !ensureLinkExists() ) | 855 | if ( !ensureLinkExists() ) |
856 | return FALSE; | 856 | return FALSE; |
857 | storeLink(); | 857 | storeLink(); |
858 | return TRUE; | 858 | return TRUE; |
859 | } | 859 | } |
860 | 860 | ||
861 | /*! | 861 | /*! |
862 | \internal | 862 | \internal |
@@ -866,25 +866,25 @@ void AppLnk::storeLink() const | |||
866 | Config config( mLinkFile, Config::File ); | 866 | Config config( mLinkFile, Config::File ); |
867 | config.setGroup("Desktop Entry"); | 867 | config.setGroup("Desktop Entry"); |
868 | config.writeEntry("Name",mName); | 868 | config.writeEntry("Name",mName); |
869 | if ( !mIconFile.isNull() ) config.writeEntry("Icon",mIconFile); | 869 | if ( !mIconFile.isNull() ) config.writeEntry("Icon",mIconFile); |
870 | config.writeEntry("Type",type()); | 870 | config.writeEntry("Type",type()); |
871 | if(!rotation().isEmpty()) | 871 | if(!rotation().isEmpty()) |
872 | config.writeEntry("Rotation",rotation()); | 872 | config.writeEntry("Rotation",rotation()); |
873 | else | 873 | else |
874 | config.removeEntry("Rotation"); | 874 | config.removeEntry("Rotation"); |
875 | if ( !mComment.isNull() ) config.writeEntry("Comment",mComment); | 875 | if ( !mComment.isNull() ) config.writeEntry("Comment",mComment); |
876 | QString f = file(); | 876 | QString f = file(); |
877 | int i = 0; | 877 | int i = 0; |
878 | while ( i < (int)f.length() && i < (int)mLinkFile.length() && f[i] == mLinkFile[i] ) | 878 | while ( i < (int)f.length() && i < (int)mLinkFile.length() && f[i] == mLinkFile[i] ) |
879 | i++; | 879 | i++; |
880 | while ( i && f[i] != '/' ) | 880 | while ( i && f[i] != '/' ) |
881 | i--; | 881 | i--; |
882 | // simple case where in the same directory | 882 | // simple case where in the same directory |
883 | if ( mLinkFile.find( '/', i + 1 ) < 0 ) | 883 | if ( mLinkFile.find( '/', i + 1 ) < 0 ) |
884 | f = f.mid(i+1); | 884 | f = f.mid(i+1); |
885 | // ### could do relative ie ../../otherDocs/file.doc | 885 | // ### could do relative ie ../../otherDocs/file.doc |
886 | config.writeEntry("File",f); | 886 | config.writeEntry("File",f); |
887 | config.writeEntry( "Categories", d->mCatList, ';' ); | 887 | config.writeEntry( "Categories", d->mCatList, ';' ); |
888 | 888 | ||
889 | #ifndef QT_NO_COP | 889 | #ifndef QT_NO_COP |
890 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); | 890 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); |
@@ -897,27 +897,27 @@ void AppLnk::storeLink() const | |||
897 | 897 | ||
898 | \sa property() | 898 | \sa property() |
899 | */ | 899 | */ |
900 | void AppLnk::setProperty(const QString& key, const QString& value) | 900 | void AppLnk::setProperty(const QString& key, const QString& value) |
901 | { | 901 | { |
902 | if ( ensureLinkExists() ) { | 902 | if ( ensureLinkExists() ) { |
903 | Config cfg(linkFile(), Config::File); | 903 | Config cfg(linkFile(), Config::File); |
904 | cfg.writeEntry(key,value); | 904 | cfg.writeEntry(key,value); |
905 | } | 905 | } |
906 | } | 906 | } |
907 | 907 | ||
908 | /*! | 908 | /*! |
909 | Returns the property named \a key. | 909 | Returns the property named \a key. |
910 | 910 | ||
911 | \sa setProperty() | 911 | \sa setProperty() |
912 | */ | 912 | */ |
913 | QString AppLnk::property(const QString& key) const | 913 | QString AppLnk::property(const QString& key) const |
914 | { | 914 | { |
915 | QString lf = linkFile(); | 915 | QString lf = linkFile(); |
916 | if ( !QFile::exists(lf) ) | 916 | if ( !QFile::exists(lf) ) |
917 | return QString::null; | 917 | return QString::null; |
918 | Config cfg(lf, Config::File); | 918 | Config cfg(lf, Config::File); |
919 | return cfg.readEntry(key); | 919 | return cfg.readEntry(key); |
920 | } | 920 | } |
921 | 921 | ||
922 | bool AppLnk::isPreloaded() const { | 922 | bool AppLnk::isPreloaded() const { |
923 | // Preload information is stored in the Launcher config in v1.5. | 923 | // Preload information is stored in the Launcher config in v1.5. |
@@ -948,49 +948,49 @@ void AppLnk::setPreloaded(bool yesNo) { | |||
948 | \sa removeLinkFile() | 948 | \sa removeLinkFile() |
949 | */ | 949 | */ |
950 | void AppLnk::removeFiles() | 950 | void AppLnk::removeFiles() |
951 | { | 951 | { |
952 | bool valid = isValid(); | 952 | bool valid = isValid(); |
953 | if ( !valid || !linkFileKnown() || QFile::remove(linkFile()) ) { | 953 | if ( !valid || !linkFileKnown() || QFile::remove(linkFile()) ) { |
954 | if ( QFile::remove(file()) ) { | 954 | if ( QFile::remove(file()) ) { |
955 | #ifndef QT_NO_COP | 955 | #ifndef QT_NO_COP |
956 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); | 956 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); |
957 | if ( linkFileKnown() ) | 957 | if ( linkFileKnown() ) |
958 | e << linkFile(); | 958 | e << linkFile(); |
959 | else | 959 | else |
960 | e << file(); | 960 | e << file(); |
961 | #endif | 961 | #endif |
962 | } else if ( valid ) { | 962 | } else if ( valid ) { |
963 | // restore link | 963 | // restore link |
964 | writeLink(); | 964 | writeLink(); |
965 | } | 965 | } |
966 | } | 966 | } |
967 | } | 967 | } |
968 | 968 | ||
969 | /*! | 969 | /*! |
970 | Deletes the linkFile(), leaving any file() untouched. | 970 | Deletes the linkFile(), leaving any file() untouched. |
971 | 971 | ||
972 | \sa removeFiles() | 972 | \sa removeFiles() |
973 | */ | 973 | */ |
974 | void AppLnk::removeLinkFile() | 974 | void AppLnk::removeLinkFile() |
975 | { | 975 | { |
976 | if ( isValid() && linkFileKnown() && QFile::remove(linkFile()) ) { | 976 | if ( isValid() && linkFileKnown() && QFile::remove(linkFile()) ) { |
977 | #ifndef QT_NO_COP | 977 | #ifndef QT_NO_COP |
978 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); | 978 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); |
979 | e << linkFile(); | 979 | e << linkFile(); |
980 | #endif | 980 | #endif |
981 | } | 981 | } |
982 | } | 982 | } |
983 | 983 | ||
984 | class AppLnkSetPrivate { | 984 | class AppLnkSetPrivate { |
985 | public: | 985 | public: |
986 | AppLnkSetPrivate() | 986 | AppLnkSetPrivate() |
987 | { | 987 | { |
988 | typPix.setAutoDelete(TRUE); | 988 | typPix.setAutoDelete(TRUE); |
989 | typPixBig.setAutoDelete(TRUE); | 989 | typPixBig.setAutoDelete(TRUE); |
990 | typName.setAutoDelete(TRUE); | 990 | typName.setAutoDelete(TRUE); |
991 | } | 991 | } |
992 | 992 | ||
993 | QDict<QPixmap> typPix; | 993 | QDict<QPixmap> typPix; |
994 | QDict<QPixmap> typPixBig; | 994 | QDict<QPixmap> typPixBig; |
995 | QDict<QString> typName; | 995 | QDict<QString> typName; |
996 | }; | 996 | }; |
@@ -1049,15 +1049,15 @@ AppLnkSet::AppLnkSet( const QString &directory ) : | |||
1049 | the caller becomes responsible for deleting the AppLnk objects. | 1049 | the caller becomes responsible for deleting the AppLnk objects. |
1050 | */ | 1050 | */ |
1051 | void AppLnkSet::detachChildren() | 1051 | void AppLnkSet::detachChildren() |
1052 | { | 1052 | { |
1053 | QListIterator<AppLnk> it( mApps ); | 1053 | QListIterator<AppLnk> it( mApps ); |
1054 | for ( ; it.current(); ) { | 1054 | for ( ; it.current(); ) { |
1055 | AppLnk* a = *it; | 1055 | AppLnk* a = *it; |
1056 | ++it; | 1056 | ++it; |
1057 | a->mId = 0; | 1057 | a->mId = 0; |
1058 | } | 1058 | } |
1059 | mApps.clear(); | 1059 | mApps.clear(); |
1060 | } | 1060 | } |
1061 | 1061 | ||
1062 | /*! | 1062 | /*! |
1063 | Destroys the set, deleting all the AppLnk objects it contains. | 1063 | Destroys the set, deleting all the AppLnk objects it contains. |
@@ -1065,95 +1065,96 @@ void AppLnkSet::detachChildren() | |||
1065 | \sa detachChildren() | 1065 | \sa detachChildren() |
1066 | */ | 1066 | */ |
1067 | AppLnkSet::~AppLnkSet() | 1067 | AppLnkSet::~AppLnkSet() |
1068 | { | 1068 | { |
1069 | QListIterator<AppLnk> it( mApps ); | 1069 | QListIterator<AppLnk> it( mApps ); |
1070 | for ( ; it.current(); ) { | 1070 | for ( ; it.current(); ) { |
1071 | AppLnk* a = *it; | 1071 | AppLnk* a = *it; |
1072 | ++it; | 1072 | ++it; |
1073 | a->mId = 0; | 1073 | a->mId = 0; |
1074 | delete a; | 1074 | delete a; |
1075 | } | 1075 | } |
1076 | delete d; | 1076 | delete d; |
1077 | } | 1077 | } |
1078 | 1078 | ||
1079 | void AppLnkSet::findChildren(const QString &dr, const QString& typ, const QString& typName, int depth) | 1079 | void AppLnkSet::findChildren(const QString &dr, const QString& typ, const QString& typName, int depth) |
1080 | { | 1080 | { |
1081 | depth++; | 1081 | depth++; |
1082 | if ( depth > 10 ) | 1082 | if ( depth > 10 ) |
1083 | return; | 1083 | return; |
1084 | 1084 | ||
1085 | QDir dir( dr ); | 1085 | QDir dir( dr ); |
1086 | QString typNameLocal = typName; | 1086 | QString typNameLocal = typName; |
1087 | 1087 | ||
1088 | if ( dir.exists( ".directory" ) ) { | 1088 | if ( dir.exists( ".directory" ) ) { |
1089 | Config config( dr + "/.directory", Config::File ); | 1089 | Config config( dr + "/.directory", Config::File ); |
1090 | config.setGroup( "Desktop Entry" ); | 1090 | config.setGroup( "Desktop Entry" ); |
1091 | typNameLocal = config.readEntry( "Name", typNameLocal ); | 1091 | typNameLocal = config.readEntry( "Name", typNameLocal ); |
1092 | if ( !typ.isEmpty() ) { | 1092 | if ( !typ.isEmpty() ) { |
1093 | QString iconFile = config.readEntry( "Icon", "AppsIcon" ); | 1093 | QString iconFile = config.readEntry( "Icon", "AppsIcon" ); |
1094 | QImage unscaledIcon = Resource::loadImage( iconFile ); | 1094 | QImage unscaledIcon = Resource::loadImage( iconFile ); |
1095 | QPixmap pm, bpm; | 1095 | QPixmap pm, bpm; |
1096 | pm.convertFromImage( unscaledIcon.smoothScale( smallSize, smallSize ) ); | 1096 | pm.convertFromImage( unscaledIcon.smoothScale( smallSize, smallSize ) ); |
1097 | bpm.convertFromImage( unscaledIcon.smoothScale( bigSize, bigSize ) ); | 1097 | bpm.convertFromImage( unscaledIcon.smoothScale( bigSize, bigSize ) ); |
1098 | d->typPix.insert(typ, new QPixmap(pm)); | 1098 | d->typPix.insert(typ, new QPixmap(pm)); |
1099 | d->typPixBig.insert(typ, new QPixmap(bpm)); | 1099 | d->typPixBig.insert(typ, new QPixmap(bpm)); |
1100 | d->typName.insert(typ, new QString(typNameLocal)); | 1100 | d->typName.insert(typ, new QString(typNameLocal)); |
1101 | } | 1101 | } |
1102 | } | 1102 | } |
1103 | 1103 | ||
1104 | const QFileInfoList *list = dir.entryInfoList(); | 1104 | const QFileInfoList *list = dir.entryInfoList(); |
1105 | if ( list ) { | 1105 | if ( list ) { |
1106 | QFileInfo* fi; | 1106 | QFileInfo* fi; |
1107 | bool cadded=FALSE; | 1107 | bool cadded=FALSE; |
1108 | for ( QFileInfoListIterator it(*list); (fi=*it); ++it ) { | 1108 | for ( QFileInfoListIterator it(*list); (fi=*it); ++it ) { |
1109 | QString bn = fi->fileName(); | 1109 | QString bn = fi->fileName(); |
1110 | if ( bn[0] != '.' && bn != "CVS" ) { | 1110 | // qDebug("findChildren "+bn); |
1111 | if ( fi->isDir() ) { | 1111 | if ( bn[0] != '.' && bn != "CVS" ) { |
1112 | QString c = typ.isNull() ? bn : typ+"/"+bn; | 1112 | if ( fi->isDir() ) { |
1113 | QString d = typNameLocal.isNull() ? bn : typNameLocal+"/"+bn; | 1113 | QString c = typ.isNull() ? bn : typ+"/"+bn; |
1114 | findChildren(fi->filePath(), c, d, depth ); | 1114 | QString d = typNameLocal.isNull() ? bn : typNameLocal+"/"+bn; |
1115 | } else { | 1115 | findChildren(fi->filePath(), c, d, depth ); |
1116 | if ( fi->extension(FALSE) == "desktop" ) { | 1116 | } else { |
1117 | AppLnk* app = new AppLnk( fi->filePath() ); | 1117 | if ( fi->extension(FALSE) == "desktop" ) { |
1118 | AppLnk* app = new AppLnk( fi->filePath() ); | ||
1118 | #ifdef QT_NO_QWS_MULTIPROCESS | 1119 | #ifdef QT_NO_QWS_MULTIPROCESS |
1119 | if ( !Global::isBuiltinCommand( app->exec() ) ) | 1120 | if ( !Global::isBuiltinCommand( app->exec() ) ) |
1120 | delete app; | 1121 | delete app; |
1121 | else | 1122 | else |
1122 | #endif | 1123 | #endif |
1123 | { | 1124 | { |
1124 | if ( !typ.isEmpty() ) { | 1125 | if ( !typ.isEmpty() ) { |
1125 | if ( !cadded ) { | 1126 | if ( !cadded ) { |
1126 | typs.append(typ); | 1127 | typs.append(typ); |
1127 | cadded = TRUE; | 1128 | cadded = TRUE; |
1128 | } | 1129 | } |
1129 | app->setType(typ); | 1130 | app->setType(typ); |
1130 | } | 1131 | } |
1131 | add(app); | 1132 | add(app); |
1132 | } | 1133 | } |
1133 | } | 1134 | } |
1134 | } | 1135 | } |
1135 | } | 1136 | } |
1136 | } | 1137 | } |
1137 | } | 1138 | } |
1138 | } | 1139 | } |
1139 | 1140 | ||
1140 | /*! | 1141 | /*! |
1141 | Adds AppLnk \a f to the set. The set takes responsibility for | 1142 | Adds AppLnk \a f to the set. The set takes responsibility for |
1142 | deleting \a f. | 1143 | deleting \a f. |
1143 | 1144 | ||
1144 | \sa remove() | 1145 | \sa remove() |
1145 | */ | 1146 | */ |
1146 | void AppLnkSet::add( AppLnk *f ) | 1147 | void AppLnkSet::add( AppLnk *f ) |
1147 | { | 1148 | { |
1148 | if ( f->mId == 0 ) { | 1149 | if ( f->mId == 0 ) { |
1149 | AppLnk::lastId++; | 1150 | AppLnk::lastId++; |
1150 | f->mId = AppLnk::lastId; | 1151 | f->mId = AppLnk::lastId; |
1151 | mApps.append( f ); | 1152 | mApps.append( f ); |
1152 | } else { | 1153 | } else { |
1153 | qWarning("Attempt to add an AppLnk twice"); | 1154 | qWarning("Attempt to add an AppLnk twice"); |
1154 | } | 1155 | } |
1155 | } | 1156 | } |
1156 | 1157 | ||
1157 | /*! | 1158 | /*! |
1158 | Removes AppLnk \a f to the set. The caller becomes responsible for | 1159 | Removes AppLnk \a f to the set. The caller becomes responsible for |
1159 | deleting \a f. Returns TRUE if \a f was in the set; otherwise | 1160 | deleting \a f. Returns TRUE if \a f was in the set; otherwise |
@@ -1161,14 +1162,14 @@ void AppLnkSet::add( AppLnk *f ) | |||
1161 | 1162 | ||
1162 | \sa add() | 1163 | \sa add() |
1163 | */ | 1164 | */ |
1164 | bool AppLnkSet::remove( AppLnk *f ) | 1165 | bool AppLnkSet::remove( AppLnk *f ) |
1165 | { | 1166 | { |
1166 | if ( mApps.remove( f ) ) { | 1167 | if ( mApps.remove( f ) ) { |
1167 | f->mId = 0; | 1168 | f->mId = 0; |
1168 | return TRUE; | 1169 | return TRUE; |
1169 | } | 1170 | } |
1170 | return FALSE; | 1171 | return FALSE; |
1171 | } | 1172 | } |
1172 | 1173 | ||
1173 | 1174 | ||
1174 | /*! | 1175 | /*! |
@@ -1212,15 +1213,15 @@ QPixmap AppLnkSet::typeBigPixmap( const QString& t ) const | |||
1212 | */ | 1213 | */ |
1213 | const AppLnk *AppLnkSet::find( int id ) const | 1214 | const AppLnk *AppLnkSet::find( int id ) const |
1214 | { | 1215 | { |
1215 | QListIterator<AppLnk> it( children() ); | 1216 | QListIterator<AppLnk> it( children() ); |
1216 | 1217 | ||
1217 | for ( ; it.current(); ++it ) { | 1218 | for ( ; it.current(); ++it ) { |
1218 | const AppLnk *app = it.current(); | 1219 | const AppLnk *app = it.current(); |
1219 | if ( app->id() == id ) | 1220 | if ( app->id() == id ) |
1220 | return app; | 1221 | return app; |
1221 | } | 1222 | } |
1222 | 1223 | ||
1223 | return 0; | 1224 | return 0; |
1224 | } | 1225 | } |
1225 | 1226 | ||
1226 | /*! | 1227 | /*! |
@@ -1228,15 +1229,15 @@ const AppLnk *AppLnkSet::find( int id ) const | |||
1228 | */ | 1229 | */ |
1229 | const AppLnk *AppLnkSet::findExec( const QString& exec ) const | 1230 | const AppLnk *AppLnkSet::findExec( const QString& exec ) const |
1230 | { | 1231 | { |
1231 | QListIterator<AppLnk> it( children() ); | 1232 | QListIterator<AppLnk> it( children() ); |
1232 | 1233 | ||
1233 | for ( ; it.current(); ++it ) { | 1234 | for ( ; it.current(); ++it ) { |
1234 | const AppLnk *app = it.current(); | 1235 | const AppLnk *app = it.current(); |
1235 | if ( app->exec() == exec ) | 1236 | if ( app->exec() == exec ) |
1236 | return app; | 1237 | return app; |
1237 | } | 1238 | } |
1238 | 1239 | ||
1239 | return 0; | 1240 | return 0; |
1240 | } | 1241 | } |
1241 | 1242 | ||
1242 | /*! | 1243 | /*! |
@@ -1278,113 +1279,112 @@ DocLnkSet::DocLnkSet( const QString &directory, const QString& mimefilter ) : | |||
1278 | mFile = dir.dirName(); | 1279 | mFile = dir.dirName(); |
1279 | QDict<void> reference; | 1280 | QDict<void> reference; |
1280 | 1281 | ||
1281 | QStringList subFilter = QStringList::split(";", mimefilter); | 1282 | QStringList subFilter = QStringList::split(";", mimefilter); |
1282 | QValueList<QRegExp> mimeFilters; | 1283 | QValueList<QRegExp> mimeFilters; |
1283 | for( QStringList::Iterator it = subFilter.begin(); it != subFilter.end(); ++ it ) | 1284 | for( QStringList::Iterator it = subFilter.begin(); it != subFilter.end(); ++ it ) |
1284 | mimeFilters.append( QRegExp(*it, FALSE, TRUE) ); | 1285 | mimeFilters.append( QRegExp(*it, FALSE, TRUE) ); |
1285 | 1286 | ||
1286 | findChildren(directory, mimeFilters, reference); | 1287 | findChildren(directory, mimeFilters, reference); |
1287 | 1288 | ||
1288 | const QList<DocLnk> &list = children(); | 1289 | const QList<DocLnk> &list = children(); |
1289 | for ( QListIterator<DocLnk> it( list ); it.current(); ++it ) { | 1290 | for ( QListIterator<DocLnk> it( list ); it.current(); ++it ) { |
1290 | reference.remove( (*it)->file() ); | 1291 | reference.remove( (*it)->file() ); |
1291 | } | 1292 | } |
1292 | |||
1293 | for ( QDictIterator<void> dit(reference); dit.current(); ++dit ) { | 1293 | for ( QDictIterator<void> dit(reference); dit.current(); ++dit ) { |
1294 | if ( dit.current() == (void*)2 ) { | 1294 | if ( dit.current() == (void*)2 ) { |
1295 | // Unreferenced, make an unwritten link | 1295 | // Unreferenced, make an unwritten link |
1296 | DocLnk* dl = new DocLnk; | 1296 | DocLnk* dl = new DocLnk; |
1297 | QFileInfo fi( dit.currentKey() ); | 1297 | QFileInfo fi( dit.currentKey() ); |
1298 | dl->setFile(fi.filePath()); | 1298 | dl->setFile(fi.filePath()); |
1299 | dl->setName(fi.baseName()); | 1299 | dl->setName(fi.baseName()); |
1300 | // #### default to current path? | 1300 | // #### default to current path? |
1301 | // dl->setCategories( ... ); | 1301 | // dl->setCategories( ... ); |
1302 | bool match = mimefilter.isNull(); | 1302 | bool match = mimefilter.isNull(); |
1303 | if ( !match ) | 1303 | if ( !match ) |
1304 | for( QValueList<QRegExp>::Iterator it = mimeFilters.begin(); it != mimeFilters.end() && !match; ++ it ) | 1304 | for( QValueList<QRegExp>::Iterator it = mimeFilters.begin(); it != mimeFilters.end() && !match; ++ it ) |
1305 | if ( (*it).match(dl->type()) >= 0 ) | 1305 | if ( (*it).match(dl->type()) >= 0 ) |
1306 | match = TRUE; | 1306 | match = TRUE; |
1307 | if ( match /* && dl->type() != "application/octet-stream" */ | 1307 | if ( match /* && dl->type() != "application/octet-stream" */ |
1308 | && !!dl->exec() ) | 1308 | && !!dl->exec() ) |
1309 | add(dl); | 1309 | add(dl); |
1310 | else | 1310 | else |
1311 | delete dl; | 1311 | delete dl; |
1312 | } | 1312 | } |
1313 | } | 1313 | } |
1314 | } | 1314 | } |
1315 | 1315 | ||
1316 | // other becomes empty | 1316 | // other becomes empty |
1317 | /*! | 1317 | /*! |
1318 | Transfers all DocLnk objects from \a other to this set. \a other becomes | 1318 | Transfers all DocLnk objects from \a other to this set. \a other becomes |
1319 | empty. | 1319 | empty. |
1320 | */ | 1320 | */ |
1321 | void DocLnkSet::appendFrom( DocLnkSet& other ) | 1321 | void DocLnkSet::appendFrom( DocLnkSet& other ) |
1322 | { | 1322 | { |
1323 | if ( &other == this ) | 1323 | if ( &other == this ) |
1324 | return; | 1324 | return; |
1325 | QListIterator<AppLnk> it( other.mApps ); | 1325 | QListIterator<AppLnk> it( other.mApps ); |
1326 | for ( ; it.current(); ) { | 1326 | for ( ; it.current(); ) { |
1327 | mApps.append(*it); | 1327 | mApps.append(*it); |
1328 | ++it; | 1328 | ++it; |
1329 | } | 1329 | } |
1330 | other.mApps.clear(); | 1330 | other.mApps.clear(); |
1331 | } | 1331 | } |
1332 | 1332 | ||
1333 | void DocLnkSet::findChildren(const QString &dr, const QValueList<QRegExp> &mimeFilters, QDict<void> &reference, int depth) | 1333 | void DocLnkSet::findChildren(const QString &dr, const QValueList<QRegExp> &mimeFilters, QDict<void> &reference, int depth) |
1334 | { | 1334 | { |
1335 | depth++; | 1335 | depth++; |
1336 | if ( depth > 10 ) | 1336 | if ( depth > 10 ) |
1337 | return; | 1337 | return; |
1338 | 1338 | ||
1339 | QDir dir( dr ); | 1339 | QDir dir( dr ); |
1340 | 1340 | ||
1341 | /* Opie got a different approach | 1341 | /* Opie got a different approach |
1342 | * I guess it's geek vs. consumer | 1342 | * I guess it's geek vs. consumer |
1343 | * in this case to be discussed | 1343 | * in this case to be discussed |
1344 | */ | 1344 | */ |
1345 | if ( dir.exists( ".Qtopia-ignore" ) ) | 1345 | if ( dir.exists( ".Qtopia-ignore" ) ) |
1346 | return; | 1346 | return; |
1347 | 1347 | ||
1348 | const QFileInfoList *list = dir.entryInfoList(); | 1348 | const QFileInfoList *list = dir.entryInfoList(); |
1349 | if ( list ) { | 1349 | if ( list ) { |
1350 | QFileInfo* fi; | 1350 | QFileInfo* fi; |
1351 | for ( QFileInfoListIterator it(*list); (fi=*it); ++it ) { | 1351 | for ( QFileInfoListIterator it(*list); (fi=*it); ++it ) { |
1352 | QString bn = fi->fileName(); | 1352 | QString bn = fi->fileName(); |
1353 | if ( bn[0] != '.' ) { | 1353 | if ( bn[0] != '.' ) { |
1354 | if ( fi->isDir() ) { | 1354 | if ( fi->isDir() ) { |
1355 | if ( bn != "CVS" && bn != "Qtopia" && bn != "QtPalmtop" ) | 1355 | if ( bn != "CVS" && bn != "Qtopia" && bn != "QtPalmtop" ) |
1356 | findChildren(fi->filePath(), mimeFilters, reference, depth); | 1356 | findChildren(fi->filePath(), mimeFilters, reference, depth); |
1357 | } else { | 1357 | } else { |
1358 | if ( fi->extension(FALSE) == "desktop" ) { | 1358 | if ( fi->extension(FALSE) == "desktop" ) { |
1359 | DocLnk* dl = new DocLnk( fi->filePath() ); | 1359 | DocLnk* dl = new DocLnk( fi->filePath() ); |
1360 | QFileInfo fi2(dl->file()); | 1360 | QFileInfo fi2(dl->file()); |
1361 | bool match = FALSE; | 1361 | bool match = FALSE; |
1362 | if ( !fi2.exists() ) { | 1362 | if ( !fi2.exists() ) { |
1363 | dir.remove( dl->file() ); | 1363 | dir.remove( dl->file() ); |
1364 | } | 1364 | } |
1365 | if ( mimeFilters.count() == 0 ) { | 1365 | if ( mimeFilters.count() == 0 ) { |
1366 | add( dl ); | 1366 | add( dl ); |
1367 | match = TRUE; | 1367 | match = TRUE; |
1368 | } else { | 1368 | } else { |
1369 | for( QValueList<QRegExp>::ConstIterator it = mimeFilters.begin(); it != mimeFilters.end(); ++ it ) { | 1369 | for( QValueList<QRegExp>::ConstIterator it = mimeFilters.begin(); it != mimeFilters.end(); ++ it ) { |
1370 | if ( (*it).match(dl->type()) >= 0 ) { | 1370 | if ( (*it).match(dl->type()) >= 0 ) { |
1371 | add(dl); | 1371 | add(dl); |
1372 | match = TRUE; | 1372 | match = TRUE; |
1373 | } | 1373 | } |
1374 | } | 1374 | } |
1375 | } | 1375 | } |
1376 | if ( !match ) | 1376 | if ( !match ) |
1377 | delete dl; | 1377 | delete dl; |
1378 | } else { | 1378 | } else { |
1379 | if ( !reference.find(fi->fileName()) ) | 1379 | if ( !reference.find(fi->fileName()) ) |
1380 | reference.insert(fi->filePath(), (void*)2); | 1380 | reference.insert(fi->filePath(), (void*)2); |
1381 | } | 1381 | } |
1382 | } | 1382 | } |
1383 | } | 1383 | } |
1384 | } | 1384 | } |
1385 | } | 1385 | } |
1386 | } | 1386 | } |
1387 | 1387 | ||
1388 | /*! | 1388 | /*! |
1389 | \class DocLnk applnk.h | 1389 | \class DocLnk applnk.h |
1390 | \brief The DocLnk class represents loaded document references. | 1390 | \brief The DocLnk class represents loaded document references. |
@@ -1419,37 +1419,37 @@ DocLnk::DocLnk( const QString &file, bool may_be_desktopfile ) : | |||
1419 | } | 1419 | } |
1420 | 1420 | ||
1421 | void DocLnk::init(const QString &file) | 1421 | void DocLnk::init(const QString &file) |
1422 | { | 1422 | { |
1423 | if ( isValid() ) { | 1423 | if ( isValid() ) { |
1424 | #ifndef FORCED_DIR_STRUCTURE_WAY | 1424 | #ifndef FORCED_DIR_STRUCTURE_WAY |
1425 | if ( mType.isNull() ) | 1425 | if ( mType.isNull() ) |
1426 | // try to infer it | 1426 | // try to infer it |
1427 | #endif | 1427 | #endif |
1428 | { | 1428 | { |
1429 | int s0 = file.findRev('/'); | 1429 | int s0 = file.findRev('/'); |
1430 | if ( s0 > 0 ) { | 1430 | if ( s0 > 0 ) { |
1431 | int s1 = file.findRev('/',s0-1); | 1431 | int s1 = file.findRev('/',s0-1); |
1432 | if ( s1 > 0 ) { | 1432 | if ( s1 > 0 ) { |
1433 | int s2 = file.findRev('/',s1-1); | 1433 | int s2 = file.findRev('/',s1-1); |
1434 | if ( s2 > 0 ) { | 1434 | if ( s2 > 0 ) { |
1435 | mType = file.mid(s2+1,s0-s2-1); | 1435 | mType = file.mid(s2+1,s0-s2-1); |
1436 | } | 1436 | } |
1437 | } | 1437 | } |
1438 | } | 1438 | } |
1439 | } | 1439 | } |
1440 | } else if ( QFile::exists(file) ) { | 1440 | } else if ( QFile::exists(file) ) { |
1441 | QString n = file; | 1441 | QString n = file; |
1442 | n.replace(QRegExp(".*/"),""); | 1442 | n.replace(QRegExp(".*/"),""); |
1443 | n.replace(QRegExp("\\..*"),""); | 1443 | n.replace(QRegExp("\\..*"),""); |
1444 | setName( n ); | 1444 | setName( n ); |
1445 | setFile( file ); | 1445 | setFile( file ); |
1446 | } | 1446 | } |
1447 | MimeType mt(mType); | 1447 | MimeType mt(mType); |
1448 | if( mt.application() ) | 1448 | if( mt.application() ) |
1449 | mExec = mt.application()->exec(); | 1449 | mExec = mt.application()->exec(); |
1450 | } | 1450 | } |
1451 | 1451 | ||
1452 | /*! | 1452 | /*! |
1453 | Constructs an invalid DocLnk. | 1453 | Constructs an invalid DocLnk. |
1454 | */ | 1454 | */ |
1455 | DocLnk::DocLnk() | 1455 | DocLnk::DocLnk() |
@@ -1469,29 +1469,29 @@ DocLnk::~DocLnk() | |||
1469 | */ | 1469 | */ |
1470 | QString DocLnk::exec() const | 1470 | QString DocLnk::exec() const |
1471 | { | 1471 | { |
1472 | MimeType mt(type()); | 1472 | MimeType mt(type()); |
1473 | const AppLnk* app = mt.application(); | 1473 | const AppLnk* app = mt.application(); |
1474 | if ( app ) | 1474 | if ( app ) |
1475 | return app->exec(); | 1475 | return app->exec(); |
1476 | else | 1476 | else |
1477 | return QString::null; | 1477 | return QString::null; |
1478 | } | 1478 | } |
1479 | 1479 | ||
1480 | /*! | 1480 | /*! |
1481 | \reimp | 1481 | \reimp |
1482 | */ | 1482 | */ |
1483 | void DocLnk::invoke(const QStringList& args) const | 1483 | void DocLnk::invoke(const QStringList& args) const |
1484 | { | 1484 | { |
1485 | MimeType mt(type()); | 1485 | MimeType mt(type()); |
1486 | const AppLnk* app = mt.application(); | 1486 | const AppLnk* app = mt.application(); |
1487 | if ( app ) { | 1487 | if ( app ) { |
1488 | QStringList a = args; | 1488 | QStringList a = args; |
1489 | if ( linkFileKnown() && QFile::exists( linkFile() ) ) | 1489 | if ( linkFileKnown() && QFile::exists( linkFile() ) ) |
1490 | a.append(linkFile()); | 1490 | a.append(linkFile()); |
1491 | else | 1491 | else |
1492 | a.append(file()); | 1492 | a.append(file()); |
1493 | app->execute(a); | 1493 | app->execute(a); |
1494 | } | 1494 | } |
1495 | } | 1495 | } |
1496 | 1496 | ||
1497 | 1497 | ||