applnk.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __APPLNK_H__
00021 #define __APPLNK_H__
00022
00023 #include <qobject.h>
00024 #include <qiconset.h>
00025 #include <qlist.h>
00026 #include <qdict.h>
00027 #include <qstringlist.h>
00028
00029 class AppLnkSetPrivate;
00030 class AppLnkPrivate;
00031
00032 class AppLnk
00033 {
00034 public:
00035 AppLnk();
00036 AppLnk( const QString &file );
00037 AppLnk( const AppLnk © );
00038 virtual ~AppLnk();
00039
00040 bool isValid() const { return !mLinkFile.isNull(); }
00041
00042 static void setSmallIconSize(int);
00043 static void setBigIconSize(int);
00044 static int smallIconSize();
00045 static int bigIconSize();
00046
00047 QString name() const { return mName; }
00048 const QPixmap& pixmap() const;
00049 const QPixmap& bigPixmap() const;
00050 QString icon() const { return mIconFile; }
00051 virtual QString exec() const { return mExec; }
00052 QString type() const;
00053 QString rotation() const { return mRotation; }
00054 QString comment() const { return mComment; }
00055 QString file() const;
00056 QString linkFile() const;
00057 QStringList mimeTypes() const { return mMimeTypes; }
00058 QStringList mimeTypeIcons() const { return mMimeTypeIcons; }
00059 const QArray<int> &categories() const;
00060 int id() const { return mId; }
00061
00062 bool fileKnown() const { return !mFile.isNull(); }
00063 bool linkFileKnown() const { return !mLinkFile.isNull(); }
00064
00065 void execute() const;
00066 void execute(const QStringList& args) const;
00067 void removeFiles();
00068 void removeLinkFile();
00069
00070 void setName( const QString& docname );
00071 void setExec( const QString& exec );
00072 void setFile( const QString& filename );
00073 void setLinkFile( const QString& filename );
00074 void setComment( const QString& comment );
00075 void setType( const QString& mimetype );
00076 inline void setRotation ( const QString &rot ) { mRotation = rot; }
00077 void setIcon( const QString& iconname );
00078 void setCategories( const QArray<int> &v );
00079 bool writeLink() const;
00080
00081 void setProperty(const QString& key, const QString& value);
00082 QString property(const QString& key) const;
00083
00084 #ifdef QTOPIA_INTERNAL_PRELOADACCESS
00085 bool isPreloaded() const;
00086 void setPreloaded(bool yesNo);
00087 #endif
00088
00089 AppLnk &operator=(const AppLnk &other);
00090
00091 protected:
00092 QString mName;
00093
00094
00095 QPixmap mPixmap;
00096
00097
00098 QPixmap mBigPixmap;
00099
00100 QString mExec;
00101 QString mType;
00102 QString mRotation;
00103 QString mComment;
00104 QString mFile;
00105 QString mLinkFile;
00106 QString mIconFile;
00107 QStringList mMimeTypes;
00108 QStringList mMimeTypeIcons;
00109 int mId;
00110 static int lastId;
00111 AppLnkPrivate *d;
00112 friend class AppLnkSet;
00113
00114 virtual void invoke(const QStringList& args) const;
00115 bool ensureLinkExists() const;
00116 void storeLink() const;
00117
00118 private:
00119 const QPixmap& pixmap(int pos, int size) const;
00120 };
00121
00122 class DocLnk : public AppLnk
00123 {
00124 public:
00125 DocLnk();
00126 DocLnk( const DocLnk &o ) : AppLnk(o) { }
00127 DocLnk( const QString &file );
00128 DocLnk( const QString &file, bool may_be_desktopfile );
00129 virtual ~DocLnk();
00130
00131
00132 #ifdef QTOPIA_INTERNAL_APPLNKASSIGN
00133 DocLnk &operator=(const DocLnk &other) { AppLnk::operator=(other); return *this; }
00134 #endif
00135
00136 QString exec() const;
00137
00138 protected:
00139 void invoke(const QStringList& args) const;
00140
00141 private:
00142 void init(const QString &file);
00143 };
00144
00145 class AppLnkSet
00146 {
00147 public:
00148 AppLnkSet();
00149 AppLnkSet( const QString &dir );
00150 ~AppLnkSet();
00151
00152 const AppLnk *find( int id ) const;
00153 const AppLnk *findExec( const QString& execname ) const;
00154
00155 QStringList types() const { return typs; }
00156 QString typeName( const QString& ) const;
00157 QPixmap typePixmap( const QString& ) const;
00158 QPixmap typeBigPixmap( const QString& ) const;
00159
00160 void add(AppLnk*);
00161 bool remove(AppLnk*);
00162 void clear() {
00163 QListIterator<AppLnk> it( mApps );
00164 for ( ; it.current(); ) {
00165 AppLnk* a = *it;
00166 ++it;
00167 a->mId = 0;
00168 delete a;
00169 }
00170 mApps.clear();
00171 typs.clear();
00172 }
00173
00174 const QList<AppLnk> &children() const { return mApps; }
00175 void detachChildren();
00176
00177 protected:
00178 friend class AppLnk;
00179 QList<AppLnk> mApps;
00180 QString mFile;
00181 QStringList typs;
00182 AppLnkSetPrivate *d;
00183
00184 private:
00185 AppLnkSet( const AppLnkSet & );
00186 void findChildren(const QString &, const QString& t, const QString& lt, int depth = 0);
00187 };
00188
00189 class DocLnkSet : public AppLnkSet
00190 {
00191 public:
00192 DocLnkSet();
00193 DocLnkSet( const QString &dir, const QString &mimefilter=QString::null );
00194
00195 const QList<DocLnk> &children() const { return (const QList<DocLnk> &)mApps; }
00196
00197 void appendFrom( DocLnkSet& other );
00198
00199 private:
00200 DocLnkSet( const DocLnkSet & );
00201 void findChildren(const QString &dr, const QValueList<QRegExp> &mimeFilters, QDict<void> &reference, int depth=0);
00202 };
00203
00204
00205 #endif // __APPLNK_H__
00206
This file is part of the documentation for OPIE Version 1.5.5.