-rw-r--r-- | noncore/apps/advancedfm/advancedfm.h | 13 | ||||
-rw-r--r-- | noncore/apps/advancedfm/advancedfmMenu.cpp | 152 |
2 files changed, 124 insertions, 41 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.h b/noncore/apps/advancedfm/advancedfm.h index 7ced056..42775ee 100644 --- a/noncore/apps/advancedfm/advancedfm.h +++ b/noncore/apps/advancedfm/advancedfm.h | |||
@@ -1,158 +1,165 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | advancedfm.h | 2 | advancedfm.h |
3 | ------------------- | 3 | ------------------- |
4 | ** Created: Sat Mar 9 23:33:09 2002 | 4 | ** Created: Sat Mar 9 23:33:09 2002 |
5 | copyright : (C) 2002 by ljp | 5 | copyright : (C) 2002 by ljp |
6 | email : ljp@llornkcor.com | 6 | email : ljp@llornkcor.com |
7 | * This program is free software; you can redistribute it and/or modify * | 7 | * This program is free software; you can redistribute it and/or modify * |
8 | * it under the terms of the GNU General Public License as published by * | 8 | * it under the terms of the GNU General Public License as published by * |
9 | * the Free Software Foundation; either version 2 of the License, or * | 9 | * the Free Software Foundation; either version 2 of the License, or * |
10 | * (at your option) any later version. * | 10 | * (at your option) any later version. * |
11 | ***************************************************************************/ | 11 | ***************************************************************************/ |
12 | #ifndef ADVANCEDFM_H | 12 | #ifndef ADVANCEDFM_H |
13 | #define ADVANCEDFM_H | 13 | #define ADVANCEDFM_H |
14 | #define QTOPIA_INTERNAL_FSLP // to get access to fileproperties | 14 | #define QTOPIA_INTERNAL_FSLP // to get access to fileproperties |
15 | #define QT_QWS_OPIE | 15 | #define QT_QWS_OPIE |
16 | 16 | ||
17 | //#include <opie/otabwidget.h> | 17 | //#include <opie/otabwidget.h> |
18 | #include <qpe/ir.h> | 18 | #include <qpe/ir.h> |
19 | 19 | ||
20 | #include <qvariant.h> | 20 | #include <qvariant.h> |
21 | #include <qdialog.h> | 21 | #include <qdialog.h> |
22 | #include <qmainwindow.h> | 22 | #include <qmainwindow.h> |
23 | #include <qstringlist.h> | 23 | #include <qstringlist.h> |
24 | #include <qdir.h> | 24 | #include <qdir.h> |
25 | #include <qstring.h> | 25 | #include <qstring.h> |
26 | #include <qpoint.h> | 26 | #include <qpoint.h> |
27 | #include <qtimer.h> | 27 | #include <qtimer.h> |
28 | 28 | ||
29 | class OTabWidget; | 29 | class OTabWidget; |
30 | class QVBoxLayout; | 30 | class QVBoxLayout; |
31 | class QHBoxLayout; | 31 | class QHBoxLayout; |
32 | class QGridLayout; | 32 | class QGridLayout; |
33 | class QComboBox; | 33 | class QComboBox; |
34 | class QListView; | 34 | class QListView; |
35 | class QListviewItem; | 35 | class QListviewItem; |
36 | class QLabel; | 36 | class QLabel; |
37 | class QProgressBar; | 37 | class QProgressBar; |
38 | class QSpinBox; | 38 | class QSpinBox; |
39 | class QTabWidget; | 39 | class QTabWidget; |
40 | class QWidget; | 40 | class QWidget; |
41 | class QPEToolBar; | 41 | class QPEToolBar; |
42 | class QPEMenuBar; | 42 | class QPEMenuBar; |
43 | class QPopupMenu; | 43 | class QPopupMenu; |
44 | class QFile; | 44 | class QFile; |
45 | class QListViewItem; | 45 | class QListViewItem; |
46 | class QLineEdit; | 46 | class QLineEdit; |
47 | |||
47 | //class QPushButton; | 48 | //class QPushButton; |
48 | class QToolButton; | 49 | class QToolButton; |
49 | class Ir; | 50 | class Ir; |
50 | 51 | ||
51 | class AdvancedFm : public QMainWindow | 52 | class AdvancedFm : public QMainWindow |
52 | { | 53 | { |
53 | Q_OBJECT | 54 | Q_OBJECT |
54 | public: | 55 | public: |
55 | AdvancedFm(); | 56 | AdvancedFm(); |
56 | ~AdvancedFm(); | 57 | ~AdvancedFm(); |
57 | 58 | ||
58 | OTabWidget *TabWidget; | 59 | OTabWidget *TabWidget; |
59 | // QTabWidget *TabWidget; | 60 | // QTabWidget *TabWidget; |
60 | QWidget *tab, *tab_2, *tab_3; | 61 | QWidget *tab, *tab_2, *tab_3; |
61 | QListView *Local_View, *Remote_View; | 62 | QListView *Local_View, *Remote_View; |
62 | 63 | ||
63 | QLineEdit *currentPathEdit; | 64 | QLineEdit *currentPathEdit; |
64 | QPopupMenu *fileMenu, *localMenu, *remoteMenu, *viewMenu; | 65 | QPopupMenu *fileMenu, *localMenu, *remoteMenu, *viewMenu; |
65 | QToolButton *homeButton, *docButton, *cdUpButton, *sdButton, *cfButton, *qpeDirButton; | 66 | QToolButton *homeButton, *docButton, *cdUpButton, *sdButton, *cfButton, *qpeDirButton; |
66 | // QPushButton *homeButton, *docButton, *cdUpButton, *sdButton, *cfButton, *qpeDirButton; | 67 | // QPushButton *homeButton, *docButton, *cdUpButton, *sdButton, *cfButton, *qpeDirButton; |
67 | QDir currentDir, currentRemoteDir; | 68 | QDir currentDir, currentRemoteDir; |
68 | QComboBox *currentPathCombo; | 69 | QComboBox *currentPathCombo; |
69 | QString filterStr; | 70 | QString filterStr; |
70 | QListViewItem * item; | 71 | QListViewItem * item; |
71 | bool b; | 72 | bool b; |
72 | QStringList fileSystemTypeList, fsList; | 73 | QStringList fileSystemTypeList, fsList; |
73 | int currentServerConfig; | 74 | int currentServerConfig; |
74 | protected slots: | 75 | protected slots: |
75 | void selectAll(); | 76 | void selectAll(); |
76 | void addToDocs(); | 77 | void addToDocs(); |
77 | void doLocalCd(); | 78 | void doLocalCd(); |
78 | void doRemoteCd(); | 79 | void doRemoteCd(); |
79 | // void copy(); | 80 | // void copy(); |
80 | void mkDir(); | 81 | void mkDir(); |
81 | void del(); | 82 | void del(); |
82 | void rn(); | 83 | void rn(); |
83 | void populateLocalView(); | 84 | void populateLocalView(); |
84 | void populateRemoteView(); | 85 | void populateRemoteView(); |
85 | void showHidden(); | 86 | void showHidden(); |
86 | void showMenuHidden(); | 87 | void showMenuHidden(); |
87 | void showRemoteHidden(); | 88 | void showRemoteHidden(); |
88 | void writeConfig(); | 89 | void writeConfig(); |
89 | void readConfig(); | 90 | void readConfig(); |
90 | void localListClicked(QListViewItem *); | 91 | void localListClicked(QListViewItem *); |
91 | void remoteListClicked(QListViewItem *); | 92 | void remoteListClicked(QListViewItem *); |
92 | void localListPressed( int, QListViewItem *, const QPoint&, int); | 93 | void localListPressed( int, QListViewItem *, const QPoint&, int); |
93 | void remoteListPressed( int, QListViewItem *, const QPoint&, int); | 94 | void remoteListPressed( int, QListViewItem *, const QPoint&, int); |
94 | void localMakDir(); | 95 | void localMakDir(); |
95 | void localDelete(); | 96 | void localDelete(); |
96 | void remoteMakDir(); | 97 | void remoteMakDir(); |
97 | void remoteDelete(); | 98 | void remoteDelete(); |
98 | /* bool remoteDirList(const QString &); */ | 99 | /* bool remoteDirList(const QString &); */ |
99 | /* bool remoteChDir(const QString &); */ | 100 | /* bool remoteChDir(const QString &); */ |
100 | void tabChanged(QWidget*); | 101 | void tabChanged(QWidget*); |
101 | void cleanUp(); | 102 | void cleanUp(); |
102 | void remoteRename(); | 103 | void remoteRename(); |
103 | void localRename(); | 104 | void localRename(); |
104 | void runThis(); | 105 | void runThis(); |
105 | void runText(); | 106 | void runText(); |
106 | void filePerms(); | 107 | void filePerms(); |
107 | void doProperties(); | 108 | void doProperties(); |
108 | void runCommand(); | 109 | void runCommand(); |
109 | void runCommandStd(); | 110 | void runCommandStd(); |
110 | QStringList getPath(); | 111 | QStringList getPath(); |
111 | void mkSym(); | 112 | void mkSym(); |
112 | void switchToLocalTab(); | 113 | void switchToLocalTab(); |
113 | void switchToRemoteTab(); | 114 | void switchToRemoteTab(); |
114 | 115 | ||
115 | protected: | 116 | protected: |
116 | bool zaurusDevice; | 117 | bool zaurusDevice; |
117 | QGridLayout *tabLayout, *tabLayout_2, *tabLayout_3; | 118 | QGridLayout *tabLayout, *tabLayout_2, *tabLayout_3; |
118 | QStringList remoteDirPathStringList, localDirPathStringList; | 119 | QStringList remoteDirPathStringList, localDirPathStringList; |
119 | 120 | QLineEdit *renameBox; | |
121 | |||
120 | void init(); | 122 | void init(); |
121 | void initConnections(); | 123 | void initConnections(); |
122 | void keyReleaseEvent( QKeyEvent *); | 124 | void keyReleaseEvent( QKeyEvent *); |
123 | QString getFileSystemType(const QString &); | 125 | QString getFileSystemType(const QString &); |
124 | QString getDiskSpace(const QString &); | 126 | QString getDiskSpace(const QString &); |
125 | void parsetab(const QString &fileName); | 127 | void parsetab(const QString &fileName); |
126 | QString checkDiskSpace(const QString &); | 128 | QString checkDiskSpace(const QString &); |
127 | QString dealWithSymName(const QString &); | 129 | QString dealWithSymName(const QString &); |
128 | 130 | ||
129 | protected slots: | 131 | protected slots: |
130 | void showFileMenu(); | 132 | void showFileMenu(); |
131 | void cancelMenuTimer(); | 133 | void cancelMenuTimer(); |
132 | void homeButtonPushed(); | 134 | void homeButtonPushed(); |
133 | void docButtonPushed(); | 135 | void docButtonPushed(); |
134 | void SDButtonPushed(); | 136 | void SDButtonPushed(); |
135 | void CFButtonPushed(); | 137 | void CFButtonPushed(); |
136 | void QPEButtonPushed(); | 138 | void QPEButtonPushed(); |
137 | void upDir(); | 139 | void upDir(); |
138 | void currentPathComboChanged(); | 140 | void currentPathComboChanged(); |
139 | void copy(); | 141 | void copy(); |
140 | void copyAs(); | 142 | void copyAs(); |
141 | void copySameDir(); | 143 | void copySameDir(); |
142 | void currentPathComboActivated(const QString &); | 144 | void currentPathComboActivated(const QString &); |
143 | void fillCombo(const QString &); | 145 | void fillCombo(const QString &); |
144 | bool copyFile( const QString & , const QString & ); | 146 | bool copyFile( const QString & , const QString & ); |
145 | void move(); | 147 | void move(); |
146 | void fileStatus(); | 148 | void fileStatus(); |
147 | void doAbout(); | 149 | void doAbout(); |
148 | void doBeam(); | 150 | void doBeam(); |
149 | void fileBeamFinished( Ir *); | 151 | void fileBeamFinished( Ir *); |
150 | 152 | ||
151 | private: | 153 | private: |
152 | QTimer menuTimer; | 154 | QString oldName; |
153 | void startProcess(const QString &); | 155 | QTimer menuTimer; |
156 | void startProcess(const QString &); | ||
157 | bool eventFilter( QObject * , QEvent * ); | ||
158 | void cancelRename(); | ||
159 | void doRename(QListView *); | ||
160 | void okRename(); | ||
154 | private slots: | 161 | private slots: |
155 | void processEnded(); | 162 | void processEnded(); |
156 | }; | 163 | }; |
157 | 164 | ||
158 | #endif // ADVANCEDFM_H | 165 | #endif // ADVANCEDFM_H |
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp index 98d024d..f067013 100644 --- a/noncore/apps/advancedfm/advancedfmMenu.cpp +++ b/noncore/apps/advancedfm/advancedfmMenu.cpp | |||
@@ -1,1049 +1,1125 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | AdvancedFm.cpp | 2 | AdvancedFm.cpp |
3 | ------------------- | 3 | ------------------- |
4 | ** Created: Sat Mar 9 23:33:09 2002 | 4 | ** Created: Sat Mar 9 23:33:09 2002 |
5 | copyright : (C) 2002 by ljp | 5 | copyright : (C) 2002 by ljp |
6 | email : ljp@llornkcor.com | 6 | email : ljp@llornkcor.com |
7 | * This program is free software; you can redistribute it and/or modify * | 7 | * This program is free software; you can redistribute it and/or modify * |
8 | * it under the terms of the GNU General Public License as published by * | 8 | * it under the terms of the GNU General Public License as published by * |
9 | * the Free Software Foundation; either version 2 of the License, or * | 9 | * the Free Software Foundation; either version 2 of the License, or * |
10 | * (at your option) any later version. * | 10 | * (at your option) any later version. * |
11 | ***************************************************************************/ | 11 | ***************************************************************************/ |
12 | #include "advancedfm.h" | 12 | #include "advancedfm.h" |
13 | #include "output.h" | 13 | #include "output.h" |
14 | #include "filePermissions.h" | 14 | #include "filePermissions.h" |
15 | 15 | ||
16 | #include <opie/otabwidget.h> | 16 | #include <opie/otabwidget.h> |
17 | #include <opie/oprocess.h> | 17 | #include <opie/oprocess.h> |
18 | 18 | ||
19 | #include <qpe/lnkproperties.h> | 19 | #include <qpe/lnkproperties.h> |
20 | #include <qpe/qpeapplication.h> | 20 | #include <qpe/qpeapplication.h> |
21 | #include <qpe/qpemenubar.h> | 21 | #include <qpe/qpemenubar.h> |
22 | #include <qpe/qpetoolbar.h> | 22 | #include <qpe/qpetoolbar.h> |
23 | #include <qpe/resource.h> | 23 | #include <qpe/resource.h> |
24 | #include <qpe/qcopenvelope_qws.h> | 24 | #include <qpe/qcopenvelope_qws.h> |
25 | #include <qpe/applnk.h> | 25 | #include <qpe/applnk.h> |
26 | #include <qpe/ir.h> | 26 | #include <qpe/ir.h> |
27 | 27 | ||
28 | #include <qmessagebox.h> | 28 | #include <qmessagebox.h> |
29 | #include <qmultilineedit.h> | 29 | #include <qmultilineedit.h> |
30 | 30 | ||
31 | #include <qstring.h> | 31 | #include <qstring.h> |
32 | 32 | ||
33 | #include <qlayout.h> | 33 | #include <qlayout.h> |
34 | #include <qpixmap.h> | 34 | #include <qpixmap.h> |
35 | #include <qcombobox.h> | 35 | #include <qcombobox.h> |
36 | #include <qpopupmenu.h> | 36 | #include <qpopupmenu.h> |
37 | #include <qtabwidget.h> | 37 | #include <qtabwidget.h> |
38 | #include <qtoolbutton.h> | 38 | #include <qtoolbutton.h> |
39 | #include <qtabwidget.h> | 39 | #include <qtabwidget.h> |
40 | #include <qlineedit.h> | 40 | #include <qlineedit.h> |
41 | #include <qlistview.h> | 41 | #include <qlistview.h> |
42 | 42 | ||
43 | #include <stdlib.h> | 43 | #include <stdlib.h> |
44 | #include <unistd.h> | 44 | #include <unistd.h> |
45 | #include <sys/stat.h> | 45 | #include <sys/stat.h> |
46 | #include <dirent.h> | 46 | #include <dirent.h> |
47 | 47 | ||
48 | 48 | ||
49 | void AdvancedFm::doLocalCd() { | 49 | void AdvancedFm::doLocalCd() { |
50 | localListClicked( Local_View->currentItem()); | 50 | localListClicked( Local_View->currentItem()); |
51 | } | 51 | } |
52 | 52 | ||
53 | void AdvancedFm::doRemoteCd() { | 53 | void AdvancedFm::doRemoteCd() { |
54 | localListClicked( Remote_View->currentItem()); | 54 | localListClicked( Remote_View->currentItem()); |
55 | } | 55 | } |
56 | 56 | ||
57 | void AdvancedFm::showMenuHidden() { | 57 | void AdvancedFm::showMenuHidden() { |
58 | if (b) { | 58 | if (b) { |
59 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 59 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
60 | currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 60 | currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
61 | fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); | 61 | fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); |
62 | // b=FALSE; | 62 | // b=FALSE; |
63 | 63 | ||
64 | } else { | 64 | } else { |
65 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 65 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
66 | currentRemoteDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 66 | currentRemoteDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
67 | fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); | 67 | fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); |
68 | // b=TRUE; | 68 | // b=TRUE; |
69 | } | 69 | } |
70 | populateLocalView(); | 70 | populateLocalView(); |
71 | populateRemoteView(); | 71 | populateRemoteView(); |
72 | // if(TabWidget->getCurrentTab() == 0) | 72 | // if(TabWidget->getCurrentTab() == 0) |
73 | // showHidden(); | 73 | // showHidden(); |
74 | // else | 74 | // else |
75 | // showRemoteHidden(); | 75 | // showRemoteHidden(); |
76 | // if(b) qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<< true"); | 76 | // if(b) qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<< true"); |
77 | if(b) b = false; else b = true; | 77 | if(b) b = false; else b = true; |
78 | } | 78 | } |
79 | 79 | ||
80 | void AdvancedFm::showHidden() { | 80 | void AdvancedFm::showHidden() { |
81 | if (b) { | 81 | if (b) { |
82 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 82 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
83 | // fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); | 83 | // fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); |
84 | // b=FALSE; | 84 | // b=FALSE; |
85 | 85 | ||
86 | } else { | 86 | } else { |
87 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 87 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
88 | // fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); | 88 | // fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); |
89 | // b=TRUE; | 89 | // b=TRUE; |
90 | } | 90 | } |
91 | populateLocalView(); | 91 | populateLocalView(); |
92 | } | 92 | } |
93 | 93 | ||
94 | void AdvancedFm::showRemoteHidden() { | 94 | void AdvancedFm::showRemoteHidden() { |
95 | if (b) { | 95 | if (b) { |
96 | currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 96 | currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
97 | // b=TRUE; | 97 | // b=TRUE; |
98 | 98 | ||
99 | } else { | 99 | } else { |
100 | currentRemoteDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 100 | currentRemoteDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
101 | // b=FALSE; | 101 | // b=FALSE; |
102 | } | 102 | } |
103 | populateRemoteView(); | 103 | populateRemoteView(); |
104 | } | 104 | } |
105 | 105 | ||
106 | QString AdvancedFm::dealWithSymName(const QString &fileName) { | 106 | QString AdvancedFm::dealWithSymName(const QString &fileName) { |
107 | QString strItem = fileName; | 107 | QString strItem = fileName; |
108 | return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); | 108 | return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); |
109 | } | 109 | } |
110 | 110 | ||
111 | void AdvancedFm::runThis() { | 111 | void AdvancedFm::runThis() { |
112 | QString fs; | 112 | QString fs; |
113 | if (TabWidget->getCurrentTab() == 0) { | 113 | if (TabWidget->getCurrentTab() == 0) { |
114 | QString curFile = Local_View->currentItem()->text(0); | 114 | QString curFile = Local_View->currentItem()->text(0); |
115 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink | 115 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink |
116 | curFile = dealWithSymName((const QString&)curFile); | 116 | curFile = dealWithSymName((const QString&)curFile); |
117 | 117 | ||
118 | if(curFile != "../") { | 118 | if(curFile != "../") { |
119 | 119 | ||
120 | fs = getFileSystemType((const QString &) currentDir.canonicalPath()); | 120 | fs = getFileSystemType((const QString &) currentDir.canonicalPath()); |
121 | QFileInfo fileInfo( currentDir.canonicalPath()+"/"+curFile); | 121 | QFileInfo fileInfo( currentDir.canonicalPath()+"/"+curFile); |
122 | qDebug( fileInfo.owner()); | 122 | qDebug( fileInfo.owner()); |
123 | if( (fileInfo.permission( QFileInfo::ExeUser) | 123 | if( (fileInfo.permission( QFileInfo::ExeUser) |
124 | | fileInfo.permission( QFileInfo::ExeGroup) | 124 | | fileInfo.permission( QFileInfo::ExeGroup) |
125 | | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { | 125 | | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { |
126 | | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { | 126 | | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { |
127 | QCopEnvelope e("QPE/System", "execute(QString)" ); | 127 | QCopEnvelope e("QPE/System", "execute(QString)" ); |
128 | e << curFile; | 128 | e << curFile; |
129 | } else { | 129 | } else { |
130 | curFile = currentDir.canonicalPath()+"/"+curFile; | 130 | curFile = currentDir.canonicalPath()+"/"+curFile; |
131 | DocLnk nf(curFile); | 131 | DocLnk nf(curFile); |
132 | QString execStr = nf.exec(); | 132 | QString execStr = nf.exec(); |
133 | qDebug( execStr); | 133 | qDebug( execStr); |
134 | if( execStr.isEmpty() ) { | 134 | if( execStr.isEmpty() ) { |
135 | } else { | 135 | } else { |
136 | nf.execute(); | 136 | nf.execute(); |
137 | } | 137 | } |
138 | } | 138 | } |
139 | } | 139 | } |
140 | } else { | 140 | } else { |
141 | QString curFile = Remote_View->currentItem()->text(0); | 141 | QString curFile = Remote_View->currentItem()->text(0); |
142 | if(curFile != "../") { | 142 | if(curFile != "../") { |
143 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink | 143 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink |
144 | curFile = dealWithSymName((const QString&)curFile); | 144 | curFile = dealWithSymName((const QString&)curFile); |
145 | 145 | ||
146 | fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath()); | 146 | fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath()); |
147 | qDebug("Filesystemtype is "+fs); | 147 | qDebug("Filesystemtype is "+fs); |
148 | QFileInfo fileInfo( currentRemoteDir.canonicalPath()+"/"+curFile); | 148 | QFileInfo fileInfo( currentRemoteDir.canonicalPath()+"/"+curFile); |
149 | if( (fileInfo.permission( QFileInfo::ExeUser) | 149 | if( (fileInfo.permission( QFileInfo::ExeUser) |
150 | | fileInfo.permission( QFileInfo::ExeGroup) | 150 | | fileInfo.permission( QFileInfo::ExeGroup) |
151 | | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { | 151 | | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { |
152 | | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { | 152 | | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { |
153 | QCopEnvelope e("QPE/System", "execute(QString)" ); | 153 | QCopEnvelope e("QPE/System", "execute(QString)" ); |
154 | e << curFile; | 154 | e << curFile; |
155 | } else { | 155 | } else { |
156 | curFile = currentRemoteDir.canonicalPath()+"/"+curFile; | 156 | curFile = currentRemoteDir.canonicalPath()+"/"+curFile; |
157 | DocLnk nf(curFile); | 157 | DocLnk nf(curFile); |
158 | QString execStr = nf.exec(); | 158 | QString execStr = nf.exec(); |
159 | qDebug(execStr); | 159 | qDebug(execStr); |
160 | if( execStr.isEmpty() ) { | 160 | if( execStr.isEmpty() ) { |
161 | } else { | 161 | } else { |
162 | nf.execute(); | 162 | nf.execute(); |
163 | } | 163 | } |
164 | } | 164 | } |
165 | } | 165 | } |
166 | } | 166 | } |
167 | } | 167 | } |
168 | 168 | ||
169 | void AdvancedFm::runText() { | 169 | void AdvancedFm::runText() { |
170 | if (TabWidget->getCurrentTab() == 0) { | 170 | if (TabWidget->getCurrentTab() == 0) { |
171 | QString curFile = Local_View->currentItem()->text(0); | 171 | QString curFile = Local_View->currentItem()->text(0); |
172 | if(curFile != "../") { | 172 | if(curFile != "../") { |
173 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink | 173 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink |
174 | curFile = dealWithSymName((const QString&)curFile); | 174 | curFile = dealWithSymName((const QString&)curFile); |
175 | curFile = currentDir.canonicalPath()+"/"+curFile; | 175 | curFile = currentDir.canonicalPath()+"/"+curFile; |
176 | QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); | 176 | QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); |
177 | e << curFile; | 177 | e << curFile; |
178 | } | 178 | } |
179 | } else { | 179 | } else { |
180 | QString curFile = Remote_View->currentItem()->text(0); | 180 | QString curFile = Remote_View->currentItem()->text(0); |
181 | if(curFile != "../") { | 181 | if(curFile != "../") { |
182 | curFile = currentRemoteDir.canonicalPath()+"/"+curFile; | 182 | curFile = currentRemoteDir.canonicalPath()+"/"+curFile; |
183 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink | 183 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink |
184 | curFile = dealWithSymName((const QString&)curFile); | 184 | curFile = dealWithSymName((const QString&)curFile); |
185 | DocLnk nf(curFile); | 185 | DocLnk nf(curFile); |
186 | QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); | 186 | QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); |
187 | e << curFile; | 187 | e << curFile; |
188 | } | 188 | } |
189 | } | 189 | } |
190 | } | 190 | } |
191 | 191 | ||
192 | void AdvancedFm::localMakDir() { | 192 | void AdvancedFm::localMakDir() { |
193 | InputDialog *fileDlg; | 193 | InputDialog *fileDlg; |
194 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); | 194 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); |
195 | fileDlg->exec(); | 195 | fileDlg->exec(); |
196 | if( fileDlg->result() == 1 ) { | 196 | if( fileDlg->result() == 1 ) { |
197 | QString filename = fileDlg->LineEdit1->text(); | 197 | QString filename = fileDlg->LineEdit1->text(); |
198 | currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); | 198 | currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); |
199 | } | 199 | } |
200 | populateLocalView(); | 200 | populateLocalView(); |
201 | } | 201 | } |
202 | 202 | ||
203 | void AdvancedFm::remoteMakDir() { | 203 | void AdvancedFm::remoteMakDir() { |
204 | InputDialog *fileDlg; | 204 | InputDialog *fileDlg; |
205 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); | 205 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); |
206 | fileDlg->exec(); | 206 | fileDlg->exec(); |
207 | if( fileDlg->result() == 1 ) { | 207 | if( fileDlg->result() == 1 ) { |
208 | QString filename = fileDlg->LineEdit1->text(); | 208 | QString filename = fileDlg->LineEdit1->text(); |
209 | currentRemoteDir.mkdir( currentRemoteDir.canonicalPath()+"/"+filename); | 209 | currentRemoteDir.mkdir( currentRemoteDir.canonicalPath()+"/"+filename); |
210 | } | 210 | } |
211 | populateRemoteView(); | 211 | populateRemoteView(); |
212 | } | 212 | } |
213 | 213 | ||
214 | void AdvancedFm::localDelete() { | 214 | void AdvancedFm::localDelete() { |
215 | QStringList curFileList = getPath(); | 215 | QStringList curFileList = getPath(); |
216 | bool doMsg=true; | 216 | bool doMsg=true; |
217 | int count=curFileList.count(); | 217 | int count=curFileList.count(); |
218 | if( count > 0) { | 218 | if( count > 0) { |
219 | if(count > 1 ){ | 219 | if(count > 1 ){ |
220 | QString msg; | 220 | QString msg; |
221 | msg=tr("Really delete\n%1 files?").arg(count); | 221 | msg=tr("Really delete\n%1 files?").arg(count); |
222 | switch ( QMessageBox::warning(this,tr("Delete"),msg | 222 | switch ( QMessageBox::warning(this,tr("Delete"),msg |
223 | ,tr("Yes"),tr("No"),0,0,1) ) { | 223 | ,tr("Yes"),tr("No"),0,0,1) ) { |
224 | case 0: | 224 | case 0: |
225 | doMsg=false; | 225 | doMsg=false; |
226 | break; | 226 | break; |
227 | case 1: | 227 | case 1: |
228 | return; | 228 | return; |
229 | break; | 229 | break; |
230 | }; | 230 | }; |
231 | } | 231 | } |
232 | 232 | ||
233 | QString myFile; | 233 | QString myFile; |
234 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 234 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
235 | myFile = (*it); | 235 | myFile = (*it); |
236 | if( myFile.find(" -> ",0,TRUE) != -1) | 236 | if( myFile.find(" -> ",0,TRUE) != -1) |
237 | myFile = myFile.left( myFile.find(" -> ",0,TRUE)); | 237 | myFile = myFile.left( myFile.find(" -> ",0,TRUE)); |
238 | 238 | ||
239 | QString f = currentDir.canonicalPath(); | 239 | QString f = currentDir.canonicalPath(); |
240 | if(f.right(1).find("/",0,TRUE) == -1) | 240 | if(f.right(1).find("/",0,TRUE) == -1) |
241 | f+="/"; | 241 | f+="/"; |
242 | f+=myFile; | 242 | f+=myFile; |
243 | if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { | 243 | if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { |
244 | switch ( QMessageBox::warning(this,tr("Delete Directory?"),tr("Really delete\n")+f+ | 244 | switch ( QMessageBox::warning(this,tr("Delete Directory?"),tr("Really delete\n")+f+ |
245 | "\nand all it's contents ?" | 245 | "\nand all it's contents ?" |
246 | ,tr("Yes"),tr("No"),0,0,1) ) { | 246 | ,tr("Yes"),tr("No"),0,0,1) ) { |
247 | case 0: { | 247 | case 0: { |
248 | f=f.left(f.length()-1); | 248 | f=f.left(f.length()-1); |
249 | QString cmd="rm -rf "+f; | 249 | QString cmd="rm -rf "+f; |
250 | startProcess( (const QString)cmd.latin1() ); | 250 | startProcess( (const QString)cmd.latin1() ); |
251 | populateLocalView(); | 251 | populateLocalView(); |
252 | } | 252 | } |
253 | break; | 253 | break; |
254 | case 1: | 254 | case 1: |
255 | // exit | 255 | // exit |
256 | break; | 256 | break; |
257 | }; | 257 | }; |
258 | 258 | ||
259 | } else { | 259 | } else { |
260 | if(doMsg) { | 260 | if(doMsg) { |
261 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Really delete\n")+f | 261 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Really delete\n")+f |
262 | +" ?",tr("Yes"),tr("No"),0,0,1) ) { | 262 | +" ?",tr("Yes"),tr("No"),0,0,1) ) { |
263 | case 1: | 263 | case 1: |
264 | return; | 264 | return; |
265 | break; | 265 | break; |
266 | }; | 266 | }; |
267 | } | 267 | } |
268 | QString cmd="rm "+f; | 268 | QString cmd="rm "+f; |
269 | QFile file(f); | 269 | QFile file(f); |
270 | if(QFileInfo(myFile).fileName().find("../",0,TRUE)==-1) | 270 | if(QFileInfo(myFile).fileName().find("../",0,TRUE)==-1) |
271 | file.remove(); | 271 | file.remove(); |
272 | } | 272 | } |
273 | } | 273 | } |
274 | } | 274 | } |
275 | populateLocalView(); | 275 | populateLocalView(); |
276 | } | 276 | } |
277 | 277 | ||
278 | void AdvancedFm::remoteDelete() { | 278 | void AdvancedFm::remoteDelete() { |
279 | QStringList curFileList = getPath(); | 279 | QStringList curFileList = getPath(); |
280 | bool doMsg=true; | 280 | bool doMsg=true; |
281 | int count=curFileList.count(); | 281 | int count=curFileList.count(); |
282 | if( count > 0) { | 282 | if( count > 0) { |
283 | if(count > 1 ){ | 283 | if(count > 1 ){ |
284 | QString msg; | 284 | QString msg; |
285 | msg=tr("Really delete\n%1 files?").arg(count); | 285 | msg=tr("Really delete\n%1 files?").arg(count); |
286 | switch ( QMessageBox::warning(this,tr("Delete"),msg | 286 | switch ( QMessageBox::warning(this,tr("Delete"),msg |
287 | ,tr("Yes"),tr("No"),0,0,1) ) { | 287 | ,tr("Yes"),tr("No"),0,0,1) ) { |
288 | case 0: | 288 | case 0: |
289 | doMsg=false; | 289 | doMsg=false; |
290 | break; | 290 | break; |
291 | case 1: | 291 | case 1: |
292 | return; | 292 | return; |
293 | break; | 293 | break; |
294 | }; | 294 | }; |
295 | } | 295 | } |
296 | 296 | ||
297 | QString myFile; | 297 | QString myFile; |
298 | 298 | ||
299 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 299 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
300 | myFile = (*it); | 300 | myFile = (*it); |
301 | if(myFile.find(" -> ",0,TRUE) != -1) | 301 | if(myFile.find(" -> ",0,TRUE) != -1) |
302 | myFile = myFile.left(myFile.find(" -> ",0,TRUE)); | 302 | myFile = myFile.left(myFile.find(" -> ",0,TRUE)); |
303 | QString f = currentRemoteDir.canonicalPath(); | 303 | QString f = currentRemoteDir.canonicalPath(); |
304 | if(f.right(1).find("/",0,TRUE) == -1) | 304 | if(f.right(1).find("/",0,TRUE) == -1) |
305 | f+="/"; | 305 | f+="/"; |
306 | f+=myFile; | 306 | f+=myFile; |
307 | if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { | 307 | if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { |
308 | switch ( QMessageBox::warning(this,tr("Delete Directory"),tr("Really delete\n")+f+ | 308 | switch ( QMessageBox::warning(this,tr("Delete Directory"),tr("Really delete\n")+f+ |
309 | "\nand all it's contents ?", | 309 | "\nand all it's contents ?", |
310 | tr("Yes"),tr("No"),0,0,1) ) { | 310 | tr("Yes"),tr("No"),0,0,1) ) { |
311 | case 0: { | 311 | case 0: { |
312 | f=f.left(f.length()-1); | 312 | f=f.left(f.length()-1); |
313 | QString cmd="rm -rf "+f; | 313 | QString cmd="rm -rf "+f; |
314 | startProcess( (const QString)cmd ); | 314 | startProcess( (const QString)cmd ); |
315 | populateRemoteView(); | 315 | populateRemoteView(); |
316 | } | 316 | } |
317 | break; | 317 | break; |
318 | case 1: | 318 | case 1: |
319 | // exit | 319 | // exit |
320 | break; | 320 | break; |
321 | }; | 321 | }; |
322 | 322 | ||
323 | } else { | 323 | } else { |
324 | if(doMsg) { | 324 | if(doMsg) { |
325 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Really delete\n")+f | 325 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Really delete\n")+f |
326 | +" ?",tr("Yes"),tr("No"),0,0,1) ) { | 326 | +" ?",tr("Yes"),tr("No"),0,0,1) ) { |
327 | case 1: | 327 | case 1: |
328 | return; | 328 | return; |
329 | break; | 329 | break; |
330 | }; | 330 | }; |
331 | } | 331 | } |
332 | QString cmd="rm "+f; | 332 | QString cmd="rm "+f; |
333 | QFile file(f); | 333 | QFile file(f); |
334 | if(QFileInfo(myFile).fileName().find("../",0,TRUE)==-1) | 334 | if(QFileInfo(myFile).fileName().find("../",0,TRUE)==-1) |
335 | file.remove(); | 335 | file.remove(); |
336 | } | 336 | } |
337 | } | 337 | } |
338 | } | 338 | } |
339 | populateRemoteView(); | 339 | populateRemoteView(); |
340 | } | 340 | } |
341 | 341 | ||
342 | void AdvancedFm::localRename() { | ||
343 | QString curFile = Local_View->currentItem()->text(0); | ||
344 | qDebug("currentItem "+curFile); | ||
345 | if( curFile !="../") { | ||
346 | InputDialog *fileDlg; | ||
347 | fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); | ||
348 | fileDlg->setInputText((const QString &)curFile); | ||
349 | fileDlg->exec(); | ||
350 | if( fileDlg->result() == 1 ) { | ||
351 | QString oldname = currentDir.canonicalPath() + "/" + curFile; | ||
352 | QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text(); | ||
353 | //+".playlist"; | ||
354 | if( rename(oldname.latin1(), newName.latin1())== -1) | ||
355 | QMessageBox::message(tr("Note"),tr("Could not rename")); | ||
356 | } | ||
357 | populateLocalView(); | ||
358 | } | ||
359 | } | ||
360 | |||
361 | void AdvancedFm::remoteRename() | ||
362 | { | ||
363 | QString curFile = Remote_View->currentItem()->text(0); | ||
364 | if( curFile !="../") { | ||
365 | InputDialog *fileDlg; | ||
366 | fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); | ||
367 | fileDlg->setInputText((const QString &)curFile); | ||
368 | fileDlg->exec(); | ||
369 | if( fileDlg->result() == 1 ) { | ||
370 | QString oldname = currentRemoteDir.canonicalPath() + "/" + curFile; | ||
371 | QString newName = currentRemoteDir.canonicalPath() + "/" + fileDlg->LineEdit1->text(); | ||
372 | //+".playlist"; | ||
373 | if( rename(oldname.latin1(), newName.latin1())== -1) | ||
374 | QMessageBox::message(tr("Note"),tr("Could not rename")); | ||
375 | } | ||
376 | populateRemoteView(); | ||
377 | } | ||
378 | } | ||
379 | |||
380 | 342 | ||
381 | void AdvancedFm::filePerms() { | 343 | void AdvancedFm::filePerms() { |
382 | 344 | ||
383 | QStringList curFileList = getPath(); | 345 | QStringList curFileList = getPath(); |
384 | QString filePath; | 346 | QString filePath; |
385 | 347 | ||
386 | if (TabWidget->getCurrentTab() == 0) { | 348 | if (TabWidget->getCurrentTab() == 0) { |
387 | filePath = currentDir.canonicalPath()+"/"; | 349 | filePath = currentDir.canonicalPath()+"/"; |
388 | } else { | 350 | } else { |
389 | filePath= currentRemoteDir.canonicalPath()+"/"; | 351 | filePath= currentRemoteDir.canonicalPath()+"/"; |
390 | } | 352 | } |
391 | 353 | ||
392 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 354 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
393 | filePermissions *filePerm; | 355 | filePermissions *filePerm; |
394 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); | 356 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); |
395 | filePerm->showMaximized(); | 357 | filePerm->showMaximized(); |
396 | filePerm->exec(); | 358 | filePerm->exec(); |
397 | if( filePerm) | 359 | if( filePerm) |
398 | delete filePerm; | 360 | delete filePerm; |
399 | } | 361 | } |
400 | if (TabWidget->getCurrentTab() == 0) { | 362 | if (TabWidget->getCurrentTab() == 0) { |
401 | populateLocalView(); | 363 | populateLocalView(); |
402 | } else { | 364 | } else { |
403 | populateRemoteView(); | 365 | populateRemoteView(); |
404 | } | 366 | } |
405 | } | 367 | } |
406 | 368 | ||
407 | void AdvancedFm::doProperties() { | 369 | void AdvancedFm::doProperties() { |
408 | #if defined(QT_QWS_OPIE) | 370 | #if defined(QT_QWS_OPIE) |
409 | 371 | ||
410 | QStringList curFileList = getPath(); | 372 | QStringList curFileList = getPath(); |
411 | 373 | ||
412 | QString filePath; | 374 | QString filePath; |
413 | if (TabWidget->getCurrentTab() == 0) { | 375 | if (TabWidget->getCurrentTab() == 0) { |
414 | filePath = currentDir.canonicalPath()+"/"; | 376 | filePath = currentDir.canonicalPath()+"/"; |
415 | } else { | 377 | } else { |
416 | filePath= currentRemoteDir.canonicalPath()+"/"; | 378 | filePath= currentRemoteDir.canonicalPath()+"/"; |
417 | } | 379 | } |
418 | qDebug("%d",curFileList.count()); | 380 | qDebug("%d",curFileList.count()); |
419 | 381 | ||
420 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 382 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
421 | qDebug((filePath+*it)); | 383 | qDebug((filePath+*it)); |
422 | DocLnk lnk( (filePath+*it)); | 384 | DocLnk lnk( (filePath+*it)); |
423 | LnkProperties prop( &lnk ); | 385 | LnkProperties prop( &lnk ); |
424 | prop.showMaximized(); | 386 | prop.showMaximized(); |
425 | prop.exec(); | 387 | prop.exec(); |
426 | } | 388 | } |
427 | #endif | 389 | #endif |
428 | 390 | ||
429 | } | 391 | } |
430 | 392 | ||
431 | void AdvancedFm::upDir() { | 393 | void AdvancedFm::upDir() { |
432 | if (TabWidget->getCurrentTab() == 0) { | 394 | if (TabWidget->getCurrentTab() == 0) { |
433 | QString current = currentDir.canonicalPath(); | 395 | QString current = currentDir.canonicalPath(); |
434 | QDir dir(current); | 396 | QDir dir(current); |
435 | dir.cdUp(); | 397 | dir.cdUp(); |
436 | current = dir.canonicalPath(); | 398 | current = dir.canonicalPath(); |
437 | chdir( current.latin1() ); | 399 | chdir( current.latin1() ); |
438 | currentDir.cd( current, TRUE); | 400 | currentDir.cd( current, TRUE); |
439 | populateLocalView(); | 401 | populateLocalView(); |
440 | update(); | 402 | update(); |
441 | } else { | 403 | } else { |
442 | QString current = currentRemoteDir.canonicalPath(); | 404 | QString current = currentRemoteDir.canonicalPath(); |
443 | QDir dir(current); | 405 | QDir dir(current); |
444 | dir.cdUp(); | 406 | dir.cdUp(); |
445 | current = dir.canonicalPath(); | 407 | current = dir.canonicalPath(); |
446 | chdir( current.latin1() ); | 408 | chdir( current.latin1() ); |
447 | currentRemoteDir.cd( current, TRUE); | 409 | currentRemoteDir.cd( current, TRUE); |
448 | populateRemoteView(); | 410 | populateRemoteView(); |
449 | update(); | 411 | update(); |
450 | } | 412 | } |
451 | } | 413 | } |
452 | 414 | ||
453 | void AdvancedFm::copy() { | 415 | void AdvancedFm::copy() { |
454 | qApp->processEvents(); | 416 | qApp->processEvents(); |
455 | QStringList curFileList = getPath(); | 417 | QStringList curFileList = getPath(); |
456 | bool doMsg=true; | 418 | bool doMsg=true; |
457 | int count=curFileList.count(); | 419 | int count=curFileList.count(); |
458 | if( count > 0) { | 420 | if( count > 0) { |
459 | if(count > 1 ){ | 421 | if(count > 1 ){ |
460 | QString msg; | 422 | QString msg; |
461 | msg=tr("Really copy\n%1 files?").arg(count); | 423 | msg=tr("Really copy\n%1 files?").arg(count); |
462 | switch ( QMessageBox::warning(this,tr("Delete"),msg | 424 | switch ( QMessageBox::warning(this,tr("Delete"),msg |
463 | ,tr("Yes"),tr("No"),0,0,1) ) { | 425 | ,tr("Yes"),tr("No"),0,0,1) ) { |
464 | case 0: | 426 | case 0: |
465 | doMsg=false; | 427 | doMsg=false; |
466 | break; | 428 | break; |
467 | case 1: | 429 | case 1: |
468 | return; | 430 | return; |
469 | break; | 431 | break; |
470 | }; | 432 | }; |
471 | } | 433 | } |
472 | 434 | ||
473 | QString curFile, item, destFile; | 435 | QString curFile, item, destFile; |
474 | if (TabWidget->getCurrentTab() == 0) { | 436 | if (TabWidget->getCurrentTab() == 0) { |
475 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 437 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
476 | item=(*it); | 438 | item=(*it); |
477 | if(item.find("->",0,TRUE)) //symlink | 439 | if(item.find("->",0,TRUE)) //symlink |
478 | item = item.left(item.find("->",0,TRUE)); | 440 | item = item.left(item.find("->",0,TRUE)); |
479 | 441 | ||
480 | destFile = currentRemoteDir.canonicalPath()+"/"+ item; | 442 | destFile = currentRemoteDir.canonicalPath()+"/"+ item; |
481 | qDebug("Destination file is "+destFile); | 443 | qDebug("Destination file is "+destFile); |
482 | 444 | ||
483 | curFile = currentDir.canonicalPath()+"/"+ item; | 445 | curFile = currentDir.canonicalPath()+"/"+ item; |
484 | qDebug("CurrentFile file is " + curFile); | 446 | qDebug("CurrentFile file is " + curFile); |
485 | 447 | ||
486 | QFile f(destFile); | 448 | QFile f(destFile); |
487 | if( f.exists()) { | 449 | if( f.exists()) { |
488 | if(doMsg) { | 450 | if(doMsg) { |
489 | switch ( QMessageBox::warning(this,tr("File Exists!"), tr("%1 exists. Ok to overwrite?").arg( item ), tr("Yes"),tr("No"),0,0,1) ) { | 451 | switch ( QMessageBox::warning(this,tr("File Exists!"), tr("%1 exists. Ok to overwrite?").arg( item ), tr("Yes"),tr("No"),0,0,1) ) { |
490 | case 1: | 452 | case 1: |
491 | return; | 453 | return; |
492 | break; | 454 | break; |
493 | }; | 455 | }; |
494 | } | 456 | } |
495 | f.remove(); | 457 | f.remove(); |
496 | } | 458 | } |
497 | if(!copyFile( curFile, destFile) ) { | 459 | if(!copyFile( curFile, destFile) ) { |
498 | QMessageBox::message("AdvancedFm",tr( "Could not copy %1 to %2").arg( curFile ).arg( destFile ) ); | 460 | QMessageBox::message("AdvancedFm",tr( "Could not copy %1 to %2").arg( curFile ).arg( destFile ) ); |
499 | return; | 461 | return; |
500 | } | 462 | } |
501 | } | 463 | } |
502 | populateRemoteView(); | 464 | populateRemoteView(); |
503 | TabWidget->setCurrentTab(1); | 465 | TabWidget->setCurrentTab(1); |
504 | 466 | ||
505 | } else { | 467 | } else { |
506 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 468 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
507 | item= (*it); | 469 | item= (*it); |
508 | if(item.find("->",0,TRUE)) //symlink | 470 | if(item.find("->",0,TRUE)) //symlink |
509 | item = item.left(item.find("->",0,TRUE)); | 471 | item = item.left(item.find("->",0,TRUE)); |
510 | 472 | ||
511 | destFile = currentDir.canonicalPath()+"/"+ item; | 473 | destFile = currentDir.canonicalPath()+"/"+ item; |
512 | qDebug("Destination file is "+destFile); | 474 | qDebug("Destination file is "+destFile); |
513 | 475 | ||
514 | curFile = currentRemoteDir.canonicalPath()+"/"+ item;; | 476 | curFile = currentRemoteDir.canonicalPath()+"/"+ item;; |
515 | qDebug("CurrentFile file is " + curFile); | 477 | qDebug("CurrentFile file is " + curFile); |
516 | 478 | ||
517 | QFile f(destFile); | 479 | QFile f(destFile); |
518 | if( f.exists()) { | 480 | if( f.exists()) { |
519 | switch ( QMessageBox::warning(this,tr("File Exists!"), | 481 | switch ( QMessageBox::warning(this,tr("File Exists!"), |
520 | item+tr("\nexists. Ok to overwrite?"), | 482 | item+tr("\nexists. Ok to overwrite?"), |
521 | tr("Yes"),tr("No"),0,0,1) ) { | 483 | tr("Yes"),tr("No"),0,0,1) ) { |
522 | case 1: | 484 | case 1: |
523 | return; | 485 | return; |
524 | break; | 486 | break; |
525 | }; | 487 | }; |
526 | f.remove(); | 488 | f.remove(); |
527 | } | 489 | } |
528 | if(!copyFile( curFile, destFile) ) { | 490 | if(!copyFile( curFile, destFile) ) { |
529 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") | 491 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") |
530 | +curFile +tr("to\n")+destFile); | 492 | +curFile +tr("to\n")+destFile); |
531 | return; | 493 | return; |
532 | 494 | ||
533 | } | 495 | } |
534 | } | 496 | } |
535 | populateLocalView(); | 497 | populateLocalView(); |
536 | TabWidget->setCurrentTab(0); | 498 | TabWidget->setCurrentTab(0); |
537 | } | 499 | } |
538 | 500 | ||
539 | } | 501 | } |
540 | } | 502 | } |
541 | 503 | ||
542 | void AdvancedFm::copyAs() { | 504 | void AdvancedFm::copyAs() { |
543 | qApp->processEvents(); | 505 | qApp->processEvents(); |
544 | 506 | ||
545 | QStringList curFileList = getPath(); | 507 | QStringList curFileList = getPath(); |
546 | QString curFile, item; | 508 | QString curFile, item; |
547 | InputDialog *fileDlg; | 509 | InputDialog *fileDlg; |
548 | if (TabWidget->getCurrentTab() == 0) { | 510 | if (TabWidget->getCurrentTab() == 0) { |
549 | qDebug("tab 1"); | 511 | qDebug("tab 1"); |
550 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 512 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
551 | QString destFile; | 513 | QString destFile; |
552 | item=(*it); | 514 | item=(*it); |
553 | curFile = currentDir.canonicalPath()+"/"+(*it); | 515 | curFile = currentDir.canonicalPath()+"/"+(*it); |
554 | fileDlg = new InputDialog( this,tr("Copy "+curFile+" As"), TRUE, 0); | 516 | fileDlg = new InputDialog( this,tr("Copy "+curFile+" As"), TRUE, 0); |
555 | 517 | ||
556 | fileDlg->setInputText((const QString &) destFile ); | 518 | fileDlg->setInputText((const QString &) destFile ); |
557 | fileDlg->exec(); | 519 | fileDlg->exec(); |
558 | 520 | ||
559 | if( fileDlg->result() == 1 ) { | 521 | if( fileDlg->result() == 1 ) { |
560 | QString filename = fileDlg->LineEdit1->text(); | 522 | QString filename = fileDlg->LineEdit1->text(); |
561 | destFile = currentRemoteDir.canonicalPath()+"/"+filename; | 523 | destFile = currentRemoteDir.canonicalPath()+"/"+filename; |
562 | 524 | ||
563 | QFile f(destFile); | 525 | QFile f(destFile); |
564 | if( f.exists()) { | 526 | if( f.exists()) { |
565 | switch (QMessageBox::warning(this,tr("File Exists!"), | 527 | switch (QMessageBox::warning(this,tr("File Exists!"), |
566 | item+tr("\nexists. Ok to overwrite?"), | 528 | item+tr("\nexists. Ok to overwrite?"), |
567 | tr("Yes"),tr("No"),0,0,1) ) { | 529 | tr("Yes"),tr("No"),0,0,1) ) { |
568 | case 0: | 530 | case 0: |
569 | f.remove(); | 531 | f.remove(); |
570 | break; | 532 | break; |
571 | case 1: | 533 | case 1: |
572 | return; | 534 | return; |
573 | break; | 535 | break; |
574 | }; | 536 | }; |
575 | } | 537 | } |
576 | if(!copyFile( curFile,destFile) ) { | 538 | if(!copyFile( curFile,destFile) ) { |
577 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") | 539 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") |
578 | +curFile +tr("to\n")+destFile); | 540 | +curFile +tr("to\n")+destFile); |
579 | return; | 541 | return; |
580 | } | 542 | } |
581 | } | 543 | } |
582 | delete fileDlg; | 544 | delete fileDlg; |
583 | 545 | ||
584 | } | 546 | } |
585 | populateRemoteView(); | 547 | populateRemoteView(); |
586 | TabWidget->setCurrentTab(1); | 548 | TabWidget->setCurrentTab(1); |
587 | 549 | ||
588 | } else { | 550 | } else { |
589 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 551 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
590 | 552 | ||
591 | item=(*it); | 553 | item=(*it); |
592 | curFile = currentRemoteDir.canonicalPath()+"/"+(*it); | 554 | curFile = currentRemoteDir.canonicalPath()+"/"+(*it); |
593 | fileDlg = new InputDialog( this,tr("Copy "+curFile+" As"), TRUE, 0); | 555 | fileDlg = new InputDialog( this,tr("Copy "+curFile+" As"), TRUE, 0); |
594 | 556 | ||
595 | QString destFile; | 557 | QString destFile; |
596 | fileDlg->setInputText((const QString &) destFile); | 558 | fileDlg->setInputText((const QString &) destFile); |
597 | fileDlg->exec(); | 559 | fileDlg->exec(); |
598 | 560 | ||
599 | if( fileDlg->result() == 1 ) { | 561 | if( fileDlg->result() == 1 ) { |
600 | QString filename = fileDlg->LineEdit1->text(); | 562 | QString filename = fileDlg->LineEdit1->text(); |
601 | destFile = currentDir.canonicalPath()+"/"+filename; | 563 | destFile = currentDir.canonicalPath()+"/"+filename; |
602 | 564 | ||
603 | QFile f( destFile); | 565 | QFile f( destFile); |
604 | if( f.exists()) { | 566 | if( f.exists()) { |
605 | switch ( QMessageBox::warning(this,tr("File Exists!"), | 567 | switch ( QMessageBox::warning(this,tr("File Exists!"), |
606 | item+tr("\nexists. Ok to overwrite?"), | 568 | item+tr("\nexists. Ok to overwrite?"), |
607 | tr("Yes"),tr("No"),0,0,1) ) { | 569 | tr("Yes"),tr("No"),0,0,1) ) { |
608 | case 0: | 570 | case 0: |
609 | f.remove(); | 571 | f.remove(); |
610 | break; | 572 | break; |
611 | case 1: | 573 | case 1: |
612 | return; | 574 | return; |
613 | break; | 575 | break; |
614 | }; | 576 | }; |
615 | } | 577 | } |
616 | if(!copyFile( curFile,destFile) ) { | 578 | if(!copyFile( curFile,destFile) ) { |
617 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") | 579 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") |
618 | +curFile +tr("to\n")+destFile); | 580 | +curFile +tr("to\n")+destFile); |
619 | return; | 581 | return; |
620 | } | 582 | } |
621 | 583 | ||
622 | } | 584 | } |
623 | delete fileDlg; | 585 | delete fileDlg; |
624 | 586 | ||
625 | } | 587 | } |
626 | populateLocalView(); | 588 | populateLocalView(); |
627 | TabWidget->setCurrentTab(0); | 589 | TabWidget->setCurrentTab(0); |
628 | } | 590 | } |
629 | } | 591 | } |
630 | 592 | ||
631 | void AdvancedFm::copySameDir() { | 593 | void AdvancedFm::copySameDir() { |
632 | qApp->processEvents(); | 594 | qApp->processEvents(); |
633 | QStringList curFileList = getPath(); | 595 | QStringList curFileList = getPath(); |
634 | QString curFile, item, destFile; | 596 | QString curFile, item, destFile; |
635 | InputDialog *fileDlg; | 597 | InputDialog *fileDlg; |
636 | 598 | ||
637 | if (TabWidget->getCurrentTab() == 0) { | 599 | if (TabWidget->getCurrentTab() == 0) { |
638 | 600 | ||
639 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 601 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
640 | item=(*it); | 602 | item=(*it); |
641 | curFile = currentDir.canonicalPath()+"/"+ item; | 603 | curFile = currentDir.canonicalPath()+"/"+ item; |
642 | 604 | ||
643 | fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); | 605 | fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); |
644 | fileDlg->setInputText((const QString &) destFile ); | 606 | fileDlg->setInputText((const QString &) destFile ); |
645 | fileDlg->exec(); | 607 | fileDlg->exec(); |
646 | 608 | ||
647 | if( fileDlg->result() == 1 ) { | 609 | if( fileDlg->result() == 1 ) { |
648 | 610 | ||
649 | QString filename = fileDlg->LineEdit1->text(); | 611 | QString filename = fileDlg->LineEdit1->text(); |
650 | destFile = currentDir.canonicalPath()+"/"+filename; | 612 | destFile = currentDir.canonicalPath()+"/"+filename; |
651 | 613 | ||
652 | QFile f(destFile); | 614 | QFile f(destFile); |
653 | if( f.exists()) { | 615 | if( f.exists()) { |
654 | switch (QMessageBox::warning(this,tr("Delete"), | 616 | switch (QMessageBox::warning(this,tr("Delete"), |
655 | destFile+tr(" already exists.\nDo you really want to delete it?"), | 617 | destFile+tr(" already exists.\nDo you really want to delete it?"), |
656 | tr("Yes"),tr("No"),0,0,1) ) { | 618 | tr("Yes"),tr("No"),0,0,1) ) { |
657 | case 0: | 619 | case 0: |
658 | 620 | ||
659 | f.remove(); | 621 | f.remove(); |
660 | break; | 622 | break; |
661 | case 1: | 623 | case 1: |
662 | return; | 624 | return; |
663 | break; | 625 | break; |
664 | }; | 626 | }; |
665 | } | 627 | } |
666 | if(!copyFile( curFile,destFile) ) { | 628 | if(!copyFile( curFile,destFile) ) { |
667 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") | 629 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") |
668 | +curFile +tr("to\n")+destFile); | 630 | +curFile +tr("to\n")+destFile); |
669 | return; | 631 | return; |
670 | } | 632 | } |
671 | 633 | ||
672 | qDebug("copy "+curFile+" as "+destFile); | 634 | qDebug("copy "+curFile+" as "+destFile); |
673 | } | 635 | } |
674 | delete fileDlg; | 636 | delete fileDlg; |
675 | } | 637 | } |
676 | populateLocalView(); | 638 | populateLocalView(); |
677 | 639 | ||
678 | } else { | 640 | } else { |
679 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 641 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
680 | item=(*it); | 642 | item=(*it); |
681 | curFile = currentRemoteDir.canonicalPath()+"/"+ item; | 643 | curFile = currentRemoteDir.canonicalPath()+"/"+ item; |
682 | 644 | ||
683 | fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); | 645 | fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); |
684 | fileDlg->setInputText((const QString &) destFile); | 646 | fileDlg->setInputText((const QString &) destFile); |
685 | fileDlg->exec(); | 647 | fileDlg->exec(); |
686 | if( fileDlg->result() == 1 ) { | 648 | if( fileDlg->result() == 1 ) { |
687 | QString filename = fileDlg->LineEdit1->text(); | 649 | QString filename = fileDlg->LineEdit1->text(); |
688 | 650 | ||
689 | destFile = currentRemoteDir.canonicalPath()+"/"+filename; | 651 | destFile = currentRemoteDir.canonicalPath()+"/"+filename; |
690 | 652 | ||
691 | QFile f(destFile); | 653 | QFile f(destFile); |
692 | if( f.exists()) { | 654 | if( f.exists()) { |
693 | switch ( QMessageBox::warning(this,tr("Delete"), | 655 | switch ( QMessageBox::warning(this,tr("Delete"), |
694 | destFile+tr(" already exists.\nDo you really want to delete it?"), | 656 | destFile+tr(" already exists.\nDo you really want to delete it?"), |
695 | tr("Yes"),tr("No"),0,0,1) ) { | 657 | tr("Yes"),tr("No"),0,0,1) ) { |
696 | case 0: | 658 | case 0: |
697 | f.remove(); | 659 | f.remove(); |
698 | break; | 660 | break; |
699 | case 1: | 661 | case 1: |
700 | return; | 662 | return; |
701 | break; | 663 | break; |
702 | }; | 664 | }; |
703 | } | 665 | } |
704 | if(!copyFile( curFile,destFile) ) { | 666 | if(!copyFile( curFile,destFile) ) { |
705 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") | 667 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") |
706 | +curFile +tr("to\n")+destFile); | 668 | +curFile +tr("to\n")+destFile); |
707 | return; | 669 | return; |
708 | } | 670 | } |
709 | qDebug("copy "+curFile+" as "+destFile); | 671 | qDebug("copy "+curFile+" as "+destFile); |
710 | } | 672 | } |
711 | delete fileDlg; | 673 | delete fileDlg; |
712 | } | 674 | } |
713 | populateRemoteView(); | 675 | populateRemoteView(); |
714 | } | 676 | } |
715 | } | 677 | } |
716 | 678 | ||
717 | void AdvancedFm::move() { | 679 | void AdvancedFm::move() { |
718 | qApp->processEvents(); | 680 | qApp->processEvents(); |
719 | 681 | ||
720 | QStringList curFileList = getPath(); | 682 | QStringList curFileList = getPath(); |
721 | if( curFileList.count() > 0) { | 683 | if( curFileList.count() > 0) { |
722 | QString curFile, destFile, item; | 684 | QString curFile, destFile, item; |
723 | 685 | ||
724 | if (TabWidget->getCurrentTab() == 0) { | 686 | if (TabWidget->getCurrentTab() == 0) { |
725 | 687 | ||
726 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 688 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
727 | item=(*it); | 689 | item=(*it); |
728 | QString destFile = currentRemoteDir.canonicalPath(); | 690 | QString destFile = currentRemoteDir.canonicalPath(); |
729 | 691 | ||
730 | if(destFile.right(1).find("/",0,TRUE) == -1) | 692 | if(destFile.right(1).find("/",0,TRUE) == -1) |
731 | destFile+="/"; | 693 | destFile+="/"; |
732 | destFile += item; | 694 | destFile += item; |
733 | curFile = currentDir.canonicalPath(); | 695 | curFile = currentDir.canonicalPath(); |
734 | 696 | ||
735 | qDebug("Destination file is "+destFile); | 697 | qDebug("Destination file is "+destFile); |
736 | 698 | ||
737 | if(curFile.right(1).find("/",0,TRUE) == -1) | 699 | if(curFile.right(1).find("/",0,TRUE) == -1) |
738 | curFile +="/"; | 700 | curFile +="/"; |
739 | 701 | ||
740 | curFile+= item; | 702 | curFile+= item; |
741 | qDebug("CurrentFile file is " + curFile); | 703 | qDebug("CurrentFile file is " + curFile); |
742 | 704 | ||
743 | QFile f( curFile); | 705 | QFile f( curFile); |
744 | if( f.exists()) { | 706 | if( f.exists()) { |
745 | if(!copyFile( curFile,destFile) ) { | 707 | if(!copyFile( curFile,destFile) ) { |
746 | QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); | 708 | QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); |
747 | return; | 709 | return; |
748 | } else | 710 | } else |
749 | QFile::remove(curFile); | 711 | QFile::remove(curFile); |
750 | } | 712 | } |
751 | } | 713 | } |
752 | 714 | ||
753 | TabWidget->setCurrentTab(1); | 715 | TabWidget->setCurrentTab(1); |
754 | 716 | ||
755 | } else { //view 2 | 717 | } else { //view 2 |
756 | 718 | ||
757 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 719 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
758 | item = (*it); | 720 | item = (*it); |
759 | QString destFile = currentDir.canonicalPath(); | 721 | QString destFile = currentDir.canonicalPath(); |
760 | 722 | ||
761 | if(destFile.right(1).find("/",0,TRUE) == -1) | 723 | if(destFile.right(1).find("/",0,TRUE) == -1) |
762 | destFile+="/"; | 724 | destFile+="/"; |
763 | 725 | ||
764 | destFile += item; | 726 | destFile += item; |
765 | 727 | ||
766 | qDebug("Destination file is "+destFile); | 728 | qDebug("Destination file is "+destFile); |
767 | 729 | ||
768 | curFile = currentRemoteDir.canonicalPath(); | 730 | curFile = currentRemoteDir.canonicalPath(); |
769 | 731 | ||
770 | if(curFile.right(1).find("/",0,TRUE) == -1) | 732 | if(curFile.right(1).find("/",0,TRUE) == -1) |
771 | curFile +="/"; | 733 | curFile +="/"; |
772 | curFile+= item; | 734 | curFile+= item; |
773 | qDebug("CurrentFile file is " + curFile); | 735 | qDebug("CurrentFile file is " + curFile); |
774 | 736 | ||
775 | QFile f( curFile); | 737 | QFile f( curFile); |
776 | if( f.exists()) { | 738 | if( f.exists()) { |
777 | if(!copyFile( curFile, destFile) ) { | 739 | if(!copyFile( curFile, destFile) ) { |
778 | QMessageBox::message(tr("Note"),tr("Could not move\n") + curFile); | 740 | QMessageBox::message(tr("Note"),tr("Could not move\n") + curFile); |
779 | return; | 741 | return; |
780 | } else | 742 | } else |
781 | QFile::remove( curFile); | 743 | QFile::remove( curFile); |
782 | } | 744 | } |
783 | TabWidget->setCurrentTab(0); | 745 | TabWidget->setCurrentTab(0); |
784 | } | 746 | } |
785 | } | 747 | } |
786 | populateRemoteView(); | 748 | populateRemoteView(); |
787 | populateLocalView(); | 749 | populateLocalView(); |
788 | } | 750 | } |
789 | } | 751 | } |
790 | 752 | ||
791 | bool AdvancedFm::copyFile( const QString & src, const QString & dest ) { | 753 | bool AdvancedFm::copyFile( const QString & src, const QString & dest ) { |
792 | char bf[ 50000 ]; | 754 | char bf[ 50000 ]; |
793 | int bytesRead; | 755 | int bytesRead; |
794 | bool success = TRUE; | 756 | bool success = TRUE; |
795 | struct stat status; | 757 | struct stat status; |
796 | 758 | ||
797 | QFile s( src ); | 759 | QFile s( src ); |
798 | QFile d( dest ); | 760 | QFile d( dest ); |
799 | 761 | ||
800 | if( s.open( IO_ReadOnly | IO_Raw ) && d.open( IO_WriteOnly | IO_Raw ) ) { | 762 | if( s.open( IO_ReadOnly | IO_Raw ) && d.open( IO_WriteOnly | IO_Raw ) ) { |
801 | while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) ) { | 763 | while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) ) { |
802 | if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){ | 764 | if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){ |
803 | success = FALSE; | 765 | success = FALSE; |
804 | break; | 766 | break; |
805 | } | 767 | } |
806 | } | 768 | } |
807 | if( success && (bytesRead > 0) ){ | 769 | if( success && (bytesRead > 0) ){ |
808 | d.writeBlock( bf, bytesRead ); | 770 | d.writeBlock( bf, bytesRead ); |
809 | } | 771 | } |
810 | } else { | 772 | } else { |
811 | success = FALSE; | 773 | success = FALSE; |
812 | } | 774 | } |
813 | 775 | ||
814 | // Set file permissions | 776 | // Set file permissions |
815 | if( stat( (const char *) src, &status ) == 0 ){ | 777 | if( stat( (const char *) src, &status ) == 0 ){ |
816 | chmod( (const char *) dest, status.st_mode ); | 778 | chmod( (const char *) dest, status.st_mode ); |
817 | } | 779 | } |
818 | 780 | ||
819 | return success; | 781 | return success; |
820 | } | 782 | } |
821 | 783 | ||
822 | void AdvancedFm::runCommand() { | 784 | void AdvancedFm::runCommand() { |
823 | QString curFile; | 785 | QString curFile; |
824 | if (TabWidget->getCurrentTab() == 0) { | 786 | if (TabWidget->getCurrentTab() == 0) { |
825 | if( Local_View->currentItem()) | 787 | if( Local_View->currentItem()) |
826 | curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0); | 788 | curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0); |
827 | } else { | 789 | } else { |
828 | if(Remote_View->currentItem()) | 790 | if(Remote_View->currentItem()) |
829 | curFile = currentRemoteDir.canonicalPath() + "/"+Remote_View->currentItem()->text(0); | 791 | curFile = currentRemoteDir.canonicalPath() + "/"+Remote_View->currentItem()->text(0); |
830 | } | 792 | } |
831 | 793 | ||
832 | InputDialog *fileDlg; | 794 | InputDialog *fileDlg; |
833 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | 795 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); |
834 | fileDlg->setInputText(curFile); | 796 | fileDlg->setInputText(curFile); |
835 | fileDlg->exec(); | 797 | fileDlg->exec(); |
836 | //QString command; | 798 | //QString command; |
837 | 799 | ||
838 | if( fileDlg->result() == 1 ) { | 800 | if( fileDlg->result() == 1 ) { |
839 | qDebug(fileDlg->LineEdit1->text()); | 801 | qDebug(fileDlg->LineEdit1->text()); |
840 | QStringList command; | 802 | QStringList command; |
841 | 803 | ||
842 | command << "/bin/sh"; | 804 | command << "/bin/sh"; |
843 | command << "-c"; | 805 | command << "-c"; |
844 | command << fileDlg->LineEdit1->text(); | 806 | command << fileDlg->LineEdit1->text(); |
845 | Output *outDlg; | 807 | Output *outDlg; |
846 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); | 808 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); |
847 | outDlg->showMaximized(); | 809 | outDlg->showMaximized(); |
848 | outDlg->exec(); | 810 | outDlg->exec(); |
849 | qApp->processEvents(); | 811 | qApp->processEvents(); |
850 | 812 | ||
851 | } | 813 | } |
852 | } | 814 | } |
853 | 815 | ||
854 | void AdvancedFm::runCommandStd() { | 816 | void AdvancedFm::runCommandStd() { |
855 | QString curFile; | 817 | QString curFile; |
856 | if (TabWidget->getCurrentTab() == 0) { | 818 | if (TabWidget->getCurrentTab() == 0) { |
857 | if( Local_View->currentItem()) | 819 | if( Local_View->currentItem()) |
858 | curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0); | 820 | curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0); |
859 | } else { | 821 | } else { |
860 | if(Remote_View->currentItem()) | 822 | if(Remote_View->currentItem()) |
861 | curFile = currentRemoteDir.canonicalPath() +"/" | 823 | curFile = currentRemoteDir.canonicalPath() +"/" |
862 | + Remote_View->currentItem()->text(0); | 824 | + Remote_View->currentItem()->text(0); |
863 | } | 825 | } |
864 | 826 | ||
865 | InputDialog *fileDlg; | 827 | InputDialog *fileDlg; |
866 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | 828 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); |
867 | fileDlg->setInputText(curFile); | 829 | fileDlg->setInputText(curFile); |
868 | fileDlg->exec(); | 830 | fileDlg->exec(); |
869 | 831 | ||
870 | if( fileDlg->result() == 1 ) { | 832 | if( fileDlg->result() == 1 ) { |
871 | qApp->processEvents(); | 833 | qApp->processEvents(); |
872 | startProcess( (const QString)fileDlg->LineEdit1->text().latin1()); | 834 | startProcess( (const QString)fileDlg->LineEdit1->text().latin1()); |
873 | } | 835 | } |
874 | } | 836 | } |
875 | 837 | ||
876 | void AdvancedFm::fileStatus() { | 838 | void AdvancedFm::fileStatus() { |
877 | QString curFile; | 839 | QString curFile; |
878 | if (TabWidget->getCurrentTab() == 0) { | 840 | if (TabWidget->getCurrentTab() == 0) { |
879 | curFile = Local_View->currentItem()->text(0); | 841 | curFile = Local_View->currentItem()->text(0); |
880 | } else { | 842 | } else { |
881 | curFile = Remote_View->currentItem()->text(0); | 843 | curFile = Remote_View->currentItem()->text(0); |
882 | } | 844 | } |
883 | 845 | ||
884 | QStringList command; | 846 | QStringList command; |
885 | command << "/bin/sh"; | 847 | command << "/bin/sh"; |
886 | command << "-c"; | 848 | command << "-c"; |
887 | command << "stat -l "+ curFile; | 849 | command << "stat -l "+ curFile; |
888 | 850 | ||
889 | Output *outDlg; | 851 | Output *outDlg; |
890 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); | 852 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); |
891 | outDlg->showMaximized(); | 853 | outDlg->showMaximized(); |
892 | outDlg->exec(); | 854 | outDlg->exec(); |
893 | qApp->processEvents(); | 855 | qApp->processEvents(); |
894 | 856 | ||
895 | 857 | ||
896 | // Output *outDlg; | 858 | // Output *outDlg; |
897 | // outDlg = new Output(this, tr("AdvancedFm Output"),FALSE); | 859 | // outDlg = new Output(this, tr("AdvancedFm Output"),FALSE); |
898 | // outDlg->showMaximized(); | 860 | // outDlg->showMaximized(); |
899 | // outDlg->show(); | 861 | // outDlg->show(); |
900 | // qApp->processEvents(); | 862 | // qApp->processEvents(); |
901 | 863 | ||
902 | // FILE *fp; | 864 | // FILE *fp; |
903 | // char line[130]; | 865 | // char line[130]; |
904 | // sleep(1); | 866 | // sleep(1); |
905 | // fp = popen( (const char *) command, "r"); | 867 | // fp = popen( (const char *) command, "r"); |
906 | // if ( !fp ) { | 868 | // if ( !fp ) { |
907 | // qDebug("Could not execute '" + command + "'! err=%d", fp); | 869 | // qDebug("Could not execute '" + command + "'! err=%d", fp); |
908 | // QMessageBox::warning( this, "AdvancedFm", tr("command failed!"), tr("&OK") ); | 870 | // QMessageBox::warning( this, "AdvancedFm", tr("command failed!"), tr("&OK") ); |
909 | // pclose(fp); | 871 | // pclose(fp); |
910 | // return; | 872 | // return; |
911 | // } else { | 873 | // } else { |
912 | // while ( fgets( line, sizeof line, fp)) { | 874 | // while ( fgets( line, sizeof line, fp)) { |
913 | // outDlg->OutputEdit->append(line); | 875 | // outDlg->OutputEdit->append(line); |
914 | // outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | 876 | // outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); |
915 | 877 | ||
916 | // } | 878 | // } |
917 | 879 | ||
918 | // } | 880 | // } |
919 | // pclose(fp); | 881 | // pclose(fp); |
920 | } | 882 | } |
921 | 883 | ||
922 | 884 | ||
923 | void AdvancedFm::mkDir() { | 885 | void AdvancedFm::mkDir() { |
924 | if (TabWidget->getCurrentTab() == 0) | 886 | if (TabWidget->getCurrentTab() == 0) |
925 | localMakDir(); | 887 | localMakDir(); |
926 | else | 888 | else |
927 | remoteMakDir(); | 889 | remoteMakDir(); |
928 | 890 | ||
929 | } | 891 | } |
930 | 892 | ||
931 | void AdvancedFm::rn() { | 893 | void AdvancedFm::rn() { |
932 | if (TabWidget->getCurrentTab() == 0) | 894 | if (TabWidget->getCurrentTab() == 0) |
933 | localRename(); | 895 | localRename(); |
934 | else | 896 | else |
935 | remoteRename(); | 897 | remoteRename(); |
936 | 898 | ||
937 | } | 899 | } |
938 | 900 | ||
939 | void AdvancedFm::del() { | 901 | void AdvancedFm::del() { |
940 | if (TabWidget->getCurrentTab() == 0) | 902 | if (TabWidget->getCurrentTab() == 0) |
941 | localDelete(); | 903 | localDelete(); |
942 | else | 904 | else |
943 | remoteDelete(); | 905 | remoteDelete(); |
944 | } | 906 | } |
945 | 907 | ||
946 | void AdvancedFm::mkSym() { | 908 | void AdvancedFm::mkSym() { |
947 | QString cmd; | 909 | QString cmd; |
948 | QStringList curFileList = getPath(); | 910 | QStringList curFileList = getPath(); |
949 | if( curFileList.count() > 0) { | 911 | if( curFileList.count() > 0) { |
950 | 912 | ||
951 | if (TabWidget->getCurrentTab() == 0) { | 913 | if (TabWidget->getCurrentTab() == 0) { |
952 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 914 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
953 | 915 | ||
954 | QString destName = currentRemoteDir.canonicalPath()+"/"+(*it); | 916 | QString destName = currentRemoteDir.canonicalPath()+"/"+(*it); |
955 | if(destName.right(1) == "/") destName = destName.left( destName.length() -1); | 917 | if(destName.right(1) == "/") destName = destName.left( destName.length() -1); |
956 | QString curFile = currentDir.canonicalPath()+"/"+(*it); | 918 | QString curFile = currentDir.canonicalPath()+"/"+(*it); |
957 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); | 919 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); |
958 | cmd = "ln -s "+curFile+" "+destName; | 920 | cmd = "ln -s "+curFile+" "+destName; |
959 | qDebug(cmd); | 921 | qDebug(cmd); |
960 | startProcess( (const QString)cmd ); | 922 | startProcess( (const QString)cmd ); |
961 | } | 923 | } |
962 | populateRemoteView(); | 924 | populateRemoteView(); |
963 | TabWidget->setCurrentTab(1); | 925 | TabWidget->setCurrentTab(1); |
964 | } else { | 926 | } else { |
965 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 927 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
966 | 928 | ||
967 | QString destName = currentDir.canonicalPath()+"/"+(*it); | 929 | QString destName = currentDir.canonicalPath()+"/"+(*it); |
968 | if(destName.right(1) == "/") destName = destName.left( destName.length() -1); | 930 | if(destName.right(1) == "/") destName = destName.left( destName.length() -1); |
969 | QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it); | 931 | QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it); |
970 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); | 932 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); |
971 | 933 | ||
972 | cmd = "ln -s "+curFile+" "+destName; | 934 | cmd = "ln -s "+curFile+" "+destName; |
973 | qDebug(cmd); | 935 | qDebug(cmd); |
974 | startProcess( (const QString)cmd ); | 936 | startProcess( (const QString)cmd ); |
975 | } | 937 | } |
976 | populateLocalView(); | 938 | populateLocalView(); |
977 | TabWidget->setCurrentTab(0); | 939 | TabWidget->setCurrentTab(0); |
978 | } | 940 | } |
979 | } | 941 | } |
980 | } | 942 | } |
981 | 943 | ||
982 | void AdvancedFm::doBeam() { | 944 | void AdvancedFm::doBeam() { |
983 | Ir ir; | 945 | Ir ir; |
984 | if(!ir.supported()){ | 946 | if(!ir.supported()){ |
985 | } else { | 947 | } else { |
986 | 948 | ||
987 | QStringList curFileList = getPath(); | 949 | QStringList curFileList = getPath(); |
988 | if( curFileList.count() > 0) { | 950 | if( curFileList.count() > 0) { |
989 | 951 | ||
990 | if (TabWidget->getCurrentTab() == 0) { | 952 | if (TabWidget->getCurrentTab() == 0) { |
991 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 953 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
992 | 954 | ||
993 | QString curFile = currentDir.canonicalPath()+"/"+(*it); | 955 | QString curFile = currentDir.canonicalPath()+"/"+(*it); |
994 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); | 956 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); |
995 | Ir *file = new Ir(this, "IR"); | 957 | Ir *file = new Ir(this, "IR"); |
996 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); | 958 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); |
997 | file->send( curFile, curFile ); | 959 | file->send( curFile, curFile ); |
998 | } | 960 | } |
999 | 961 | ||
1000 | } else { | 962 | } else { |
1001 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 963 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
1002 | 964 | ||
1003 | QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it); | 965 | QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it); |
1004 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); | 966 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); |
1005 | Ir *file = new Ir(this, "IR"); | 967 | Ir *file = new Ir(this, "IR"); |
1006 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); | 968 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); |
1007 | file->send( curFile, curFile ); | 969 | file->send( curFile, curFile ); |
1008 | 970 | ||
1009 | } | 971 | } |
1010 | } | 972 | } |
1011 | } | 973 | } |
1012 | } | 974 | } |
1013 | 975 | ||
1014 | } | 976 | } |
1015 | 977 | ||
1016 | void AdvancedFm::fileBeamFinished( Ir *) { | 978 | void AdvancedFm::fileBeamFinished( Ir *) { |
1017 | QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); | 979 | QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); |
1018 | 980 | ||
1019 | } | 981 | } |
1020 | 982 | ||
1021 | void AdvancedFm::selectAll() { | 983 | void AdvancedFm::selectAll() { |
1022 | if (TabWidget->getCurrentTab() == 0) { | 984 | if (TabWidget->getCurrentTab() == 0) { |
1023 | Local_View->selectAll(true); | 985 | Local_View->selectAll(true); |
1024 | Local_View->setSelected( Local_View->firstChild(),false); | 986 | Local_View->setSelected( Local_View->firstChild(),false); |
1025 | } else { | 987 | } else { |
1026 | Remote_View->selectAll(true); | 988 | Remote_View->selectAll(true); |
1027 | Remote_View->setSelected( Remote_View->firstChild(),false); | 989 | Remote_View->setSelected( Remote_View->firstChild(),false); |
1028 | } | 990 | } |
1029 | } | 991 | } |
1030 | 992 | ||
1031 | void AdvancedFm::startProcess(const QString & cmd) { | 993 | void AdvancedFm::startProcess(const QString & cmd) { |
1032 | QStringList command; | 994 | QStringList command; |
1033 | OProcess *process; | 995 | OProcess *process; |
1034 | process = new OProcess(); | 996 | process = new OProcess(); |
1035 | connect(process, SIGNAL(processExited(OProcess *)), | 997 | connect(process, SIGNAL(processExited(OProcess *)), |
1036 | this, SLOT( processEnded())); | 998 | this, SLOT( processEnded())); |
1037 | 999 | ||
1038 | command << "/bin/sh"; | 1000 | command << "/bin/sh"; |
1039 | command << "-c"; | 1001 | command << "-c"; |
1040 | command << cmd.latin1(); | 1002 | command << cmd.latin1(); |
1041 | *process << command; | 1003 | *process << command; |
1042 | if(!process->start(OProcess::NotifyOnExit) ) | 1004 | if(!process->start(OProcess::NotifyOnExit) ) |
1043 | qDebug("could not start process"); | 1005 | qDebug("could not start process"); |
1044 | } | 1006 | } |
1045 | 1007 | ||
1046 | void AdvancedFm::processEnded() { | 1008 | void AdvancedFm::processEnded() { |
1047 | populateLocalView(); | 1009 | populateLocalView(); |
1048 | populateRemoteView(); | 1010 | populateRemoteView(); |
1049 | } | 1011 | } |
1012 | |||
1013 | bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) { | ||
1014 | if ( o->inherits( "QLineEdit" ) ) { | ||
1015 | if ( e->type() == QEvent::KeyPress ) { | ||
1016 | QKeyEvent *ke = (QKeyEvent*)e; | ||
1017 | if ( ke->key() == Key_Return || | ||
1018 | ke->key() == Key_Enter ) { | ||
1019 | okRename(); | ||
1020 | return true; | ||
1021 | } else if ( ke->key() == Key_Escape ) { | ||
1022 | cancelRename(); | ||
1023 | return true; | ||
1024 | } | ||
1025 | } else if ( e->type() == QEvent::FocusOut ) { | ||
1026 | cancelRename(); | ||
1027 | return true; | ||
1028 | } | ||
1029 | } | ||
1030 | return QWidget::eventFilter( o, e ); | ||
1031 | } | ||
1032 | |||
1033 | |||
1034 | void AdvancedFm::cancelRename() { | ||
1035 | qDebug("cancel rename"); | ||
1036 | QListView * view; | ||
1037 | if (TabWidget->getCurrentTab() == 0) { | ||
1038 | view = Local_View; | ||
1039 | } | ||
1040 | else | ||
1041 | { | ||
1042 | view = Remote_View; | ||
1043 | } | ||
1044 | |||
1045 | bool resetFocus = view->viewport()->focusProxy() == renameBox; | ||
1046 | delete renameBox; | ||
1047 | renameBox = 0; | ||
1048 | if ( resetFocus ) { | ||
1049 | view->viewport()->setFocusProxy( view); | ||
1050 | view->setFocus(); | ||
1051 | } | ||
1052 | } | ||
1053 | |||
1054 | void AdvancedFm::doRename(QListView * view) { | ||
1055 | |||
1056 | QRect r = view->itemRect( view->currentItem( )); | ||
1057 | r = QRect( view->viewportToContents( r.topLeft() ), r.size() ); | ||
1058 | r.setX( view->contentsX() ); | ||
1059 | if ( r.width() > view->visibleWidth() ) | ||
1060 | r.setWidth( view->visibleWidth() ); | ||
1061 | |||
1062 | renameBox = new QLineEdit( view->viewport(), "qt_renamebox" ); | ||
1063 | renameBox->setFrame(true); | ||
1064 | |||
1065 | renameBox->setText( view->currentItem()->text(0) ); | ||
1066 | |||
1067 | renameBox->selectAll(); | ||
1068 | renameBox->installEventFilter( this ); | ||
1069 | view->addChild( renameBox, r.x(), r.y() ); | ||
1070 | renameBox->resize( r.size() ); | ||
1071 | view->viewport()->setFocusProxy( renameBox ); | ||
1072 | renameBox->setFocus(); | ||
1073 | renameBox->show(); | ||
1074 | |||
1075 | } | ||
1076 | |||
1077 | |||
1078 | void AdvancedFm::localRename() { | ||
1079 | oldName = Local_View->currentItem()->text(0); | ||
1080 | doRename(Local_View ); | ||
1081 | populateLocalView(); | ||
1082 | } | ||
1083 | |||
1084 | void AdvancedFm::remoteRename() | ||
1085 | { | ||
1086 | oldName = Remote_View->currentItem()->text(0); | ||
1087 | doRename(Local_View ); | ||
1088 | populateRemoteView(); | ||
1089 | } | ||
1090 | |||
1091 | void AdvancedFm::okRename() { | ||
1092 | QString newName = renameBox->text(); | ||
1093 | cancelRename(); | ||
1094 | int tabs=0; | ||
1095 | QListView * view; | ||
1096 | tabs = TabWidget->getCurrentTab(); | ||
1097 | if ( tabs == 0) | ||
1098 | { | ||
1099 | view = Local_View; | ||
1100 | QString path = currentDir.canonicalPath() + "/"; | ||
1101 | oldName = path + oldName; | ||
1102 | newName = path + newName; | ||
1103 | } | ||
1104 | else | ||
1105 | { | ||
1106 | view = Remote_View; | ||
1107 | QString path = currentRemoteDir.canonicalPath() + "/"; | ||
1108 | oldName = path + oldName; | ||
1109 | newName = path + newName; | ||
1110 | } | ||
1111 | |||
1112 | if( view->currentItem() == NULL) | ||
1113 | return; | ||
1114 | if( rename(oldName.latin1(), newName.latin1())== -1) | ||
1115 | QMessageBox::message(tr("Note"),tr("Could not rename")); | ||
1116 | else | ||
1117 | oldName = ""; | ||
1118 | |||
1119 | view->takeItem( view->currentItem() ); | ||
1120 | delete view->currentItem(); | ||
1121 | if ( tabs == 0) | ||
1122 | populateLocalView(); | ||
1123 | else | ||
1124 | populateRemoteView(); | ||
1125 | } | ||