summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-07-11 16:36:34 (UTC)
committer llornkcor <llornkcor>2002-07-11 16:36:34 (UTC)
commit1651f048bb129b8e748a01c514d84c8626e0f1e2 (patch) (unidiff)
tree9b2783cfbb8b754a5aae098b2f4ae165b65f340c
parentf568737c20bea96fb79d85681a72e142ec05d66f (diff)
downloadopie-1651f048bb129b8e748a01c514d84c8626e0f1e2.zip
opie-1651f048bb129b8e748a01c514d84c8626e0f1e2.tar.gz
opie-1651f048bb129b8e748a01c514d84c8626e0f1e2.tar.bz2
added messageboc when copy, or move fileif file exists to ask ok to delete, added copy same dir to menu
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/advancedfm/advancedfm.cpp314
-rw-r--r--noncore/apps/advancedfm/advancedfm.h1
2 files changed, 232 insertions, 83 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp
index 9e38d14..f97ae99 100644
--- a/noncore/apps/advancedfm/advancedfm.cpp
+++ b/noncore/apps/advancedfm/advancedfm.cpp
@@ -95,5 +95,5 @@ AdvancedFm::AdvancedFm( )
95 95
96 qpeDirButton= new QToolButton(this,"QPEButton"); 96 qpeDirButton= new QToolButton(this,"QPEButton");
97 qpeDirButton->setPixmap( Resource::loadPixmap("launcher/opielogo16x16"));//,"",this,"QPEButton"); 97 qpeDirButton->setPixmap( Resource::loadPixmap("launcher/opielogo16x16"));//,"",this,"QPEButton");
98// qpeDirButton= new QPushButton(Resource::loadIconSet("launcher/opielogo16x16"),"",this,"QPEButton"); 98// qpeDirButton= new QPushButton(Resource::loadIconSet("launcher/opielogo16x16"),"",this,"QPEButton");
99 qpeDirButton ->setFixedSize( QSize( 20, 20 ) ); 99 qpeDirButton ->setFixedSize( QSize( 20, 20 ) );
@@ -103,5 +103,5 @@ AdvancedFm::AdvancedFm( )
103 103
104 cfButton = new QToolButton( this,"CFButton"); 104 cfButton = new QToolButton( this,"CFButton");
105 cfButton->setPixmap(Resource::loadPixmap("cardmon/pcmcia")); 105 cfButton->setPixmap(Resource::loadPixmap("cardmon/pcmcia"));
106// cfButton = new QPushButton(Resource::loadIconSet("cardmon/pcmcia"),"",this,"CFButton"); 106// cfButton = new QPushButton(Resource::loadIconSet("cardmon/pcmcia"),"",this,"CFButton");
107 cfButton ->setFixedSize( QSize( 20, 20 ) ); 107 cfButton ->setFixedSize( QSize( 20, 20 ) );
@@ -111,5 +111,5 @@ AdvancedFm::AdvancedFm( )
111 111
112 sdButton = new QToolButton( this,"SDButton"); 112 sdButton = new QToolButton( this,"SDButton");
113 sdButton->setPixmap(Resource::loadPixmap("sdmon/sdcard")); 113 sdButton->setPixmap(Resource::loadPixmap("sdmon/sdcard"));
114// sdButton = new QPushButton(Resource::loadIconSet("sdmon/sdcard"),"",this,"SDButton"); 114// sdButton = new QPushButton(Resource::loadIconSet("sdmon/sdcard"),"",this,"SDButton");
115 sdButton->setFixedSize( QSize( 20, 20 ) ); 115 sdButton->setFixedSize( QSize( 20, 20 ) );
@@ -119,5 +119,5 @@ AdvancedFm::AdvancedFm( )
119 119
120 cdUpButton = new QToolButton( this,"cdUpButton"); 120 cdUpButton = new QToolButton( this,"cdUpButton");
121 cdUpButton->setPixmap(Resource::loadPixmap("up")); 121 cdUpButton->setPixmap(Resource::loadPixmap("up"));
122// cdUpButton = new QPushButton(Resource::loadIconSet("up"),"",this,"cdUpButton"); 122// cdUpButton = new QPushButton(Resource::loadIconSet("up"),"",this,"cdUpButton");
123 cdUpButton ->setFixedSize( QSize( 20, 20 ) ); 123 cdUpButton ->setFixedSize( QSize( 20, 20 ) );
@@ -127,5 +127,5 @@ AdvancedFm::AdvancedFm( )
127 127
128 docButton = new QToolButton( this,"docsButton"); 128 docButton = new QToolButton( this,"docsButton");
129 docButton->setPixmap(Resource::loadPixmap("DocsIcon")); 129 docButton->setPixmap(Resource::loadPixmap("DocsIcon"));
130// docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"",this,"docsButton"); 130// docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"",this,"docsButton");
131 docButton->setFixedSize( QSize( 20, 20 ) ); 131 docButton->setFixedSize( QSize( 20, 20 ) );
@@ -135,5 +135,5 @@ AdvancedFm::AdvancedFm( )
135 135
136 homeButton = new QToolButton( this,"homeButton"); 136 homeButton = new QToolButton( this,"homeButton");
137 homeButton->setPixmap(Resource::loadPixmap("home")); 137 homeButton->setPixmap(Resource::loadPixmap("home"));
138// homeButton = new QPushButton( Resource::loadIconSet("home"),"",this,"homeButton"); 138// homeButton = new QPushButton( Resource::loadIconSet("home"),"",this,"homeButton");
139 homeButton->setFixedSize( QSize( 20, 20 ) ); 139 homeButton->setFixedSize( QSize( 20, 20 ) );
@@ -1186,6 +1186,16 @@ void AdvancedFm::copy()
1186 1186
1187 QFile f(destFile); 1187 QFile f(destFile);
1188 if( f.exists()) 1188 if( f.exists()) {
1189 switch ( QMessageBox::warning(this,tr("Delete"),
1190 destFile+tr(" already exists\nDo you really want to delete it?"),
1191 tr("Yes"),tr("No"),0,0,1) ) {
1192 case 0:
1189 f.remove(); 1193 f.remove();
1194 break;
1195 case 1:
1196 return;
1197 break;
1198 };
1199 }
1190 if(!copyFile(destFile, curFile) ) { 1200 if(!copyFile(destFile, curFile) ) {
1191 QMessageBox::message("AdvancedFm","Could not copy\n"+curFile +"to\n"+destFile); 1201 QMessageBox::message("AdvancedFm","Could not copy\n"+curFile +"to\n"+destFile);
@@ -1203,6 +1213,16 @@ void AdvancedFm::copy()
1203 1213
1204 QFile f(destFile); 1214 QFile f(destFile);
1205 if( f.exists()) 1215 if( f.exists()) {
1216 switch ( QMessageBox::warning(this,tr("Delete"),
1217 destFile+tr(" already exists\nDo you really want to delete it?"),
1218 tr("Yes"),tr("No"),0,0,1) ) {
1219 case 0:
1206 f.remove(); 1220 f.remove();
1221 break;
1222 case 1:
1223 return;
1224 break;
1225 };
1226 }
1207 if(!copyFile(destFile, curFile) ) { 1227 if(!copyFile(destFile, curFile) ) {
1208 QMessageBox::message("AdvancedFm","Could not copy\n"+curFile +"to\n"+destFile); 1228 QMessageBox::message("AdvancedFm","Could not copy\n"+curFile +"to\n"+destFile);
@@ -1214,5 +1234,5 @@ void AdvancedFm::copy()
1214 TabWidget->setCurrentPage(0); 1234 TabWidget->setCurrentPage(0);
1215 } 1235 }
1216} 1236 }
1217} 1237}
1218 1238
@@ -1221,117 +1241,244 @@ void AdvancedFm::copyAs()
1221 QStringList curFileList = getPath(); 1241 QStringList curFileList = getPath();
1222 if( curFileList.count() > 0) { 1242 if( curFileList.count() > 0) {
1223 QString curFile; 1243 QString curFile;
1224 InputDialog *fileDlg; 1244 InputDialog *fileDlg;
1225 fileDlg = new InputDialog(this,tr("Copy As"),TRUE, 0); 1245 fileDlg = new InputDialog(this,tr("Copy As"),TRUE, 0);
1226 1246
1227 if (TabWidget->currentPageIndex() == 0) { 1247 if (TabWidget->currentPageIndex() == 0) {
1228 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 1248 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
1229 QString destFile; 1249 QString destFile;
1230 curFile = currentDir.canonicalPath()+"/"+(*it); 1250 curFile = currentDir.canonicalPath()+"/"+(*it);
1231// InputDialog *fileDlg; 1251// InputDialog *fileDlg;
1232// fileDlg = new InputDialog(this,tr("Copy As"),TRUE, 0); 1252// fileDlg = new InputDialog(this,tr("Copy As"),TRUE, 0);
1233 fileDlg->setInputText((const QString &) destFile ); 1253 fileDlg->setInputText((const QString &) destFile );
1234 fileDlg->exec(); 1254 fileDlg->exec();
1235 if( fileDlg->result() == 1 ) { 1255 if( fileDlg->result() == 1 ) {
1236 QString filename = fileDlg->LineEdit1->text(); 1256 QString filename = fileDlg->LineEdit1->text();
1237 destFile = currentRemoteDir.canonicalPath()+"/"+(*it); 1257 destFile = currentRemoteDir.canonicalPath()+"/"+(*it);
1238 1258
1239 QFile f(destFile); 1259 QFile f(destFile);
1240 if( f.exists()) 1260 if( f.exists()) {
1241 f.remove(); 1261 switch (QMessageBox::warning(this,tr("Delete"),
1242 if(!copyFile(destFile, curFile) ) { 1262 destFile+tr(" already exists\nDo you really want to delete it?"),
1243 QMessageBox::message("AdvancedFm","Could not copy\n"+curFile +"to\n"+destFile); 1263 tr("Yes"),tr("No"),0,0,1) ) {
1244 qWarning("nothin doing"); 1264 case 0:
1265 f.remove();
1266 break;
1267 case 1:
1268 return;
1269 break;
1270 };
1271 }
1272 if(!copyFile(destFile, curFile) ) {
1273 QMessageBox::message("AdvancedFm","Could not copy\n"+curFile +"to\n"+destFile);
1274 qWarning("nothin doing");
1275 }
1245 } 1276 }
1246 } 1277 }
1278 populateRemoteView();
1279 TabWidget->setCurrentPage(1);
1280 } else {
1281 if (TabWidget->currentPageIndex() == 0) {
1282 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
1283
1284 curFile = currentDir.canonicalPath()+"/"+(*it);
1285 QString destFile;
1286 fileDlg->setInputText((const QString &) destFile);
1287 fileDlg->exec();
1288 if( fileDlg->result() == 1 ) {
1289 QString filename = fileDlg->LineEdit1->text();
1290 destFile = currentDir.canonicalPath()+"/"+(*it);
1291
1292 QFile f(destFile);
1293 if( f.exists()) {
1294 switch ( QMessageBox::warning(this,tr("Delete"),
1295 destFile+tr(" already exists\nDo you really want to delete it?"),
1296 tr("Yes"),tr("No"),0,0,1) ) {
1297 case 0:
1298 f.remove();
1299 break;
1300 case 1:
1301 return;
1302 break;
1303 };
1304 }
1305 if(!copyFile(destFile, curFile) ) {
1306 QMessageBox::message("AdvancedFm","Could not copy\n"+curFile +"to\n"+destFile);
1307 qWarning("nothin doing");
1308 }
1309
1310 }
1311 }
1312 populateLocalView();
1313 TabWidget->setCurrentPage(0);
1314 }
1247 } 1315 }
1316 }
1317
1318}
1319
1320void AdvancedFm::copySameDir() {
1321 QStringList curFileList = getPath();
1322 if( curFileList.count() > 0) {
1323 QString curFile;
1324 InputDialog *fileDlg;
1248 1325
1249 populateRemoteView();
1250 TabWidget->setCurrentPage(1);
1251 } else {
1252 if (TabWidget->currentPageIndex() == 0) { 1326 if (TabWidget->currentPageIndex() == 0) {
1253 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 1327 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
1254
1255 curFile = currentDir.canonicalPath()+"/"+(*it);
1256 QString destFile; 1328 QString destFile;
1257 fileDlg->setInputText((const QString &) destFile); 1329 curFile = currentDir.canonicalPath()+"/"+(*it);
1330 fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0);
1331// InputDialog *fileDlg;
1332// fileDlg = new InputDialog(this,tr("Copy As"),TRUE, 0);
1333 fileDlg->setInputText((const QString &) destFile );
1258 fileDlg->exec(); 1334 fileDlg->exec();
1259 if( fileDlg->result() == 1 ) { 1335 if( fileDlg->result() == 1 ) {
1260 QString filename = fileDlg->LineEdit1->text(); 1336 QString filename = fileDlg->LineEdit1->text();
1261 destFile = currentDir.canonicalPath()+"/"+(*it); 1337 destFile = currentDir.canonicalPath()+"/"+filename;
1262 1338
1263 QFile f(destFile); 1339 QFile f(destFile);
1264 if( f.exists()) 1340 if( f.exists()) {
1265 f.remove(); 1341 switch (QMessageBox::warning(this,tr("Delete"),
1342 destFile+tr(" already exists\nDo you really want to delete it?"),
1343 tr("Yes"),tr("No"),0,0,1) ) {
1344 case 0:
1345 qDebug("");
1346 f.remove();
1347 break;
1348 case 1:
1349 return;
1350 break;
1351 };
1352 }
1266 if(!copyFile(destFile, curFile) ) { 1353 if(!copyFile(destFile, curFile) ) {
1267 QMessageBox::message("AdvancedFm","Could not copy\n"+curFile +"to\n"+destFile); 1354 QMessageBox::message("AdvancedFm","Could not copy\n"+curFile +"to\n"+destFile);
1268 qWarning("nothin doing"); 1355 qWarning("nothin doing");
1269 } 1356 }
1357
1358 qDebug("copy "+curFile+" as "+destFile);
1270 } 1359 }
1360 delete fileDlg;
1361 }
1362 populateRemoteView();
1363 TabWidget->setCurrentPage(1);
1364 } else {
1365 if (TabWidget->currentPageIndex() == 0) {
1366 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
1367
1368 curFile = currentRemoteDir.canonicalPath()+"/"+(*it);
1369 fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0);
1370 QString destFile;
1371 fileDlg->setInputText((const QString &) destFile);
1372 fileDlg->exec();
1373 if( fileDlg->result() == 1 ) {
1374 QString filename = fileDlg->LineEdit1->text();
1375 destFile = currentDir.canonicalPath()+"/"+filename;
1376
1377 QFile f(destFile);
1378 if( f.exists()) {
1379 switch ( QMessageBox::warning(this,tr("Delete"),
1380 destFile+tr(" already exists\nDo you really want to delete it?"),
1381 tr("Yes"),tr("No"),0,0,1) ) {
1382 case 0:
1383 f.remove();
1384 break;
1385 case 1:
1386 return;
1387 break;
1388 };
1389 }
1390 if(!copyFile(destFile, curFile) ) {
1391 QMessageBox::message("AdvancedFm","Could not copy\n"+curFile +"to\n"+destFile);
1392 qWarning("nothin doing");
1393 }
1394 qDebug("copy "+curFile+" as "+destFile);
1395 }
1396 delete fileDlg;
1397 }
1398 populateLocalView();
1399 TabWidget->setCurrentPage(0);
1271 } 1400 }
1272 populateLocalView();
1273 TabWidget->setCurrentPage(0);
1274 } 1401 }
1275 } 1402 }
1276}
1277}
1278 1403
1404}
1405
1279void AdvancedFm::move() { 1406void AdvancedFm::move() {
1280 1407
1281 QStringList curFileList = getPath(); 1408 QStringList curFileList = getPath();
1282 if( curFileList.count() > 0) { 1409 if( curFileList.count() > 0) {
1283 QString curFile; 1410 QString curFile;
1284// qDebug(curFile); 1411// qDebug(curFile);
1285 QString destFile; 1412 QString destFile;
1286 1413
1287 if (TabWidget->currentPageIndex() == 0) { 1414 if (TabWidget->currentPageIndex() == 0) {
1288 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 1415 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
1289 QString destFile = currentRemoteDir.canonicalPath(); 1416 QString destFile = currentRemoteDir.canonicalPath();
1290 if(destFile.right(1).find("/",0,TRUE) == -1) 1417 if(destFile.right(1).find("/",0,TRUE) == -1)
1291 destFile+="/"; 1418 destFile+="/";
1292 destFile +=(*it); 1419 destFile +=(*it);
1293 curFile = currentDir.canonicalPath(); 1420 curFile = currentDir.canonicalPath();
1294 qDebug("Destination file is "+destFile); 1421 qDebug("Destination file is "+destFile);
1295 if(curFile.right(1).find("/",0,TRUE) == -1) 1422 if(curFile.right(1).find("/",0,TRUE) == -1)
1296 curFile +="/"; 1423 curFile +="/";
1297 curFile+=(*it); 1424 curFile+=(*it);
1298 1425
1299 QFile f(destFile); 1426 QFile f(destFile);
1300 if( f.exists()) 1427 if( f.exists()) {
1301 f.remove(); 1428 switch (QMessageBox::warning(this,tr("Delete"),
1302 if(!copyFile( destFile, curFile) ) { 1429 destFile+tr(" already exists\nDo you really want to delete it?"),
1303 QMessageBox::message(tr("Note"),tr("Could not move\n"+curFile)); 1430 tr("Yes"),tr("No"),0,0,1) ) {
1304 return; 1431 case 0:
1432 f.remove();
1433 break;
1434 case 1:
1435 return;
1436 break;
1437 };
1438 if(!copyFile( destFile, curFile) ) {
1439 QMessageBox::message(tr("Note"),tr("Could not move\n"+curFile));
1440 return;
1441 }
1442 QFile::remove(curFile);
1443 }
1305 } 1444 }
1306 QFile::remove(curFile); 1445 TabWidget->setCurrentPage(1);
1307 } 1446 } else {
1308 TabWidget->setCurrentPage(1); 1447 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
1309 } else { 1448 QString destFile = currentRemoteDir.canonicalPath();
1310 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
1311 QString destFile = currentRemoteDir.canonicalPath();
1312 if(destFile.right(1).find("/",0,TRUE) == -1) 1449 if(destFile.right(1).find("/",0,TRUE) == -1)
1313 destFile+="/"; 1450 destFile+="/";
1314 destFile +=(*it); 1451 destFile +=(*it);
1315 qDebug("Destination file is "+destFile); 1452 qDebug("Destination file is "+destFile);
1316 curFile = currentDir.canonicalPath(); 1453 curFile = currentDir.canonicalPath();
1317 if(curFile.right(1).find("/",0,TRUE) == -1) 1454 if(curFile.right(1).find("/",0,TRUE) == -1)
1318 curFile +="/"; 1455 curFile +="/";
1319 curFile+=(*it); 1456 curFile+=(*it);
1320 1457
1321 QFile f(destFile); 1458 QFile f(destFile);
1322 if( f.exists()) 1459 if( f.exists()) {
1323 f.remove(); 1460 switch (QMessageBox::warning(this,tr("Delete"),
1324 if(!copyFile(destFile, curFile) ) { 1461 destFile+tr(" already exists\nDo you really want to delete it?"),
1325 QMessageBox::message(tr("Note"),tr("Could not move\n"+curFile)); 1462 tr("Yes"),tr("No"),0,0,1) ) {
1326 return; 1463 case 0:
1464 f.remove();
1465 break;
1466 case 1:
1467 return;
1468 break;
1469 };
1470 if(!copyFile(destFile, curFile) ) {
1471 QMessageBox::message(tr("Note"),tr("Could not move\n"+curFile));
1472 return;
1473 }
1474 }
1475 QFile::remove(curFile);
1476 TabWidget->setCurrentPage(0);
1477 }
1327 } 1478 }
1328 QFile::remove(curFile); 1479 populateRemoteView();
1329 TabWidget->setCurrentPage(0); 1480 populateLocalView();
1330 } 1481 }
1331 }
1332 populateRemoteView();
1333 populateLocalView();
1334} 1482}
1335 }
1336 1483
1337 bool AdvancedFm::copyFile( const QString & dest, const QString & src ) 1484 bool AdvancedFm::copyFile( const QString & dest, const QString & src )
@@ -1756,4 +1903,5 @@ void AdvancedFm::showFileMenu() {
1756 m->insertItem( tr( "Copy" ), this, SLOT( copy() )); 1903 m->insertItem( tr( "Copy" ), this, SLOT( copy() ));
1757 m->insertItem( tr( "Copy As" ), this, SLOT( copyAs() )); 1904 m->insertItem( tr( "Copy As" ), this, SLOT( copyAs() ));
1905 m->insertItem( tr( "Copy Same Dir" ), this, SLOT( copySameDir() ));
1758 m->insertItem( tr( "Move" ), this, SLOT( move() )); 1906 m->insertItem( tr( "Move" ), this, SLOT( move() ));
1759 m->insertSeparator(); 1907 m->insertSeparator();
diff --git a/noncore/apps/advancedfm/advancedfm.h b/noncore/apps/advancedfm/advancedfm.h
index 7335773..7665fe9 100644
--- a/noncore/apps/advancedfm/advancedfm.h
+++ b/noncore/apps/advancedfm/advancedfm.h
@@ -125,4 +125,5 @@ protected slots:
125 void copy(); 125 void copy();
126 void copyAs(); 126 void copyAs();
127 void copySameDir();
127 void currentPathComboActivated(const QString &); 128 void currentPathComboActivated(const QString &);
128 void fillCombo(const QString &); 129 void fillCombo(const QString &);