-rw-r--r-- | library/applnk.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/library/applnk.cpp b/library/applnk.cpp index 35822dd..00030e8 100644 --- a/library/applnk.cpp +++ b/library/applnk.cpp | |||
@@ -1,719 +1,735 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the 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 | 20 | ||
21 | #define QTOPIA_INTERNAL_MIMEEXT | 21 | #define QTOPIA_INTERNAL_MIMEEXT |
22 | #define QTOPIA_INTERNAL_PRELOADACCESS | 22 | #define QTOPIA_INTERNAL_PRELOADACCESS |
23 | #define QTOPIA_INTERNAL_APPLNKASSIGN | 23 | #define QTOPIA_INTERNAL_APPLNKASSIGN |
24 | 24 | ||
25 | #include "applnk.h" | 25 | #include "applnk.h" |
26 | 26 | ||
27 | #include <qpe/qpeapplication.h> | 27 | #include <qpe/qpeapplication.h> |
28 | #include <qpe/categories.h> | 28 | #include <qpe/categories.h> |
29 | #include <qpe/categoryselect.h> | 29 | #include <qpe/categoryselect.h> |
30 | #include <qpe/qcopenvelope_qws.h> | 30 | #include <qpe/qcopenvelope_qws.h> |
31 | #include <qpe/global.h> | 31 | #include <qpe/global.h> |
32 | #include <qpe/mimetype.h> | 32 | #include <qpe/mimetype.h> |
33 | #include <qpe/config.h> | 33 | #include <qpe/config.h> |
34 | #include <qpe/storage.h> | 34 | #include <qpe/storage.h> |
35 | #include <qpe/resource.h> | 35 | #include <qpe/resource.h> |
36 | 36 | ||
37 | #include <qdict.h> | 37 | #include <qdict.h> |
38 | #include <qdir.h> | 38 | #include <qdir.h> |
39 | #include <qregexp.h> | 39 | #include <qregexp.h> |
40 | 40 | ||
41 | #include <qgfx_qws.h> | 41 | #include <qgfx_qws.h> |
42 | 42 | ||
43 | #include <stdlib.h> | 43 | #include <stdlib.h> |
44 | 44 | ||
45 | int AppLnk::lastId = 5000; | 45 | int AppLnk::lastId = 5000; |
46 | 46 | ||
47 | static int smallSize = 14; | 47 | static int smallSize = 14; |
48 | static int bigSize = 32; | 48 | static int bigSize = 32; |
49 | 49 | ||
50 | static QString safeFileName(const QString& n) | 50 | 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.]"),"_"); |
54 | safename.replace(QRegExp("^[^A-Za-z]*"),""); | 54 | safename.replace(QRegExp("^[^A-Za-z]*"),""); |
55 | if ( safename.isEmpty() ) | 55 | if ( safename.isEmpty() ) |
56 | safename = "_"; | 56 | safename = "_"; |
57 | return safename; | 57 | return safename; |
58 | } | 58 | } |
59 | 59 | ||
60 | static bool prepareDirectories(const QString& lf) | 60 | static bool prepareDirectories(const QString& lf) |
61 | { | 61 | { |
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 | } |
68 | return TRUE; | 68 | return TRUE; |
69 | } | 69 | } |
70 | 70 | ||
71 | class AppLnkPrivate | 71 | class AppLnkPrivate |
72 | { | 72 | { |
73 | public: | 73 | public: |
74 | /* the size of the Pixmap */ | 74 | /* the size of the Pixmap */ |
75 | enum Size {Normal = 0, Big }; | 75 | enum Size {Normal = 0, Big }; |
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 | // 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(); |
94 | for (uint i = 0; i < mCat.count(); i++ ) | 94 | for (uint i = 0; i < mCat.count(); i++ ) |
95 | mCatList << cat.label("Document View", mCat[i] ); | 95 | mCatList << cat.label("Document View", mCat[i] ); |
96 | 96 | ||
97 | } | 97 | } |
98 | 98 | ||
99 | void setCatArrayDirty() | 99 | void setCatArrayDirty() |
100 | { | 100 | { |
101 | mCat.resize(0); | 101 | mCat.resize(0); |
102 | } | 102 | } |
103 | 103 | ||
104 | void ensureCatArray() | 104 | void ensureCatArray() |
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 | } |
127 | }; | 127 | }; |
128 | 128 | ||
129 | /*! | 129 | /*! |
130 | \class AppLnk applnk.h | 130 | \class AppLnk applnk.h |
131 | \brief The AppLnk class represents an application available on the system. | 131 | \brief The AppLnk class represents an application available on the system. |
132 | 132 | ||
133 | Every Qtopia application \e app has a corresponding \e app.desktop | 133 | Every Qtopia application \e app has a corresponding \e app.desktop |
134 | file. When one of these files is read its data is stored as an | 134 | file. When one of these files is read its data is stored as an |
135 | AppLnk object. | 135 | AppLnk object. |
136 | 136 | ||
137 | The AppLnk class introduces some Qtopia-specific concepts, and | 137 | The AppLnk class introduces some Qtopia-specific concepts, and |
138 | provides a variety of functions, as described in the following | 138 | provides a variety of functions, as described in the following |
139 | sections. | 139 | sections. |
140 | \tableofcontents | 140 | \tableofcontents |
141 | 141 | ||
142 | \target Types | 142 | \target Types |
143 | \section1 Types | 143 | \section1 Types |
144 | 144 | ||
145 | Every AppLnk object has a \e type. For applications, games and | 145 | Every AppLnk object has a \e type. For applications, games and |
146 | settings the type is \c Application; for documents the | 146 | settings the type is \c Application; for documents the |
147 | type is the document's MIME type. | 147 | type is the document's MIME type. |
148 | 148 | ||
149 | \target files-and-links | 149 | \target files-and-links |
150 | \section1 Files and Links | 150 | \section1 Files and Links |
151 | 151 | ||
152 | When you create an AppLnk (or more likely, a \link doclnk.html | 152 | When you create an AppLnk (or more likely, a \link doclnk.html |
153 | DocLnk\endlink), you don't deal directly with filenames in the | 153 | DocLnk\endlink), you don't deal directly with filenames in the |
154 | filesystem. Instead you do this: | 154 | filesystem. Instead you do this: |
155 | \code | 155 | \code |
156 | DocLnk d; | 156 | DocLnk d; |
157 | d.setType("text/plain"); | 157 | d.setType("text/plain"); |
158 | d.setName("My Nicely Named Document / Whatever"); // Yes, "/" is legal. | 158 | d.setName("My Nicely Named Document / Whatever"); // Yes, "/" is legal. |
159 | \endcode | 159 | \endcode |
160 | At this point, the file() and linkFile() are unknown. Normally | 160 | At this point, the file() and linkFile() are unknown. Normally |
161 | this is uninteresting, and the names become automatically known, | 161 | this is uninteresting, and the names become automatically known, |
162 | and more importantly, becomes reserved, when you ask what they are: | 162 | and more importantly, becomes reserved, when you ask what they are: |
163 | 163 | ||
164 | \code | 164 | \code |
165 | QString fn = d.file(); | 165 | QString fn = d.file(); |
166 | \endcode | 166 | \endcode |
167 | This invents a filename, and creates the file on disk (an empty | 167 | This invents a filename, and creates the file on disk (an empty |
168 | reservation file) to prevent the name being used by another | 168 | reservation file) to prevent the name being used by another |
169 | application. | 169 | application. |
170 | 170 | ||
171 | In some circumstances, you don't want to create the file if it | 171 | In some circumstances, you don't want to create the file if it |
172 | doesn't already exist (e.g. in the Document tab, some of the \link | 172 | doesn't already exist (e.g. in the Document tab, some of the \link |
173 | doclnk.html DocLnk\endlink objects represented by icons are | 173 | doclnk.html DocLnk\endlink objects represented by icons are |
174 | DocLnk's created just for that view - they don't have | 174 | DocLnk's created just for that view - they don't have |
175 | corresponding \c .desktop files. To avoid littering empty | 175 | corresponding \c .desktop files. To avoid littering empty |
176 | reservation files around, we check in a few places to see whether | 176 | reservation files around, we check in a few places to see whether |
177 | the file really needs to exist). | 177 | the file really needs to exist). |
178 | 178 | ||
179 | \section1 Functionality | 179 | \section1 Functionality |
180 | 180 | ||
181 | AppLnk objects are created by calling the constructor with the | 181 | AppLnk objects are created by calling the constructor with the |
182 | name of a \e .desktop file. The object can be checked for validity | 182 | name of a \e .desktop file. The object can be checked for validity |
183 | using isValid(). | 183 | using isValid(). |
184 | 184 | ||
185 | The following functions are used to set or retrieve information | 185 | The following functions are used to set or retrieve information |
186 | about the application: | 186 | about the application: |
187 | \table | 187 | \table |
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 |
207 | \endtable | 207 | \endtable |
208 | 208 | ||
209 | To save an AppLnk to disk use writeLink(). To execute the | 209 | To save an AppLnk to disk use writeLink(). To execute the |
210 | application that the AppLnk object refers to, use execute(). | 210 | application that the AppLnk object refers to, use execute(). |
211 | 211 | ||
212 | AppLnk's can be deleted from disk using removeLinkFile(). To | 212 | AppLnk's can be deleted from disk using removeLinkFile(). To |
213 | remove both the link and the application's executable use | 213 | remove both the link and the application's executable use |
214 | removeFiles(). | 214 | removeFiles(). |
215 | 215 | ||
216 | Icon sizes can be globally changed (but only for AppLnk objects | 216 | Icon sizes can be globally changed (but only for AppLnk objects |
217 | created after the calls) with setSmallIconSize() and | 217 | created after the calls) with setSmallIconSize() and |
218 | setBigIconSize(). | 218 | setBigIconSize(). |
219 | 219 | ||
220 | \ingroup qtopiaemb | 220 | \ingroup qtopiaemb |
221 | */ | 221 | */ |
222 | 222 | ||
223 | /*! | 223 | /*! |
224 | Sets the size used for small icons to \a small pixels. | 224 | Sets the size used for small icons to \a small pixels. |
225 | Only affects AppLnk objects created after the call. | 225 | Only affects AppLnk objects created after the call. |
226 | 226 | ||
227 | \sa smallIconSize() setIcon() | 227 | \sa smallIconSize() setIcon() |
228 | */ | 228 | */ |
229 | void AppLnk::setSmallIconSize(int small) | 229 | void AppLnk::setSmallIconSize(int small) |
230 | { | 230 | { |
231 | smallSize = small; | 231 | smallSize = small; |
232 | } | 232 | } |
233 | 233 | ||
234 | /*! | 234 | /*! |
235 | Returns the size used for small icons. | 235 | Returns the size used for small icons. |
236 | 236 | ||
237 | \sa setSmallIconSize() setIcon() | 237 | \sa setSmallIconSize() setIcon() |
238 | */ | 238 | */ |
239 | int AppLnk::smallIconSize() | 239 | int AppLnk::smallIconSize() |
240 | { | 240 | { |
241 | return smallSize; | 241 | return smallSize; |
242 | } | 242 | } |
243 | 243 | ||
244 | 244 | ||
245 | /*! | 245 | /*! |
246 | Sets the size used for large icons to \a big pixels. | 246 | Sets the size used for large icons to \a big pixels. |
247 | Only affects AppLnk objects created after the call. | 247 | Only affects AppLnk objects created after the call. |
248 | 248 | ||
249 | \sa bigIconSize() setIcon() | 249 | \sa bigIconSize() setIcon() |
250 | */ | 250 | */ |
251 | void AppLnk::setBigIconSize(int big) | 251 | void AppLnk::setBigIconSize(int big) |
252 | { | 252 | { |
253 | bigSize = big; | 253 | bigSize = big; |
254 | } | 254 | } |
255 | 255 | ||
256 | /*! | 256 | /*! |
257 | Returns the size used for large icons. | 257 | Returns the size used for large icons. |
258 | 258 | ||
259 | \sa setBigIconSize() setIcon() | 259 | \sa setBigIconSize() setIcon() |
260 | */ | 260 | */ |
261 | int AppLnk::bigIconSize() | 261 | int AppLnk::bigIconSize() |
262 | { | 262 | { |
263 | return bigSize; | 263 | return bigSize; |
264 | } | 264 | } |
265 | 265 | ||
266 | 266 | ||
267 | /*! | 267 | /*! |
268 | \fn QString AppLnk::name() const | 268 | \fn QString AppLnk::name() const |
269 | 269 | ||
270 | Returns the Name property. This is the user-visible name for the | 270 | Returns the Name property. This is the user-visible name for the |
271 | document or application, not the filename. | 271 | document or application, not the filename. |
272 | 272 | ||
273 | See \link #files-and-links Files and Links\endlink. | 273 | See \link #files-and-links Files and Links\endlink. |
274 | 274 | ||
275 | \sa setName() | 275 | \sa setName() |
276 | */ | 276 | */ |
277 | /*! | 277 | /*! |
278 | \fn QString AppLnk::exec() const | 278 | \fn QString AppLnk::exec() const |
279 | 279 | ||
280 | Returns the Exec property. This is the name of the executable | 280 | Returns the Exec property. This is the name of the executable |
281 | program associated with the AppLnk. | 281 | program associated with the AppLnk. |
282 | 282 | ||
283 | \sa setExec() | 283 | \sa setExec() |
284 | */ | 284 | */ |
285 | /*! | 285 | /*! |
286 | \fn QString AppLnk::rotation() const | 286 | \fn QString AppLnk::rotation() const |
287 | 287 | ||
288 | Returns the Rotation property. The value is 0, 90, 180 or 270 | 288 | Returns the Rotation property. The value is 0, 90, 180 or 270 |
289 | degrees. | 289 | degrees. |
290 | */ | 290 | */ |
291 | /*! | 291 | /*! |
292 | \fn QString AppLnk::comment() const | 292 | \fn QString AppLnk::comment() const |
293 | 293 | ||
294 | Returns the Comment property. | 294 | Returns the Comment property. |
295 | 295 | ||
296 | \sa setComment() | 296 | \sa setComment() |
297 | */ | 297 | */ |
298 | /*! | 298 | /*! |
299 | \fn QStringList AppLnk::mimeTypes() const | 299 | \fn QStringList AppLnk::mimeTypes() const |
300 | 300 | ||
301 | Returns the MimeTypes property. This is the list of MIME types | 301 | Returns the MimeTypes property. This is the list of MIME types |
302 | that the application can view or edit. | 302 | that the application can view or edit. |
303 | */ | 303 | */ |
304 | /*! | 304 | /*! |
305 | \fn const QArray<int>& AppLnk::categories() const | 305 | \fn const QArray<int>& AppLnk::categories() const |
306 | 306 | ||
307 | Returns the Categories property. | 307 | Returns the Categories property. |
308 | 308 | ||
309 | See the CategoryWidget for more details. | 309 | See the CategoryWidget for more details. |
310 | 310 | ||
311 | \sa setCategories() | 311 | \sa setCategories() |
312 | */ | 312 | */ |
313 | 313 | ||
314 | const QArray<int>& AppLnk::categories() const | 314 | const QArray<int>& AppLnk::categories() const |
315 | { | 315 | { |
316 | d->ensureCatArray(); | 316 | d->ensureCatArray(); |
317 | return d->mCat; | 317 | return d->mCat; |
318 | } | 318 | } |
319 | 319 | ||
320 | /*! | 320 | /*! |
321 | \fn int AppLnk::id() const | 321 | \fn int AppLnk::id() const |
322 | 322 | ||
323 | Returns the id of the AppLnk. If the AppLnk is not in an AppLnkSet, | 323 | Returns the id of the AppLnk. If the AppLnk is not in an AppLnkSet, |
324 | this value is 0, otherwise it is a value that is unique for the | 324 | this value is 0, otherwise it is a value that is unique for the |
325 | duration of the current process. | 325 | duration of the current process. |
326 | 326 | ||
327 | \sa AppLnkSet::find() | 327 | \sa AppLnkSet::find() |
328 | */ | 328 | */ |
329 | 329 | ||
330 | /*! | 330 | /*! |
331 | \fn bool AppLnk::isValid() const | 331 | \fn bool AppLnk::isValid() const |
332 | 332 | ||
333 | Returns TRUE if this AppLnk is valid; otherwise returns FALSE. | 333 | Returns TRUE if this AppLnk is valid; otherwise returns FALSE. |
334 | */ | 334 | */ |
335 | /*! | ||
336 | \fn bool AppLnk::fileKnown() const | ||
337 | |||
338 | If the with the AppLnk associated file is not equal to QString::null | ||
339 | */ | ||
340 | /*! | ||
341 | \fn bool AppLnk::linkFileKnown()const | ||
342 | |||
343 | The filename of the AppLnk | ||
335 | 344 | ||
345 | */ | ||
346 | /*! | ||
347 | \fn void AppLnk::setRotation( const QString& ) | ||
348 | |||
349 | The default rotation of the associated application. This | ||
350 | function is included inline for binary compatible issues | ||
351 | */ | ||
336 | /*! | 352 | /*! |
337 | Creates an invalid AppLnk. | 353 | Creates an invalid AppLnk. |
338 | 354 | ||
339 | \sa isValid() | 355 | \sa isValid() |
340 | */ | 356 | */ |
341 | AppLnk::AppLnk() | 357 | AppLnk::AppLnk() |
342 | { | 358 | { |
343 | mId = 0; | 359 | mId = 0; |
344 | d = new AppLnkPrivate(); | 360 | d = new AppLnkPrivate(); |
345 | } | 361 | } |
346 | 362 | ||
347 | /*! | 363 | /*! |
348 | Loads \a file (e.g. \e app.desktop) as an AppLnk. | 364 | Loads \a file (e.g. \e app.desktop) as an AppLnk. |
349 | 365 | ||
350 | \sa writeLink() | 366 | \sa writeLink() |
351 | */ | 367 | */ |
352 | AppLnk::AppLnk( const QString &file ) | 368 | AppLnk::AppLnk( const QString &file ) |
353 | { | 369 | { |
354 | QStringList sl; | 370 | QStringList sl; |
355 | d = new AppLnkPrivate(); | 371 | d = new AppLnkPrivate(); |
356 | if ( !file.isNull() ) { | 372 | if ( !file.isNull() ) { |
357 | Config config( file, Config::File ); | 373 | Config config( file, Config::File ); |
358 | 374 | ||
359 | if ( config.isValid() ) { | 375 | if ( config.isValid() ) { |
360 | config.setGroup( "Desktop Entry" ); | 376 | config.setGroup( "Desktop Entry" ); |
361 | 377 | ||
362 | mName = config.readEntry( "Name", file ); | 378 | mName = config.readEntry( "Name", file ); |
363 | mExec = config.readEntry( "Exec" ); | 379 | mExec = config.readEntry( "Exec" ); |
364 | mType = config.readEntry( "Type", QString::null ); | 380 | mType = config.readEntry( "Type", QString::null ); |
365 | mIconFile = config.readEntry( "Icon", QString::null ); | 381 | mIconFile = config.readEntry( "Icon", QString::null ); |
366 | mRotation = config.readEntry( "Rotation", "" ); | 382 | mRotation = config.readEntry( "Rotation", "" ); |
367 | mComment = config.readEntry( "Comment", QString::null ); | 383 | mComment = config.readEntry( "Comment", QString::null ); |
368 | // MIME types are case-insensitive. | 384 | // MIME types are case-insensitive. |
369 | mMimeTypes = config.readListEntry( "MimeType", ';' ); | 385 | mMimeTypes = config.readListEntry( "MimeType", ';' ); |
370 | for (QStringList::Iterator it=mMimeTypes.begin(); it!=mMimeTypes.end(); ++it) | 386 | for (QStringList::Iterator it=mMimeTypes.begin(); it!=mMimeTypes.end(); ++it) |
371 | *it = (*it).lower(); | 387 | *it = (*it).lower(); |
372 | mMimeTypeIcons = config.readListEntry( "MimeTypeIcons", ';' ); | 388 | mMimeTypeIcons = config.readListEntry( "MimeTypeIcons", ';' ); |
373 | mLinkFile = file; | 389 | mLinkFile = file; |
374 | mFile = config.readEntry("File", QString::null); | 390 | mFile = config.readEntry("File", QString::null); |
375 | if ( !mExec. isEmpty ( )) { | 391 | if ( !mExec. isEmpty ( )) { |
376 | mFile = QString::null; | 392 | mFile = QString::null; |
377 | } | 393 | } |
378 | else if ( mFile[0] != '/' ) { | 394 | else if ( mFile[0] != '/' ) { |
379 | int slash = file.findRev('/'); | 395 | int slash = file.findRev('/'); |
380 | if ( slash >= 0 ) { | 396 | if ( slash >= 0 ) { |
381 | mFile = file.left(slash) + '/' + mFile; | 397 | mFile = file.left(slash) + '/' + mFile; |
382 | } | 398 | } |
383 | } | 399 | } |
384 | d->mCatList = config.readListEntry("Categories", ';'); | 400 | d->mCatList = config.readListEntry("Categories", ';'); |
385 | if ( d->mCatList[0].toInt() < -1 ) { | 401 | if ( d->mCatList[0].toInt() < -1 ) { |
386 | // numeric cats in file! convert to text | 402 | // numeric cats in file! convert to text |
387 | Categories cat( 0 ); | 403 | Categories cat( 0 ); |
388 | cat.load( categoryFileName() ); | 404 | cat.load( categoryFileName() ); |
389 | d->mCat.resize( d->mCatList.count() ); | 405 | d->mCat.resize( d->mCatList.count() ); |
390 | int i; | 406 | int i; |
391 | QStringList::ConstIterator it; | 407 | QStringList::ConstIterator it; |
392 | for ( i = 0, it = d->mCatList.begin(); it != d->mCatList.end(); | 408 | for ( i = 0, it = d->mCatList.begin(); it != d->mCatList.end(); |
393 | ++it, i++ ) { | 409 | ++it, i++ ) { |
394 | bool number; | 410 | bool number; |
395 | int id = (*it).toInt( &number ); | 411 | int id = (*it).toInt( &number ); |
396 | if ( !number ) { | 412 | if ( !number ) { |
397 | // convert from text | 413 | // convert from text |
398 | id = cat.id( "Document View", *it ); | 414 | id = cat.id( "Document View", *it ); |
399 | if ( id == 0 ) | 415 | if ( id == 0 ) |
400 | id = cat.addCategory( "Document View", *it ); | 416 | id = cat.addCategory( "Document View", *it ); |
401 | } | 417 | } |
402 | d->mCat[i] = id; | 418 | d->mCat[i] = id; |
403 | } | 419 | } |
404 | d->updateCatListFromArray(); | 420 | d->updateCatListFromArray(); |
405 | } | 421 | } |
406 | } | 422 | } |
407 | } | 423 | } |
408 | mId = 0; | 424 | mId = 0; |
409 | } | 425 | } |
410 | 426 | ||
411 | AppLnk& AppLnk::operator=(const AppLnk ©) | 427 | AppLnk& AppLnk::operator=(const AppLnk ©) |
412 | { | 428 | { |
413 | if ( this == © ) return *this; | 429 | if ( this == © ) return *this; |
414 | if ( mId ) | 430 | if ( mId ) |
415 | qWarning("Deleting AppLnk that is in an AppLnkSet"); | 431 | qWarning("Deleting AppLnk that is in an AppLnkSet"); |
416 | if ( d ) | 432 | if ( d ) |
417 | delete d; | 433 | delete d; |
418 | 434 | ||
419 | 435 | ||
420 | mName = copy.mName; | 436 | mName = copy.mName; |
421 | 437 | ||
422 | /* remove for Qtopia 3.0 -zecke */ | 438 | /* remove for Qtopia 3.0 -zecke */ |
423 | mPixmap = copy.mPixmap; | 439 | mPixmap = copy.mPixmap; |
424 | mBigPixmap = copy.mBigPixmap; | 440 | mBigPixmap = copy.mBigPixmap; |
425 | 441 | ||
426 | mExec = copy.mExec; | 442 | mExec = copy.mExec; |
427 | mType = copy.mType; | 443 | mType = copy.mType; |
428 | mRotation = copy.mRotation; | 444 | mRotation = copy.mRotation; |
429 | mComment = copy.mComment; | 445 | mComment = copy.mComment; |
430 | mFile = copy.mFile; | 446 | mFile = copy.mFile; |
431 | mLinkFile = copy.mLinkFile; | 447 | mLinkFile = copy.mLinkFile; |
432 | mIconFile = copy.mIconFile; | 448 | mIconFile = copy.mIconFile; |
433 | mMimeTypes = copy.mMimeTypes; | 449 | mMimeTypes = copy.mMimeTypes; |
434 | mMimeTypeIcons = copy.mMimeTypeIcons; | 450 | mMimeTypeIcons = copy.mMimeTypeIcons; |
435 | mId = 0; | 451 | mId = 0; |
436 | d = new AppLnkPrivate(); | 452 | d = new AppLnkPrivate(); |
437 | d->mCat = copy.d->mCat; | 453 | d->mCat = copy.d->mCat; |
438 | d->mCatList = copy.d->mCatList; | 454 | d->mCatList = copy.d->mCatList; |
439 | d->mPixmaps = copy.d->mPixmaps; | 455 | d->mPixmaps = copy.d->mPixmaps; |
440 | 456 | ||
441 | return *this; | 457 | return *this; |
442 | } | 458 | } |
443 | /*! | 459 | /*! |
444 | protected internally to share code | 460 | protected internally to share code |
445 | should I document that at all? | 461 | should I document that at all? |
446 | I don't know the TT style for that | 462 | I don't know the TT style for that |
447 | */ | 463 | */ |
448 | const QPixmap& AppLnk::pixmap( int pos, int size ) const { | 464 | const QPixmap& AppLnk::pixmap( int pos, int size ) const { |
449 | if ( d->mPixmaps[pos].isNull() ) { | 465 | if ( d->mPixmaps[pos].isNull() ) { |
450 | AppLnk* that = (AppLnk*)this; | 466 | AppLnk* that = (AppLnk*)this; |
451 | if ( mIconFile.isEmpty() ) { | 467 | if ( mIconFile.isEmpty() ) { |
452 | MimeType mt(type()); | 468 | MimeType mt(type()); |
453 | that->d->mPixmaps[pos] = mt.pixmap(); | 469 | that->d->mPixmaps[pos] = mt.pixmap(); |
454 | if ( that->d->mPixmaps[pos].isNull() ) | 470 | if ( that->d->mPixmaps[pos].isNull() ) |
455 | that->d->mPixmaps[pos].convertFromImage( | 471 | that->d->mPixmaps[pos].convertFromImage( |
456 | Resource::loadImage("UnknownDocument") | 472 | Resource::loadImage("UnknownDocument") |
457 | .smoothScale( size, size ) ); | 473 | .smoothScale( size, size ) ); |
458 | return that->d->mPixmaps[pos]; | 474 | return that->d->mPixmaps[pos]; |
459 | } | 475 | } |
460 | QImage unscaledIcon = Resource::loadImage( that->mIconFile ); | 476 | QImage unscaledIcon = Resource::loadImage( that->mIconFile ); |
461 | if ( unscaledIcon.isNull() ) { | 477 | if ( unscaledIcon.isNull() ) { |
462 | qDebug( "Cannot find icon: %s", that->mIconFile.latin1() ); | 478 | qDebug( "Cannot find icon: %s", that->mIconFile.latin1() ); |
463 | that->d->mPixmaps[pos].convertFromImage( | 479 | that->d->mPixmaps[pos].convertFromImage( |
464 | Resource::loadImage("UnknownDocument") | 480 | Resource::loadImage("UnknownDocument") |
465 | .smoothScale( size, size ) ); | 481 | .smoothScale( size, size ) ); |
466 | } else { | 482 | } else { |
467 | that->d->mPixmaps[0].convertFromImage( unscaledIcon.smoothScale( smallSize, smallSize ) ); | 483 | that->d->mPixmaps[0].convertFromImage( unscaledIcon.smoothScale( smallSize, smallSize ) ); |
468 | that->d->mPixmaps[1].convertFromImage( unscaledIcon.smoothScale( bigSize, bigSize ) ); | 484 | that->d->mPixmaps[1].convertFromImage( unscaledIcon.smoothScale( bigSize, bigSize ) ); |
469 | } | 485 | } |
470 | return that->d->mPixmaps[pos]; | 486 | return that->d->mPixmaps[pos]; |
471 | } | 487 | } |
472 | return d->mPixmaps[pos]; | 488 | return d->mPixmaps[pos]; |
473 | } | 489 | } |
474 | 490 | ||
475 | /*! | 491 | /*! |
476 | Returns a small pixmap associated with the application. | 492 | Returns a small pixmap associated with the application. |
477 | 493 | ||
478 | \sa bigPixmap() setIcon() | 494 | \sa bigPixmap() setIcon() |
479 | */ | 495 | */ |
480 | const QPixmap& AppLnk::pixmap() const | 496 | const QPixmap& AppLnk::pixmap() const |
481 | { | 497 | { |
482 | if ( d->mPixmaps[0].isNull() ) { | 498 | if ( d->mPixmaps[0].isNull() ) { |
483 | return pixmap(AppLnkPrivate::Normal, smallSize ); | 499 | return pixmap(AppLnkPrivate::Normal, smallSize ); |
484 | } | 500 | } |
485 | return d->mPixmaps[0]; | 501 | return d->mPixmaps[0]; |
486 | } | 502 | } |
487 | 503 | ||
488 | /*! | 504 | /*! |
489 | Returns a large pixmap associated with the application. | 505 | Returns a large pixmap associated with the application. |
490 | 506 | ||
491 | \sa pixmap() setIcon() | 507 | \sa pixmap() setIcon() |
492 | */ | 508 | */ |
493 | const QPixmap& AppLnk::bigPixmap() const | 509 | const QPixmap& AppLnk::bigPixmap() const |
494 | { | 510 | { |
495 | if ( d->mPixmaps[1].isNull() ) { | 511 | if ( d->mPixmaps[1].isNull() ) { |
496 | return pixmap( AppLnkPrivate::Big, bigSize ); | 512 | return pixmap( AppLnkPrivate::Big, bigSize ); |
497 | } | 513 | } |
498 | return d->mPixmaps[1]; | 514 | return d->mPixmaps[1]; |
499 | } | 515 | } |
500 | 516 | ||
501 | /*! | 517 | /*! |
502 | Returns the type of the AppLnk. For applications, games and | 518 | Returns the type of the AppLnk. For applications, games and |
503 | settings the type is \c Application; for documents the type is the | 519 | settings the type is \c Application; for documents the type is the |
504 | document's MIME type. | 520 | document's MIME type. |
505 | */ | 521 | */ |
506 | QString AppLnk::type() const | 522 | QString AppLnk::type() const |
507 | { | 523 | { |
508 | if ( mType.isNull() ) { | 524 | if ( mType.isNull() ) { |
509 | AppLnk* that = (AppLnk*)this; | 525 | AppLnk* that = (AppLnk*)this; |
510 | QString f = file(); | 526 | QString f = file(); |
511 | if ( !f.isNull() ) { | 527 | if ( !f.isNull() ) { |
512 | MimeType mt(f); | 528 | MimeType mt(f); |
513 | that->mType = mt.id(); | 529 | that->mType = mt.id(); |
514 | return that->mType; | 530 | return that->mType; |
515 | } | 531 | } |
516 | } | 532 | } |
517 | return mType; | 533 | return mType; |
518 | } | 534 | } |
519 | 535 | ||
520 | /*! | 536 | /*! |
521 | Returns the file associated with the AppLnk. | 537 | Returns the file associated with the AppLnk. |
522 | 538 | ||
523 | \sa exec() name() | 539 | \sa exec() name() |
524 | */ | 540 | */ |
525 | QString AppLnk::file() const | 541 | QString AppLnk::file() const |
526 | { | 542 | { |
527 | if ( mExec.isEmpty ( ) && mFile.isNull() ) { | 543 | if ( mExec.isEmpty ( ) && mFile.isNull() ) { |
528 | AppLnk* that = (AppLnk*)this; | 544 | AppLnk* that = (AppLnk*)this; |
529 | QString ext = MimeType(mType).extension(); | 545 | QString ext = MimeType(mType).extension(); |
530 | if ( !ext.isEmpty() ) | 546 | if ( !ext.isEmpty() ) |
531 | ext = "." + ext; | 547 | ext = "." + ext; |
532 | if ( !mLinkFile.isEmpty() ) { | 548 | if ( !mLinkFile.isEmpty() ) { |
533 | that->mFile = | 549 | that->mFile = |
534 | mLinkFile.right(8)==".desktop" // 8 = strlen(".desktop") | 550 | mLinkFile.right(8)==".desktop" // 8 = strlen(".desktop") |
535 | ? mLinkFile.left(mLinkFile.length()-8) : mLinkFile; | 551 | ? mLinkFile.left(mLinkFile.length()-8) : mLinkFile; |
536 | qDebug("mFile now == %s", mFile.latin1()); | 552 | qDebug("mFile now == %s", mFile.latin1()); |
537 | } else if ( mType.contains('/') ) { | 553 | } else if ( mType.contains('/') ) { |
538 | that->mFile = | 554 | that->mFile = |
539 | QString(getenv("HOME"))+"/Documents/"+mType+"/"+safeFileName(that->mName); | 555 | QString(getenv("HOME"))+"/Documents/"+mType+"/"+safeFileName(that->mName); |
540 | /* | 556 | /* |
541 | * A file with the same name or a .desktop file already exists | 557 | * A file with the same name or a .desktop file already exists |
542 | */ | 558 | */ |
543 | if ( QFile::exists(that->mFile+ext) || QFile::exists(that->mFile+".desktop") ) { | 559 | if ( QFile::exists(that->mFile+ext) || QFile::exists(that->mFile+".desktop") ) { |
544 | int n=1; | 560 | int n=1; |
545 | QString nn; | 561 | QString nn; |
546 | while (QFile::exists((nn=(that->mFile+"_"+QString::number(n)))+ext) | 562 | while (QFile::exists((nn=(that->mFile+"_"+QString::number(n)))+ext) |
547 | || QFile::exists(nn+".desktop")) | 563 | || QFile::exists(nn+".desktop")) |
548 | n++; | 564 | n++; |
549 | that->mFile = nn; | 565 | that->mFile = nn; |
550 | } | 566 | } |
551 | that->mLinkFile = that->mFile+".desktop"; | 567 | that->mLinkFile = that->mFile+".desktop"; |
552 | that->mFile += ext; | 568 | that->mFile += ext; |
553 | } | 569 | } |
554 | prepareDirectories(that->mFile); | 570 | prepareDirectories(that->mFile); |
555 | if ( !that->mFile.isEmpty() ) { | 571 | if ( !that->mFile.isEmpty() ) { |
556 | QFile f(that->mFile); | 572 | QFile f(that->mFile); |
557 | if ( !f.open(IO_WriteOnly) ) | 573 | if ( !f.open(IO_WriteOnly) ) |
558 | that->mFile = QString::null; | 574 | that->mFile = QString::null; |
559 | return that->mFile; | 575 | return that->mFile; |
560 | } | 576 | } |
561 | } | 577 | } |
562 | return mFile; | 578 | return mFile; |
563 | } | 579 | } |
564 | 580 | ||
565 | /*! | 581 | /*! |
566 | Returns the desktop file corresponding to this AppLnk. | 582 | Returns the desktop file corresponding to this AppLnk. |
567 | 583 | ||
568 | \sa file() exec() name() | 584 | \sa file() exec() name() |
569 | */ | 585 | */ |
570 | QString AppLnk::linkFile() const | 586 | QString AppLnk::linkFile() const |
571 | { | 587 | { |
572 | if ( mLinkFile.isNull() ) { | 588 | if ( mLinkFile.isNull() ) { |
573 | AppLnk* that = (AppLnk*)this; | 589 | AppLnk* that = (AppLnk*)this; |
574 | if ( type().contains('/') ) { | 590 | if ( type().contains('/') ) { |
575 | StorageInfo storage; | 591 | StorageInfo storage; |
576 | const FileSystem *fs = storage.fileSystemOf( that->mFile ); | 592 | const FileSystem *fs = storage.fileSystemOf( that->mFile ); |
577 | /* tmpfs + and ramfs are available too but not removable | 593 | /* tmpfs + and ramfs are available too but not removable |
578 | * either we fix storage or add this | 594 | * either we fix storage or add this |
579 | */ | 595 | */ |
580 | if ( fs && ( fs->isRemovable() || fs->disk() == "/dev/mtdblock6" || fs->disk() == "tmpfs") ) { | 596 | if ( fs && ( fs->isRemovable() || fs->disk() == "/dev/mtdblock6" || fs->disk() == "tmpfs") ) { |
581 | that->mLinkFile = fs->path(); | 597 | that->mLinkFile = fs->path(); |
582 | } else | 598 | } else |
583 | that->mLinkFile = getenv( "HOME" ); | 599 | that->mLinkFile = getenv( "HOME" ); |
584 | that->mLinkFile += "/Documents/"+type()+"/"+safeFileName(that->mName); | 600 | that->mLinkFile += "/Documents/"+type()+"/"+safeFileName(that->mName); |
585 | 601 | ||
586 | /* 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 */ |
587 | if ( QFile::exists(that->mLinkFile+".desktop") ) { | 603 | if ( QFile::exists(that->mLinkFile+".desktop") ) { |
588 | AppLnk lnk( that->mLinkFile + ".desktop" ); | 604 | AppLnk lnk( that->mLinkFile + ".desktop" ); |
589 | 605 | ||
590 | /* the linked is different */ | 606 | /* the linked is different */ |
591 | if(that->file() != lnk.file() ) { | 607 | if(that->file() != lnk.file() ) { |
592 | int n = 1; | 608 | int n = 1; |
593 | QString nn; | 609 | QString nn; |
594 | while (QFile::exists((nn=that->mLinkFile+"_"+QString::number(n))+".desktop")) { | 610 | while (QFile::exists((nn=that->mLinkFile+"_"+QString::number(n))+".desktop")) { |
595 | n++; | 611 | n++; |
596 | /* just to be sure */ | 612 | /* just to be sure */ |
597 | AppLnk lnk(nn ); | 613 | AppLnk lnk(nn ); |
598 | if (lnk.file() == that->file() ) | 614 | if (lnk.file() == that->file() ) |
599 | break; | 615 | break; |
600 | } | 616 | } |
601 | that->mLinkFile = nn; | 617 | that->mLinkFile = nn; |
602 | } | 618 | } |
603 | } | 619 | } |
604 | that->mLinkFile += ".desktop"; | 620 | that->mLinkFile += ".desktop"; |
605 | storeLink(); | 621 | storeLink(); |
606 | } | 622 | } |
607 | return that->mLinkFile; | 623 | return that->mLinkFile; |
608 | } | 624 | } |
609 | return mLinkFile; | 625 | return mLinkFile; |
610 | } | 626 | } |
611 | 627 | ||
612 | /*! | 628 | /*! |
613 | Copies \a copy. | 629 | Copies \a copy. |
614 | */ | 630 | */ |
615 | AppLnk::AppLnk( const AppLnk © ) | 631 | AppLnk::AppLnk( const AppLnk © ) |
616 | { | 632 | { |
617 | mName = copy.mName; | 633 | mName = copy.mName; |
618 | mPixmap = copy.mPixmap; | 634 | mPixmap = copy.mPixmap; |
619 | mBigPixmap = copy.mBigPixmap; | 635 | mBigPixmap = copy.mBigPixmap; |
620 | mExec = copy.mExec; | 636 | mExec = copy.mExec; |
621 | mType = copy.mType; | 637 | mType = copy.mType; |
622 | mRotation = copy.mRotation; | 638 | mRotation = copy.mRotation; |
623 | mComment = copy.mComment; | 639 | mComment = copy.mComment; |
624 | mFile = copy.mFile; | 640 | mFile = copy.mFile; |
625 | mLinkFile = copy.mLinkFile; | 641 | mLinkFile = copy.mLinkFile; |
626 | mIconFile = copy.mIconFile; | 642 | mIconFile = copy.mIconFile; |
627 | mMimeTypes = copy.mMimeTypes; | 643 | mMimeTypes = copy.mMimeTypes; |
628 | mMimeTypeIcons = copy.mMimeTypeIcons; | 644 | mMimeTypeIcons = copy.mMimeTypeIcons; |
629 | mId = 0; | 645 | mId = 0; |
630 | d = new AppLnkPrivate(); | 646 | d = new AppLnkPrivate(); |
631 | d->mCat = copy.d->mCat; | 647 | d->mCat = copy.d->mCat; |
632 | d->mCatList = copy.d->mCatList; | 648 | d->mCatList = copy.d->mCatList; |
633 | d->mPixmaps = copy.d->mPixmaps; | 649 | d->mPixmaps = copy.d->mPixmaps; |
634 | } | 650 | } |
635 | 651 | ||
636 | /*! | 652 | /*! |
637 | Destroys the AppLnk. Note that if the AppLnk is currently a member | 653 | Destroys the AppLnk. Note that if the AppLnk is currently a member |
638 | of an AppLnkSet, this will produce a run-time warning. | 654 | of an AppLnkSet, this will produce a run-time warning. |
639 | 655 | ||
640 | \sa AppLnkSet::add() AppLnkSet::remove() | 656 | \sa AppLnkSet::add() AppLnkSet::remove() |
641 | */ | 657 | */ |
642 | AppLnk::~AppLnk() | 658 | AppLnk::~AppLnk() |
643 | { | 659 | { |
644 | if ( mId ) | 660 | if ( mId ) |
645 | qWarning("Deleting AppLnk that is in an AppLnkSet"); | 661 | qWarning("Deleting AppLnk that is in an AppLnkSet"); |
646 | if ( d ) | 662 | if ( d ) |
647 | delete d; | 663 | delete d; |
648 | } | 664 | } |
649 | 665 | ||
650 | /*! | 666 | /*! |
651 | \overload | 667 | \overload |
652 | Executes the application associated with this AppLnk. | 668 | Executes the application associated with this AppLnk. |
653 | 669 | ||
654 | \sa exec() | 670 | \sa exec() |
655 | */ | 671 | */ |
656 | void AppLnk::execute() const | 672 | void AppLnk::execute() const |
657 | { | 673 | { |
658 | execute(QStringList()); | 674 | execute(QStringList()); |
659 | } | 675 | } |
660 | 676 | ||
661 | /*! | 677 | /*! |
662 | Executes the application associated with this AppLnk, with | 678 | Executes the application associated with this AppLnk, with |
663 | \a args as arguments. | 679 | \a args as arguments. |
664 | 680 | ||
665 | \sa exec() | 681 | \sa exec() |
666 | */ | 682 | */ |
667 | void AppLnk::execute(const QStringList& args) const | 683 | void AppLnk::execute(const QStringList& args) const |
668 | { | 684 | { |
669 | #ifdef Q_WS_QWS | 685 | #ifdef Q_WS_QWS |
670 | if ( !mRotation.isEmpty() ) { | 686 | if ( !mRotation.isEmpty() ) { |
671 | // ######## this will only work in the server | 687 | // ######## this will only work in the server |
672 | int rot = QPEApplication::defaultRotation(); | 688 | int rot = QPEApplication::defaultRotation(); |
673 | rot = (rot+mRotation.toInt())%360; | 689 | rot = (rot+mRotation.toInt())%360; |
674 | QCString old = getenv("QWS_DISPLAY"); | 690 | QCString old = getenv("QWS_DISPLAY"); |
675 | setenv("QWS_DISPLAY", QString("Transformed:Rot%1:0").arg(rot), 1); | 691 | setenv("QWS_DISPLAY", QString("Transformed:Rot%1:0").arg(rot), 1); |
676 | invoke(args); | 692 | invoke(args); |
677 | setenv("QWS_DISPLAY", old.data(), 1); | 693 | setenv("QWS_DISPLAY", old.data(), 1); |
678 | } else | 694 | } else |
679 | #endif | 695 | #endif |
680 | invoke(args); | 696 | invoke(args); |
681 | } | 697 | } |
682 | 698 | ||
683 | /*! | 699 | /*! |
684 | Invokes the application associated with this AppLnk, with | 700 | Invokes the application associated with this AppLnk, with |
685 | \a args as arguments. Rotation is not taken into account by | 701 | \a args as arguments. Rotation is not taken into account by |
686 | this function, so you should not call it directly. | 702 | this function, so you should not call it directly. |
687 | 703 | ||
688 | \sa execute() | 704 | \sa execute() |
689 | */ | 705 | */ |
690 | void AppLnk::invoke(const QStringList& args) const | 706 | void AppLnk::invoke(const QStringList& args) const |
691 | { | 707 | { |
692 | Global::execute( exec(), args[0] ); | 708 | Global::execute( exec(), args[0] ); |
693 | } | 709 | } |
694 | 710 | ||
695 | /*! | 711 | /*! |
696 | Sets the Exec property to \a exec. | 712 | Sets the Exec property to \a exec. |
697 | 713 | ||
698 | \sa exec() name() | 714 | \sa exec() name() |
699 | */ | 715 | */ |
700 | void AppLnk::setExec( const QString& exec ) | 716 | void AppLnk::setExec( const QString& exec ) |
701 | { | 717 | { |
702 | mExec = exec; | 718 | mExec = exec; |
703 | } | 719 | } |
704 | 720 | ||
705 | #if 0 // this was inlined for better BC | 721 | #if 0 // this was inlined for better BC |
706 | /*! | 722 | /*! |
707 | Sets the Rotation property to \a rot. | 723 | Sets the Rotation property to \a rot. |
708 | 724 | ||
709 | \sa rotation() | 725 | \sa rotation() |
710 | */ | 726 | */ |
711 | void AppLnk::setRotation ( const QString &rot ) | 727 | void AppLnk::setRotation ( const QString &rot ) |
712 | { | 728 | { |
713 | mRotation = rot; | 729 | mRotation = rot; |
714 | } | 730 | } |
715 | #endif | 731 | #endif |
716 | 732 | ||
717 | /*! | 733 | /*! |
718 | Sets the Name property to \a docname. | 734 | Sets the Name property to \a docname. |
719 | 735 | ||