summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-04-27 22:47:48 (UTC)
committer llornkcor <llornkcor>2002-04-27 22:47:48 (UTC)
commit8e3c0aa915801b862f97ba7a7598ef5f3bd350aa (patch) (unidiff)
tree6fed799512ebdcd4c78a56097c49d354de648690
parent392596c06dedf8ddaea7c55745460e631073d15a (diff)
downloadopie-8e3c0aa915801b862f97ba7a7598ef5f3bd350aa.zip
opie-8e3c0aa915801b862f97ba7a7598ef5f3bd350aa.tar.gz
opie-8e3c0aa915801b862f97ba7a7598ef5f3bd350aa.tar.bz2
fixed some bugs, added multi select, added symlink handling and keyboard shortcuts, but listview steals the event to move selection according to alpha. delete works
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/apps/advancedfm/advancedfm.cpp267
-rw-r--r--noncore/apps/advancedfm/advancedfm.h6
2 files changed, 230 insertions, 43 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp
index 5f47b9b..bb932c5 100644
--- a/noncore/apps/advancedfm/advancedfm.cpp
+++ b/noncore/apps/advancedfm/advancedfm.cpp
@@ -152,4 +152,5 @@ AdvancedFm::AdvancedFm( )
152 Local_View->setAllColumnsShowFocus(TRUE); 152 Local_View->setAllColumnsShowFocus(TRUE);
153// Local_View->setMultiSelection( TRUE ); 153 Local_View->setMultiSelection( TRUE );
154// Local_View->setSelectionMode(QListView::Extended); 154 Local_View->setSelectionMode(QListView::Extended);
155
155 QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold); 156 QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold);
@@ -177,4 +178,5 @@ AdvancedFm::AdvancedFm( )
177 Remote_View->setAllColumnsShowFocus(TRUE); 178 Remote_View->setAllColumnsShowFocus(TRUE);
178// Remote_View->setMultiSelection( TRUE ); 179 Remote_View->setMultiSelection( TRUE );
179// Remote_View->setSelectionMode(QListView::Extended); 180 Remote_View->setSelectionMode(QListView::Extended);
181
180 QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold); 182 QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold);
@@ -371,2 +373,3 @@ void AdvancedFm::populateLocalView()
371 373
374
372void AdvancedFm::populateRemoteView() 375void AdvancedFm::populateRemoteView()
@@ -566,5 +569,6 @@ void AdvancedFm::showHidden()
566 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 569 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
570 fileMenu->setItemChecked( fileMenu->idAt(0),TRUE);
567// localMenu->setItemChecked(localMenu->idAt(0),TRUE); 571// localMenu->setItemChecked(localMenu->idAt(0),TRUE);
568// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 572// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
569 b=TRUE; 573 b=FALSE;
570 574
@@ -572,7 +576,9 @@ void AdvancedFm::showHidden()
572 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 576 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
577 fileMenu->setItemChecked( fileMenu->idAt(0),FALSE);
573// localMenu->setItemChecked(localMenu->idAt(0),FALSE); 578// localMenu->setItemChecked(localMenu->idAt(0),FALSE);
574// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 579// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
575 b=FALSE; 580 b=TRUE;
576 } 581 }
577 populateLocalView(); 582 populateLocalView();
583
578} 584}
@@ -632,2 +638,4 @@ void AdvancedFm::showLocalMenu(QListViewItem * item)
632 m.insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); 638 m.insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() ));
639 m.insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() ));
640 m.insertSeparator();
633 m.insertItem( tr( "Rename" ), this, SLOT( localRename() )); 641 m.insertItem( tr( "Rename" ), this, SLOT( localRename() ));
@@ -665,2 +673,4 @@ void AdvancedFm::showRemoteMenu(QListViewItem * item)
665 m.insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); 673 m.insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() ));
674 m.insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() ));
675 m.insertSeparator();
666 m.insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); 676 m.insertItem( tr( "Rename" ), this, SLOT( remoteRename() ));
@@ -754,9 +764,15 @@ void AdvancedFm::localDelete()
754{ 764{
755 QString f = Local_View->currentItem()->text(0); 765 QStringList curFileList = getPath();
756 if(QDir(f).exists() ) { 766 QString myFile;
757 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+ 767 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
758 tr(" ?\nIt must be empty"),tr("Yes"),tr("No"),0,0,1) ) { 768 myFile = (*it);
769 if( myFile.find(" -> ",0,TRUE) != -1)
770 myFile = myFile.left( myFile.find(" -> ",0,TRUE));
771
772 QString f = currentDir.canonicalPath()+"/"+myFile;
773 if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) {
774 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+" ?"
775 ,tr("Yes"),tr("No"),0,0,1) ) {
759 case 0: { 776 case 0: {
760 f=currentDir.canonicalPath()+"/"+f; 777 QString cmd="rmdir -rf "+f;
761 QString cmd="rmdir "+f;
762 system( cmd.latin1()); 778 system( cmd.latin1());
@@ -774,5 +790,6 @@ void AdvancedFm::localDelete()
774 case 0: { 790 case 0: {
775 f=currentDir.canonicalPath()+"/"+f;
776 QString cmd="rm "+f; 791 QString cmd="rm "+f;
777 system( cmd.latin1()); 792 QFile file(f);
793 file.remove();
794// system( cmd.latin1());
778 populateLocalView(); 795 populateLocalView();
@@ -785,2 +802,4 @@ void AdvancedFm::localDelete()
785 } 802 }
803
804 }
786} 805}
@@ -789,9 +808,15 @@ void AdvancedFm::remoteDelete()
789{ 808{
790 QString f = Remote_View->currentItem()->text(0); 809 QStringList curFileList = getPath();
791 if(QDir(f).exists() ) { 810 QString myFile;
792 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+ 811
793 tr(" ?\nIt must be empty"),tr("Yes"),tr("No"),0,0,1) ) { 812 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
813 myFile = (*it);
814 if(myFile.find(" -> ",0,TRUE) != -1)
815 myFile = myFile.left(myFile.find(" -> ",0,TRUE));
816 QString f = currentRemoteDir.canonicalPath()+"/"+myFile;
817 if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) {
818 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+" ?",
819 tr("Yes"),tr("No"),0,0,1) ) {
794 case 0: { 820 case 0: {
795 f = currentRemoteDir.canonicalPath()+"/"+f; 821 QString cmd="rmdir -rf "+f;
796 QString cmd="rmdir "+f;
797 system( cmd.latin1()); 822 system( cmd.latin1());
@@ -809,5 +834,6 @@ void AdvancedFm::remoteDelete()
809 case 0: { 834 case 0: {
810 f = currentRemoteDir.canonicalPath()+"/"+f;
811 QString cmd="rm "+f; 835 QString cmd="rm "+f;
812 system( cmd.latin1()); 836 QFile file(f);
837 file.remove();
838// system( cmd.latin1());
813 populateRemoteView(); 839 populateRemoteView();
@@ -821,2 +847,3 @@ void AdvancedFm::remoteDelete()
821} 847}
848}
822 849
@@ -857,2 +884,3 @@ void AdvancedFm::switchToLocalTab()
857 TabWidget->setCurrentPage(0); 884 TabWidget->setCurrentPage(0);
885 Local_View->setFocus();
858} 886}
@@ -862,2 +890,3 @@ void AdvancedFm::switchToRemoteTab()
862 TabWidget->setCurrentPage(1); 890 TabWidget->setCurrentPage(1);
891 Remote_View->setFocus();
863} 892}
@@ -928,5 +957,15 @@ void AdvancedFm::currentPathComboActivated(const QString & currentPath) {
928void AdvancedFm::filePerms() { 957void AdvancedFm::filePerms() {
929 QString curFile = getPath(); 958
959 QStringList curFileList = getPath();
960 QString filePath;
961
962 if (TabWidget->currentPageIndex() == 0) {
963 filePath = currentDir.canonicalPath()+"/";
964 } else {
965 filePath= currentRemoteDir.canonicalPath()+"/";
966 }
967
968 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
930 filePermissions *filePerm; 969 filePermissions *filePerm;
931 filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(curFile)); 970 filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it));
932 filePerm->showMaximized(); 971 filePerm->showMaximized();
@@ -936,6 +975,14 @@ void AdvancedFm::filePerms() {
936} 975}
976}
937 977
938void AdvancedFm::doProperties() { 978void AdvancedFm::doProperties() {
939 979 QStringList curFileList = getPath();
940 DocLnk lnk( getPath()); 980 QString filePath;
981 if (TabWidget->currentPageIndex() == 0) {
982 filePath = currentDir.canonicalPath()+"/";
983 } else {
984 filePath= currentRemoteDir.canonicalPath()+"/";
985 }
986 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
987 DocLnk lnk( (filePath+*it));
941 LnkProperties prop( &lnk ); 988 LnkProperties prop( &lnk );
@@ -945,10 +992,27 @@ void AdvancedFm::doProperties() {
945} 992}
993}
946 994
947QString AdvancedFm::getPath() { 995QStringList AdvancedFm::getPath() {
996 QStringList strList;
948 if (TabWidget->currentPageIndex() == 0) { 997 if (TabWidget->currentPageIndex() == 0) {
949 return currentDir.canonicalPath()+"/"+ Local_View->currentItem()->text(0); 998 QList<QListViewItem> * getSelectedItems( QListView * Local_View );
999 QListViewItemIterator it( Local_View );
1000 for ( ; it.current(); ++it ) {
1001 if ( it.current()->isSelected() ) {
1002 strList << it.current()->text(0);
1003 }
1004 }
1005 return strList;
950 } else { 1006 } else {
951 return currentRemoteDir.canonicalPath() + "/"+Remote_View->currentItem()->text(0); 1007 QList<QListViewItem> * getSelectedItems( QListView * Remote_View );
1008 QListViewItemIterator it( Remote_View );
1009 for ( ; it.current(); ++it ) {
1010 if ( it.current()->isSelected() ) {
1011 strList << currentDir.canonicalPath()+"/"+ it.current()->text(0);
952 } 1012 }
953} 1013}
1014 return strList;
1015 }
1016 return "";
1017}
954 1018
@@ -1034,5 +1098,9 @@ void AdvancedFm::copy()
1034{ 1098{
1035 QString curFile = getPath(); 1099 QStringList curFileList = getPath();
1100 QString curFile;
1036 if (TabWidget->currentPageIndex() == 0) { 1101 if (TabWidget->currentPageIndex() == 0) {
1037 QString destFile = currentRemoteDir.canonicalPath()+"/"+Local_View->currentItem()->text(0); 1102 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
1103
1104 QString destFile = currentRemoteDir.canonicalPath()+"/"+(*it);
1105 curFile = currentDir.canonicalPath()+"/"+(*it);
1038 QFile f(destFile); 1106 QFile f(destFile);
@@ -1042,6 +1110,11 @@ void AdvancedFm::copy()
1042 qWarning("nothin doing"); 1110 qWarning("nothin doing");
1111 }
1043 populateRemoteView(); 1112 populateRemoteView();
1044 TabWidget->setCurrentPage(1); 1113 TabWidget->setCurrentPage(1);
1114
1045 } else { 1115 } else {
1046 QString destFile = currentDir.canonicalPath()+"/"+Remote_View->currentItem()->text(0); 1116 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
1117
1118 QString destFile = currentDir.canonicalPath()+"/"+(*it);
1119 curFile = currentRemoteDir.canonicalPath()+"/"+(*it);
1047 QFile f(destFile); 1120 QFile f(destFile);
@@ -1051,2 +1124,3 @@ void AdvancedFm::copy()
1051 qWarning("nothin doing"); 1124 qWarning("nothin doing");
1125 }
1052 populateLocalView(); 1126 populateLocalView();
@@ -1058,7 +1132,13 @@ void AdvancedFm::copyAs()
1058{ 1132{
1059 QString curFile = getPath(); 1133 QStringList curFileList = getPath();
1060 if (TabWidget->currentPageIndex() == 0) { 1134 QString curFile;
1061 QString destFile = Local_View->currentItem()->text(0);
1062 InputDialog *fileDlg; 1135 InputDialog *fileDlg;
1063 fileDlg = new InputDialog(this,tr("Copy As"),TRUE, 0); 1136 fileDlg = new InputDialog(this,tr("Copy As"),TRUE, 0);
1137
1138 if (TabWidget->currentPageIndex() == 0) {
1139 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
1140 QString destFile = *it;
1141 curFile = currentDir.canonicalPath()+"/"+(*it);
1142// InputDialog *fileDlg;
1143// fileDlg = new InputDialog(this,tr("Copy As"),TRUE, 0);
1064 fileDlg->setInputText((const QString &) destFile ); 1144 fileDlg->setInputText((const QString &) destFile );
@@ -1075,2 +1155,4 @@ void AdvancedFm::copyAs()
1075 } 1155 }
1156 }
1157
1076 populateRemoteView(); 1158 populateRemoteView();
@@ -1078,5 +1160,7 @@ void AdvancedFm::copyAs()
1078 } else { 1160 } else {
1079 QString destFile = Remote_View->currentItem()->text(0); 1161 if (TabWidget->currentPageIndex() == 0) {
1080 InputDialog *fileDlg; 1162 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
1081 fileDlg = new InputDialog(this,tr("Copy As"),TRUE, 0); 1163
1164 curFile = currentDir.canonicalPath()+"/"+(*it);
1165 QString destFile = *it;
1082 fileDlg->setInputText((const QString &) destFile); 1166 fileDlg->setInputText((const QString &) destFile);
@@ -1093,2 +1177,3 @@ void AdvancedFm::copyAs()
1093 } 1177 }
1178 }
1094 populateLocalView(); 1179 populateLocalView();
@@ -1097,9 +1182,15 @@ void AdvancedFm::copyAs()
1097} 1182}
1183}
1098 1184
1099void AdvancedFm::move() { 1185void AdvancedFm::move() {
1100 QString curFile = getPath(); 1186
1187 QStringList curFileList = getPath();
1188 QString curFile;
1101// qDebug(curFile); 1189// qDebug(curFile);
1102 QString destFile; 1190 QString destFile;
1191
1103 if (TabWidget->currentPageIndex() == 0) { 1192 if (TabWidget->currentPageIndex() == 0) {
1104 QString destFile = currentRemoteDir.canonicalPath() + "/" + Local_View->currentItem()->text(0); 1193 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
1194 QString destFile = currentRemoteDir.canonicalPath() + "/" + *it;
1195 curFile = currentDir.canonicalPath()+"/"+(*it);
1105 qDebug("Destination file is "+destFile); 1196 qDebug("Destination file is "+destFile);
@@ -1114,6 +1205,9 @@ void AdvancedFm::move() {
1114 QFile::remove(curFile); 1205 QFile::remove(curFile);
1206 }
1115 TabWidget->setCurrentPage(1); 1207 TabWidget->setCurrentPage(1);
1116 } else { 1208 } else {
1117 QString destFile = currentDir.canonicalPath() + "/" + Remote_View->currentItem()->text(0); 1209 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
1210 QString destFile = currentRemoteDir.canonicalPath() + "/" + *it;
1118 qDebug("Destination file is "+destFile); 1211 qDebug("Destination file is "+destFile);
1212 curFile = currentDir.canonicalPath()+"/"+(*it);
1119 1213
@@ -1129,2 +1223,3 @@ void AdvancedFm::move() {
1129 } 1223 }
1224 }
1130 populateRemoteView(); 1225 populateRemoteView();
@@ -1295 +1390,91 @@ void AdvancedFm::doAbout() {
1295} 1390}
1391
1392void AdvancedFm::keyReleaseEvent( QKeyEvent *e)
1393{
1394 switch ( e->key() ) {
1395 case Key_Delete:
1396 del();
1397 break;
1398 case Key_H:
1399 showHidden();
1400 break;
1401 case Key_E:
1402 runThis();
1403 break;
1404 case Key_C:
1405 copy();
1406 break;
1407 case Key_A:
1408 copyAs();
1409 break;
1410 case Key_M:
1411 move();
1412 break;
1413 case Key_R:
1414 rn();
1415 break;
1416 case Key_I:
1417 fileStatus();
1418 break;
1419 case Key_U:
1420 upDir();
1421 break;
1422 case Key_P:
1423 filePerms();
1424 break;
1425 case Key_N:
1426 mkDir();
1427 break;
1428 case Key_1:
1429 switchToLocalTab();
1430 break;
1431 case Key_2:
1432 switchToRemoteTab();
1433 break;
1434 case Key_3:
1435 CFButtonPushed();
1436 break;
1437 case Key_4:
1438 SDButtonPushed();
1439 break;
1440 case Key_5:
1441 homeButtonPushed();
1442 break;
1443 case Key_6:
1444 docButtonPushed();
1445 break;
1446 case Key_7:
1447 break;
1448 case Key_8:
1449 break;
1450 case Key_9:
1451 break;
1452 case Key_0:
1453 break;
1454
1455
1456
1457 }
1458
1459}
1460
1461void AdvancedFm::mkSym() {
1462 QString cmd;
1463 if (TabWidget->currentPageIndex() == 0) {
1464 QString curFile = Local_View->currentItem()->text(0);
1465 if(curFile.right(1) == "/") curFile = curFile.left(curFile.length() - 1);
1466 QString destName = currentRemoteDir.canonicalPath()+"/"+curFile;
1467 curFile = currentDir.canonicalPath()+"/"+curFile;
1468 cmd = "ln -s "+curFile+" "+destName;
1469 system(cmd.latin1() );
1470 populateRemoteView();
1471 } else {
1472 QString curFile = Remote_View->currentItem()->text(0);
1473 if(curFile.right(1) == "/") curFile = curFile.left(curFile.length() - 1);
1474 QString destName = currentDir.canonicalPath()+"/"+curFile;
1475 curFile = currentRemoteDir.canonicalPath()+"/"+curFile;
1476 cmd = "ln -s "+curFile+" "+destName;
1477 system(cmd.latin1() );
1478 populateLocalView();
1479 }
1480}
diff --git a/noncore/apps/advancedfm/advancedfm.h b/noncore/apps/advancedfm/advancedfm.h
index a5f26a7..c00713f 100644
--- a/noncore/apps/advancedfm/advancedfm.h
+++ b/noncore/apps/advancedfm/advancedfm.h
@@ -20,2 +20,3 @@
20#include <qpoint.h> 20#include <qpoint.h>
21#include <qstringlist.h>
21 22
@@ -95,3 +96,4 @@ protected slots:
95 void runCommandStd(); 96 void runCommandStd();
96 QString getPath(); 97 QStringList getPath();
98 void mkSym();
97 void switchToLocalTab(); 99 void switchToLocalTab();
@@ -102,3 +104,3 @@ protected:
102 QStringList remoteDirPathStringList, localDirPathStringList; 104 QStringList remoteDirPathStringList, localDirPathStringList;
103 105 void keyReleaseEvent( QKeyEvent *);
104protected slots: 106protected slots: