-rw-r--r-- | library/applnk.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/library/applnk.h b/library/applnk.h index c6f92a3..18e20b6 100644 --- a/library/applnk.h +++ b/library/applnk.h | |||
@@ -1,169 +1,172 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef __APPLNK_H__ | 20 | #ifndef __APPLNK_H__ |
21 | #define __APPLNK_H__ | 21 | #define __APPLNK_H__ |
22 | 22 | ||
23 | #include <qobject.h> | 23 | #include <qobject.h> |
24 | #include <qiconset.h> | 24 | #include <qiconset.h> |
25 | #include <qlist.h> | 25 | #include <qlist.h> |
26 | #include <qdict.h> | 26 | #include <qdict.h> |
27 | #include <qstringlist.h> | 27 | #include <qstringlist.h> |
28 | 28 | ||
29 | class AppLnkSetPrivate; | 29 | class AppLnkSetPrivate; |
30 | class AppLnkPrivate; | 30 | class AppLnkPrivate; |
31 | 31 | ||
32 | class AppLnk | 32 | class AppLnk |
33 | { | 33 | { |
34 | public: | 34 | public: |
35 | AppLnk(); | 35 | AppLnk(); |
36 | AppLnk( const QString &file ); | 36 | AppLnk( const QString &file ); |
37 | AppLnk( const AppLnk © ); // copy constructor | 37 | AppLnk( const AppLnk © ); // copy constructor |
38 | virtual ~AppLnk(); | 38 | virtual ~AppLnk(); |
39 | 39 | ||
40 | bool isValid() const { return !mLinkFile.isNull(); } | 40 | bool isValid() const { return !mLinkFile.isNull(); } |
41 | 41 | ||
42 | static void setSmallIconSize(int); | 42 | static void setSmallIconSize(int); |
43 | static void setBigIconSize(int); | 43 | static void setBigIconSize(int); |
44 | static int smallIconSize(); | 44 | static int smallIconSize(); |
45 | static int bigIconSize(); | 45 | static int bigIconSize(); |
46 | 46 | ||
47 | QString name() const { return mName; } | 47 | QString name() const { return mName; } |
48 | const QPixmap& pixmap() const; | 48 | const QPixmap& pixmap() const; |
49 | const QPixmap& bigPixmap() const; | 49 | const QPixmap& bigPixmap() const; |
50 | virtual QString exec() const { return mExec; } | 50 | virtual QString exec() const { return mExec; } |
51 | QString type() const; | 51 | QString type() const; |
52 | QString rotation() const { return mRotation; } | 52 | QString rotation() const { return mRotation; } |
53 | QString comment() const { return mComment; } | 53 | QString comment() const { return mComment; } |
54 | QString file() const; | 54 | QString file() const; |
55 | QString linkFile() const; | 55 | QString linkFile() const; |
56 | QStringList mimeTypes() const { return mMimeTypes; } | 56 | QStringList mimeTypes() const { return mMimeTypes; } |
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(); } | ||
62 | |||
61 | void execute() const; | 63 | void execute() const; |
62 | void execute(const QStringList& args) const; | 64 | void execute(const QStringList& args) const; |
63 | void removeFiles(); | 65 | void removeFiles(); |
64 | void removeLinkFile(); | 66 | void removeLinkFile(); |
65 | 67 | ||
66 | void setName( const QString& docname ); | 68 | void setName( const QString& docname ); |
67 | void setExec( const QString& exec ); | 69 | void setExec( const QString& exec ); |
68 | void setFile( const QString& filename ); | 70 | void setFile( const QString& filename ); |
69 | void setLinkFile( const QString& filename ); | 71 | void setLinkFile( const QString& filename ); |
70 | void setComment( const QString& comment ); | 72 | void setComment( const QString& comment ); |
71 | void setType( const QString& mimetype ); | 73 | void setType( const QString& mimetype ); |
72 | void setIcon( const QString& iconname ); | 74 | void setIcon( const QString& iconname ); |
73 | void setCategories( const QArray<int> &v ); | 75 | void setCategories( const QArray<int> &v ); |
74 | bool writeLink() const; | 76 | bool writeLink() const; |
75 | 77 | ||
76 | void setProperty(const QString& key, const QString& value); | 78 | void setProperty(const QString& key, const QString& value); |
77 | QString property(const QString& key) const; | 79 | QString property(const QString& key) const; |
78 | 80 | ||
79 | protected: | 81 | protected: |
80 | QString mName; | 82 | QString mName; |
81 | QPixmap mPixmap; | 83 | QPixmap mPixmap; |
82 | QPixmap mBigPixmap; | 84 | QPixmap mBigPixmap; |
83 | QString mExec; | 85 | QString mExec; |
84 | QString mType; | 86 | QString mType; |
85 | QString mRotation; | 87 | QString mRotation; |
86 | QString mComment; | 88 | QString mComment; |
87 | QString mFile; | 89 | QString mFile; |
88 | QString mLinkFile; | 90 | QString mLinkFile; |
89 | QString mIconFile; | 91 | QString mIconFile; |
90 | QStringList mMimeTypes; | 92 | QStringList mMimeTypes; |
91 | QStringList mMimeTypeIcons; | 93 | QStringList mMimeTypeIcons; |
92 | int mId; | 94 | int mId; |
93 | static int lastId; | 95 | static int lastId; |
94 | AppLnkPrivate *d; | 96 | AppLnkPrivate *d; |
95 | friend class AppLnkSet; | 97 | friend class AppLnkSet; |
96 | 98 | ||
97 | virtual void invoke(const QStringList& args) const; | 99 | virtual void invoke(const QStringList& args) const; |
98 | bool ensureLinkExists() const; | 100 | bool ensureLinkExists() const; |
101 | void storeLink() const; | ||
99 | }; | 102 | }; |
100 | 103 | ||
101 | class DocLnk : public AppLnk | 104 | class DocLnk : public AppLnk |
102 | { | 105 | { |
103 | public: | 106 | public: |
104 | DocLnk(); | 107 | DocLnk(); |
105 | DocLnk( const DocLnk &o ) : AppLnk(o) { } | 108 | DocLnk( const DocLnk &o ) : AppLnk(o) { } |
106 | DocLnk( const QString &file ); | 109 | DocLnk( const QString &file ); |
107 | DocLnk( const QString &file, bool may_be_desktopfile ); | 110 | DocLnk( const QString &file, bool may_be_desktopfile ); |
108 | virtual ~DocLnk(); | 111 | virtual ~DocLnk(); |
109 | 112 | ||
110 | QString exec() const; | 113 | QString exec() const; |
111 | 114 | ||
112 | protected: | 115 | protected: |
113 | void invoke(const QStringList& args) const; | 116 | void invoke(const QStringList& args) const; |
114 | 117 | ||
115 | private: | 118 | private: |
116 | void init(const QString &file); | 119 | void init(const QString &file); |
117 | }; | 120 | }; |
118 | 121 | ||
119 | class AppLnkSet | 122 | class AppLnkSet |
120 | { | 123 | { |
121 | public: | 124 | public: |
122 | AppLnkSet(); | 125 | AppLnkSet(); |
123 | AppLnkSet( const QString &dir ); | 126 | AppLnkSet( const QString &dir ); |
124 | ~AppLnkSet(); | 127 | ~AppLnkSet(); |
125 | 128 | ||
126 | const AppLnk *find( int id ) const; | 129 | const AppLnk *find( int id ) const; |
127 | const AppLnk *findExec( const QString& execname ) const; | 130 | const AppLnk *findExec( const QString& execname ) const; |
128 | 131 | ||
129 | QStringList types() const { return typs; } | 132 | QStringList types() const { return typs; } |
130 | QString typeName( const QString& ) const; | 133 | QString typeName( const QString& ) const; |
131 | QPixmap typePixmap( const QString& ) const; | 134 | QPixmap typePixmap( const QString& ) const; |
132 | QPixmap typeBigPixmap( const QString& ) const; | 135 | QPixmap typeBigPixmap( const QString& ) const; |
133 | 136 | ||
134 | void add(AppLnk*); | 137 | void add(AppLnk*); |
135 | bool remove(AppLnk*); | 138 | bool remove(AppLnk*); |
136 | 139 | ||
137 | const QList<AppLnk> &children() const { return mApps; } | 140 | const QList<AppLnk> &children() const { return mApps; } |
138 | void detachChildren(); | 141 | void detachChildren(); |
139 | 142 | ||
140 | protected: | 143 | protected: |
141 | friend class AppLnk; | 144 | friend class AppLnk; |
142 | QList<AppLnk> mApps; | 145 | QList<AppLnk> mApps; |
143 | QString mFile; | 146 | QString mFile; |
144 | QStringList typs; | 147 | QStringList typs; |
145 | AppLnkSetPrivate *d; | 148 | AppLnkSetPrivate *d; |
146 | 149 | ||
147 | private: | 150 | private: |
148 | AppLnkSet( const AppLnkSet & ); // no copying! | 151 | AppLnkSet( const AppLnkSet & ); // no copying! |
149 | void findChildren(const QString &, const QString& t, const QString& lt, int depth = 0); | 152 | void findChildren(const QString &, const QString& t, const QString& lt, int depth = 0); |
150 | }; | 153 | }; |
151 | 154 | ||
152 | class DocLnkSet : public AppLnkSet | 155 | class DocLnkSet : public AppLnkSet |
153 | { | 156 | { |
154 | public: | 157 | public: |
155 | DocLnkSet(); | 158 | DocLnkSet(); |
156 | DocLnkSet( const QString &dir, const QString &mimefilter=QString::null ); | 159 | DocLnkSet( const QString &dir, const QString &mimefilter=QString::null ); |
157 | 160 | ||
158 | const QList<DocLnk> &children() const { return (const QList<DocLnk> &)mApps; } | 161 | const QList<DocLnk> &children() const { return (const QList<DocLnk> &)mApps; } |
159 | 162 | ||
160 | void appendFrom( DocLnkSet& other ); | 163 | void appendFrom( DocLnkSet& other ); |
161 | 164 | ||
162 | private: | 165 | private: |
163 | DocLnkSet( const DocLnkSet & ); // no copying! | 166 | DocLnkSet( const DocLnkSet & ); // no copying! |
164 | void findChildren(const QString &dr, const QValueList<QRegExp> &mimeFilters, QDict<void> &reference, int depth=0); | 167 | void findChildren(const QString &dr, const QValueList<QRegExp> &mimeFilters, QDict<void> &reference, int depth=0); |
165 | }; | 168 | }; |
166 | 169 | ||
167 | 170 | ||
168 | #endif // __APPLNK_H__ | 171 | #endif // __APPLNK_H__ |
169 | 172 | ||