-rw-r--r-- | noncore/apps/advancedfm/advancedfm.cpp | 120 |
1 files changed, 67 insertions, 53 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp index 818a281..b169a79 100644 --- a/noncore/apps/advancedfm/advancedfm.cpp +++ b/noncore/apps/advancedfm/advancedfm.cpp | |||
@@ -1003,6 +1003,7 @@ QStringList AdvancedFm::getPath() { | |||
1003 | for ( ; it.current(); ++it ) { | 1003 | for ( ; it.current(); ++it ) { |
1004 | if ( it.current()->isSelected() ) { | 1004 | if ( it.current()->isSelected() ) { |
1005 | strList << it.current()->text(0); | 1005 | strList << it.current()->text(0); |
1006 | qDebug(it.current()->text(0)); | ||
1006 | } | 1007 | } |
1007 | } | 1008 | } |
1008 | return strList; | 1009 | return strList; |
@@ -1012,6 +1013,7 @@ QStringList AdvancedFm::getPath() { | |||
1012 | for ( ; it.current(); ++it ) { | 1013 | for ( ; it.current(); ++it ) { |
1013 | if ( it.current()->isSelected() ) { | 1014 | if ( it.current()->isSelected() ) { |
1014 | strList << it.current()->text(0); | 1015 | strList << it.current()->text(0); |
1016 | qDebug(it.current()->text(0)); | ||
1015 | } | 1017 | } |
1016 | } | 1018 | } |
1017 | return strList; | 1019 | return strList; |
@@ -1099,6 +1101,7 @@ void AdvancedFm::upDir() | |||
1099 | 1101 | ||
1100 | void AdvancedFm::copy() | 1102 | void AdvancedFm::copy() |
1101 | { | 1103 | { |
1104 | qApp->processEvents(); | ||
1102 | QStringList curFileList = getPath(); | 1105 | QStringList curFileList = getPath(); |
1103 | if( curFileList.count() > 0) { | 1106 | if( curFileList.count() > 0) { |
1104 | QString curFile; | 1107 | QString curFile; |
@@ -1106,7 +1109,11 @@ void AdvancedFm::copy() | |||
1106 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 1109 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
1107 | 1110 | ||
1108 | QString destFile = currentRemoteDir.canonicalPath()+"/"+(*it); | 1111 | QString destFile = currentRemoteDir.canonicalPath()+"/"+(*it); |
1112 | qDebug("Destination file is "+destFile); | ||
1113 | |||
1109 | curFile = currentDir.canonicalPath()+"/"+(*it); | 1114 | curFile = currentDir.canonicalPath()+"/"+(*it); |
1115 | qDebug("CurrentFile file is " + curFile); | ||
1116 | |||
1110 | QFile f(destFile); | 1117 | QFile f(destFile); |
1111 | if( f.exists()) { | 1118 | if( f.exists()) { |
1112 | switch ( QMessageBox::warning(this,tr("Delete"), | 1119 | switch ( QMessageBox::warning(this,tr("Delete"), |
@@ -1132,7 +1139,9 @@ void AdvancedFm::copy() | |||
1132 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 1139 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
1133 | 1140 | ||
1134 | QString destFile = currentDir.canonicalPath()+"/"+(*it); | 1141 | QString destFile = currentDir.canonicalPath()+"/"+(*it); |
1142 | qDebug("Destination file is "+destFile); | ||
1135 | curFile = currentRemoteDir.canonicalPath()+"/"+(*it); | 1143 | curFile = currentRemoteDir.canonicalPath()+"/"+(*it); |
1144 | qDebug("CurrentFile file is " + curFile); | ||
1136 | 1145 | ||
1137 | QFile f(destFile); | 1146 | QFile f(destFile); |
1138 | if( f.exists()) { | 1147 | if( f.exists()) { |
@@ -1156,26 +1165,29 @@ void AdvancedFm::copy() | |||
1156 | populateLocalView(); | 1165 | populateLocalView(); |
1157 | TabWidget->setCurrentPage(0); | 1166 | TabWidget->setCurrentPage(0); |
1158 | } | 1167 | } |
1168 | |||
1159 | } | 1169 | } |
1160 | } | 1170 | } |
1161 | 1171 | ||
1162 | void AdvancedFm::copyAs() | 1172 | void AdvancedFm::copyAs() { |
1163 | { | 1173 | qApp->processEvents(); |
1174 | |||
1164 | QStringList curFileList = getPath(); | 1175 | QStringList curFileList = getPath(); |
1165 | if( curFileList.count() > 0) { | ||
1166 | QString curFile; | 1176 | QString curFile; |
1167 | InputDialog *fileDlg; | 1177 | InputDialog *fileDlg; |
1168 | fileDlg = new InputDialog(this,tr("Copy As"),TRUE, 0); | ||
1169 | |||
1170 | if (TabWidget->currentPageIndex() == 0) { | 1178 | if (TabWidget->currentPageIndex() == 0) { |
1179 | qDebug("tab 1"); | ||
1171 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 1180 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
1172 | QString destFile; | 1181 | QString destFile; |
1173 | curFile = currentDir.canonicalPath()+"/"+(*it); | 1182 | curFile = currentDir.canonicalPath()+"/"+(*it); |
1183 | fileDlg = new InputDialog( this,tr("Copy "+curFile+" As"), TRUE, 0); | ||
1184 | |||
1174 | fileDlg->setInputText((const QString &) destFile ); | 1185 | fileDlg->setInputText((const QString &) destFile ); |
1175 | fileDlg->exec(); | 1186 | fileDlg->exec(); |
1187 | |||
1176 | if( fileDlg->result() == 1 ) { | 1188 | if( fileDlg->result() == 1 ) { |
1177 | QString filename = fileDlg->LineEdit1->text(); | 1189 | QString filename = fileDlg->LineEdit1->text(); |
1178 | destFile = currentRemoteDir.canonicalPath()+"/"+(*it); | 1190 | destFile = currentRemoteDir.canonicalPath()+"/"+filename; |
1179 | 1191 | ||
1180 | QFile f(destFile); | 1192 | QFile f(destFile); |
1181 | if( f.exists()) { | 1193 | if( f.exists()) { |
@@ -1195,20 +1207,25 @@ void AdvancedFm::copyAs() | |||
1195 | qWarning("nothin doing"); | 1207 | qWarning("nothin doing"); |
1196 | } | 1208 | } |
1197 | } | 1209 | } |
1210 | delete fileDlg; | ||
1211 | |||
1198 | } | 1212 | } |
1199 | populateRemoteView(); | 1213 | populateRemoteView(); |
1200 | TabWidget->setCurrentPage(1); | 1214 | TabWidget->setCurrentPage(1); |
1215 | |||
1201 | } else { | 1216 | } else { |
1202 | if (TabWidget->currentPageIndex() == 0) { | ||
1203 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 1217 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
1204 | 1218 | ||
1205 | curFile = currentDir.canonicalPath()+"/"+(*it); | 1219 | curFile = currentRemoteDir.canonicalPath()+"/"+(*it); |
1220 | fileDlg = new InputDialog( this,tr("Copy "+curFile+" As"), TRUE, 0); | ||
1221 | |||
1206 | QString destFile; | 1222 | QString destFile; |
1207 | fileDlg->setInputText((const QString &) destFile); | 1223 | fileDlg->setInputText((const QString &) destFile); |
1208 | fileDlg->exec(); | 1224 | fileDlg->exec(); |
1225 | |||
1209 | if( fileDlg->result() == 1 ) { | 1226 | if( fileDlg->result() == 1 ) { |
1210 | QString filename = fileDlg->LineEdit1->text(); | 1227 | QString filename = fileDlg->LineEdit1->text(); |
1211 | destFile = currentDir.canonicalPath()+"/"+(*it); | 1228 | destFile = currentDir.canonicalPath()+"/"+filename; |
1212 | 1229 | ||
1213 | QFile f(destFile); | 1230 | QFile f(destFile); |
1214 | if( f.exists()) { | 1231 | if( f.exists()) { |
@@ -1229,29 +1246,33 @@ void AdvancedFm::copyAs() | |||
1229 | } | 1246 | } |
1230 | 1247 | ||
1231 | } | 1248 | } |
1249 | delete fileDlg; | ||
1250 | |||
1232 | } | 1251 | } |
1233 | populateLocalView(); | 1252 | populateLocalView(); |
1234 | TabWidget->setCurrentPage(0); | 1253 | TabWidget->setCurrentPage(0); |
1235 | } | 1254 | } |
1236 | } | 1255 | } |
1237 | } | ||
1238 | |||
1239 | } | ||
1240 | 1256 | ||
1241 | void AdvancedFm::copySameDir() { | 1257 | void AdvancedFm::copySameDir() { |
1258 | qApp->processEvents(); | ||
1242 | QStringList curFileList = getPath(); | 1259 | QStringList curFileList = getPath(); |
1243 | if( curFileList.count() > 0) { | ||
1244 | QString curFile; | 1260 | QString curFile; |
1245 | InputDialog *fileDlg; | 1261 | InputDialog *fileDlg; |
1246 | 1262 | ||
1247 | if (TabWidget->currentPageIndex() == 0) { | 1263 | if (TabWidget->currentPageIndex() == 0) { |
1264 | |||
1248 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 1265 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
1266 | |||
1249 | QString destFile; | 1267 | QString destFile; |
1250 | curFile = currentDir.canonicalPath()+"/"+(*it); | 1268 | curFile = currentDir.canonicalPath()+"/"+(*it); |
1269 | |||
1251 | fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); | 1270 | fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); |
1252 | fileDlg->setInputText((const QString &) destFile ); | 1271 | fileDlg->setInputText((const QString &) destFile ); |
1253 | fileDlg->exec(); | 1272 | fileDlg->exec(); |
1273 | |||
1254 | if( fileDlg->result() == 1 ) { | 1274 | if( fileDlg->result() == 1 ) { |
1275 | |||
1255 | QString filename = fileDlg->LineEdit1->text(); | 1276 | QString filename = fileDlg->LineEdit1->text(); |
1256 | destFile = currentDir.canonicalPath()+"/"+filename; | 1277 | destFile = currentDir.canonicalPath()+"/"+filename; |
1257 | 1278 | ||
@@ -1278,20 +1299,21 @@ void AdvancedFm::copySameDir() { | |||
1278 | } | 1299 | } |
1279 | delete fileDlg; | 1300 | delete fileDlg; |
1280 | } | 1301 | } |
1281 | populateRemoteView(); | 1302 | populateLocalView(); |
1282 | TabWidget->setCurrentPage(1); | 1303 | |
1283 | } else { | 1304 | } else { |
1284 | if (TabWidget->currentPageIndex() == 0) { | ||
1285 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 1305 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
1286 | 1306 | ||
1287 | curFile = currentRemoteDir.canonicalPath()+"/"+(*it); | 1307 | curFile = currentRemoteDir.canonicalPath()+"/"+(*it); |
1308 | |||
1288 | fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); | 1309 | fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); |
1289 | QString destFile; | 1310 | QString destFile; |
1290 | fileDlg->setInputText((const QString &) destFile); | 1311 | fileDlg->setInputText((const QString &) destFile); |
1291 | fileDlg->exec(); | 1312 | fileDlg->exec(); |
1292 | if( fileDlg->result() == 1 ) { | 1313 | if( fileDlg->result() == 1 ) { |
1293 | QString filename = fileDlg->LineEdit1->text(); | 1314 | QString filename = fileDlg->LineEdit1->text(); |
1294 | destFile = currentDir.canonicalPath()+"/"+filename; | 1315 | |
1316 | destFile = currentRemoteDir.canonicalPath()+"/"+filename; | ||
1295 | 1317 | ||
1296 | QFile f(destFile); | 1318 | QFile f(destFile); |
1297 | if( f.exists()) { | 1319 | if( f.exists()) { |
@@ -1314,84 +1336,77 @@ void AdvancedFm::copySameDir() { | |||
1314 | } | 1336 | } |
1315 | delete fileDlg; | 1337 | delete fileDlg; |
1316 | } | 1338 | } |
1317 | populateLocalView(); | 1339 | populateRemoteView(); |
1318 | TabWidget->setCurrentPage(0); | ||
1319 | } | ||
1320 | } | ||
1321 | } | 1340 | } |
1322 | |||
1323 | } | 1341 | } |
1324 | 1342 | ||
1325 | void AdvancedFm::move() { | 1343 | void AdvancedFm::move() { |
1344 | qApp->processEvents(); | ||
1326 | 1345 | ||
1327 | QStringList curFileList = getPath(); | 1346 | QStringList curFileList = getPath(); |
1328 | if( curFileList.count() > 0) { | 1347 | if( curFileList.count() > 0) { |
1329 | QString curFile; | 1348 | QString curFile; |
1330 | // qDebug(curFile); | ||
1331 | QString destFile; | 1349 | QString destFile; |
1332 | 1350 | ||
1333 | if (TabWidget->currentPageIndex() == 0) { | 1351 | if (TabWidget->currentPageIndex() == 0) { |
1352 | |||
1334 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 1353 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
1354 | |||
1335 | QString destFile = currentRemoteDir.canonicalPath(); | 1355 | QString destFile = currentRemoteDir.canonicalPath(); |
1356 | |||
1336 | if(destFile.right(1).find("/",0,TRUE) == -1) | 1357 | if(destFile.right(1).find("/",0,TRUE) == -1) |
1337 | destFile+="/"; | 1358 | destFile+="/"; |
1338 | destFile +=(*it); | 1359 | destFile +=(*it); |
1339 | curFile = currentDir.canonicalPath(); | 1360 | curFile = currentDir.canonicalPath(); |
1361 | |||
1340 | qDebug("Destination file is "+destFile); | 1362 | qDebug("Destination file is "+destFile); |
1363 | |||
1341 | if(curFile.right(1).find("/",0,TRUE) == -1) | 1364 | if(curFile.right(1).find("/",0,TRUE) == -1) |
1342 | curFile +="/"; | 1365 | curFile +="/"; |
1366 | |||
1343 | curFile+=(*it); | 1367 | curFile+=(*it); |
1368 | qDebug("CurrentFile file is " + curFile); | ||
1344 | 1369 | ||
1345 | QFile f(destFile); | 1370 | QFile f( curFile); |
1346 | if( f.exists()) { | 1371 | if( f.exists()) { |
1347 | switch (QMessageBox::warning(this,tr("Delete"), | ||
1348 | destFile+tr(" already exists\nDo you really want to delete it?"), | ||
1349 | tr("Yes"),tr("No"),0,0,1) ) { | ||
1350 | case 0: | ||
1351 | f.remove(); | ||
1352 | break; | ||
1353 | case 1: | ||
1354 | return; | ||
1355 | break; | ||
1356 | }; | ||
1357 | if(!copyFile( destFile, curFile) ) { | 1372 | if(!copyFile( destFile, curFile) ) { |
1358 | QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); | 1373 | QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); |
1359 | return; | 1374 | return; |
1360 | } | 1375 | } else |
1361 | QFile::remove(curFile); | 1376 | QFile::remove(curFile); |
1362 | } | 1377 | } |
1363 | } | 1378 | } |
1379 | |||
1364 | TabWidget->setCurrentPage(1); | 1380 | TabWidget->setCurrentPage(1); |
1365 | } else { | 1381 | |
1382 | } else { //view 2 | ||
1383 | |||
1366 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 1384 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
1367 | QString destFile = currentRemoteDir.canonicalPath(); | 1385 | |
1386 | QString destFile = currentDir.canonicalPath(); | ||
1387 | |||
1368 | if(destFile.right(1).find("/",0,TRUE) == -1) | 1388 | if(destFile.right(1).find("/",0,TRUE) == -1) |
1369 | destFile+="/"; | 1389 | destFile+="/"; |
1390 | |||
1370 | destFile +=(*it); | 1391 | destFile +=(*it); |
1392 | |||
1371 | qDebug("Destination file is "+destFile); | 1393 | qDebug("Destination file is "+destFile); |
1372 | curFile = currentDir.canonicalPath(); | 1394 | |
1395 | curFile = currentRemoteDir.canonicalPath(); | ||
1396 | |||
1373 | if(curFile.right(1).find("/",0,TRUE) == -1) | 1397 | if(curFile.right(1).find("/",0,TRUE) == -1) |
1374 | curFile +="/"; | 1398 | curFile +="/"; |
1375 | curFile+=(*it); | 1399 | curFile+=(*it); |
1400 | qDebug("CurrentFile file is " + curFile); | ||
1376 | 1401 | ||
1377 | QFile f(destFile); | 1402 | QFile f( curFile); |
1378 | if( f.exists()) { | 1403 | 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 | if(!copyFile(destFile, curFile) ) { | 1404 | if(!copyFile(destFile, curFile) ) { |
1390 | QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); | 1405 | QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); |
1391 | return; | 1406 | return; |
1392 | } | 1407 | } else |
1393 | } | ||
1394 | QFile::remove(curFile); | 1408 | QFile::remove(curFile); |
1409 | } | ||
1395 | TabWidget->setCurrentPage(0); | 1410 | TabWidget->setCurrentPage(0); |
1396 | } | 1411 | } |
1397 | } | 1412 | } |
@@ -1400,8 +1415,7 @@ void AdvancedFm::move() { | |||
1400 | } | 1415 | } |
1401 | } | 1416 | } |
1402 | 1417 | ||
1403 | bool AdvancedFm::copyFile( const QString & dest, const QString & src ) | 1418 | bool AdvancedFm::copyFile( const QString & dest, const QString & src ) { |
1404 | { | ||
1405 | char bf[ 50000 ]; | 1419 | char bf[ 50000 ]; |
1406 | int bytesRead; | 1420 | int bytesRead; |
1407 | bool success = TRUE; | 1421 | bool success = TRUE; |