-rw-r--r-- | library/applnk.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/library/applnk.cpp b/library/applnk.cpp index 5185b5f..778ccab 100644 --- a/library/applnk.cpp +++ b/library/applnk.cpp | |||
@@ -295,97 +295,97 @@ QString AppLnk::type() const | |||
295 | QString AppLnk::file() const | 295 | QString AppLnk::file() const |
296 | { | 296 | { |
297 | if ( mFile.isNull() ) { | 297 | if ( mFile.isNull() ) { |
298 | AppLnk* that = (AppLnk*)this; // copy? | 298 | AppLnk* that = (AppLnk*)this; // copy? |
299 | QString ext = MimeType(mType).extension(); | 299 | QString ext = MimeType(mType).extension(); |
300 | if ( !ext.isEmpty() ) | 300 | if ( !ext.isEmpty() ) |
301 | ext = "." + ext; | 301 | ext = "." + ext; |
302 | if ( !mLinkFile.isEmpty() ) { | 302 | if ( !mLinkFile.isEmpty() ) { |
303 | that->mFile = | 303 | that->mFile = |
304 | mLinkFile.right(8)==".desktop" // 8 = strlen(".desktop") | 304 | mLinkFile.right(8)==".desktop" // 8 = strlen(".desktop") |
305 | ? mLinkFile.left(mLinkFile.length()-8) : mLinkFile; | 305 | ? mLinkFile.left(mLinkFile.length()-8) : mLinkFile; |
306 | } else if ( mType.contains('/') ) { | 306 | } else if ( mType.contains('/') ) { |
307 | that->mFile = | 307 | that->mFile = |
308 | QString(getenv("HOME"))+"/Documents/"+mType+"/"+safeFileName(that->mName); | 308 | QString(getenv("HOME"))+"/Documents/"+mType+"/"+safeFileName(that->mName); |
309 | if ( QFile::exists(that->mFile+ext) || QFile::exists(that->mFile+".desktop") ) { // a .desktop with the same name exists | 309 | if ( QFile::exists(that->mFile+ext) || QFile::exists(that->mFile+".desktop") ) { // a .desktop with the same name exists |
310 | int n=1; | 310 | int n=1; |
311 | qWarning("AppLnk::file() n=1 %s", that->mFile.latin1() ); | 311 | qWarning("AppLnk::file() n=1 %s", that->mFile.latin1() ); |
312 | QString nn; | 312 | QString nn; |
313 | while (QFile::exists((nn=(that->mFile+"_"+QString::number(n)))+ext) | 313 | while (QFile::exists((nn=(that->mFile+"_"+QString::number(n)))+ext) |
314 | || QFile::exists(nn+".desktop")) | 314 | || QFile::exists(nn+".desktop")) |
315 | n++; | 315 | n++; |
316 | that->mFile = nn; | 316 | that->mFile = nn; |
317 | qWarning("AppLnl::file() now mFile is %s", that->mFile.latin1() ); | 317 | qWarning("AppLnl::file() now mFile is %s", that->mFile.latin1() ); |
318 | } | 318 | } |
319 | that->mLinkFile = that->mFile+".desktop"; | 319 | that->mLinkFile = that->mFile+".desktop"; |
320 | that->mFile += ext; | 320 | that->mFile += ext; |
321 | } | 321 | } |
322 | prepareDirectories(that->mFile); | 322 | prepareDirectories(that->mFile); |
323 | QFile f(that->mFile); | 323 | QFile f(that->mFile); |
324 | if ( !f.open(IO_WriteOnly) ) | 324 | if ( !f.open(IO_WriteOnly) ) |
325 | that->mFile = QString::null; | 325 | that->mFile = QString::null; |
326 | return that->mFile; | 326 | return that->mFile; |
327 | } | 327 | } |
328 | return mFile; | 328 | return mFile; |
329 | } | 329 | } |
330 | 330 | ||
331 | /*! | 331 | /*! |
332 | Returns the desktop file coresponding to this AppLnk. | 332 | Returns the desktop file coresponding to this AppLnk. |
333 | 333 | ||
334 | \sa file(), exec() | 334 | \sa file(), exec() |
335 | */ | 335 | */ |
336 | QString AppLnk::linkFile() const | 336 | QString 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() ) { | 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 | */ |
376 | AppLnk::AppLnk( const AppLnk © ) | 376 | AppLnk::AppLnk( const AppLnk © ) |
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; |
385 | mFile = copy.mFile; | 385 | mFile = copy.mFile; |
386 | mLinkFile = copy.mLinkFile; | 386 | mLinkFile = copy.mLinkFile; |
387 | mIconFile = copy.mIconFile; | 387 | mIconFile = copy.mIconFile; |
388 | mMimeTypes = copy.mMimeTypes; | 388 | mMimeTypes = copy.mMimeTypes; |
389 | mMimeTypeIcons = copy.mMimeTypeIcons; | 389 | mMimeTypeIcons = copy.mMimeTypeIcons; |
390 | mId = 0; | 390 | mId = 0; |
391 | d = new AppLnkPrivate(); | 391 | d = new AppLnkPrivate(); |