summaryrefslogtreecommitdiff
path: root/library/applnk.cpp
authorllornkcor <llornkcor>2003-05-04 13:12:11 (UTC)
committer llornkcor <llornkcor>2003-05-04 13:12:11 (UTC)
commit8409a251d52b59585889e1bcaa278a6b847db2fc (patch) (unidiff)
tree50f085a116cdb739705aa3c40ceececc99833465 /library/applnk.cpp
parent8489a583d5b762c5530076271ee3c3be7011b9ef (diff)
downloadopie-8409a251d52b59585889e1bcaa278a6b847db2fc.zip
opie-8409a251d52b59585889e1bcaa278a6b847db2fc.tar.gz
opie-8409a251d52b59585889e1bcaa278a6b847db2fc.tar.bz2
remove debug message - Cannot find icon
Diffstat (limited to 'library/applnk.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--library/applnk.cpp712
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
@@ -51,3 +51,3 @@ 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.]"),"_");
@@ -55,3 +55,3 @@ static QString safeFileName(const QString& n)
55 if ( safename.isEmpty() ) 55 if ( safename.isEmpty() )
56 safename = "_"; 56 safename = "_";
57 return safename; 57 return safename;
@@ -62,6 +62,6 @@ static bool prepareDirectories(const QString& lf)
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 }
@@ -89,5 +89,5 @@ public:
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();
@@ -100,3 +100,3 @@ public:
100 { 100 {
101 mCat.resize(0); 101 mCat.resize(0);
102 } 102 }
@@ -105,22 +105,22 @@ public:
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 }
@@ -188,19 +188,19 @@ public:
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
@@ -372,52 +372,52 @@ AppLnk::AppLnk( const QString &file )
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 }
@@ -430,5 +430,5 @@ AppLnk& AppLnk::operator=(const AppLnk &copy)
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
@@ -465,23 +465,23 @@ 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 }
@@ -524,9 +524,9 @@ QString AppLnk::type() const
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 }
@@ -543,14 +543,14 @@ QString AppLnk::file() const
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 /*
@@ -558,20 +558,20 @@ QString AppLnk::file() const
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 }
@@ -588,6 +588,6 @@ QString AppLnk::linkFile() const
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
@@ -595,10 +595,10 @@ QString AppLnk::linkFile() const
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" );
@@ -618,7 +618,7 @@ QString AppLnk::linkFile() const
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 }
@@ -660,5 +660,5 @@ AppLnk::~AppLnk()
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}
@@ -686,12 +686,12 @@ void AppLnk::execute(const QStringList& args) const
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}
@@ -728,3 +728,3 @@ void AppLnk::setRotation ( const QString &rot )
728{ 728{
729 mRotation = rot; 729 mRotation = rot;
730} 730}
@@ -855,3 +855,3 @@ bool AppLnk::writeLink() const
855 if ( !ensureLinkExists() ) 855 if ( !ensureLinkExists() )
856 return FALSE; 856 return FALSE;
857 storeLink(); 857 storeLink();
@@ -871,5 +871,5 @@ void AppLnk::storeLink() const
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);
@@ -878,8 +878,8 @@ void AppLnk::storeLink() const
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
@@ -902,4 +902,4 @@ void AppLnk::setProperty(const QString& key, const QString& value)
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 }
@@ -916,3 +916,3 @@ QString AppLnk::property(const QString& key) const
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);
@@ -953,14 +953,14 @@ void AppLnk::removeFiles()
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 }
@@ -977,4 +977,4 @@ void AppLnk::removeLinkFile()
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
@@ -987,5 +987,5 @@ public:
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 }
@@ -1054,5 +1054,5 @@ void AppLnkSet::detachChildren()
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 }
@@ -1070,6 +1070,6 @@ AppLnkSet::~AppLnkSet()
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 }
@@ -1082,3 +1082,3 @@ void AppLnkSet::findChildren(const QString &dr, const QString& typ, const QStrin
1082 if ( depth > 10 ) 1082 if ( depth > 10 )
1083 return; 1083 return;
1084 1084
@@ -1088,15 +1088,15 @@ void AppLnkSet::findChildren(const QString &dr, const QString& typ, const QStrin
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 }
@@ -1105,33 +1105,34 @@ void AppLnkSet::findChildren(const QString &dr, const QString& typ, const QStrin
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 }
@@ -1148,7 +1149,7 @@ void AppLnkSet::add( AppLnk *f )
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 }
@@ -1166,4 +1167,4 @@ bool AppLnkSet::remove( AppLnk *f )
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 }
@@ -1217,5 +1218,5 @@ const AppLnk *AppLnkSet::find( int id ) const
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 }
@@ -1233,5 +1234,5 @@ const AppLnk *AppLnkSet::findExec( const QString& exec ) const
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 }
@@ -1283,3 +1284,3 @@ DocLnkSet::DocLnkSet( const QString &directory, const QString& mimefilter ) :
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
@@ -1289,25 +1290,24 @@ DocLnkSet::DocLnkSet( const QString &directory, const QString& mimefilter ) :
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 }
@@ -1323,7 +1323,7 @@ void DocLnkSet::appendFrom( DocLnkSet& other )
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 }
@@ -1336,3 +1336,3 @@ void DocLnkSet::findChildren(const QString &dr, const QValueList<QRegExp> &mimeF
1336 if ( depth > 10 ) 1336 if ( depth > 10 )
1337 return; 1337 return;
1338 1338
@@ -1345,3 +1345,3 @@ void DocLnkSet::findChildren(const QString &dr, const QValueList<QRegExp> &mimeF
1345 if ( dir.exists( ".Qtopia-ignore" ) ) 1345 if ( dir.exists( ".Qtopia-ignore" ) )
1346 return; 1346 return;
1347 1347
@@ -1349,37 +1349,37 @@ void DocLnkSet::findChildren(const QString &dr, const QValueList<QRegExp> &mimeF
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 }
@@ -1424,23 +1424,23 @@ void DocLnk::init(const QString &file)
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 }
@@ -1448,3 +1448,3 @@ void DocLnk::init(const QString &file)
1448 if( mt.application() ) 1448 if( mt.application() )
1449 mExec = mt.application()->exec(); 1449 mExec = mt.application()->exec();
1450} 1450}
@@ -1474,5 +1474,5 @@ QString DocLnk::exec() const
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}
@@ -1487,8 +1487,8 @@ void DocLnk::invoke(const QStringList& args) const
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 }