summaryrefslogtreecommitdiff
path: root/noncore/apps/advancedfm/advancedfmMenu.cpp
authorllornkcor <llornkcor>2004-10-06 08:10:14 (UTC)
committer llornkcor <llornkcor>2004-10-06 08:10:14 (UTC)
commit14c237a2d5c60314935d51d9beea0527e337a9d8 (patch) (unidiff)
treeaaa74a61444febeec1db1760b79e5a07f47e8fd9 /noncore/apps/advancedfm/advancedfmMenu.cpp
parent637e5e26c5d30778234c03412f1bf44ed7b38a8e (diff)
downloadopie-14c237a2d5c60314935d51d9beea0527e337a9d8.zip
opie-14c237a2d5c60314935d51d9beea0527e337a9d8.tar.gz
opie-14c237a2d5c60314935d51d9beea0527e337a9d8.tar.bz2
if user clicks dialog's X, dont go ahead and do the actions
Diffstat (limited to 'noncore/apps/advancedfm/advancedfmMenu.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/advancedfm/advancedfmMenu.cpp137
1 files changed, 80 insertions, 57 deletions
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp
index 4802771..f25048a 100644
--- a/noncore/apps/advancedfm/advancedfmMenu.cpp
+++ b/noncore/apps/advancedfm/advancedfmMenu.cpp
@@ -148,66 +148,74 @@ void AdvancedFm::doDelete() {
148 if(count > 1 ) { 148 if(count > 1 ) {
149 QString msg; 149 QString msg;
150 msg=tr("<p>Really delete %1 files?</p>").arg(count); 150 msg=tr("<p>Really delete %1 files?</p>").arg(count);
151 switch ( QMessageBox::warning(this,tr("Delete"),msg 151 switch ( QMessageBox::warning(this,tr("Delete"),msg
152 ,tr("Yes"),tr("No"),0,0,1) ) 152 ,tr("Yes"),tr("No"),0,0,1) )
153 { 153 {
154 case 0: 154 case 0:
155 doMsg=false; 155 doMsg=false;
156 break; 156 break;
157 case 1: 157 case 1:
158 return; 158 return;
159 break; 159 break;
160 default:
161 return;
162 break;
160 }; 163 };
161 } 164 }
162 165
163 QString myFile; 166 QString myFile;
164 167
165 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 168 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
166 myFile = (*it); 169 myFile = (*it);
167 if( myFile.find(" -> ",0,TRUE) != -1) 170 if( myFile.find(" -> ",0,TRUE) != -1)
168 myFile = myFile.left( myFile.find(" -> ",0,TRUE)); 171 myFile = myFile.left( myFile.find(" -> ",0,TRUE));
169 172
170 QString f = CurrentDir()->canonicalPath(); 173 QString f = CurrentDir()->canonicalPath();
171 if(f.right(1).find("/",0,TRUE) == -1) 174 if(f.right(1).find("/",0,TRUE) == -1)
172 f += "/"; 175 f += "/";
173 f += myFile; 176 f += myFile;
174 if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { 177 if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) {
175 //if file is a directory 178 //if file is a directory
176 179
177 switch ( QMessageBox::warning( this, tr("Delete Directory?"), 180 switch ( QMessageBox::warning( this, tr("Delete Directory?"),
178 tr("<p>Really delete %1 and all it's contents?</p>" ).arg( f ) , 181 tr("<p>Really delete %1 and all it's contents?</p>" ).arg( f ) ,
179 tr("Yes"), tr("No"), 0, 0, 1) ) { 182 tr("Yes"), tr("No"), 0, 0, 1) ) {
180 case 0: 183 case 0:
181 { 184 {
182 f=f.left(f.length()-1); 185 f=f.left(f.length()-1);
183 QString cmd="rm -rf "+f; 186 QString cmd="rm -rf "+f;
184 startProcess( (const QString)cmd.latin1() ); 187 startProcess( (const QString)cmd.latin1() );
185 populateView(); 188 populateView();
186 } 189 }
187 break; 190 break;
188 case 1: 191 case 1:
189 // exit 192 // exit
190 break; 193 break;
194 default:
195 break;
191 }; 196 };
192 197
193 } else { 198 } else {
194 if(doMsg) { 199 if(doMsg) {
195 switch ( QMessageBox::warning(this,tr("Delete"), 200 switch ( QMessageBox::warning(this,tr("Delete"),
196 tr("<p>Really delete %1?</p>").arg( myFile ), 201 tr("<p>Really delete %1?</p>").arg( myFile ),
197 tr("Yes"), tr("No"), 0, 0, 1) ) { 202 tr("Yes"), tr("No"), 0, 0, 1) ) {
198 case 1: 203 case 1:
199 return; 204 return;
200 break; 205 break;
201 }; 206 default:
207 return;
208 break;
209 };
202 } 210 }
203 211
204 QString cmd="rm "+f; 212 QString cmd="rm "+f;
205 QFile file(f); 213 QFile file(f);
206 QFileInfo fi(myFile); 214 QFileInfo fi(myFile);
207 if( fi.fileName().find("../",0,TRUE)==-1) { 215 if( fi.fileName().find("../",0,TRUE)==-1) {
208// odebug << "remove link files "+myFile << oendl; 216// odebug << "remove link files "+myFile << oendl;
209 217
210// DocLnk lnk(f); 218// DocLnk lnk(f);
211 DocLnk *lnk; 219 DocLnk *lnk;
212 lnk = new DocLnk(f); 220 lnk = new DocLnk(f);
213// odebug << "Deleting doclnk " + lnk->linkFile() << oendl; 221// odebug << "Deleting doclnk " + lnk->linkFile() << oendl;
@@ -275,55 +283,61 @@ void AdvancedFm::copy() {
275 QDir *thisDir = CurrentDir(); 283 QDir *thisDir = CurrentDir();
276 QDir *thatDir = OtherDir(); 284 QDir *thatDir = OtherDir();
277 285
278 bool doMsg = true; 286 bool doMsg = true;
279 int count = curFileList.count(); 287 int count = curFileList.count();
280 if( count > 0) { 288 if( count > 0) {
281 if(count > 1 ){ 289 if(count > 1 ){
282 QString msg; 290 QString msg;
283 msg=tr("<p>Really copy %1 files?</p>").arg(count); 291 msg=tr("<p>Really copy %1 files?</p>").arg(count);
284 switch ( QMessageBox::warning(this,tr("Copy"),msg 292 switch ( QMessageBox::warning(this,tr("Copy"),msg
285 ,tr("Yes"),tr("No"),0,0,1) ) 293 ,tr("Yes"),tr("No"),0,0,1) )
286 { 294 {
287 case 0: 295 case 0:
288 doMsg=false; 296 doMsg=false;
289 break; 297 break;
290 case 1: 298 case 1:
291 return; 299 return;
292 break; 300 break;
301 default:
302 return;
303 break;
293 }; 304 };
294 } 305 }
295 306
296 QString curFile, item, destFile; 307 QString curFile, item, destFile;
297 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 308 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
298 item=(*it); 309 item=(*it);
299 if(item.find("->",0,TRUE)) //symlink 310 if(item.find("->",0,TRUE)) //symlink
300 item = item.left(item.find("->",0,TRUE)); 311 item = item.left(item.find("->",0,TRUE));
301 312
302 curFile = thisDir->canonicalPath()+"/"+ item; 313 curFile = thisDir->canonicalPath()+"/"+ item;
303 destFile = thatDir->canonicalPath()+"/"+ item; 314 destFile = thatDir->canonicalPath()+"/"+ item;
304 315
305// odebug << "Destination file is "+destFile << oendl; 316// odebug << "Destination file is "+destFile << oendl;
306// odebug << "CurrentFile file is " + curFile << oendl; 317// odebug << "CurrentFile file is " + curFile << oendl;
307 318
308 QFile f(destFile); 319 QFile f(destFile);
309 if( f.exists()) { 320 if( f.exists()) {
310 if(doMsg) { 321 if(doMsg) {
311 switch ( QMessageBox::warning(this,tr("File Exists!"), 322 switch ( QMessageBox::warning(this,tr("File Exists!"),
312 tr("<p>%1 already exists. Ok to overwrite?</P>").arg(item), 323 tr("<p>%1 already exists. Ok to overwrite?</P>").arg(item),
313 tr("Yes"),tr("No"),0,0,1)) { 324 tr("Yes"),tr("No"),0,0,1)) {
314 case 1: 325 case 1:
315 return; 326 return;
316 break; 327 break;
317 }; 328 default:
329 return;
330 break;
331 };
318 } 332 }
319 f.remove(); 333 f.remove();
320 } 334 }
321 335
322 if( !copyFile( curFile, destFile) ) { 336 if( !copyFile( curFile, destFile) ) {
323 QMessageBox::message("AdvancedFm", 337 QMessageBox::message("AdvancedFm",
324 tr( "<P>Could not copy %1 to %2</P>").arg(curFile).arg(destFile)); 338 tr( "<P>Could not copy %1 to %2</P>").arg(curFile).arg(destFile));
325 return; 339 return;
326 } 340 }
327 } 341 }
328 rePopulate(); 342 rePopulate();
329 } 343 }
@@ -348,34 +362,37 @@ void AdvancedFm::copyAs() {
348 curFile = thisDir->canonicalPath()+"/"+(*it); 362 curFile = thisDir->canonicalPath()+"/"+(*it);
349 fileDlg = new InputDialog( this, tr("Copy %1 As").arg(curFile), TRUE, 0); 363 fileDlg = new InputDialog( this, tr("Copy %1 As").arg(curFile), TRUE, 0);
350 364
351 fileDlg->setInputText((const QString &) destFile ); 365 fileDlg->setInputText((const QString &) destFile );
352 fileDlg->exec(); 366 fileDlg->exec();
353 367
354 if( fileDlg->result() == 1 ) { 368 if( fileDlg->result() == 1 ) {
355 QString filename = fileDlg->LineEdit1->text(); 369 QString filename = fileDlg->LineEdit1->text();
356 destFile = thatDir->canonicalPath()+"/"+filename; 370 destFile = thatDir->canonicalPath()+"/"+filename;
357 371
358 QFile f( destFile); 372 QFile f( destFile);
359 if( f.exists()) { 373 if( f.exists()) {
360 switch (QMessageBox::warning(this,tr("File Exists!"), 374 switch (QMessageBox::warning(this,tr("File Exists!"),
361 tr("<P> %1 already exists. Ok to overwrite?</p>").arg(item), 375 tr("<P> %1 already exists. Ok to overwrite?</p>").arg(item),
362 tr("Yes"),tr("No"),0,0,1) ) { 376 tr("Yes"),tr("No"),0,0,1) ) {
363 case 0: 377 case 0:
364 f.remove(); 378 f.remove();
365 break; 379 break;
366 case 1: 380 case 1:
367 return; 381 return;
368 break; 382 break;
369 }; 383 default:
384 return;
385 break;
386 };
370 } 387 }
371 if( !copyFile( curFile, destFile) ) { 388 if( !copyFile( curFile, destFile) ) {
372 QMessageBox::message("AdvancedFm",tr("<p>Could not copy %1 to %2</P>").arg(curFile).arg(destFile)); 389 QMessageBox::message("AdvancedFm",tr("<p>Could not copy %1 to %2</P>").arg(curFile).arg(destFile));
373 return; 390 return;
374 } 391 }
375 } 392 }
376 delete fileDlg; 393 delete fileDlg;
377 394
378 } 395 }
379 rePopulate(); 396 rePopulate();
380 // setOtherTabCurrent(); 397 // setOtherTabCurrent();
381 qApp->processEvents(); 398 qApp->processEvents();
@@ -400,35 +417,38 @@ void AdvancedFm::copySameDir() {
400 417
401 fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); 418 fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0);
402 fileDlg->setInputText((const QString &) destFile ); 419 fileDlg->setInputText((const QString &) destFile );
403 fileDlg->exec(); 420 fileDlg->exec();
404 421
405 if( fileDlg->result() == 1 ) { 422 if( fileDlg->result() == 1 ) {
406 423
407 QString filename = fileDlg->LineEdit1->text(); 424 QString filename = fileDlg->LineEdit1->text();
408 destFile = thisDir->canonicalPath()+"/"+filename; 425 destFile = thisDir->canonicalPath()+"/"+filename;
409 426
410 QFile f(destFile); 427 QFile f(destFile);
411 if( f.exists()) { 428 if( f.exists()) {
412 switch (QMessageBox::warning(this,tr("Delete"), 429 switch (QMessageBox::warning(this,tr("Delete"),
413 tr("<p> %1 already exists. Do you really want to delete it?</P>").arg(destFile), 430 tr("<p> %1 already exists. Do you really want to delete it?</P>").arg(destFile),
414 tr("Yes"),tr("No"),0,0,1) ) { 431 tr("Yes"),tr("No"),0,0,1) ) {
415 case 0: 432 case 0:
416 433
417 f.remove(); 434 f.remove();
418 break; 435 break;
419 case 1: 436 case 1:
420 return; 437 return;
421 break; 438 break;
422 }; 439 default:
440 return;
441 break;
442 };
423 } 443 }
424 if(!copyFile( curFile,destFile) ) { 444 if(!copyFile( curFile,destFile) ) {
425 QMessageBox::message("AdvancedFm",tr("<P>Could not copy %1 to %2</P>").arg(curFile).arg(destFile)); 445 QMessageBox::message("AdvancedFm",tr("<P>Could not copy %1 to %2</P>").arg(curFile).arg(destFile));
426 return; 446 return;
427 } 447 }
428 448
429// odebug << "copy "+curFile+" as "+destFile << oendl; 449// odebug << "copy "+curFile+" as "+destFile << oendl;
430 } 450 }
431 delete fileDlg; 451 delete fileDlg;
432 } 452 }
433 rePopulate(); 453 rePopulate();
434} 454}
@@ -458,31 +478,34 @@ void AdvancedFm::move() {
458 if(curFile.right(1).find("/",0,TRUE) == -1) 478 if(curFile.right(1).find("/",0,TRUE) == -1)
459 curFile +="/"; 479 curFile +="/";
460 curFile+= item; 480 curFile+= item;
461// odebug << "CurrentFile file is " + curFile << oendl; 481// odebug << "CurrentFile file is " + curFile << oendl;
462 482
463 if(QFileInfo(curFile).isDir()) { 483 if(QFileInfo(curFile).isDir()) {
464 moveDirectory( curFile, destFile ); 484 moveDirectory( curFile, destFile );
465 rePopulate(); 485 rePopulate();
466 return; 486 return;
467 } 487 }
468 QFile f( destFile); 488 QFile f( destFile);
469 if( f.exists()) { 489 if( f.exists()) {
470 switch ( QMessageBox::warning(this,tr("File Exists!"), 490 switch ( QMessageBox::warning(this,tr("File Exists!"),
471 tr("<p>%1 already exists. Ok to overwrite?</P>").arg(destFile), 491 tr("<p>%1 already exists. Ok to overwrite?</P>").arg(destFile),
472 tr("Yes"),tr("No"),0,0,1)) { 492 tr("Yes"),tr("No"),0,0,1)) {
473 case 1: 493 case 1:
474 return; 494 return;
475 break; 495 break;
476 }; 496 default:
497 return;
498 break;
499 };
477 if( !copyFile( curFile, destFile) ) { 500 if( !copyFile( curFile, destFile) ) {
478 QMessageBox::message(tr("Note"),tr("<p>Could not move %1</p>").arg(curFile)); 501 QMessageBox::message(tr("Note"),tr("<p>Could not move %1</p>").arg(curFile));
479 return; 502 return;
480 } else 503 } else
481 QFile::remove(curFile); 504 QFile::remove(curFile);
482 } 505 }
483 } 506 }
484 } 507 }
485 rePopulate(); 508 rePopulate();
486 //setOtherTabCurrent(); 509 //setOtherTabCurrent();
487} 510}
488 511