author | zecke <zecke> | 2003-04-16 10:57:59 (UTC) |
---|---|---|
committer | zecke <zecke> | 2003-04-16 10:57:59 (UTC) |
commit | eeb29547890a2d162de66d7d5b98d3840a7e2d79 (patch) (unidiff) | |
tree | 973c6de7aae2fd5ba368efb87fa24234f0e12aa3 /library/applnk.cpp | |
parent | dfa2d294b3af09bf3757a3c2294a925093e72fc6 (diff) | |
download | opie-eeb29547890a2d162de66d7d5b98d3840a7e2d79.zip opie-eeb29547890a2d162de66d7d5b98d3840a7e2d79.tar.gz opie-eeb29547890a2d162de66d7d5b98d3840a7e2d79.tar.bz2 |
Fix API docu
-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 | |||
@@ -207,257 +207,273 @@ public: | |||
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( |