author | llornkcor <llornkcor> | 2002-07-02 11:56:46 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-07-02 11:56:46 (UTC) |
commit | 2ffc9e4a46ec40075e6ee55e4583120e6964168d (patch) (side-by-side diff) | |
tree | 0a38d56cd249d71075a9cb784e3461b3dda1551a /library | |
parent | 75b6c4bb13fcc6d54a249b7885b212f473d654a3 (diff) | |
download | opie-2ffc9e4a46ec40075e6ee55e4583120e6964168d.zip opie-2ffc9e4a46ec40075e6ee55e4583120e6964168d.tar.gz opie-2ffc9e4a46ec40075e6ee55e4583120e6964168d.tar.bz2 |
attempt to fix bug #95, now it checks for existing file before trying to delete
-rw-r--r-- | library/lnkproperties.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/library/lnkproperties.cpp b/library/lnkproperties.cpp index 28a71e9..bd43e21 100644 --- a/library/lnkproperties.cpp +++ b/library/lnkproperties.cpp @@ -66,134 +66,135 @@ LnkProperties::LnkProperties( AppLnk* l, QWidget* parent ) } else { d->type->setText( l->type() ); } if ( l->comment().isEmpty() ) { d->comment->hide(); d->commentLabel->hide(); } else { d->comment->setText( l->comment() ); } connect(d->beam,SIGNAL(clicked()),this,SLOT(beamLnk())); if ( lnk->type().contains('/') ) { // A document? (#### better predicate needed) connect(d->unlink,SIGNAL(clicked()),this,SLOT(unlinkLnk())); connect(d->duplicate,SIGNAL(clicked()),this,SLOT(duplicateLnk())); connect(d->delicon,SIGNAL(clicked()),this,SLOT(unlinkIcon())); d->docname->setReadOnly( FALSE ); d->preload->hide(); d->spacer->hide(); // ### THIS MUST GO, FIX WIERD BUG in QLAYOUT d->categoryEdit->kludge(); d->categoryEdit->setCategories( lnk->categories(), "Document View", tr("Document View") ); setupLocations(); } else { d->unlink->hide(); d->duplicate->hide(); d->beam->hide(); d->hline->hide(); d->locationLabel->hide(); d->locationCombo->hide(); // Can't edit categories, since the app .desktop files are global, // possibly read-only. d->categoryEdit->hide(); d->docname->setReadOnly( TRUE ); if ( l->property("CanFastload") == "0" ) d->preload->hide(); Config cfg("Launcher"); cfg.setGroup("Preload"); QStringList apps = cfg.readListEntry("Apps",','); d->preload->setChecked( apps.contains(l->exec()) ); if ( Global::isBuiltinCommand(lnk->exec()) ) d->preload->hide(); // builtins are always fast currentLocation = 0; // apps not movable (yet) } setCaption( l->file()); } LnkProperties::~LnkProperties() { } void LnkProperties::unlinkLnk() { if ( QPEMessageBox::confirmDelete( this, tr("Delete"), lnk->name() ) ) { - lnk->removeFiles(); - if ( QFile::exists(lnk->file()) ) { - QMessageBox::warning( this, tr("Delete"), tr("File deletion failed.") ); - } else { - reject(); - } + if ( QFile::exists(lnk->file()) ) + lnk->removeFiles(); + if ( QFile::exists(lnk->file()) ) { + QMessageBox::warning( this, tr("Delete"), tr("File deletion failed.") ); + } else { + reject(); + } } } /* * remove only the link from documents, not also the file */ void LnkProperties::unlinkIcon() { if ( QPEMessageBox::confirmDelete( this, tr("Delete Icon and leave file"), lnk->name() ) ) { lnk->removeLinkFile(); if ( QFile::exists(lnk->linkFile()) ) { QMessageBox::warning( this, tr("Delete"), tr("Icon deletion failed.") ); } else { reject(); } } } void LnkProperties::setupLocations() { QFileInfo fi( lnk->file() ); fileSize = fi.size(); StorageInfo storage; const QList<FileSystem> &fs = storage.fileSystems(); QListIterator<FileSystem> it ( fs ); QString s; QString homeDir = getenv("HOME"); QString hardDiskHome; QString hardDiskPath; int index = 0; currentLocation = -1; for ( ; it.current(); ++it ) { // we add 10k to the file size so we are sure we can also save the desktop file if ( (*it)->availBlocks() * (*it)->blockSize() > fileSize + 10000 ) { if ( (*it)->isRemovable() || (*it)->disk() == "/dev/mtdblock1" || (*it)->disk() == "/dev/mtdblock/1" || (*it)->disk().left(13) == "/dev/mtdblock" ) { d->locationCombo->insertItem( (*it)->name(), index ); locations.append( ((*it)->isRemovable() ? (*it)->path() : homeDir) ); if ( lnk->file().contains( (*it)->path() ) ) { d->locationCombo->setCurrentItem( index ); currentLocation = index; } index++; } else if ( (*it)->name().contains( "Hard Disk") && homeDir.contains( (*it)->path() ) && (*it)->path().length() > hardDiskHome.length() ) { hardDiskHome = (*it)->name(); hardDiskPath = (*it)->path(); } } } if ( !hardDiskHome.isEmpty() ) { d->locationCombo->insertItem( hardDiskHome ); locations.append( hardDiskPath ); if ( currentLocation == -1 ) { // assume it's the hard disk d->locationCombo->setCurrentItem( index ); currentLocation = index; } } } void LnkProperties::duplicateLnk() |