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