author | llornkcor <llornkcor> | 2003-02-23 03:47:07 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2003-02-23 03:47:07 (UTC) |
commit | 2678456bf180bcf0ab7cfa112f3c723cf1d87c84 (patch) (unidiff) | |
tree | eb7edd83adc3204088f2f3e0ed3c0ff9e48f5040 | |
parent | d51ca116a8c4d234db93021ccad36506980c317f (diff) | |
download | opie-2678456bf180bcf0ab7cfa112f3c723cf1d87c84.zip opie-2678456bf180bcf0ab7cfa112f3c723cf1d87c84.tar.gz opie-2678456bf180bcf0ab7cfa112f3c723cf1d87c84.tar.bz2 |
fix rename
-rw-r--r-- | noncore/apps/advancedfm/advancedfmMenu.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp index 2ddcabc..e7c0b6a 100644 --- a/noncore/apps/advancedfm/advancedfmMenu.cpp +++ b/noncore/apps/advancedfm/advancedfmMenu.cpp | |||
@@ -1,1137 +1,1137 @@ | |||
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 | 342 | ||
343 | void AdvancedFm::filePerms() { | 343 | void AdvancedFm::filePerms() { |
344 | 344 | ||
345 | QStringList curFileList = getPath(); | 345 | QStringList curFileList = getPath(); |
346 | QString filePath; | 346 | QString filePath; |
347 | 347 | ||
348 | if (TabWidget->getCurrentTab() == 0) { | 348 | if (TabWidget->getCurrentTab() == 0) { |
349 | filePath = currentDir.canonicalPath()+"/"; | 349 | filePath = currentDir.canonicalPath()+"/"; |
350 | } else { | 350 | } else { |
351 | filePath= currentRemoteDir.canonicalPath()+"/"; | 351 | filePath= currentRemoteDir.canonicalPath()+"/"; |
352 | } | 352 | } |
353 | 353 | ||
354 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 354 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
355 | filePermissions *filePerm; | 355 | filePermissions *filePerm; |
356 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); | 356 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); |
357 | filePerm->showMaximized(); | 357 | filePerm->showMaximized(); |
358 | filePerm->exec(); | 358 | filePerm->exec(); |
359 | if( filePerm) | 359 | if( filePerm) |
360 | delete filePerm; | 360 | delete filePerm; |
361 | } | 361 | } |
362 | if (TabWidget->getCurrentTab() == 0) { | 362 | if (TabWidget->getCurrentTab() == 0) { |
363 | populateLocalView(); | 363 | populateLocalView(); |
364 | } else { | 364 | } else { |
365 | populateRemoteView(); | 365 | populateRemoteView(); |
366 | } | 366 | } |
367 | } | 367 | } |
368 | 368 | ||
369 | void AdvancedFm::doProperties() { | 369 | void AdvancedFm::doProperties() { |
370 | #if defined(QT_QWS_OPIE) | 370 | #if defined(QT_QWS_OPIE) |
371 | 371 | ||
372 | QStringList curFileList = getPath(); | 372 | QStringList curFileList = getPath(); |
373 | 373 | ||
374 | QString filePath; | 374 | QString filePath; |
375 | if (TabWidget->getCurrentTab() == 0) { | 375 | if (TabWidget->getCurrentTab() == 0) { |
376 | filePath = currentDir.canonicalPath()+"/"; | 376 | filePath = currentDir.canonicalPath()+"/"; |
377 | } else { | 377 | } else { |
378 | filePath= currentRemoteDir.canonicalPath()+"/"; | 378 | filePath= currentRemoteDir.canonicalPath()+"/"; |
379 | } | 379 | } |
380 | qDebug("%d",curFileList.count()); | 380 | qDebug("%d",curFileList.count()); |
381 | 381 | ||
382 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 382 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
383 | qDebug((filePath+*it)); | 383 | qDebug((filePath+*it)); |
384 | DocLnk lnk( (filePath+*it)); | 384 | DocLnk lnk( (filePath+*it)); |
385 | LnkProperties prop( &lnk ); | 385 | LnkProperties prop( &lnk ); |
386 | prop.showMaximized(); | 386 | prop.showMaximized(); |
387 | prop.exec(); | 387 | prop.exec(); |
388 | } | 388 | } |
389 | #endif | 389 | #endif |
390 | 390 | ||
391 | } | 391 | } |
392 | 392 | ||
393 | void AdvancedFm::upDir() { | 393 | void AdvancedFm::upDir() { |
394 | if (TabWidget->getCurrentTab() == 0) { | 394 | if (TabWidget->getCurrentTab() == 0) { |
395 | QString current = currentDir.canonicalPath(); | 395 | QString current = currentDir.canonicalPath(); |
396 | QDir dir(current); | 396 | QDir dir(current); |
397 | dir.cdUp(); | 397 | dir.cdUp(); |
398 | current = dir.canonicalPath(); | 398 | current = dir.canonicalPath(); |
399 | chdir( current.latin1() ); | 399 | chdir( current.latin1() ); |
400 | currentDir.cd( current, TRUE); | 400 | currentDir.cd( current, TRUE); |
401 | populateLocalView(); | 401 | populateLocalView(); |
402 | update(); | 402 | update(); |
403 | } else { | 403 | } else { |
404 | QString current = currentRemoteDir.canonicalPath(); | 404 | QString current = currentRemoteDir.canonicalPath(); |
405 | QDir dir(current); | 405 | QDir dir(current); |
406 | dir.cdUp(); | 406 | dir.cdUp(); |
407 | current = dir.canonicalPath(); | 407 | current = dir.canonicalPath(); |
408 | chdir( current.latin1() ); | 408 | chdir( current.latin1() ); |
409 | currentRemoteDir.cd( current, TRUE); | 409 | currentRemoteDir.cd( current, TRUE); |
410 | populateRemoteView(); | 410 | populateRemoteView(); |
411 | update(); | 411 | update(); |
412 | } | 412 | } |
413 | } | 413 | } |
414 | 414 | ||
415 | void AdvancedFm::copy() { | 415 | void AdvancedFm::copy() { |
416 | qApp->processEvents(); | 416 | qApp->processEvents(); |
417 | QStringList curFileList = getPath(); | 417 | QStringList curFileList = getPath(); |
418 | bool doMsg=true; | 418 | bool doMsg=true; |
419 | int count=curFileList.count(); | 419 | int count=curFileList.count(); |
420 | if( count > 0) { | 420 | if( count > 0) { |
421 | if(count > 1 ){ | 421 | if(count > 1 ){ |
422 | QString msg; | 422 | QString msg; |
423 | msg=tr("Really copy\n%1 files?").arg(count); | 423 | msg=tr("Really copy\n%1 files?").arg(count); |
424 | switch ( QMessageBox::warning(this,tr("Delete"),msg | 424 | switch ( QMessageBox::warning(this,tr("Delete"),msg |
425 | ,tr("Yes"),tr("No"),0,0,1) ) { | 425 | ,tr("Yes"),tr("No"),0,0,1) ) { |
426 | case 0: | 426 | case 0: |
427 | doMsg=false; | 427 | doMsg=false; |
428 | break; | 428 | break; |
429 | case 1: | 429 | case 1: |
430 | return; | 430 | return; |
431 | break; | 431 | break; |
432 | }; | 432 | }; |
433 | } | 433 | } |
434 | 434 | ||
435 | QString curFile, item, destFile; | 435 | QString curFile, item, destFile; |
436 | if (TabWidget->getCurrentTab() == 0) { | 436 | if (TabWidget->getCurrentTab() == 0) { |
437 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 437 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
438 | item=(*it); | 438 | item=(*it); |
439 | if(item.find("->",0,TRUE)) //symlink | 439 | if(item.find("->",0,TRUE)) //symlink |
440 | item = item.left(item.find("->",0,TRUE)); | 440 | item = item.left(item.find("->",0,TRUE)); |
441 | 441 | ||
442 | destFile = currentRemoteDir.canonicalPath()+"/"+ item; | 442 | destFile = currentRemoteDir.canonicalPath()+"/"+ item; |
443 | qDebug("Destination file is "+destFile); | 443 | qDebug("Destination file is "+destFile); |
444 | 444 | ||
445 | curFile = currentDir.canonicalPath()+"/"+ item; | 445 | curFile = currentDir.canonicalPath()+"/"+ item; |
446 | qDebug("CurrentFile file is " + curFile); | 446 | qDebug("CurrentFile file is " + curFile); |
447 | 447 | ||
448 | QFile f(destFile); | 448 | QFile f(destFile); |
449 | if( f.exists()) { | 449 | if( f.exists()) { |
450 | if(doMsg) { | 450 | if(doMsg) { |
451 | 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) ) { |
452 | case 1: | 452 | case 1: |
453 | return; | 453 | return; |
454 | break; | 454 | break; |
455 | }; | 455 | }; |
456 | } | 456 | } |
457 | f.remove(); | 457 | f.remove(); |
458 | } | 458 | } |
459 | if(!copyFile( curFile, destFile) ) { | 459 | if(!copyFile( curFile, destFile) ) { |
460 | 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 ) ); |
461 | return; | 461 | return; |
462 | } | 462 | } |
463 | } | 463 | } |
464 | populateRemoteView(); | 464 | populateRemoteView(); |
465 | TabWidget->setCurrentTab(1); | 465 | TabWidget->setCurrentTab(1); |
466 | 466 | ||
467 | } else { | 467 | } else { |
468 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 468 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
469 | item= (*it); | 469 | item= (*it); |
470 | if(item.find("->",0,TRUE)) //symlink | 470 | if(item.find("->",0,TRUE)) //symlink |
471 | item = item.left(item.find("->",0,TRUE)); | 471 | item = item.left(item.find("->",0,TRUE)); |
472 | 472 | ||
473 | destFile = currentDir.canonicalPath()+"/"+ item; | 473 | destFile = currentDir.canonicalPath()+"/"+ item; |
474 | qDebug("Destination file is "+destFile); | 474 | qDebug("Destination file is "+destFile); |
475 | 475 | ||
476 | curFile = currentRemoteDir.canonicalPath()+"/"+ item;; | 476 | curFile = currentRemoteDir.canonicalPath()+"/"+ item;; |
477 | qDebug("CurrentFile file is " + curFile); | 477 | qDebug("CurrentFile file is " + curFile); |
478 | 478 | ||
479 | QFile f(destFile); | 479 | QFile f(destFile); |
480 | if( f.exists()) { | 480 | if( f.exists()) { |
481 | switch ( QMessageBox::warning(this,tr("File Exists!"), | 481 | switch ( QMessageBox::warning(this,tr("File Exists!"), |
482 | item+tr("\nexists. Ok to overwrite?"), | 482 | item+tr("\nexists. Ok to overwrite?"), |
483 | tr("Yes"),tr("No"),0,0,1) ) { | 483 | tr("Yes"),tr("No"),0,0,1) ) { |
484 | case 1: | 484 | case 1: |
485 | return; | 485 | return; |
486 | break; | 486 | break; |
487 | }; | 487 | }; |
488 | f.remove(); | 488 | f.remove(); |
489 | } | 489 | } |
490 | if(!copyFile( curFile, destFile) ) { | 490 | if(!copyFile( curFile, destFile) ) { |
491 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") | 491 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") |
492 | +curFile +tr("to\n")+destFile); | 492 | +curFile +tr("to\n")+destFile); |
493 | return; | 493 | return; |
494 | 494 | ||
495 | } | 495 | } |
496 | } | 496 | } |
497 | populateLocalView(); | 497 | populateLocalView(); |
498 | TabWidget->setCurrentTab(0); | 498 | TabWidget->setCurrentTab(0); |
499 | } | 499 | } |
500 | 500 | ||
501 | } | 501 | } |
502 | } | 502 | } |
503 | 503 | ||
504 | void AdvancedFm::copyAs() { | 504 | void AdvancedFm::copyAs() { |
505 | qApp->processEvents(); | 505 | qApp->processEvents(); |
506 | 506 | ||
507 | QStringList curFileList = getPath(); | 507 | QStringList curFileList = getPath(); |
508 | QString curFile, item; | 508 | QString curFile, item; |
509 | InputDialog *fileDlg; | 509 | InputDialog *fileDlg; |
510 | if (TabWidget->getCurrentTab() == 0) { | 510 | if (TabWidget->getCurrentTab() == 0) { |
511 | qDebug("tab 1"); | 511 | qDebug("tab 1"); |
512 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 512 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
513 | QString destFile; | 513 | QString destFile; |
514 | item=(*it); | 514 | item=(*it); |
515 | curFile = currentDir.canonicalPath()+"/"+(*it); | 515 | curFile = currentDir.canonicalPath()+"/"+(*it); |
516 | fileDlg = new InputDialog( this,tr("Copy "+curFile+" As"), TRUE, 0); | 516 | fileDlg = new InputDialog( this,tr("Copy "+curFile+" As"), TRUE, 0); |
517 | 517 | ||
518 | fileDlg->setInputText((const QString &) destFile ); | 518 | fileDlg->setInputText((const QString &) destFile ); |
519 | fileDlg->exec(); | 519 | fileDlg->exec(); |
520 | 520 | ||
521 | if( fileDlg->result() == 1 ) { | 521 | if( fileDlg->result() == 1 ) { |
522 | QString filename = fileDlg->LineEdit1->text(); | 522 | QString filename = fileDlg->LineEdit1->text(); |
523 | destFile = currentRemoteDir.canonicalPath()+"/"+filename; | 523 | destFile = currentRemoteDir.canonicalPath()+"/"+filename; |
524 | 524 | ||
525 | QFile f(destFile); | 525 | QFile f(destFile); |
526 | if( f.exists()) { | 526 | if( f.exists()) { |
527 | switch (QMessageBox::warning(this,tr("File Exists!"), | 527 | switch (QMessageBox::warning(this,tr("File Exists!"), |
528 | item+tr("\nexists. Ok to overwrite?"), | 528 | item+tr("\nexists. Ok to overwrite?"), |
529 | tr("Yes"),tr("No"),0,0,1) ) { | 529 | tr("Yes"),tr("No"),0,0,1) ) { |
530 | case 0: | 530 | case 0: |
531 | f.remove(); | 531 | f.remove(); |
532 | break; | 532 | break; |
533 | case 1: | 533 | case 1: |
534 | return; | 534 | return; |
535 | break; | 535 | break; |
536 | }; | 536 | }; |
537 | } | 537 | } |
538 | if(!copyFile( curFile,destFile) ) { | 538 | if(!copyFile( curFile,destFile) ) { |
539 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") | 539 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") |
540 | +curFile +tr("to\n")+destFile); | 540 | +curFile +tr("to\n")+destFile); |
541 | return; | 541 | return; |
542 | } | 542 | } |
543 | } | 543 | } |
544 | delete fileDlg; | 544 | delete fileDlg; |
545 | 545 | ||
546 | } | 546 | } |
547 | populateRemoteView(); | 547 | populateRemoteView(); |
548 | TabWidget->setCurrentTab(1); | 548 | TabWidget->setCurrentTab(1); |
549 | 549 | ||
550 | } else { | 550 | } else { |
551 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 551 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
552 | 552 | ||
553 | item=(*it); | 553 | item=(*it); |
554 | curFile = currentRemoteDir.canonicalPath()+"/"+(*it); | 554 | curFile = currentRemoteDir.canonicalPath()+"/"+(*it); |
555 | fileDlg = new InputDialog( this,tr("Copy "+curFile+" As"), TRUE, 0); | 555 | fileDlg = new InputDialog( this,tr("Copy "+curFile+" As"), TRUE, 0); |
556 | 556 | ||
557 | QString destFile; | 557 | QString destFile; |
558 | fileDlg->setInputText((const QString &) destFile); | 558 | fileDlg->setInputText((const QString &) destFile); |
559 | fileDlg->exec(); | 559 | fileDlg->exec(); |
560 | 560 | ||
561 | if( fileDlg->result() == 1 ) { | 561 | if( fileDlg->result() == 1 ) { |
562 | QString filename = fileDlg->LineEdit1->text(); | 562 | QString filename = fileDlg->LineEdit1->text(); |
563 | destFile = currentDir.canonicalPath()+"/"+filename; | 563 | destFile = currentDir.canonicalPath()+"/"+filename; |
564 | 564 | ||
565 | QFile f( destFile); | 565 | QFile f( destFile); |
566 | if( f.exists()) { | 566 | if( f.exists()) { |
567 | switch ( QMessageBox::warning(this,tr("File Exists!"), | 567 | switch ( QMessageBox::warning(this,tr("File Exists!"), |
568 | item+tr("\nexists. Ok to overwrite?"), | 568 | item+tr("\nexists. Ok to overwrite?"), |
569 | tr("Yes"),tr("No"),0,0,1) ) { | 569 | tr("Yes"),tr("No"),0,0,1) ) { |
570 | case 0: | 570 | case 0: |
571 | f.remove(); | 571 | f.remove(); |
572 | break; | 572 | break; |
573 | case 1: | 573 | case 1: |
574 | return; | 574 | return; |
575 | break; | 575 | break; |
576 | }; | 576 | }; |
577 | } | 577 | } |
578 | if(!copyFile( curFile,destFile) ) { | 578 | if(!copyFile( curFile,destFile) ) { |
579 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") | 579 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") |
580 | +curFile +tr("to\n")+destFile); | 580 | +curFile +tr("to\n")+destFile); |
581 | return; | 581 | return; |
582 | } | 582 | } |
583 | 583 | ||
584 | } | 584 | } |
585 | delete fileDlg; | 585 | delete fileDlg; |
586 | 586 | ||
587 | } | 587 | } |
588 | populateLocalView(); | 588 | populateLocalView(); |
589 | TabWidget->setCurrentTab(0); | 589 | TabWidget->setCurrentTab(0); |
590 | } | 590 | } |
591 | } | 591 | } |
592 | 592 | ||
593 | void AdvancedFm::copySameDir() { | 593 | void AdvancedFm::copySameDir() { |
594 | qApp->processEvents(); | 594 | qApp->processEvents(); |
595 | QStringList curFileList = getPath(); | 595 | QStringList curFileList = getPath(); |
596 | QString curFile, item, destFile; | 596 | QString curFile, item, destFile; |
597 | InputDialog *fileDlg; | 597 | InputDialog *fileDlg; |
598 | 598 | ||
599 | if (TabWidget->getCurrentTab() == 0) { | 599 | if (TabWidget->getCurrentTab() == 0) { |
600 | 600 | ||
601 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 601 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
602 | item=(*it); | 602 | item=(*it); |
603 | curFile = currentDir.canonicalPath()+"/"+ item; | 603 | curFile = currentDir.canonicalPath()+"/"+ item; |
604 | 604 | ||
605 | fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); | 605 | fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); |
606 | fileDlg->setInputText((const QString &) destFile ); | 606 | fileDlg->setInputText((const QString &) destFile ); |
607 | fileDlg->exec(); | 607 | fileDlg->exec(); |
608 | 608 | ||
609 | if( fileDlg->result() == 1 ) { | 609 | if( fileDlg->result() == 1 ) { |
610 | 610 | ||
611 | QString filename = fileDlg->LineEdit1->text(); | 611 | QString filename = fileDlg->LineEdit1->text(); |
612 | destFile = currentDir.canonicalPath()+"/"+filename; | 612 | destFile = currentDir.canonicalPath()+"/"+filename; |
613 | 613 | ||
614 | QFile f(destFile); | 614 | QFile f(destFile); |
615 | if( f.exists()) { | 615 | if( f.exists()) { |
616 | switch (QMessageBox::warning(this,tr("Delete"), | 616 | switch (QMessageBox::warning(this,tr("Delete"), |
617 | destFile+tr(" already exists.\nDo you really want to delete it?"), | 617 | destFile+tr(" already exists.\nDo you really want to delete it?"), |
618 | tr("Yes"),tr("No"),0,0,1) ) { | 618 | tr("Yes"),tr("No"),0,0,1) ) { |
619 | case 0: | 619 | case 0: |
620 | 620 | ||
621 | f.remove(); | 621 | f.remove(); |
622 | break; | 622 | break; |
623 | case 1: | 623 | case 1: |
624 | return; | 624 | return; |
625 | break; | 625 | break; |
626 | }; | 626 | }; |
627 | } | 627 | } |
628 | if(!copyFile( curFile,destFile) ) { | 628 | if(!copyFile( curFile,destFile) ) { |
629 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") | 629 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") |
630 | +curFile +tr("to\n")+destFile); | 630 | +curFile +tr("to\n")+destFile); |
631 | return; | 631 | return; |
632 | } | 632 | } |
633 | 633 | ||
634 | qDebug("copy "+curFile+" as "+destFile); | 634 | qDebug("copy "+curFile+" as "+destFile); |
635 | } | 635 | } |
636 | delete fileDlg; | 636 | delete fileDlg; |
637 | } | 637 | } |
638 | populateLocalView(); | 638 | populateLocalView(); |
639 | 639 | ||
640 | } else { | 640 | } else { |
641 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 641 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
642 | item=(*it); | 642 | item=(*it); |
643 | curFile = currentRemoteDir.canonicalPath()+"/"+ item; | 643 | curFile = currentRemoteDir.canonicalPath()+"/"+ item; |
644 | 644 | ||
645 | fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); | 645 | fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); |
646 | fileDlg->setInputText((const QString &) destFile); | 646 | fileDlg->setInputText((const QString &) destFile); |
647 | fileDlg->exec(); | 647 | fileDlg->exec(); |
648 | if( fileDlg->result() == 1 ) { | 648 | if( fileDlg->result() == 1 ) { |
649 | QString filename = fileDlg->LineEdit1->text(); | 649 | QString filename = fileDlg->LineEdit1->text(); |
650 | 650 | ||
651 | destFile = currentRemoteDir.canonicalPath()+"/"+filename; | 651 | destFile = currentRemoteDir.canonicalPath()+"/"+filename; |
652 | 652 | ||
653 | QFile f(destFile); | 653 | QFile f(destFile); |
654 | if( f.exists()) { | 654 | if( f.exists()) { |
655 | switch ( QMessageBox::warning(this,tr("Delete"), | 655 | switch ( QMessageBox::warning(this,tr("Delete"), |
656 | destFile+tr(" already exists.\nDo you really want to delete it?"), | 656 | destFile+tr(" already exists.\nDo you really want to delete it?"), |
657 | tr("Yes"),tr("No"),0,0,1) ) { | 657 | tr("Yes"),tr("No"),0,0,1) ) { |
658 | case 0: | 658 | case 0: |
659 | f.remove(); | 659 | f.remove(); |
660 | break; | 660 | break; |
661 | case 1: | 661 | case 1: |
662 | return; | 662 | return; |
663 | break; | 663 | break; |
664 | }; | 664 | }; |
665 | } | 665 | } |
666 | if(!copyFile( curFile,destFile) ) { | 666 | if(!copyFile( curFile,destFile) ) { |
667 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") | 667 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") |
668 | +curFile +tr("to\n")+destFile); | 668 | +curFile +tr("to\n")+destFile); |
669 | return; | 669 | return; |
670 | } | 670 | } |
671 | qDebug("copy "+curFile+" as "+destFile); | 671 | qDebug("copy "+curFile+" as "+destFile); |
672 | } | 672 | } |
673 | delete fileDlg; | 673 | delete fileDlg; |
674 | } | 674 | } |
675 | populateRemoteView(); | 675 | populateRemoteView(); |
676 | } | 676 | } |
677 | } | 677 | } |
678 | 678 | ||
679 | void AdvancedFm::move() { | 679 | void AdvancedFm::move() { |
680 | qApp->processEvents(); | 680 | qApp->processEvents(); |
681 | 681 | ||
682 | QStringList curFileList = getPath(); | 682 | QStringList curFileList = getPath(); |
683 | if( curFileList.count() > 0) { | 683 | if( curFileList.count() > 0) { |
684 | QString curFile, destFile, item; | 684 | QString curFile, destFile, item; |
685 | 685 | ||
686 | if (TabWidget->getCurrentTab() == 0) { | 686 | if (TabWidget->getCurrentTab() == 0) { |
687 | 687 | ||
688 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 688 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
689 | item=(*it); | 689 | item=(*it); |
690 | QString destFile = currentRemoteDir.canonicalPath(); | 690 | QString destFile = currentRemoteDir.canonicalPath(); |
691 | 691 | ||
692 | if(destFile.right(1).find("/",0,TRUE) == -1) | 692 | if(destFile.right(1).find("/",0,TRUE) == -1) |
693 | destFile+="/"; | 693 | destFile+="/"; |
694 | destFile += item; | 694 | destFile += item; |
695 | curFile = currentDir.canonicalPath(); | 695 | curFile = currentDir.canonicalPath(); |
696 | 696 | ||
697 | qDebug("Destination file is "+destFile); | 697 | qDebug("Destination file is "+destFile); |
698 | 698 | ||
699 | if(curFile.right(1).find("/",0,TRUE) == -1) | 699 | if(curFile.right(1).find("/",0,TRUE) == -1) |
700 | curFile +="/"; | 700 | curFile +="/"; |
701 | 701 | ||
702 | curFile+= item; | 702 | curFile+= item; |
703 | qDebug("CurrentFile file is " + curFile); | 703 | qDebug("CurrentFile file is " + curFile); |
704 | 704 | ||
705 | QFile f( curFile); | 705 | QFile f( curFile); |
706 | if( f.exists()) { | 706 | if( f.exists()) { |
707 | if(!copyFile( curFile,destFile) ) { | 707 | if(!copyFile( curFile,destFile) ) { |
708 | QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); | 708 | QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); |
709 | return; | 709 | return; |
710 | } else | 710 | } else |
711 | QFile::remove(curFile); | 711 | QFile::remove(curFile); |
712 | } | 712 | } |
713 | } | 713 | } |
714 | 714 | ||
715 | TabWidget->setCurrentTab(1); | 715 | TabWidget->setCurrentTab(1); |
716 | 716 | ||
717 | } else { //view 2 | 717 | } else { //view 2 |
718 | 718 | ||
719 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 719 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
720 | item = (*it); | 720 | item = (*it); |
721 | QString destFile = currentDir.canonicalPath(); | 721 | QString destFile = currentDir.canonicalPath(); |
722 | 722 | ||
723 | if(destFile.right(1).find("/",0,TRUE) == -1) | 723 | if(destFile.right(1).find("/",0,TRUE) == -1) |
724 | destFile+="/"; | 724 | destFile+="/"; |
725 | 725 | ||
726 | destFile += item; | 726 | destFile += item; |
727 | 727 | ||
728 | qDebug("Destination file is "+destFile); | 728 | qDebug("Destination file is "+destFile); |
729 | 729 | ||
730 | curFile = currentRemoteDir.canonicalPath(); | 730 | curFile = currentRemoteDir.canonicalPath(); |
731 | 731 | ||
732 | if(curFile.right(1).find("/",0,TRUE) == -1) | 732 | if(curFile.right(1).find("/",0,TRUE) == -1) |
733 | curFile +="/"; | 733 | curFile +="/"; |
734 | curFile+= item; | 734 | curFile+= item; |
735 | qDebug("CurrentFile file is " + curFile); | 735 | qDebug("CurrentFile file is " + curFile); |
736 | 736 | ||
737 | QFile f( curFile); | 737 | QFile f( curFile); |
738 | if( f.exists()) { | 738 | if( f.exists()) { |
739 | if(!copyFile( curFile, destFile) ) { | 739 | if(!copyFile( curFile, destFile) ) { |
740 | QMessageBox::message(tr("Note"),tr("Could not move\n") + curFile); | 740 | QMessageBox::message(tr("Note"),tr("Could not move\n") + curFile); |
741 | return; | 741 | return; |
742 | } else | 742 | } else |
743 | QFile::remove( curFile); | 743 | QFile::remove( curFile); |
744 | } | 744 | } |
745 | TabWidget->setCurrentTab(0); | 745 | TabWidget->setCurrentTab(0); |
746 | } | 746 | } |
747 | } | 747 | } |
748 | populateRemoteView(); | 748 | populateRemoteView(); |
749 | populateLocalView(); | 749 | populateLocalView(); |
750 | } | 750 | } |
751 | } | 751 | } |
752 | 752 | ||
753 | bool AdvancedFm::copyFile( const QString & src, const QString & dest ) { | 753 | bool AdvancedFm::copyFile( const QString & src, const QString & dest ) { |
754 | char bf[ 50000 ]; | 754 | char bf[ 50000 ]; |
755 | int bytesRead; | 755 | int bytesRead; |
756 | bool success = TRUE; | 756 | bool success = TRUE; |
757 | struct stat status; | 757 | struct stat status; |
758 | 758 | ||
759 | QFile s( src ); | 759 | QFile s( src ); |
760 | QFile d( dest ); | 760 | QFile d( dest ); |
761 | 761 | ||
762 | 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 ) ) { |
763 | while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) ) { | 763 | while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) ) { |
764 | if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){ | 764 | if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){ |
765 | success = FALSE; | 765 | success = FALSE; |
766 | break; | 766 | break; |
767 | } | 767 | } |
768 | } | 768 | } |
769 | if( success && (bytesRead > 0) ){ | 769 | if( success && (bytesRead > 0) ){ |
770 | d.writeBlock( bf, bytesRead ); | 770 | d.writeBlock( bf, bytesRead ); |
771 | } | 771 | } |
772 | } else { | 772 | } else { |
773 | success = FALSE; | 773 | success = FALSE; |
774 | } | 774 | } |
775 | 775 | ||
776 | // Set file permissions | 776 | // Set file permissions |
777 | if( stat( (const char *) src, &status ) == 0 ){ | 777 | if( stat( (const char *) src, &status ) == 0 ){ |
778 | chmod( (const char *) dest, status.st_mode ); | 778 | chmod( (const char *) dest, status.st_mode ); |
779 | } | 779 | } |
780 | 780 | ||
781 | return success; | 781 | return success; |
782 | } | 782 | } |
783 | 783 | ||
784 | void AdvancedFm::runCommand() { | 784 | void AdvancedFm::runCommand() { |
785 | QString curFile; | 785 | QString curFile; |
786 | if (TabWidget->getCurrentTab() == 0) { | 786 | if (TabWidget->getCurrentTab() == 0) { |
787 | if( Local_View->currentItem()) | 787 | if( Local_View->currentItem()) |
788 | curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0); | 788 | curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0); |
789 | } else { | 789 | } else { |
790 | if(Remote_View->currentItem()) | 790 | if(Remote_View->currentItem()) |
791 | curFile = currentRemoteDir.canonicalPath() + "/"+Remote_View->currentItem()->text(0); | 791 | curFile = currentRemoteDir.canonicalPath() + "/"+Remote_View->currentItem()->text(0); |
792 | } | 792 | } |
793 | 793 | ||
794 | InputDialog *fileDlg; | 794 | InputDialog *fileDlg; |
795 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | 795 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); |
796 | fileDlg->setInputText(curFile); | 796 | fileDlg->setInputText(curFile); |
797 | fileDlg->exec(); | 797 | fileDlg->exec(); |
798 | //QString command; | 798 | //QString command; |
799 | 799 | ||
800 | if( fileDlg->result() == 1 ) { | 800 | if( fileDlg->result() == 1 ) { |
801 | qDebug(fileDlg->LineEdit1->text()); | 801 | qDebug(fileDlg->LineEdit1->text()); |
802 | QStringList command; | 802 | QStringList command; |
803 | 803 | ||
804 | command << "/bin/sh"; | 804 | command << "/bin/sh"; |
805 | command << "-c"; | 805 | command << "-c"; |
806 | command << fileDlg->LineEdit1->text(); | 806 | command << fileDlg->LineEdit1->text(); |
807 | Output *outDlg; | 807 | Output *outDlg; |
808 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); | 808 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); |
809 | outDlg->showMaximized(); | 809 | outDlg->showMaximized(); |
810 | outDlg->exec(); | 810 | outDlg->exec(); |
811 | qApp->processEvents(); | 811 | qApp->processEvents(); |
812 | 812 | ||
813 | } | 813 | } |
814 | } | 814 | } |
815 | 815 | ||
816 | void AdvancedFm::runCommandStd() { | 816 | void AdvancedFm::runCommandStd() { |
817 | QString curFile; | 817 | QString curFile; |
818 | if (TabWidget->getCurrentTab() == 0) { | 818 | if (TabWidget->getCurrentTab() == 0) { |
819 | if( Local_View->currentItem()) | 819 | if( Local_View->currentItem()) |
820 | curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0); | 820 | curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0); |
821 | } else { | 821 | } else { |
822 | if(Remote_View->currentItem()) | 822 | if(Remote_View->currentItem()) |
823 | curFile = currentRemoteDir.canonicalPath() +"/" | 823 | curFile = currentRemoteDir.canonicalPath() +"/" |
824 | + Remote_View->currentItem()->text(0); | 824 | + Remote_View->currentItem()->text(0); |
825 | } | 825 | } |
826 | 826 | ||
827 | InputDialog *fileDlg; | 827 | InputDialog *fileDlg; |
828 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | 828 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); |
829 | fileDlg->setInputText(curFile); | 829 | fileDlg->setInputText(curFile); |
830 | fileDlg->exec(); | 830 | fileDlg->exec(); |
831 | 831 | ||
832 | if( fileDlg->result() == 1 ) { | 832 | if( fileDlg->result() == 1 ) { |
833 | qApp->processEvents(); | 833 | qApp->processEvents(); |
834 | startProcess( (const QString)fileDlg->LineEdit1->text().latin1()); | 834 | startProcess( (const QString)fileDlg->LineEdit1->text().latin1()); |
835 | } | 835 | } |
836 | } | 836 | } |
837 | 837 | ||
838 | void AdvancedFm::fileStatus() { | 838 | void AdvancedFm::fileStatus() { |
839 | QString curFile; | 839 | QString curFile; |
840 | if (TabWidget->getCurrentTab() == 0) { | 840 | if (TabWidget->getCurrentTab() == 0) { |
841 | curFile = Local_View->currentItem()->text(0); | 841 | curFile = Local_View->currentItem()->text(0); |
842 | } else { | 842 | } else { |
843 | curFile = Remote_View->currentItem()->text(0); | 843 | curFile = Remote_View->currentItem()->text(0); |
844 | } | 844 | } |
845 | 845 | ||
846 | QStringList command; | 846 | QStringList command; |
847 | command << "/bin/sh"; | 847 | command << "/bin/sh"; |
848 | command << "-c"; | 848 | command << "-c"; |
849 | command << "stat -l "+ curFile; | 849 | command << "stat -l "+ curFile; |
850 | 850 | ||
851 | Output *outDlg; | 851 | Output *outDlg; |
852 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); | 852 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); |
853 | outDlg->showMaximized(); | 853 | outDlg->showMaximized(); |
854 | outDlg->exec(); | 854 | outDlg->exec(); |
855 | qApp->processEvents(); | 855 | qApp->processEvents(); |
856 | 856 | ||
857 | 857 | ||
858 | // Output *outDlg; | 858 | // Output *outDlg; |
859 | // outDlg = new Output(this, tr("AdvancedFm Output"),FALSE); | 859 | // outDlg = new Output(this, tr("AdvancedFm Output"),FALSE); |
860 | // outDlg->showMaximized(); | 860 | // outDlg->showMaximized(); |
861 | // outDlg->show(); | 861 | // outDlg->show(); |
862 | // qApp->processEvents(); | 862 | // qApp->processEvents(); |
863 | 863 | ||
864 | // FILE *fp; | 864 | // FILE *fp; |
865 | // char line[130]; | 865 | // char line[130]; |
866 | // sleep(1); | 866 | // sleep(1); |
867 | // fp = popen( (const char *) command, "r"); | 867 | // fp = popen( (const char *) command, "r"); |
868 | // if ( !fp ) { | 868 | // if ( !fp ) { |
869 | // qDebug("Could not execute '" + command + "'! err=%d", fp); | 869 | // qDebug("Could not execute '" + command + "'! err=%d", fp); |
870 | // QMessageBox::warning( this, "AdvancedFm", tr("command failed!"), tr("&OK") ); | 870 | // QMessageBox::warning( this, "AdvancedFm", tr("command failed!"), tr("&OK") ); |
871 | // pclose(fp); | 871 | // pclose(fp); |
872 | // return; | 872 | // return; |
873 | // } else { | 873 | // } else { |
874 | // while ( fgets( line, sizeof line, fp)) { | 874 | // while ( fgets( line, sizeof line, fp)) { |
875 | // outDlg->OutputEdit->append(line); | 875 | // outDlg->OutputEdit->append(line); |
876 | // outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | 876 | // outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); |
877 | 877 | ||
878 | // } | 878 | // } |
879 | 879 | ||
880 | // } | 880 | // } |
881 | // pclose(fp); | 881 | // pclose(fp); |
882 | } | 882 | } |
883 | 883 | ||
884 | 884 | ||
885 | void AdvancedFm::mkDir() { | 885 | void AdvancedFm::mkDir() { |
886 | if (TabWidget->getCurrentTab() == 0) | 886 | if (TabWidget->getCurrentTab() == 0) |
887 | localMakDir(); | 887 | localMakDir(); |
888 | else | 888 | else |
889 | remoteMakDir(); | 889 | remoteMakDir(); |
890 | 890 | ||
891 | } | 891 | } |
892 | 892 | ||
893 | void AdvancedFm::rn() { | 893 | void AdvancedFm::rn() { |
894 | if (TabWidget->getCurrentTab() == 0) | 894 | if (TabWidget->getCurrentTab() == 0) |
895 | localRename(); | 895 | localRename(); |
896 | else | 896 | else |
897 | remoteRename(); | 897 | remoteRename(); |
898 | 898 | ||
899 | } | 899 | } |
900 | 900 | ||
901 | void AdvancedFm::del() { | 901 | void AdvancedFm::del() { |
902 | if (TabWidget->getCurrentTab() == 0) | 902 | if (TabWidget->getCurrentTab() == 0) |
903 | localDelete(); | 903 | localDelete(); |
904 | else | 904 | else |
905 | remoteDelete(); | 905 | remoteDelete(); |
906 | } | 906 | } |
907 | 907 | ||
908 | void AdvancedFm::mkSym() { | 908 | void AdvancedFm::mkSym() { |
909 | QString cmd; | 909 | QString cmd; |
910 | QStringList curFileList = getPath(); | 910 | QStringList curFileList = getPath(); |
911 | if( curFileList.count() > 0) { | 911 | if( curFileList.count() > 0) { |
912 | 912 | ||
913 | if (TabWidget->getCurrentTab() == 0) { | 913 | if (TabWidget->getCurrentTab() == 0) { |
914 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 914 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
915 | 915 | ||
916 | QString destName = currentRemoteDir.canonicalPath()+"/"+(*it); | 916 | QString destName = currentRemoteDir.canonicalPath()+"/"+(*it); |
917 | if(destName.right(1) == "/") destName = destName.left( destName.length() -1); | 917 | if(destName.right(1) == "/") destName = destName.left( destName.length() -1); |
918 | QString curFile = currentDir.canonicalPath()+"/"+(*it); | 918 | QString curFile = currentDir.canonicalPath()+"/"+(*it); |
919 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); | 919 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); |
920 | cmd = "ln -s "+curFile+" "+destName; | 920 | cmd = "ln -s "+curFile+" "+destName; |
921 | qDebug(cmd); | 921 | qDebug(cmd); |
922 | startProcess( (const QString)cmd ); | 922 | startProcess( (const QString)cmd ); |
923 | } | 923 | } |
924 | populateRemoteView(); | 924 | populateRemoteView(); |
925 | TabWidget->setCurrentTab(1); | 925 | TabWidget->setCurrentTab(1); |
926 | } else { | 926 | } else { |
927 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 927 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
928 | 928 | ||
929 | QString destName = currentDir.canonicalPath()+"/"+(*it); | 929 | QString destName = currentDir.canonicalPath()+"/"+(*it); |
930 | if(destName.right(1) == "/") destName = destName.left( destName.length() -1); | 930 | if(destName.right(1) == "/") destName = destName.left( destName.length() -1); |
931 | QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it); | 931 | QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it); |
932 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); | 932 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); |
933 | 933 | ||
934 | cmd = "ln -s "+curFile+" "+destName; | 934 | cmd = "ln -s "+curFile+" "+destName; |
935 | qDebug(cmd); | 935 | qDebug(cmd); |
936 | startProcess( (const QString)cmd ); | 936 | startProcess( (const QString)cmd ); |
937 | } | 937 | } |
938 | populateLocalView(); | 938 | populateLocalView(); |
939 | TabWidget->setCurrentTab(0); | 939 | TabWidget->setCurrentTab(0); |
940 | } | 940 | } |
941 | } | 941 | } |
942 | } | 942 | } |
943 | 943 | ||
944 | void AdvancedFm::doBeam() { | 944 | void AdvancedFm::doBeam() { |
945 | Ir ir; | 945 | Ir ir; |
946 | if(!ir.supported()){ | 946 | if(!ir.supported()){ |
947 | } else { | 947 | } else { |
948 | 948 | ||
949 | QStringList curFileList = getPath(); | 949 | QStringList curFileList = getPath(); |
950 | if( curFileList.count() > 0) { | 950 | if( curFileList.count() > 0) { |
951 | 951 | ||
952 | if (TabWidget->getCurrentTab() == 0) { | 952 | if (TabWidget->getCurrentTab() == 0) { |
953 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 953 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
954 | 954 | ||
955 | QString curFile = currentDir.canonicalPath()+"/"+(*it); | 955 | QString curFile = currentDir.canonicalPath()+"/"+(*it); |
956 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); | 956 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); |
957 | Ir *file = new Ir(this, "IR"); | 957 | Ir *file = new Ir(this, "IR"); |
958 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); | 958 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); |
959 | file->send( curFile, curFile ); | 959 | file->send( curFile, curFile ); |
960 | } | 960 | } |
961 | 961 | ||
962 | } else { | 962 | } else { |
963 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 963 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
964 | 964 | ||
965 | QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it); | 965 | QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it); |
966 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); | 966 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); |
967 | Ir *file = new Ir(this, "IR"); | 967 | Ir *file = new Ir(this, "IR"); |
968 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); | 968 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); |
969 | file->send( curFile, curFile ); | 969 | file->send( curFile, curFile ); |
970 | 970 | ||
971 | } | 971 | } |
972 | } | 972 | } |
973 | } | 973 | } |
974 | } | 974 | } |
975 | 975 | ||
976 | } | 976 | } |
977 | 977 | ||
978 | void AdvancedFm::fileBeamFinished( Ir *) { | 978 | void AdvancedFm::fileBeamFinished( Ir *) { |
979 | QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); | 979 | QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); |
980 | 980 | ||
981 | } | 981 | } |
982 | 982 | ||
983 | void AdvancedFm::selectAll() { | 983 | void AdvancedFm::selectAll() { |
984 | if (TabWidget->getCurrentTab() == 0) { | 984 | if (TabWidget->getCurrentTab() == 0) { |
985 | Local_View->selectAll(true); | 985 | Local_View->selectAll(true); |
986 | Local_View->setSelected( Local_View->firstChild(),false); | 986 | Local_View->setSelected( Local_View->firstChild(),false); |
987 | } else { | 987 | } else { |
988 | Remote_View->selectAll(true); | 988 | Remote_View->selectAll(true); |
989 | Remote_View->setSelected( Remote_View->firstChild(),false); | 989 | Remote_View->setSelected( Remote_View->firstChild(),false); |
990 | } | 990 | } |
991 | } | 991 | } |
992 | 992 | ||
993 | void AdvancedFm::startProcess(const QString & cmd) { | 993 | void AdvancedFm::startProcess(const QString & cmd) { |
994 | QStringList command; | 994 | QStringList command; |
995 | OProcess *process; | 995 | OProcess *process; |
996 | process = new OProcess(); | 996 | process = new OProcess(); |
997 | connect(process, SIGNAL(processExited(OProcess *)), | 997 | connect(process, SIGNAL(processExited(OProcess *)), |
998 | this, SLOT( processEnded())); | 998 | this, SLOT( processEnded())); |
999 | 999 | ||
1000 | command << "/bin/sh"; | 1000 | command << "/bin/sh"; |
1001 | command << "-c"; | 1001 | command << "-c"; |
1002 | command << cmd.latin1(); | 1002 | command << cmd.latin1(); |
1003 | *process << command; | 1003 | *process << command; |
1004 | if(!process->start(OProcess::NotifyOnExit) ) | 1004 | if(!process->start(OProcess::NotifyOnExit) ) |
1005 | qDebug("could not start process"); | 1005 | qDebug("could not start process"); |
1006 | } | 1006 | } |
1007 | 1007 | ||
1008 | void AdvancedFm::processEnded() { | 1008 | void AdvancedFm::processEnded() { |
1009 | populateLocalView(); | 1009 | populateLocalView(); |
1010 | populateRemoteView(); | 1010 | populateRemoteView(); |
1011 | } | 1011 | } |
1012 | 1012 | ||
1013 | bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) { | 1013 | bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) { |
1014 | if ( o->inherits( "QLineEdit" ) ) { | 1014 | if ( o->inherits( "QLineEdit" ) ) { |
1015 | if ( e->type() == QEvent::KeyPress ) { | 1015 | if ( e->type() == QEvent::KeyPress ) { |
1016 | QKeyEvent *ke = (QKeyEvent*)e; | 1016 | QKeyEvent *ke = (QKeyEvent*)e; |
1017 | if ( ke->key() == Key_Return || | 1017 | if ( ke->key() == Key_Return || |
1018 | ke->key() == Key_Enter ) { | 1018 | ke->key() == Key_Enter ) { |
1019 | okRename(); | 1019 | okRename(); |
1020 | return true; | 1020 | return true; |
1021 | } else if ( ke->key() == Key_Escape ) { | 1021 | } else if ( ke->key() == Key_Escape ) { |
1022 | cancelRename(); | 1022 | cancelRename(); |
1023 | return true; | 1023 | return true; |
1024 | } | 1024 | } |
1025 | } else if ( e->type() == QEvent::FocusOut ) { | 1025 | } else if ( e->type() == QEvent::FocusOut ) { |
1026 | cancelRename(); | 1026 | cancelRename(); |
1027 | return true; | 1027 | return true; |
1028 | } | 1028 | } |
1029 | } | 1029 | } |
1030 | if ( o->inherits( "QListView" ) ) { | 1030 | if ( o->inherits( "QListView" ) ) { |
1031 | if ( e->type() == QEvent::FocusOut ) { | 1031 | if ( e->type() == QEvent::FocusOut ) { |
1032 | printf("focusIn\n"); | 1032 | printf("focusIn\n"); |
1033 | 1033 | ||
1034 | } | 1034 | } |
1035 | } | 1035 | } |
1036 | 1036 | ||
1037 | return QWidget::eventFilter( o, e ); | 1037 | return QWidget::eventFilter( o, e ); |
1038 | } | 1038 | } |
1039 | 1039 | ||
1040 | 1040 | ||
1041 | void AdvancedFm::cancelRename() | 1041 | void AdvancedFm::cancelRename() |
1042 | { | 1042 | { |
1043 | qDebug("cancel rename"); | 1043 | qDebug("cancel rename"); |
1044 | QListView * view; | 1044 | QListView * view; |
1045 | if (TabWidget->getCurrentTab() == 0) | 1045 | if (TabWidget->getCurrentTab() == 0) |
1046 | { | 1046 | { |
1047 | view = Local_View; | 1047 | view = Local_View; |
1048 | } | 1048 | } |
1049 | else | 1049 | else |
1050 | { | 1050 | { |
1051 | view = Remote_View; | 1051 | view = Remote_View; |
1052 | } | 1052 | } |
1053 | 1053 | ||
1054 | bool resetFocus = view->viewport()->focusProxy() == renameBox; | 1054 | bool resetFocus = view->viewport()->focusProxy() == renameBox; |
1055 | delete renameBox; | 1055 | delete renameBox; |
1056 | renameBox = 0; | 1056 | renameBox = 0; |
1057 | if ( resetFocus ) { | 1057 | if ( resetFocus ) { |
1058 | view->viewport()->setFocusProxy( view); | 1058 | view->viewport()->setFocusProxy( view); |
1059 | view->setFocus(); | 1059 | view->setFocus(); |
1060 | } | 1060 | } |
1061 | } | 1061 | } |
1062 | 1062 | ||
1063 | void AdvancedFm::doRename(QListView * view) | 1063 | void AdvancedFm::doRename(QListView * view) |
1064 | { | 1064 | { |
1065 | 1065 | ||
1066 | QRect r = view->itemRect( view->currentItem( )); | 1066 | QRect r = view->itemRect( view->currentItem( )); |
1067 | r = QRect( view->viewportToContents( r.topLeft() ), r.size() ); | 1067 | r = QRect( view->viewportToContents( r.topLeft() ), r.size() ); |
1068 | r.setX( view->contentsX() ); | 1068 | r.setX( view->contentsX() ); |
1069 | if ( r.width() > view->visibleWidth() ) | 1069 | if ( r.width() > view->visibleWidth() ) |
1070 | r.setWidth( view->visibleWidth() ); | 1070 | r.setWidth( view->visibleWidth() ); |
1071 | 1071 | ||
1072 | renameBox = new QLineEdit( view->viewport(), "qt_renamebox" ); | 1072 | renameBox = new QLineEdit( view->viewport(), "qt_renamebox" ); |
1073 | renameBox->setFrame(true); | 1073 | renameBox->setFrame(true); |
1074 | 1074 | ||
1075 | renameBox->setText( view->currentItem()->text(0) ); | 1075 | renameBox->setText( view->currentItem()->text(0) ); |
1076 | 1076 | ||
1077 | renameBox->selectAll(); | 1077 | renameBox->selectAll(); |
1078 | renameBox->installEventFilter( this ); | 1078 | renameBox->installEventFilter( this ); |
1079 | view->addChild( renameBox, r.x(), r.y() ); | 1079 | view->addChild( renameBox, r.x(), r.y() ); |
1080 | renameBox->resize( r.size() ); | 1080 | renameBox->resize( r.size() ); |
1081 | view->viewport()->setFocusProxy( renameBox ); | 1081 | view->viewport()->setFocusProxy( renameBox ); |
1082 | renameBox->setFocus(); | 1082 | renameBox->setFocus(); |
1083 | renameBox->show(); | 1083 | renameBox->show(); |
1084 | 1084 | ||
1085 | } | 1085 | } |
1086 | 1086 | ||
1087 | 1087 | ||
1088 | void AdvancedFm::localRename() | 1088 | void AdvancedFm::localRename() |
1089 | { | 1089 | { |
1090 | oldName = Local_View->currentItem()->text(0); | 1090 | oldName = Local_View->currentItem()->text(0); |
1091 | doRename(Local_View ); | 1091 | doRename(Local_View ); |
1092 | populateLocalView(); | 1092 | populateLocalView(); |
1093 | } | 1093 | } |
1094 | 1094 | ||
1095 | void AdvancedFm::remoteRename() | 1095 | void AdvancedFm::remoteRename() |
1096 | { | 1096 | { |
1097 | oldName = Remote_View->currentItem()->text(0); | 1097 | oldName = Remote_View->currentItem()->text(0); |
1098 | doRename(Local_View ); | 1098 | doRename(Remote_View ); |
1099 | populateRemoteView(); | 1099 | populateRemoteView(); |
1100 | } | 1100 | } |
1101 | 1101 | ||
1102 | void AdvancedFm::okRename() | 1102 | void AdvancedFm::okRename() |
1103 | { | 1103 | { |
1104 | QString newName = renameBox->text(); | 1104 | QString newName = renameBox->text(); |
1105 | cancelRename(); | 1105 | cancelRename(); |
1106 | int tabs=0; | 1106 | int tabs=0; |
1107 | QListView * view; | 1107 | QListView * view; |
1108 | tabs = TabWidget->getCurrentTab(); | 1108 | tabs = TabWidget->getCurrentTab(); |
1109 | if ( tabs == 0) | 1109 | if ( tabs == 0) |
1110 | { | 1110 | { |
1111 | view = Local_View; | 1111 | view = Local_View; |
1112 | QString path = currentDir.canonicalPath() + "/"; | 1112 | QString path = currentDir.canonicalPath() + "/"; |
1113 | oldName = path + oldName; | 1113 | oldName = path + oldName; |
1114 | newName = path + newName; | 1114 | newName = path + newName; |
1115 | } | 1115 | } |
1116 | else | 1116 | else |
1117 | { | 1117 | { |
1118 | view = Remote_View; | 1118 | view = Remote_View; |
1119 | QString path = currentRemoteDir.canonicalPath() + "/"; | 1119 | QString path = currentRemoteDir.canonicalPath() + "/"; |
1120 | oldName = path + oldName; | 1120 | oldName = path + oldName; |
1121 | newName = path + newName; | 1121 | newName = path + newName; |
1122 | } | 1122 | } |
1123 | 1123 | ||
1124 | if( view->currentItem() == NULL) | 1124 | if( view->currentItem() == NULL) |
1125 | return; | 1125 | return; |
1126 | if( rename(oldName.latin1(), newName.latin1())== -1) | 1126 | if( rename(oldName.latin1(), newName.latin1())== -1) |
1127 | QMessageBox::message(tr("Note"),tr("Could not rename")); | 1127 | QMessageBox::message(tr("Note"),tr("Could not rename")); |
1128 | else | 1128 | else |
1129 | oldName = ""; | 1129 | oldName = ""; |
1130 | 1130 | ||
1131 | view->takeItem( view->currentItem() ); | 1131 | view->takeItem( view->currentItem() ); |
1132 | delete view->currentItem(); | 1132 | delete view->currentItem(); |
1133 | if ( tabs == 0) | 1133 | if ( tabs == 0) |
1134 | populateLocalView(); | 1134 | populateLocalView(); |
1135 | else | 1135 | else |
1136 | populateRemoteView(); | 1136 | populateRemoteView(); |
1137 | } | 1137 | } |