Diffstat (limited to 'noncore/apps/advancedfm/advancedfmMenu.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/advancedfm/advancedfmMenu.cpp | 1398 |
1 files changed, 565 insertions, 833 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 | |||
@@ -48,12 +48,11 @@ | |||
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); |
@@ -63,3 +62,5 @@ void AdvancedFm::showMenuHidden() { | |||
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); |
@@ -71,6 +72,2 @@ void AdvancedFm::showMenuHidden() { | |||
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"); |
@@ -79,5 +76,7 @@ void AdvancedFm::showMenuHidden() { | |||
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); |
@@ -85,23 +84,14 @@ void AdvancedFm::showHidden() { | |||
85 | 84 | ||
86 | } else { | 85 | } |
87 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 86 | else |
87 | { | ||
88 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | ||
88 | // fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); | 89 | // fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); |
89 | // b=TRUE; | 90 | // b=TRUE; |
90 | } | 91 | } |
91 | populateLocalView(); | 92 | PopulateView(); |
92 | } | 93 | } |
93 | 94 | ||
94 | void AdvancedFm::showRemoteHidden() { | 95 | QString AdvancedFm::dealWithSymName(const QString &fileName) |
95 | if (b) { | 96 | { |
96 | currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | ||
97 | // b=TRUE; | ||
98 | |||
99 | } else { | ||
100 | currentRemoteDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | ||
101 | // b=FALSE; | ||
102 | } | ||
103 | populateRemoteView(); | ||
104 | } | ||
105 | |||
106 | QString AdvancedFm::dealWithSymName(const QString &fileName) { | ||
107 | QString strItem = fileName; | 97 | QString strItem = fileName; |
@@ -110,77 +100,53 @@ QString AdvancedFm::dealWithSymName(const QString &fileName) { | |||
110 | 100 | ||
111 | void AdvancedFm::runThis() { | 101 | void AdvancedFm::runThis() |
112 | QString fs; | 102 | { |
113 | if (TabWidget->getCurrentTab() == 0) { | 103 | QString fs; |
114 | QString curFile = Local_View->currentItem()->text(0); | 104 | QDir *thisDir = CurrentDir(); |
115 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink | 105 | |
116 | curFile = dealWithSymName((const QString&)curFile); | 106 | QString curFile = CurrentView()->currentItem()->text(0); |
117 | 107 | QString path = thisDir->canonicalPath(); | |
118 | if(curFile != "../") { | 108 | |
119 | 109 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink | |
120 | fs = getFileSystemType((const QString &) currentDir.canonicalPath()); | 110 | |
121 | QFileInfo fileInfo( currentDir.canonicalPath()+"/"+curFile); | 111 | curFile = dealWithSymName((const QString&)curFile); |
122 | qDebug( fileInfo.owner()); | 112 | |
123 | if( (fileInfo.permission( QFileInfo::ExeUser) | 113 | if(curFile != "../") |
124 | | fileInfo.permission( QFileInfo::ExeGroup) | 114 | { |
125 | | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { | 115 | |
126 | | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { | 116 | fs = getFileSystemType((const QString &) path); |
127 | QCopEnvelope e("QPE/System", "execute(QString)" ); | 117 | QFileInfo fileInfo( path + "/" + curFile); |
128 | e << curFile; | 118 | qDebug( fileInfo.owner()); |
129 | } else { | 119 | |
130 | curFile = currentDir.canonicalPath()+"/"+curFile; | 120 | if( (fileInfo.permission( QFileInfo::ExeUser) |
131 | DocLnk nf(curFile); | 121 | | fileInfo.permission( QFileInfo::ExeGroup) |
132 | QString execStr = nf.exec(); | 122 | | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { |
133 | qDebug( execStr); | 123 | | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { |
134 | if( execStr.isEmpty() ) { | 124 | QCopEnvelope e("QPE/System", "execute(QString)" ); |
135 | } else { | 125 | e << curFile; |
136 | nf.execute(); | 126 | } |
137 | } | 127 | else |
138 | } | 128 | { |
139 | } | 129 | curFile = path + "/" + curFile; |
140 | } else { | 130 | DocLnk nf(curFile); |
141 | QString curFile = Remote_View->currentItem()->text(0); | 131 | QString execStr = nf.exec(); |
142 | if(curFile != "../") { | 132 | qDebug( execStr); |
143 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink | 133 | if( execStr.isEmpty() ) |
144 | curFile = dealWithSymName((const QString&)curFile); | 134 | { |
145 | 135 | } | |
146 | fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath()); | 136 | else |
147 | qDebug("Filesystemtype is "+fs); | 137 | { |
148 | QFileInfo fileInfo( currentRemoteDir.canonicalPath()+"/"+curFile); | 138 | nf.execute(); |
149 | if( (fileInfo.permission( QFileInfo::ExeUser) | 139 | } |
150 | | fileInfo.permission( QFileInfo::ExeGroup) | 140 | } |
151 | | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { | 141 | } |
152 | | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { | 142 | } |
153 | QCopEnvelope e("QPE/System", "execute(QString)" ); | 143 | |
154 | e << curFile; | 144 | void AdvancedFm::runText() |
155 | } else { | 145 | { |
156 | curFile = currentRemoteDir.canonicalPath()+"/"+curFile; | 146 | QString curFile = CurrentView()->currentItem()->text(0); |
157 | DocLnk nf(curFile); | 147 | if(curFile != "../") |
158 | QString execStr = nf.exec(); | 148 | { |
159 | qDebug(execStr); | 149 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink |
160 | if( execStr.isEmpty() ) { | ||
161 | } else { | ||
162 | nf.execute(); | ||
163 | } | ||
164 | } | ||
165 | } | ||
166 | } | ||
167 | } | ||
168 | |||
169 | void AdvancedFm::runText() { | ||
170 | if (TabWidget->getCurrentTab() == 0) { | ||
171 | QString curFile = Local_View->currentItem()->text(0); | ||
172 | if(curFile != "../") { | ||
173 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink | ||
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 | ||
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)" ); |
@@ -188,6 +154,6 @@ void AdvancedFm::runText() { | |||
188 | } | 154 | } |
189 | } | ||
190 | } | 155 | } |
191 | 156 | ||
192 | void AdvancedFm::localMakDir() { | 157 | void AdvancedFm::makeDir() |
158 | { | ||
193 | InputDialog *fileDlg; | 159 | InputDialog *fileDlg; |
@@ -195,26 +161,21 @@ void AdvancedFm::localMakDir() { | |||
195 | fileDlg->exec(); | 161 | fileDlg->exec(); |
196 | if( fileDlg->result() == 1 ) { | 162 | if( fileDlg->result() == 1 ) |
197 | QString filename = fileDlg->LineEdit1->text(); | 163 | { |
198 | currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); | 164 | QDir *thisDir = CurrentDir(); |
165 | QString filename = fileDlg->LineEdit1->text(); | ||
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; |
@@ -222,3 +183,4 @@ void AdvancedFm::localDelete() { | |||
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: |
@@ -233,3 +195,4 @@ void AdvancedFm::localDelete() { | |||
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); |
@@ -238,11 +201,14 @@ void AdvancedFm::localDelete() { | |||
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() ) |
244 | switch ( QMessageBox::warning(this,tr("Delete Directory?"),tr("Really delete\n")+f+ | 207 | { |
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 | { |
212 | case 0: | ||
213 | { | ||
248 | f=f.left(f.length()-1); | 214 | f=f.left(f.length()-1); |
@@ -250,3 +216,3 @@ void AdvancedFm::localDelete() { | |||
250 | startProcess( (const QString)cmd.latin1() ); | 216 | startProcess( (const QString)cmd.latin1() ); |
251 | populateLocalView(); | 217 | PopulateView(); |
252 | } | 218 | } |
@@ -274,110 +240,37 @@ void AdvancedFm::localDelete() { | |||
274 | } | 240 | } |
275 | populateLocalView(); | 241 | PopulateView(); |
276 | } | 242 | } |
277 | 243 | ||
278 | void AdvancedFm::remoteDelete() { | 244 | void AdvancedFm::filePerms() |
279 | QStringList curFileList = getPath(); | 245 | { |
280 | bool doMsg=true; | 246 | QStringList curFileList = getPath(); |
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: | ||
289 | doMsg=false; | ||
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); | ||
313 | QString cmd="rm -rf "+f; | ||
314 | startProcess( (const QString)cmd ); | ||
315 | populateRemoteView(); | ||
316 | } | ||
317 | break; | ||
318 | case 1: | ||
319 | // exit | ||
320 | break; | ||
321 | }; | ||
322 | |||
323 | } else { | ||
324 | if(doMsg) { | ||
325 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Really delete\n")+f | ||
326 | +" ?",tr("Yes"),tr("No"),0,0,1) ) { | ||
327 | case 1: | ||
328 | return; | ||
329 | break; | ||
330 | }; | ||
331 | } | ||
332 | QString cmd="rm "+f; | ||
333 | QFile file(f); | ||
334 | if(QFileInfo(myFile).fileName().find("../",0,TRUE)==-1) | ||
335 | file.remove(); | ||
336 | } | ||
337 | } | ||
338 | } | ||
339 | populateRemoteView(); | ||
340 | } | ||
341 | |||
342 | |||
343 | void AdvancedFm::filePerms() { | ||
344 | |||
345 | 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 ) |
355 | filePermissions *filePerm; | 252 | { |
356 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); | 253 | filePermissions *filePerm; |
357 | filePerm->showMaximized(); | 254 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); |
358 | filePerm->exec(); | 255 | filePerm->showMaximized(); |
359 | if( filePerm) | 256 | filePerm->exec(); |
360 | delete filePerm; | 257 | if( filePerm) |
361 | } | 258 | delete filePerm; |
362 | if (TabWidget->getCurrentTab() == 0) { | 259 | } |
363 | populateLocalView(); | 260 | PopulateView(); |
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()+"/"; | ||
377 | } else { | ||
378 | filePath= currentRemoteDir.canonicalPath()+"/"; | ||
379 | } | ||
380 | qDebug("%d",curFileList.count()); | ||
381 | 271 | ||
382 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 272 | qDebug("%d",curFileList.count()); |
273 | |||
274 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | ||
275 | { | ||
383 | qDebug((filePath+*it)); | 276 | qDebug((filePath+*it)); |
@@ -388,118 +281,91 @@ void AdvancedFm::doProperties() { | |||
388 | } | 281 | } |
389 | #endif | 282 | #endif |
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(); | 290 | QDir dir(current); |
398 | current = dir.canonicalPath(); | 291 | dir.cdUp(); |
399 | chdir( current.latin1() ); | 292 | current = dir.canonicalPath(); |
400 | currentDir.cd( current, TRUE); | 293 | chdir( current.latin1() ); |
401 | populateLocalView(); | 294 | thisDir->cd( current, TRUE); |
402 | update(); | 295 | |
403 | } else { | 296 | PopulateView(); |
404 | QString current = currentRemoteDir.canonicalPath(); | 297 | update(); |
405 | QDir dir(current); | ||
406 | dir.cdUp(); | ||
407 | current = dir.canonicalPath(); | ||
408 | chdir( current.latin1() ); | ||
409 | currentRemoteDir.cd( current, TRUE); | ||
410 | populateRemoteView(); | ||
411 | update(); | ||
412 | } | ||
413 | } | 298 | } |
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(); |
418 | bool doMsg=true; | 304 | |
419 | int count=curFileList.count(); | 305 | QDir *thisDir = CurrentDir(); |
420 | if( count > 0) { | 306 | QDir *thatDir = OtherDir(); |
421 | if(count > 1 ){ | 307 | |
422 | QString msg; | 308 | bool doMsg=true; |
423 | msg=tr("Really copy\n%1 files?").arg(count); | 309 | int count=curFileList.count(); |
424 | switch ( QMessageBox::warning(this,tr("Delete"),msg | 310 | if( count > 0) { |
425 | ,tr("Yes"),tr("No"),0,0,1) ) { | 311 | if(count > 1 ){ |
426 | case 0: | 312 | QString msg; |
427 | doMsg=false; | 313 | msg=tr("Really copy\n%1 files?").arg(count); |
428 | break; | 314 | switch ( QMessageBox::warning(this,tr("Delete"),msg |
429 | case 1: | 315 | ,tr("Yes"),tr("No"),0,0,1) ) |
430 | return; | 316 | { |
431 | break; | 317 | case 0: |
432 | }; | 318 | doMsg=false; |
433 | } | 319 | break; |
320 | case 1: | ||
321 | return; | ||
322 | break; | ||
323 | }; | ||
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 | 335 | ||
445 | curFile = currentDir.canonicalPath()+"/"+ item; | 336 | qDebug("Destination file is "+destFile); |
446 | qDebug("CurrentFile file is " + curFile); | 337 | qDebug("CurrentFile file is " + curFile); |
447 | 338 | ||
448 | QFile f(destFile); | 339 | QFile f(destFile); |
449 | if( f.exists()) { | 340 | if( f.exists()) |
450 | if(doMsg) { | 341 | { |
451 | switch ( QMessageBox::warning(this,tr("File Exists!"), tr("%1 exists. Ok to overwrite?").arg( item ), tr("Yes"),tr("No"),0,0,1) ) { | 342 | if(doMsg) |
452 | case 1: | 343 | { |
453 | return; | 344 | switch ( QMessageBox::warning(this,tr("File Exists!"), |
454 | break; | 345 | tr("%1 exists. Ok to overwrite?").arg( item ), |
346 | tr("Yes"),tr("No"),0,0,1) ) | ||
347 | { | ||
348 | case 1: | ||
349 | return; | ||
350 | break; | ||
455 | }; | 351 | }; |
456 | } | 352 | } |
457 | f.remove(); | 353 | f.remove(); |
458 | } | 354 | } |
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); | ||
475 | |||
476 | curFile = currentRemoteDir.canonicalPath()+"/"+ item;; | ||
477 | qDebug("CurrentFile file is " + curFile); | ||
478 | |||
479 | QFile f(destFile); | ||
480 | if( f.exists()) { | ||
481 | switch ( QMessageBox::warning(this,tr("File Exists!"), | ||
482 | item+tr("\nexists. Ok to overwrite?"), | ||
483 | tr("Yes"),tr("No"),0,0,1) ) { | ||
484 | case 1: | ||
485 | return; | ||
486 | break; | ||
487 | }; | ||
488 | f.remove(); | ||
489 | } | ||
490 | if(!copyFile( curFile, destFile) ) { | ||
491 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") | ||
492 | +curFile +tr("to\n")+destFile); | ||
493 | return; | ||
494 | 355 | ||
495 | } | 356 | if( !copyFile( curFile, destFile) ) |
357 | { | ||
358 | QMessageBox::message("AdvancedFm", | ||
359 | tr( "Could not copy %1 to %2").arg( curFile ).arg( destFile ) ); | ||
360 | return; | ||
361 | } | ||
496 | } | 362 | } |
497 | populateLocalView(); | ||
498 | TabWidget->setCurrentTab(0); | ||
499 | } | ||
500 | 363 | ||
501 | } | 364 | PopulateView(); |
365 | // TabWidget->setCurrentTab(1); | ||
366 | } | ||
502 | } | 367 | } |
503 | 368 | ||
504 | void AdvancedFm::copyAs() { | 369 | void AdvancedFm::copyAs() |
370 | { | ||
505 | qApp->processEvents(); | 371 | qApp->processEvents(); |
@@ -509,77 +375,43 @@ void AdvancedFm::copyAs() { | |||
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 | |||
518 | fileDlg->setInputText((const QString &) destFile ); | ||
519 | fileDlg->exec(); | ||
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 | 376 | ||
546 | } | 377 | QDir *thisDir = CurrentDir(); |
547 | populateRemoteView(); | 378 | QDir *thatDir = OtherDir(); |
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; | 387 | fileDlg->setInputText((const QString &) destFile ); |
558 | fileDlg->setInputText((const QString &) destFile); | ||
559 | fileDlg->exec(); | 388 | fileDlg->exec(); |
560 | 389 | ||
561 | if( fileDlg->result() == 1 ) { | 390 | if( fileDlg->result() == 1 ) |
562 | QString filename = fileDlg->LineEdit1->text(); | 391 | { |
563 | destFile = currentDir.canonicalPath()+"/"+filename; | 392 | QString filename = fileDlg->LineEdit1->text(); |
564 | 393 | destFile = thatDir->canonicalPath()+"/"+filename; | |
565 | QFile f( destFile); | 394 | |
566 | if( f.exists()) { | 395 | QFile f( destFile); |
567 | switch ( QMessageBox::warning(this,tr("File Exists!"), | 396 | if( f.exists()) |
568 | item+tr("\nexists. Ok to overwrite?"), | 397 | { |
569 | tr("Yes"),tr("No"),0,0,1) ) { | 398 | switch (QMessageBox::warning(this,tr("File Exists!"), |
570 | case 0: | 399 | item+tr("\nexists. Ok to overwrite?"), |
571 | f.remove(); | 400 | tr("Yes"),tr("No"),0,0,1) ) |
572 | break; | 401 | { |
573 | case 1: | 402 | case 0: |
574 | return; | 403 | f.remove(); |
575 | break; | 404 | break; |
576 | }; | 405 | case 1: |
577 | } | 406 | return; |
578 | if(!copyFile( curFile,destFile) ) { | 407 | break; |
579 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") | 408 | }; |
580 | +curFile +tr("to\n")+destFile); | 409 | } |
581 | return; | 410 | if( !copyFile( curFile, destFile) ) |
582 | } | 411 | { |
583 | 412 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") | |
584 | } | 413 | +curFile +tr("to\n")+destFile); |
414 | return; | ||
415 | } | ||
416 | } | ||
585 | delete fileDlg; | 417 | delete fileDlg; |
@@ -587,8 +419,7 @@ void AdvancedFm::copyAs() { | |||
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(); |
@@ -598,7 +429,8 @@ void AdvancedFm::copySameDir() { | |||
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 ) |
602 | item=(*it); | 433 | { |
603 | curFile = currentDir.canonicalPath()+"/"+ item; | 434 | item=(*it); |
435 | curFile = thisDir->canonicalPath()+"/"+ item; | ||
604 | 436 | ||
@@ -608,73 +440,39 @@ void AdvancedFm::copySameDir() { | |||
608 | 440 | ||
609 | if( fileDlg->result() == 1 ) { | 441 | if( fileDlg->result() == 1 ) |
610 | 442 | { | |
611 | QString filename = fileDlg->LineEdit1->text(); | 443 | |
612 | destFile = currentDir.canonicalPath()+"/"+filename; | 444 | QString filename = fileDlg->LineEdit1->text(); |
613 | 445 | destFile = thisDir->canonicalPath()+"/"+filename; | |
614 | QFile f(destFile); | 446 | |
615 | if( f.exists()) { | 447 | QFile f(destFile); |
616 | switch (QMessageBox::warning(this,tr("Delete"), | 448 | if( f.exists()) |
617 | destFile+tr(" already exists.\nDo you really want to delete it?"), | 449 | { |
618 | tr("Yes"),tr("No"),0,0,1) ) { | 450 | switch (QMessageBox::warning(this,tr("Delete"), |
619 | case 0: | 451 | destFile+tr(" already exists.\nDo you really want to delete it?"), |
620 | 452 | tr("Yes"),tr("No"),0,0,1) ) { | |
621 | f.remove(); | 453 | case 0: |
622 | break; | 454 | |
623 | case 1: | 455 | f.remove(); |
624 | return; | 456 | break; |
625 | break; | 457 | case 1: |
626 | }; | 458 | return; |
627 | } | 459 | break; |
628 | if(!copyFile( curFile,destFile) ) { | 460 | }; |
629 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") | 461 | } |
630 | +curFile +tr("to\n")+destFile); | 462 | if(!copyFile( curFile,destFile) ) |
631 | return; | 463 | { |
632 | } | 464 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") |
633 | 465 | +curFile +tr("to\n")+destFile); | |
634 | qDebug("copy "+curFile+" as "+destFile); | 466 | return; |
635 | } | 467 | } |
468 | |||
469 | qDebug("copy "+curFile+" as "+destFile); | ||
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(); |
@@ -682,73 +480,42 @@ void AdvancedFm::move() { | |||
682 | QStringList curFileList = getPath(); | 480 | QStringList curFileList = getPath(); |
683 | if( curFileList.count() > 0) { | 481 | if( curFileList.count() > 0) |
684 | QString curFile, destFile, item; | 482 | { |
685 | 483 | QString curFile, destFile, item; | |
686 | if (TabWidget->getCurrentTab() == 0) { | 484 | |
687 | 485 | QDir *thisDir = CurrentDir(); | |
688 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 486 | QDir *thatDir = OtherDir(); |
689 | item=(*it); | 487 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) |
690 | QString destFile = currentRemoteDir.canonicalPath(); | 488 | { |
691 | 489 | item=(*it); | |
692 | if(destFile.right(1).find("/",0,TRUE) == -1) | 490 | QString destFile = thatDir->canonicalPath(); |
693 | destFile+="/"; | 491 | |
694 | destFile += item; | 492 | if(destFile.right(1).find("/",0,TRUE) == -1) |
695 | curFile = currentDir.canonicalPath(); | 493 | destFile+="/"; |
696 | 494 | destFile += item; | |
697 | qDebug("Destination file is "+destFile); | 495 | qDebug("Destination file is "+destFile); |
698 | 496 | ||
699 | if(curFile.right(1).find("/",0,TRUE) == -1) | 497 | curFile = thisDir->canonicalPath(); |
700 | curFile +="/"; | 498 | if(curFile.right(1).find("/",0,TRUE) == -1) |
701 | 499 | curFile +="/"; | |
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) ) |
708 | QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); | 506 | { |
709 | return; | 507 | QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); |
710 | } else | 508 | return; |
711 | QFile::remove(curFile); | 509 | } else |
712 | } | 510 | QFile::remove(curFile); |
713 | } | 511 | } |
714 | 512 | } | |
715 | TabWidget->setCurrentTab(1); | 513 | |
716 | 514 | } | |
717 | } else { //view 2 | 515 | populateRemoteView(); |
718 | 516 | populateLocalView(); | |
719 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 517 | } |
720 | item = (*it); | 518 | |
721 | QString destFile = currentDir.canonicalPath(); | 519 | bool AdvancedFm::copyFile( const QString & src, const QString & dest ) |
722 | 520 | { | |
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 | } | ||
748 | populateRemoteView(); | ||
749 | populateLocalView(); | ||
750 | } | ||
751 | } | ||
752 | |||
753 | bool AdvancedFm::copyFile( const QString & src, const QString & dest ) { | ||
754 | char bf[ 50000 ]; | 521 | char bf[ 50000 ]; |
@@ -761,20 +528,26 @@ bool AdvancedFm::copyFile( const QString & src, const QString & 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 | { |
764 | if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){ | 531 | while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) ) |
765 | success = FALSE; | 532 | { |
766 | break; | 533 | if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){ |
767 | } | 534 | success = FALSE; |
768 | } | 535 | break; |
769 | if( success && (bytesRead > 0) ){ | 536 | } |
770 | d.writeBlock( bf, bytesRead ); | 537 | } |
771 | } | 538 | if( success && (bytesRead > 0) ) |
772 | } else { | 539 | { |
773 | success = FALSE; | 540 | d.writeBlock( bf, bytesRead ); |
774 | } | 541 | } |
775 | 542 | } | |
776 | // Set file permissions | 543 | else |
777 | if( stat( (const char *) src, &status ) == 0 ){ | 544 | { |
778 | chmod( (const char *) dest, status.st_mode ); | 545 | success = FALSE; |
779 | } | 546 | } |
547 | |||
548 | // Set file permissions | ||
549 | if( stat( (const char *) src, &status ) == 0 ) | ||
550 | { | ||
551 | chmod( (const char *) dest, status.st_mode ); | ||
552 | } | ||
780 | 553 | ||
@@ -783,30 +556,28 @@ bool AdvancedFm::copyFile( const QString & src, const QString & dest ) { | |||
783 | 556 | ||
784 | void AdvancedFm::runCommand() { | 557 | void AdvancedFm::runCommand() |
785 | QString curFile; | 558 | { |
786 | if (TabWidget->getCurrentTab() == 0) { | 559 | QDir *thisDir = CurrentDir(); |
787 | if( Local_View->currentItem()) | 560 | |
788 | curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0); | 561 | QString curFile; |
789 | } else { | 562 | curFile = thisDir->canonicalPath() +"/"+ CurrentView()->currentItem()->text(0); |
790 | if(Remote_View->currentItem()) | 563 | |
791 | curFile = currentRemoteDir.canonicalPath() + "/"+Remote_View->currentItem()->text(0); | 564 | InputDialog *fileDlg; |
792 | } | 565 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); |
793 | 566 | fileDlg->setInputText(curFile); | |
794 | InputDialog *fileDlg; | 567 | fileDlg->exec(); |
795 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | 568 | //QString command; |
796 | fileDlg->setInputText(curFile); | 569 | |
797 | fileDlg->exec(); | 570 | if( fileDlg->result() == 1 ) |
798 | //QString command; | 571 | { |
799 | 572 | qDebug(fileDlg->LineEdit1->text()); | |
800 | if( fileDlg->result() == 1 ) { | 573 | QStringList command; |
801 | qDebug(fileDlg->LineEdit1->text()); | 574 | |
802 | QStringList command; | 575 | command << "/bin/sh"; |
803 | 576 | command << "-c"; | |
804 | command << "/bin/sh"; | 577 | command << fileDlg->LineEdit1->text(); |
805 | command << "-c"; | 578 | Output *outDlg; |
806 | command << fileDlg->LineEdit1->text(); | 579 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); |
807 | Output *outDlg; | 580 | outDlg->showMaximized(); |
808 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); | 581 | outDlg->exec(); |
809 | outDlg->showMaximized(); | 582 | qApp->processEvents(); |
810 | outDlg->exec(); | ||
811 | qApp->processEvents(); | ||
812 | 583 | ||
@@ -815,12 +586,9 @@ void AdvancedFm::runCommand() { | |||
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 | ||
@@ -831,52 +599,24 @@ void AdvancedFm::runCommandStd() { | |||
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"; |
848 | command << "-c"; | 614 | command << "-c"; |
849 | command << "stat -l "+ curFile; | 615 | command << "stat -l "+ curFile; |
850 | |||
851 | Output *outDlg; | ||
852 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); | ||
853 | outDlg->showMaximized(); | ||
854 | outDlg->exec(); | ||
855 | 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 | 616 | ||
878 | // } | 617 | Output *outDlg; |
879 | 618 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); | |
880 | // } | 619 | outDlg->showMaximized(); |
881 | // pclose(fp); | 620 | outDlg->exec(); |
621 | qApp->processEvents(); | ||
882 | } | 622 | } |
@@ -884,57 +624,67 @@ void AdvancedFm::fileStatus() { | |||
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() |
909 | QString cmd; | 641 | { |
910 | QStringList curFileList = getPath(); | 642 | QString cmd; |
911 | if( curFileList.count() > 0) { | 643 | QStringList curFileList = getPath(); |
912 | 644 | if( curFileList.count() > 0) | |
913 | if (TabWidget->getCurrentTab() == 0) { | 645 | { |
914 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 646 | if ( whichTab == 1) |
915 | 647 | { | |
916 | QString destName = currentRemoteDir.canonicalPath()+"/"+(*it); | 648 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) |
917 | if(destName.right(1) == "/") destName = destName.left( destName.length() -1); | 649 | { |
918 | QString curFile = currentDir.canonicalPath()+"/"+(*it); | 650 | |
919 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); | 651 | QString destName = currentRemoteDir.canonicalPath()+"/"+(*it); |
920 | cmd = "ln -s "+curFile+" "+destName; | 652 | if(destName.right(1) == "/") |
921 | qDebug(cmd); | 653 | { |
922 | startProcess( (const QString)cmd ); | 654 | destName = destName.left( destName.length() -1); |
655 | } | ||
656 | QString curFile = currentDir.canonicalPath()+"/"+(*it); | ||
657 | if( curFile.right(1) == "/") | ||
658 | { | ||
659 | curFile = curFile.left( curFile.length() -1); | ||
660 | } | ||
661 | cmd = "ln -s "+curFile+" "+destName; | ||
662 | qDebug(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 |
928 | 669 | { | |
929 | QString destName = currentDir.canonicalPath()+"/"+(*it); | 670 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) |
930 | if(destName.right(1) == "/") destName = destName.left( destName.length() -1); | 671 | { |
931 | QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it); | 672 | |
932 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); | 673 | QString destName = currentDir.canonicalPath()+"/"+(*it); |
933 | 674 | if(destName.right(1) == "/") | |
934 | cmd = "ln -s "+curFile+" "+destName; | 675 | { |
935 | qDebug(cmd); | 676 | destName = destName.left( destName.length() -1); |
936 | startProcess( (const QString)cmd ); | 677 | } |
678 | QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it); | ||
679 | if( curFile.right(1) == "/") | ||
680 | { | ||
681 | curFile = curFile.left( curFile.length() -1); | ||
682 | } | ||
683 | |||
684 | cmd = "ln -s "+curFile+" "+destName; | ||
685 | qDebug(cmd); | ||
686 | startProcess( (const QString)cmd ); | ||
937 | } | 687 | } |
938 | populateLocalView(); | 688 | populateLocalView(); |
939 | TabWidget->setCurrentTab(0); | 689 | TabWidget->setCurrentTab(0); |
940 | } | 690 | } |
@@ -943,67 +693,66 @@ void AdvancedFm::mkSym() { | |||
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 | { |
948 | 699 | } | |
949 | QStringList curFileList = getPath(); | 700 | else |
950 | if( curFileList.count() > 0) { | 701 | { |
951 | 702 | ||
952 | if (TabWidget->getCurrentTab() == 0) { | 703 | QStringList curFileList = getPath(); |
953 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 704 | if( curFileList.count() > 0) |
954 | 705 | { | |
955 | QString curFile = currentDir.canonicalPath()+"/"+(*it); | 706 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) |
956 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); | 707 | { |
957 | Ir *file = new Ir(this, "IR"); | 708 | |
958 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); | 709 | QString curFile = CurrentDir()->canonicalPath()+"/"+(*it); |
959 | file->send( curFile, curFile ); | 710 | if( curFile.right(1) == "/") |
960 | } | 711 | { |
961 | 712 | curFile = curFile.left( curFile.length() -1); | |
962 | } else { | 713 | } |
963 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 714 | Ir *file = new Ir(this, "IR"); |
964 | 715 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); | |
965 | QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it); | 716 | file->send( curFile, curFile ); |
966 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); | 717 | } |
967 | Ir *file = new Ir(this, "IR"); | 718 | } |
968 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); | 719 | } |
969 | file->send( curFile, curFile ); | 720 | |
970 | 721 | } | |
971 | } | 722 | |
972 | } | 723 | void AdvancedFm::fileBeamFinished( Ir *) |
973 | } | 724 | { |
974 | } | ||
975 | |||
976 | } | ||
977 | |||
978 | void AdvancedFm::fileBeamFinished( Ir *) { | ||
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) |
994 | QStringList command; | 741 | { |
995 | OProcess *process; | 742 | QStringList command; |
996 | process = new OProcess(); | 743 | OProcess *process; |
997 | connect(process, SIGNAL(processExited(OProcess *)), | 744 | process = new OProcess(); |
998 | this, SLOT( processEnded())); | 745 | connect(process, SIGNAL(processExited(OProcess *)), |
999 | 746 | this, SLOT( processEnded())); | |
1000 | command << "/bin/sh"; | 747 | |
1001 | command << "-c"; | 748 | command << "/bin/sh"; |
1002 | command << cmd.latin1(); | 749 | command << "-c"; |
1003 | *process << command; | 750 | command << cmd.latin1(); |
1004 | if(!process->start(OProcess::NotifyOnExit) ) | 751 | *process << command; |
1005 | qDebug("could not start process"); | 752 | if(!process->start(OProcess::NotifyOnExit) ) |
753 | qDebug("could not start process"); | ||
1006 | } | 754 | } |
1007 | 755 | ||
1008 | void AdvancedFm::processEnded() { | 756 | void AdvancedFm::processEnded() |
757 | { | ||
1009 | populateLocalView(); | 758 | populateLocalView(); |
@@ -1012,27 +761,37 @@ void AdvancedFm::processEnded() { | |||
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" ) ) |
1016 | QKeyEvent *ke = (QKeyEvent*)e; | 765 | { |
1017 | if ( ke->key() == Key_Return || | 766 | if ( e->type() == QEvent::KeyPress ) |
1018 | ke->key() == Key_Enter ) { | 767 | { |
1019 | okRename(); | 768 | QKeyEvent *ke = (QKeyEvent*)e; |
1020 | return true; | 769 | if ( ke->key() == Key_Return || |
1021 | } else if ( ke->key() == Key_Escape ) { | 770 | ke->key() == Key_Enter ) |
1022 | cancelRename(); | 771 | { |
1023 | return true; | 772 | okRename(); |
773 | return true; | ||
1024 | } | 774 | } |
1025 | } else if ( e->type() == QEvent::FocusOut ) { | 775 | else if ( ke->key() == Key_Escape ) |
1026 | cancelRename(); | 776 | { |
1027 | return true; | 777 | cancelRename(); |
778 | return true; | ||
779 | } | ||
1028 | } | 780 | } |
781 | else if ( e->type() == QEvent::FocusOut ) | ||
782 | { | ||
783 | cancelRename(); | ||
784 | return true; | ||
785 | } | ||
1029 | } | 786 | } |
1030 | if ( o->inherits( "QListView" ) ) { | 787 | if ( o->inherits( "QListView" ) ) |
1031 | if ( e->type() == QEvent::FocusOut ) { | 788 | { |
1032 | printf("focusIn\n"); | 789 | if ( e->type() == QEvent::FocusOut ) |
1033 | 790 | { | |
791 | printf("focusIn\n"); | ||
792 | |||
1034 | } | 793 | } |
1035 | } | 794 | } |
1036 | 795 | ||
1037 | return QWidget::eventFilter( o, e ); | 796 | return QWidget::eventFilter( o, e ); |
1038 | } | 797 | } |
@@ -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 | { | 805 | |
1047 | view = Local_View; | 806 | bool resetFocus = view->viewport()->focusProxy() == renameBox; |
1048 | } | 807 | delete renameBox; |
1049 | else | 808 | renameBox = 0; |
1050 | { | 809 | if ( resetFocus ) |
1051 | view = Remote_View; | 810 | { |
1052 | } | 811 | view->viewport()->setFocusProxy( view); |
1053 | 812 | view->setFocus(); | |
1054 | bool resetFocus = view->viewport()->focusProxy() == renameBox; | ||
1055 | delete renameBox; | ||
1056 | renameBox = 0; | ||
1057 | if ( resetFocus ) { | ||
1058 | view->viewport()->setFocusProxy( view); | ||
1059 | view->setFocus(); | ||
1060 | } | 813 | } |
@@ -1087,14 +840,8 @@ void AdvancedFm::doRename(QListView * view) | |||
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 | } |
@@ -1103,35 +850,20 @@ 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) | 856 | oldName = path + oldName; |
1110 | { | 857 | newName = path + newName; |
1111 | view = Local_View; | 858 | |
1112 | QString path = currentDir.canonicalPath() + "/"; | 859 | if( view->currentItem() == NULL) |
1113 | oldName = path + oldName; | 860 | return; |
1114 | newName = path + newName; | 861 | if( rename( oldName.latin1(), newName.latin1())== -1) |
1115 | } | 862 | QMessageBox::message(tr("Note"),tr("Could not rename")); |
1116 | else | 863 | else |
1117 | { | 864 | oldName = ""; |
1118 | view = Remote_View; | 865 | |
1119 | QString path = currentRemoteDir.canonicalPath() + "/"; | 866 | view->takeItem( view->currentItem() ); |
1120 | oldName = path + oldName; | 867 | delete view->currentItem(); |
1121 | newName = path + newName; | 868 | PopulateView(); |
1122 | } | ||
1123 | |||
1124 | if( view->currentItem() == NULL) | ||
1125 | return; | ||
1126 | if( rename(oldName.latin1(), newName.latin1())== -1) | ||
1127 | QMessageBox::message(tr("Note"),tr("Could not rename")); | ||
1128 | else | ||
1129 | oldName = ""; | ||
1130 | |||
1131 | view->takeItem( view->currentItem() ); | ||
1132 | delete view->currentItem(); | ||
1133 | if ( tabs == 0) | ||
1134 | populateLocalView(); | ||
1135 | else | ||
1136 | populateRemoteView(); | ||
1137 | } | 869 | } |