summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--library/applnk.cpp29
-rw-r--r--library/applnk.h5
2 files changed, 31 insertions, 3 deletions
diff --git a/library/applnk.cpp b/library/applnk.cpp
index 778ccab..9498f84 100644
--- a/library/applnk.cpp
+++ b/library/applnk.cpp
@@ -333,52 +333,52 @@ QString AppLnk::file() const
333 333
334 \sa file(), exec() 334 \sa file(), exec()
335*/ 335*/
336QString AppLnk::linkFile() const 336QString AppLnk::linkFile() const
337{ 337{
338 if ( mLinkFile.isNull() ) { 338 if ( mLinkFile.isNull() ) {
339 AppLnk* that = (AppLnk*)this; 339 AppLnk* that = (AppLnk*)this;
340 if ( type().contains('/') ) { 340 if ( type().contains('/') ) {
341 StorageInfo storage; 341 StorageInfo storage;
342 const FileSystem *fs = storage.fileSystemOf( that->mFile ); 342 const FileSystem *fs = storage.fileSystemOf( that->mFile );
343 if ( fs && ( fs->isRemovable() || fs->disk() == "/dev/mtdblock6" || fs->disk() == "tmpfs" ) ) { 343 if ( fs && ( fs->isRemovable() || fs->disk() == "/dev/mtdblock6" || fs->disk() == "tmpfs" ) ) {
344 that->mLinkFile = fs->path(); 344 that->mLinkFile = fs->path();
345 } else 345 } else
346 that->mLinkFile = getenv( "HOME" ); 346 that->mLinkFile = getenv( "HOME" );
347 that->mLinkFile += "/Documents/"+type()+"/"+safeFileName(that->mName); 347 that->mLinkFile += "/Documents/"+type()+"/"+safeFileName(that->mName);
348 if ( QFile::exists(that->mLinkFile+".desktop") ) { // ok the file exists lets check if we point to the same file 348 if ( QFile::exists(that->mLinkFile+".desktop") ) { // ok the file exists lets check if we point to the same file
349 int n=1; 349 int n=1;
350 QString nn; 350 QString nn;
351 AppLnk lnk( that->mLinkFile+".desktop" ); 351 AppLnk lnk( that->mLinkFile+".desktop" );
352 if(that->file() != lnk.file() ){ 352 if(that->file() != lnk.file() ){
353 qWarning("AppLnk::linkFile exists %s", that->mLinkFile.latin1() ); 353 qWarning("AppLnk::linkFile exists %s", that->mLinkFile.latin1() );
354 while (QFile::exists((nn=that->mLinkFile+"_"+QString::number(n))+".desktop")){ 354 while (QFile::exists((nn=that->mLinkFile+"_"+QString::number(n))+".desktop")){
355 n++; 355 n++;
356 AppLnk lnk(nn ); // just to be sure 356 AppLnk lnk(nn ); // just to be sure
357 if(lnk.file() ==that->file() ){ 357 if(lnk.file() ==that->file() ){
358 break; 358 break;
359 } 359 }
360 } 360 }
361 that->mLinkFile = nn; 361 that->mLinkFile = nn;
362 } 362 }
363 } 363 }
364 that->mLinkFile += ".desktop"; 364 that->mLinkFile += ".desktop";
365 qWarning("AppLnk::linkFile is %s", that->mLinkFile.latin1() ); 365 qWarning("AppLnk::linkFile is %s", that->mLinkFile.latin1() );
366 storeLink(); 366 storeLink();
367 } 367 }
368 return that->mLinkFile; 368 return that->mLinkFile;
369 } 369 }
370 return mLinkFile; 370 return mLinkFile;
371} 371}
372 372
373/*! 373/*!
374 Copies \a copy. 374 Copies \a copy.
375*/ 375*/
376AppLnk::AppLnk( const AppLnk &copy ) 376AppLnk::AppLnk( const AppLnk &copy )
377{ 377{
378 mName = copy.mName; 378 mName = copy.mName;
379 mPixmap = copy.mPixmap; 379 mPixmap = copy.mPixmap;
380 mBigPixmap = copy.mBigPixmap; 380 mBigPixmap = copy.mBigPixmap;
381 mExec = copy.mExec; 381 mExec = copy.mExec;
382 mType = copy.mType; 382 mType = copy.mType;
383 mRotation = copy.mRotation; 383 mRotation = copy.mRotation;
384 mComment = copy.mComment; 384 mComment = copy.mComment;
@@ -585,48 +585,71 @@ void AppLnk::storeLink() const
585/*! 585/*!
586 Sets the property named \a key to \a value. 586 Sets the property named \a key to \a value.
587*/ 587*/
588void AppLnk::setProperty(const QString& key, const QString& value) 588void AppLnk::setProperty(const QString& key, const QString& value)
589{ 589{
590 if ( ensureLinkExists() ) { 590 if ( ensureLinkExists() ) {
591 Config cfg(linkFile(), Config::File); 591 Config cfg(linkFile(), Config::File);
592 cfg.writeEntry(key,value); 592 cfg.writeEntry(key,value);
593 } 593 }
594} 594}
595 595
596/*! 596/*!
597 Returns the property named \a key. 597 Returns the property named \a key.
598*/ 598*/
599QString AppLnk::property(const QString& key) const 599QString AppLnk::property(const QString& key) const
600{ 600{
601 QString lf = linkFile(); 601 QString lf = linkFile();
602 if ( !QFile::exists(lf) ) 602 if ( !QFile::exists(lf) )
603 return QString::null; 603 return QString::null;
604 Config cfg(lf, Config::File); 604 Config cfg(lf, Config::File);
605 return cfg.readEntry(key); 605 return cfg.readEntry(key);
606} 606}
607 607
608 608
609bool AppLnk::isPreloaded() const {
610 // Preload information is stored in the Launcher config in v1.5.
611 Config cfg("Launcher");
612 cfg.setGroup("Preload");
613 QStringList apps = cfg.readListEntry("Apps",',');
614 if (apps.contains(exec()))
615 return true;
616 return false;
617}
618
619void AppLnk::setPreloaded(bool yesNo) {
620 // Preload information is stored in the Launcher config in v1.5.
621 Config cfg("Launcher");
622 cfg.setGroup("Preload");
623 QStringList apps = cfg.readListEntry("Apps", ',');
624 if (apps.contains(exec()) && !yesNo)
625 apps.remove(exec());
626 else if (yesNo && !apps.contains(exec()))
627 apps.append(exec());
628 cfg.writeEntry("Apps", apps, ',');
629}
630
631
609/*! 632/*!
610 Deletes both the linkFile() and file() associated with this AppLnk. 633 Deletes both the linkFile() and file() associated with this AppLnk.
611*/ 634*/
612void AppLnk::removeFiles() 635void AppLnk::removeFiles()
613{ 636{
614 bool valid = isValid(); 637 bool valid = isValid();
615 if ( !valid || !linkFileKnown() || QFile::remove(linkFile()) ) { 638 if ( !valid || !linkFileKnown() || QFile::remove(linkFile()) ) {
616 if ( QFile::remove(file()) ) { 639 if ( QFile::remove(file()) ) {
617 QCopEnvelope e("QPE/System", "linkChanged(QString)"); 640 QCopEnvelope e("QPE/System", "linkChanged(QString)");
618 if ( linkFileKnown() ) 641 if ( linkFileKnown() )
619 e << linkFile(); 642 e << linkFile();
620 else 643 else
621 e << file(); 644 e << file();
622 } else if ( valid ) { 645 } else if ( valid ) {
623 // restore link 646 // restore link
624 writeLink(); 647 writeLink();
625 } 648 }
626 } 649 }
627} 650}
628 651
629/*! 652/*!
630 Delete the linkFile(), leaving any file() untouched. 653 Delete the linkFile(), leaving any file() untouched.
631*/ 654*/
632void AppLnk::removeLinkFile() 655void AppLnk::removeLinkFile()
diff --git a/library/applnk.h b/library/applnk.h
index 18e20b6..9b5523e 100644
--- a/library/applnk.h
+++ b/library/applnk.h
@@ -57,48 +57,53 @@ public:
57 QStringList mimeTypeIcons() const { return mMimeTypeIcons; } 57 QStringList mimeTypeIcons() const { return mMimeTypeIcons; }
58 const QArray<int> &categories() const; 58 const QArray<int> &categories() const;
59 int id() const { return mId; } 59 int id() const { return mId; }
60 60
61 bool linkFileKnown() const { return !mLinkFile.isNull(); } 61 bool linkFileKnown() const { return !mLinkFile.isNull(); }
62 62
63 void execute() const; 63 void execute() const;
64 void execute(const QStringList& args) const; 64 void execute(const QStringList& args) const;
65 void removeFiles(); 65 void removeFiles();
66 void removeLinkFile(); 66 void removeLinkFile();
67 67
68 void setName( const QString& docname ); 68 void setName( const QString& docname );
69 void setExec( const QString& exec ); 69 void setExec( const QString& exec );
70 void setFile( const QString& filename ); 70 void setFile( const QString& filename );
71 void setLinkFile( const QString& filename ); 71 void setLinkFile( const QString& filename );
72 void setComment( const QString& comment ); 72 void setComment( const QString& comment );
73 void setType( const QString& mimetype ); 73 void setType( const QString& mimetype );
74 void setIcon( const QString& iconname ); 74 void setIcon( const QString& iconname );
75 void setCategories( const QArray<int> &v ); 75 void setCategories( const QArray<int> &v );
76 bool writeLink() const; 76 bool writeLink() const;
77 77
78 void setProperty(const QString& key, const QString& value); 78 void setProperty(const QString& key, const QString& value);
79 QString property(const QString& key) const; 79 QString property(const QString& key) const;
80 80
81//#ifdef QTOPIA_INTERNAL_PRELOADACCESS
82 bool isPreloaded() const;
83 void setPreloaded(bool yesNo);
84//#endif
85
81protected: 86protected:
82 QString mName; 87 QString mName;
83 QPixmap mPixmap; 88 QPixmap mPixmap;
84 QPixmap mBigPixmap; 89 QPixmap mBigPixmap;
85 QString mExec; 90 QString mExec;
86 QString mType; 91 QString mType;
87 QString mRotation; 92 QString mRotation;
88 QString mComment; 93 QString mComment;
89 QString mFile; 94 QString mFile;
90 QString mLinkFile; 95 QString mLinkFile;
91 QString mIconFile; 96 QString mIconFile;
92 QStringList mMimeTypes; 97 QStringList mMimeTypes;
93 QStringList mMimeTypeIcons; 98 QStringList mMimeTypeIcons;
94 int mId; 99 int mId;
95 static int lastId; 100 static int lastId;
96 AppLnkPrivate *d; 101 AppLnkPrivate *d;
97 friend class AppLnkSet; 102 friend class AppLnkSet;
98 103
99 virtual void invoke(const QStringList& args) const; 104 virtual void invoke(const QStringList& args) const;
100 bool ensureLinkExists() const; 105 bool ensureLinkExists() const;
101 void storeLink() const; 106 void storeLink() const;
102}; 107};
103 108
104class DocLnk : public AppLnk 109class DocLnk : public AppLnk