-rw-r--r-- | library/applnk.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/library/applnk.cpp b/library/applnk.cpp index 5763c62..35822dd 100644 --- a/library/applnk.cpp +++ b/library/applnk.cpp | |||
@@ -76,33 +76,37 @@ public: | |||
76 | AppLnkPrivate() { | 76 | AppLnkPrivate() { |
77 | /* we want one normal and one big item */ | 77 | /* we want one normal and one big item */ |
78 | 78 | ||
79 | QPixmap pix; | 79 | QPixmap pix; |
80 | mPixmaps.insert(0, pix ); | 80 | mPixmaps.insert(0, pix ); |
81 | mPixmaps.insert(1, pix); | 81 | mPixmaps.insert(1, pix); |
82 | } | 82 | } |
83 | 83 | ||
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 | mCatList = cat.labels("Document View",mCat); | 92 | // we need to update the names for the mCat... to mCatList |
93 | mCatList.clear(); | ||
94 | for (uint i = 0; i < mCat.count(); i++ ) | ||
95 | mCatList << cat.label("Document View", mCat[i] ); | ||
96 | |||
93 | } | 97 | } |
94 | 98 | ||
95 | void setCatArrayDirty() | 99 | void setCatArrayDirty() |
96 | { | 100 | { |
97 | mCat.resize(0); | 101 | mCat.resize(0); |
98 | } | 102 | } |
99 | 103 | ||
100 | void ensureCatArray() | 104 | void ensureCatArray() |
101 | { | 105 | { |
102 | if ( mCat.count() > 0 || mCatList.count()==0 ) | 106 | if ( mCat.count() > 0 || mCatList.count()==0 ) |
103 | return; | 107 | return; |
104 | 108 | ||
105 | Categories cat( 0 ); | 109 | Categories cat( 0 ); |
106 | cat.load( categoryFileName() ); | 110 | cat.load( categoryFileName() ); |
107 | mCat.resize( mCatList.count() ); | 111 | mCat.resize( mCatList.count() ); |
108 | int i; | 112 | int i; |
@@ -393,32 +397,33 @@ AppLnk::AppLnk( const QString &file ) | |||
393 | // convert from text | 397 | // convert from text |
394 | id = cat.id( "Document View", *it ); | 398 | id = cat.id( "Document View", *it ); |
395 | if ( id == 0 ) | 399 | if ( id == 0 ) |
396 | id = cat.addCategory( "Document View", *it ); | 400 | id = cat.addCategory( "Document View", *it ); |
397 | } | 401 | } |
398 | d->mCat[i] = id; | 402 | d->mCat[i] = id; |
399 | } | 403 | } |
400 | d->updateCatListFromArray(); | 404 | d->updateCatListFromArray(); |
401 | } | 405 | } |
402 | } | 406 | } |
403 | } | 407 | } |
404 | mId = 0; | 408 | mId = 0; |
405 | } | 409 | } |
406 | 410 | ||
407 | AppLnk& AppLnk::operator=(const AppLnk ©) | 411 | AppLnk& AppLnk::operator=(const AppLnk ©) |
408 | { | 412 | { |
413 | if ( this == © ) return *this; | ||
409 | if ( mId ) | 414 | if ( mId ) |
410 | qWarning("Deleting AppLnk that is in an AppLnkSet"); | 415 | qWarning("Deleting AppLnk that is in an AppLnkSet"); |
411 | if ( d ) | 416 | if ( d ) |
412 | delete d; | 417 | delete d; |
413 | 418 | ||
414 | 419 | ||
415 | mName = copy.mName; | 420 | mName = copy.mName; |
416 | 421 | ||
417 | /* remove for Qtopia 3.0 -zecke */ | 422 | /* remove for Qtopia 3.0 -zecke */ |
418 | mPixmap = copy.mPixmap; | 423 | mPixmap = copy.mPixmap; |
419 | mBigPixmap = copy.mBigPixmap; | 424 | mBigPixmap = copy.mBigPixmap; |
420 | 425 | ||
421 | mExec = copy.mExec; | 426 | mExec = copy.mExec; |
422 | mType = copy.mType; | 427 | mType = copy.mType; |
423 | mRotation = copy.mRotation; | 428 | mRotation = copy.mRotation; |
424 | mComment = copy.mComment; | 429 | mComment = copy.mComment; |
@@ -837,33 +842,33 @@ bool AppLnk::writeLink() const | |||
837 | return TRUE; | 842 | return TRUE; |
838 | } | 843 | } |
839 | 844 | ||
840 | /*! | 845 | /*! |
841 | \internal | 846 | \internal |
842 | */ | 847 | */ |
843 | void AppLnk::storeLink() const | 848 | void AppLnk::storeLink() const |
844 | { | 849 | { |
845 | Config config( mLinkFile, Config::File ); | 850 | Config config( mLinkFile, Config::File ); |
846 | config.setGroup("Desktop Entry"); | 851 | config.setGroup("Desktop Entry"); |
847 | config.writeEntry("Name",mName); | 852 | config.writeEntry("Name",mName); |
848 | if ( !mIconFile.isNull() ) config.writeEntry("Icon",mIconFile); | 853 | if ( !mIconFile.isNull() ) config.writeEntry("Icon",mIconFile); |
849 | config.writeEntry("Type",type()); | 854 | config.writeEntry("Type",type()); |
850 | if(!rotation().isEmpty()) | 855 | if(!rotation().isEmpty()) |
851 | config.writeEntry("Rotation",rotation()); | 856 | config.writeEntry("Rotation",rotation()); |
852 | else | 857 | else |
853 | config.removeEntry("Rotation"); | 858 | config.removeEntry("Rotation"); |
854 | if ( !mComment.isNull() ) config.writeEntry("Comment",mComment); | 859 | if ( !mComment.isNull() ) config.writeEntry("Comment",mComment); |
855 | QString f = file(); | 860 | QString f = file(); |
856 | int i = 0; | 861 | int i = 0; |
857 | while ( i < (int)f.length() && i < (int)mLinkFile.length() && f[i] == mLinkFile[i] ) | 862 | while ( i < (int)f.length() && i < (int)mLinkFile.length() && f[i] == mLinkFile[i] ) |
858 | i++; | 863 | i++; |
859 | while ( i && f[i] != '/' ) | 864 | while ( i && f[i] != '/' ) |
860 | i--; | 865 | i--; |
861 | // simple case where in the same directory | 866 | // simple case where in the same directory |
862 | if ( mLinkFile.find( '/', i + 1 ) < 0 ) | 867 | if ( mLinkFile.find( '/', i + 1 ) < 0 ) |
863 | f = f.mid(i+1); | 868 | f = f.mid(i+1); |
864 | // ### could do relative ie ../../otherDocs/file.doc | 869 | // ### could do relative ie ../../otherDocs/file.doc |
865 | config.writeEntry("File",f); | 870 | config.writeEntry("File",f); |
866 | config.writeEntry( "Categories", d->mCatList, ';' ); | 871 | config.writeEntry( "Categories", d->mCatList, ';' ); |
867 | 872 | ||
868 | #ifndef QT_NO_COP | 873 | #ifndef QT_NO_COP |
869 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); | 874 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); |