-rw-r--r-- | noncore/apps/advancedfm/advancedfm.cpp | 30 | ||||
-rw-r--r-- | noncore/apps/advancedfm/advancedfmMenu.cpp | 62 |
2 files changed, 48 insertions, 44 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp index 9aa0c77..8cc5d7b 100644 --- a/noncore/apps/advancedfm/advancedfm.cpp +++ b/noncore/apps/advancedfm/advancedfm.cpp | |||
@@ -60,43 +60,39 @@ AdvancedFm::~AdvancedFm() { | |||
60 | void AdvancedFm::cleanUp() { | 60 | void AdvancedFm::cleanUp() { |
61 | QString sfile=QDir::homeDirPath(); | 61 | QString sfile=QDir::homeDirPath(); |
62 | if(sfile.right(1) != "/") | 62 | if(sfile.right(1) != "/") |
63 | sfile+="/._temp"; | 63 | sfile+="/._temp"; |
64 | else | 64 | else |
65 | sfile+="._temp"; | 65 | sfile+="._temp"; |
66 | QFile file( sfile); | 66 | QFile file( sfile); |
67 | if(file.exists()) | 67 | if(file.exists()) |
68 | file.remove(); | 68 | file.remove(); |
69 | } | 69 | } |
70 | 70 | ||
71 | void AdvancedFm::tabChanged(QWidget *wd) { | 71 | void AdvancedFm::tabChanged(QWidget *wd) { |
72 | // qDebug("tabChanged"); | ||
73 | if(wd == tab) { | 72 | if(wd == tab) { |
74 | whichTab = 1; | 73 | whichTab = 1; |
75 | viewMenu->setItemChecked(viewMenu->idAt(0), true); | 74 | viewMenu->setItemChecked(viewMenu->idAt(0), true); |
76 | viewMenu->setItemChecked(viewMenu->idAt(1), false); | 75 | viewMenu->setItemChecked(viewMenu->idAt(1), false); |
77 | // qDebug("tabchanged: LOCAL VIEW SHOWN"); | 76 | // qDebug("tabchanged: LOCAL VIEW SHOWN"); |
78 | } | 77 | } |
78 | |||
79 | else if(wd == tab_2) { | 79 | else if(wd == tab_2) { |
80 | whichTab = 2; | 80 | whichTab = 2; |
81 | viewMenu->setItemChecked(viewMenu->idAt(0), false); | 81 | viewMenu->setItemChecked(viewMenu->idAt(0), false); |
82 | viewMenu->setItemChecked(viewMenu->idAt(1), true); | 82 | viewMenu->setItemChecked(viewMenu->idAt(1), true); |
83 | // qDebug("tabchanged: REMOTE VIEW SHOWN"); | 83 | // qDebug("tabchanged: REMOTE VIEW SHOWN"); |
84 | } | 84 | } |
85 | qApp->processEvents(); | 85 | qApp->processEvents(); |
86 | QString path = CurrentDir()->canonicalPath(); | 86 | QString path = CurrentDir()->canonicalPath(); |
87 | // qDebug(path); | ||
88 | if ( TabWidget->currentWidget() == tab) { | ||
89 | } else { | ||
90 | } | ||
91 | 87 | ||
92 | chdir( path.latin1()); | 88 | chdir( path.latin1()); |
93 | currentPathCombo->lineEdit()->setText(path); | 89 | currentPathCombo->lineEdit()->setText(path); |
94 | } | 90 | } |
95 | 91 | ||
96 | 92 | ||
97 | void AdvancedFm::populateView() { | 93 | void AdvancedFm::populateView() { |
98 | 94 | ||
99 | QPixmap pm; | 95 | QPixmap pm; |
100 | QListView *thisView = CurrentView(); | 96 | QListView *thisView = CurrentView(); |
101 | QDir *thisDir = CurrentDir(); | 97 | QDir *thisDir = CurrentDir(); |
102 | QString path = thisDir->canonicalPath(); | 98 | QString path = thisDir->canonicalPath(); |
@@ -257,33 +253,33 @@ void AdvancedFm::ListPressed( int mouse, QListViewItem *item, const QPoint& , in | |||
257 | // menuTimer.start( 50, TRUE ); | 253 | // menuTimer.start( 50, TRUE ); |
258 | // break; | 254 | // break; |
259 | }; | 255 | }; |
260 | } | 256 | } |
261 | 257 | ||
262 | 258 | ||
263 | void AdvancedFm::refreshCurrentTab() { | 259 | void AdvancedFm::refreshCurrentTab() { |
264 | populateView(); | 260 | populateView(); |
265 | // if ( TabWidget->currentWidget() == tab) { | 261 | // if ( TabWidget->currentWidget() == tab) { |
266 | } | 262 | } |
267 | 263 | ||
268 | void AdvancedFm::switchToLocalTab() { | 264 | void AdvancedFm::switchToLocalTab() { |
269 | TabWidget->setCurrentWidget(0); | 265 | TabWidget->setCurrentWidget(tab); |
270 | // Local_View->setFocus(); | 266 | Local_View->setFocus(); |
271 | whichTab = 1; | 267 | // whichTab = 1; |
272 | } | 268 | } |
273 | 269 | ||
274 | void AdvancedFm::switchToRemoteTab() { | 270 | void AdvancedFm::switchToRemoteTab() { |
275 | TabWidget->setCurrentWidget(1); | 271 | TabWidget->setCurrentWidget(tab_2); |
276 | // Remote_View->setFocus(); | 272 | Remote_View->setFocus(); |
277 | whichTab = 2; | 273 | // whichTab = 2; |
278 | } | 274 | } |
279 | 275 | ||
280 | void AdvancedFm::currentPathComboChanged() { | 276 | void AdvancedFm::currentPathComboChanged() { |
281 | QString pDir = currentPathCombo->lineEdit()->text(); | 277 | QString pDir = currentPathCombo->lineEdit()->text(); |
282 | if(QDir(pDir).exists()) { | 278 | if(QDir(pDir).exists()) { |
283 | CurrentDir()->setPath(pDir ); | 279 | CurrentDir()->setPath(pDir ); |
284 | populateView(); | 280 | populateView(); |
285 | } else { | 281 | } else { |
286 | QMessageBox::message(tr("Note"),tr("<p>%1 does not exist</p>").arg(pDir)); | 282 | QMessageBox::message(tr("Note"),tr("<p>%1 does not exist</p>").arg(pDir)); |
287 | } | 283 | } |
288 | } | 284 | } |
289 | 285 | ||
@@ -749,21 +745,27 @@ void AdvancedFm::qcopReceive(const QCString &msg, const QByteArray &data) { | |||
749 | QString file; | 745 | QString file; |
750 | stream >> file; | 746 | stream >> file; |
751 | changeTo( (const QString &) file); | 747 | changeTo( (const QString &) file); |
752 | } | 748 | } |
753 | } | 749 | } |
754 | 750 | ||
755 | void AdvancedFm::setDocument(const QString &file) { | 751 | void AdvancedFm::setDocument(const QString &file) { |
756 | changeTo( file); | 752 | changeTo( file); |
757 | } | 753 | } |
758 | 754 | ||
759 | 755 | ||
760 | void AdvancedFm::slotSwitchMenu(int item) { | 756 | void AdvancedFm::slotSwitchMenu(int item) { |
761 | Q_UNUSED(item); | 757 | if(item == -23) { |
762 | // qDebug( "Switch %d",item); | 758 | switchToLocalTab(); |
763 | // viewMenu->setItemChecked(item, true); | 759 | tabChanged( tab); |
760 | } | ||
761 | |||
762 | if(item == -24) { | ||
763 | switchToRemoteTab(); | ||
764 | tabChanged( tab_2); | ||
765 | } | ||
764 | } | 766 | } |
765 | 767 | ||
766 | void AdvancedFm::navigateToSelected() { | 768 | void AdvancedFm::navigateToSelected() { |
767 | if( !CurrentView()->currentItem()) return; | 769 | if( !CurrentView()->currentItem()) return; |
768 | doDirChange(); | 770 | doDirChange(); |
769 | } | 771 | } |
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp index 171e7c4..4802771 100644 --- a/noncore/apps/advancedfm/advancedfmMenu.cpp +++ b/noncore/apps/advancedfm/advancedfmMenu.cpp | |||
@@ -35,25 +35,25 @@ using namespace Opie::Core; | |||
35 | #include <sys/stat.h> | 35 | #include <sys/stat.h> |
36 | #include <dirent.h> | 36 | #include <dirent.h> |
37 | #include <sys/sendfile.h> | 37 | #include <sys/sendfile.h> |
38 | #include <fcntl.h> | 38 | #include <fcntl.h> |
39 | 39 | ||
40 | void AdvancedFm::doDirChange() { | 40 | void AdvancedFm::doDirChange() { |
41 | QString pathItem = CurrentView()->currentItem()->text(0); | 41 | QString pathItem = CurrentView()->currentItem()->text(0); |
42 | if( pathItem == "../") { | 42 | if( pathItem == "../") { |
43 | ListClicked( CurrentView()->currentItem()); | 43 | ListClicked( CurrentView()->currentItem()); |
44 | } else { | 44 | } else { |
45 | if( pathItem.find(" -> ",0,TRUE) != -1) | 45 | if( pathItem.find(" -> ",0,TRUE) != -1) |
46 | pathItem = dealWithSymName((const QString&)pathItem)+"/"; | 46 | pathItem = dealWithSymName((const QString&)pathItem)+"/"; |
47 | // owarn << pathItem << oendl; | 47 | // owarn << pathItem << oendl; |
48 | changeTo( CurrentDir()->path()+"/"+pathItem.left( pathItem.length() - 1) ); | 48 | changeTo( CurrentDir()->path()+"/"+pathItem.left( pathItem.length() - 1) ); |
49 | } | 49 | } |
50 | } | 50 | } |
51 | 51 | ||
52 | void AdvancedFm::showMenuHidden() { | 52 | void AdvancedFm::showMenuHidden() { |
53 | if (b) { | 53 | if (b) { |
54 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 54 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
55 | OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 55 | OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
56 | fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); | 56 | fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); |
57 | } else { | 57 | } else { |
58 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 58 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
59 | OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 59 | OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
@@ -86,37 +86,37 @@ void AdvancedFm::runThis() { | |||
86 | 86 | ||
87 | QString curFile = CurrentView()->currentItem()->text(0); | 87 | QString curFile = CurrentView()->currentItem()->text(0); |
88 | QString path = thisDir->canonicalPath(); | 88 | QString path = thisDir->canonicalPath(); |
89 | 89 | ||
90 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink | 90 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink |
91 | 91 | ||
92 | curFile = dealWithSymName((const QString&)curFile); | 92 | curFile = dealWithSymName((const QString&)curFile); |
93 | 93 | ||
94 | if(curFile != "../") { | 94 | if(curFile != "../") { |
95 | 95 | ||
96 | fs = getFileSystemType((const QString &) path); | 96 | fs = getFileSystemType((const QString &) path); |
97 | QFileInfo fileInfo( path + "/" + curFile); | 97 | QFileInfo fileInfo( path + "/" + curFile); |
98 | // odebug << fileInfo.owner() << oendl; | 98 | // odebug << fileInfo.owner() << oendl; |
99 | 99 | ||
100 | if( (fileInfo.permission( QFileInfo::ExeUser) | 100 | if( (fileInfo.permission( QFileInfo::ExeUser) |
101 | | fileInfo.permission( QFileInfo::ExeGroup) | 101 | | fileInfo.permission( QFileInfo::ExeGroup) |
102 | | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { | 102 | | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { |
103 | | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { | 103 | | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { |
104 | QCopEnvelope e("QPE/System", "execute(QString)" ); | 104 | QCopEnvelope e("QPE/System", "execute(QString)" ); |
105 | e << curFile; | 105 | e << curFile; |
106 | } else { | 106 | } else { |
107 | curFile = path + "/" + curFile; | 107 | curFile = path + "/" + curFile; |
108 | DocLnk nf(curFile); | 108 | DocLnk nf(curFile); |
109 | QString execStr = nf.exec(); | 109 | QString execStr = nf.exec(); |
110 | // odebug << execStr << oendl; | 110 | // odebug << execStr << oendl; |
111 | if( execStr.isEmpty() ) { | 111 | if( execStr.isEmpty() ) { |
112 | } else { | 112 | } else { |
113 | nf.execute(); | 113 | nf.execute(); |
114 | } | 114 | } |
115 | } | 115 | } |
116 | } | 116 | } |
117 | } | 117 | } |
118 | 118 | ||
119 | void AdvancedFm::runText() { | 119 | void AdvancedFm::runText() { |
120 | if( !CurrentView()->currentItem()) return; | 120 | if( !CurrentView()->currentItem()) return; |
121 | QString curFile = CurrentView()->currentItem()->text(0); | 121 | QString curFile = CurrentView()->currentItem()->text(0); |
122 | if(curFile != "../") { | 122 | if(curFile != "../") { |
@@ -196,30 +196,30 @@ void AdvancedFm::doDelete() { | |||
196 | tr("<p>Really delete %1?</p>").arg( myFile ), | 196 | tr("<p>Really delete %1?</p>").arg( myFile ), |
197 | tr("Yes"), tr("No"), 0, 0, 1) ) { | 197 | tr("Yes"), tr("No"), 0, 0, 1) ) { |
198 | case 1: | 198 | case 1: |
199 | return; | 199 | return; |
200 | break; | 200 | break; |
201 | }; | 201 | }; |
202 | } | 202 | } |
203 | 203 | ||
204 | QString cmd="rm "+f; | 204 | QString cmd="rm "+f; |
205 | QFile file(f); | 205 | QFile file(f); |
206 | QFileInfo fi(myFile); | 206 | QFileInfo fi(myFile); |
207 | if( fi.fileName().find("../",0,TRUE)==-1) { | 207 | if( fi.fileName().find("../",0,TRUE)==-1) { |
208 | // odebug << "remove link files "+myFile << oendl; | 208 | // odebug << "remove link files "+myFile << oendl; |
209 | 209 | ||
210 | // DocLnk lnk(f); | 210 | // DocLnk lnk(f); |
211 | DocLnk *lnk; | 211 | DocLnk *lnk; |
212 | lnk = new DocLnk(f); | 212 | lnk = new DocLnk(f); |
213 | // odebug << "Deleting doclnk " + lnk->linkFile() << oendl; | 213 | // odebug << "Deleting doclnk " + lnk->linkFile() << oendl; |
214 | if(lnk->isValid()) | 214 | if(lnk->isValid()) |
215 | lnk->removeLinkFile(); | 215 | lnk->removeLinkFile(); |
216 | // delete lnk; | 216 | // delete lnk; |
217 | file.remove(); | 217 | file.remove(); |
218 | } | 218 | } |
219 | } | 219 | } |
220 | } | 220 | } |
221 | } | 221 | } |
222 | populateView(); | 222 | populateView(); |
223 | } | 223 | } |
224 | 224 | ||
225 | void AdvancedFm::filePerms() { | 225 | void AdvancedFm::filePerms() { |
@@ -237,28 +237,28 @@ void AdvancedFm::filePerms() { | |||
237 | } | 237 | } |
238 | populateView(); | 238 | populateView(); |
239 | } | 239 | } |
240 | 240 | ||
241 | void AdvancedFm::doProperties() { | 241 | void AdvancedFm::doProperties() { |
242 | #if defined(QT_QWS_OPIE) | 242 | #if defined(QT_QWS_OPIE) |
243 | 243 | ||
244 | QStringList curFileList = getPath(); | 244 | QStringList curFileList = getPath(); |
245 | 245 | ||
246 | QString filePath; | 246 | QString filePath; |
247 | filePath = CurrentDir()->canonicalPath()+"/"; | 247 | filePath = CurrentDir()->canonicalPath()+"/"; |
248 | 248 | ||
249 | // odebug << "" << curFileList.count() << "" << oendl; | 249 | // odebug << "" << curFileList.count() << "" << oendl; |
250 | 250 | ||
251 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 251 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
252 | // odebug << (filePath+*it) << oendl; | 252 | // odebug << (filePath+*it) << oendl; |
253 | DocLnk lnk( (filePath+*it)); | 253 | DocLnk lnk( (filePath+*it)); |
254 | LnkProperties prop( &lnk ); | 254 | LnkProperties prop( &lnk ); |
255 | QPEApplication::execDialog( &prop ); | 255 | QPEApplication::execDialog( &prop ); |
256 | } | 256 | } |
257 | #endif | 257 | #endif |
258 | 258 | ||
259 | } | 259 | } |
260 | 260 | ||
261 | void AdvancedFm::upDir() { | 261 | void AdvancedFm::upDir() { |
262 | 262 | ||
263 | QDir dir( CurrentDir()->canonicalPath()); | 263 | QDir dir( CurrentDir()->canonicalPath()); |
264 | dir.cdUp(); | 264 | dir.cdUp(); |
@@ -293,26 +293,26 @@ void AdvancedFm::copy() { | |||
293 | }; | 293 | }; |
294 | } | 294 | } |
295 | 295 | ||
296 | QString curFile, item, destFile; | 296 | QString curFile, item, destFile; |
297 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 297 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
298 | item=(*it); | 298 | item=(*it); |
299 | if(item.find("->",0,TRUE)) //symlink | 299 | if(item.find("->",0,TRUE)) //symlink |
300 | item = item.left(item.find("->",0,TRUE)); | 300 | item = item.left(item.find("->",0,TRUE)); |
301 | 301 | ||
302 | curFile = thisDir->canonicalPath()+"/"+ item; | 302 | curFile = thisDir->canonicalPath()+"/"+ item; |
303 | destFile = thatDir->canonicalPath()+"/"+ item; | 303 | destFile = thatDir->canonicalPath()+"/"+ item; |
304 | 304 | ||
305 | // odebug << "Destination file is "+destFile << oendl; | 305 | // odebug << "Destination file is "+destFile << oendl; |
306 | // odebug << "CurrentFile file is " + curFile << oendl; | 306 | // odebug << "CurrentFile file is " + curFile << oendl; |
307 | 307 | ||
308 | QFile f(destFile); | 308 | QFile f(destFile); |
309 | if( f.exists()) { | 309 | if( f.exists()) { |
310 | if(doMsg) { | 310 | if(doMsg) { |
311 | switch ( QMessageBox::warning(this,tr("File Exists!"), | 311 | switch ( QMessageBox::warning(this,tr("File Exists!"), |
312 | tr("<p>%1 already exists. Ok to overwrite?</P>").arg(item), | 312 | tr("<p>%1 already exists. Ok to overwrite?</P>").arg(item), |
313 | tr("Yes"),tr("No"),0,0,1)) { | 313 | tr("Yes"),tr("No"),0,0,1)) { |
314 | case 1: | 314 | case 1: |
315 | return; | 315 | return; |
316 | break; | 316 | break; |
317 | }; | 317 | }; |
318 | } | 318 | } |
@@ -417,25 +417,25 @@ void AdvancedFm::copySameDir() { | |||
417 | f.remove(); | 417 | f.remove(); |
418 | break; | 418 | break; |
419 | case 1: | 419 | case 1: |
420 | return; | 420 | return; |
421 | break; | 421 | break; |
422 | }; | 422 | }; |
423 | } | 423 | } |
424 | if(!copyFile( curFile,destFile) ) { | 424 | if(!copyFile( curFile,destFile) ) { |
425 | QMessageBox::message("AdvancedFm",tr("<P>Could not copy %1 to %2</P>").arg(curFile).arg(destFile)); | 425 | QMessageBox::message("AdvancedFm",tr("<P>Could not copy %1 to %2</P>").arg(curFile).arg(destFile)); |
426 | return; | 426 | return; |
427 | } | 427 | } |
428 | 428 | ||
429 | // odebug << "copy "+curFile+" as "+destFile << oendl; | 429 | // odebug << "copy "+curFile+" as "+destFile << oendl; |
430 | } | 430 | } |
431 | delete fileDlg; | 431 | delete fileDlg; |
432 | } | 432 | } |
433 | rePopulate(); | 433 | rePopulate(); |
434 | } | 434 | } |
435 | 435 | ||
436 | void AdvancedFm::moveTimer() { | 436 | void AdvancedFm::moveTimer() { |
437 | QTimer::singleShot(125,this,SLOT(move())); | 437 | QTimer::singleShot(125,this,SLOT(move())); |
438 | } | 438 | } |
439 | 439 | ||
440 | void AdvancedFm::move() { | 440 | void AdvancedFm::move() { |
441 | 441 | ||
@@ -443,31 +443,31 @@ void AdvancedFm::move() { | |||
443 | if( curFileList.count() > 0) { | 443 | if( curFileList.count() > 0) { |
444 | QString curFile, destFile, item; | 444 | QString curFile, destFile, item; |
445 | 445 | ||
446 | QDir *thisDir = CurrentDir(); | 446 | QDir *thisDir = CurrentDir(); |
447 | QDir *thatDir = OtherDir(); | 447 | QDir *thatDir = OtherDir(); |
448 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 448 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
449 | item=(*it); | 449 | item=(*it); |
450 | QString destFile = thatDir->canonicalPath(); | 450 | QString destFile = thatDir->canonicalPath(); |
451 | 451 | ||
452 | if(destFile.right(1).find("/",0,TRUE) == -1) | 452 | if(destFile.right(1).find("/",0,TRUE) == -1) |
453 | destFile+="/"; | 453 | destFile+="/"; |
454 | destFile += item; | 454 | destFile += item; |
455 | // odebug << "Destination file is "+destFile << oendl; | 455 | // odebug << "Destination file is "+destFile << oendl; |
456 | 456 | ||
457 | curFile = thisDir->canonicalPath(); | 457 | curFile = thisDir->canonicalPath(); |
458 | if(curFile.right(1).find("/",0,TRUE) == -1) | 458 | if(curFile.right(1).find("/",0,TRUE) == -1) |
459 | curFile +="/"; | 459 | curFile +="/"; |
460 | curFile+= item; | 460 | curFile+= item; |
461 | // odebug << "CurrentFile file is " + curFile << oendl; | 461 | // odebug << "CurrentFile file is " + curFile << oendl; |
462 | 462 | ||
463 | if(QFileInfo(curFile).isDir()) { | 463 | if(QFileInfo(curFile).isDir()) { |
464 | moveDirectory( curFile, destFile ); | 464 | moveDirectory( curFile, destFile ); |
465 | rePopulate(); | 465 | rePopulate(); |
466 | return; | 466 | return; |
467 | } | 467 | } |
468 | QFile f( destFile); | 468 | QFile f( destFile); |
469 | if( f.exists()) { | 469 | if( f.exists()) { |
470 | switch ( QMessageBox::warning(this,tr("File Exists!"), | 470 | switch ( QMessageBox::warning(this,tr("File Exists!"), |
471 | tr("<p>%1 already exists. Ok to overwrite?</P>").arg(destFile), | 471 | tr("<p>%1 already exists. Ok to overwrite?</P>").arg(destFile), |
472 | tr("Yes"),tr("No"),0,0,1)) { | 472 | tr("Yes"),tr("No"),0,0,1)) { |
473 | case 1: | 473 | case 1: |
@@ -495,25 +495,25 @@ bool AdvancedFm::moveDirectory( const QString & src, const QString & dest ) { | |||
495 | err = -1; | 495 | err = -1; |
496 | 496 | ||
497 | if(err!=0) { | 497 | if(err!=0) { |
498 | QMessageBox::message(tr("Note"),tr("<p>Could not move %1</p>").arg( src)); | 498 | QMessageBox::message(tr("Note"),tr("<p>Could not move %1</p>").arg( src)); |
499 | return false; | 499 | return false; |
500 | } | 500 | } |
501 | return true; | 501 | return true; |
502 | } | 502 | } |
503 | 503 | ||
504 | bool AdvancedFm::copyDirectory( const QString & src, const QString & dest ) { | 504 | bool AdvancedFm::copyDirectory( const QString & src, const QString & dest ) { |
505 | 505 | ||
506 | QString cmd = "/bin/cp -fpR " + src + " " + dest; | 506 | QString cmd = "/bin/cp -fpR " + src + " " + dest; |
507 | owarn << cmd << oendl; | 507 | owarn << cmd << oendl; |
508 | int err = system( (const char *) cmd ); | 508 | int err = system( (const char *) cmd ); |
509 | if ( err != 0 ) { | 509 | if ( err != 0 ) { |
510 | QMessageBox::message("AdvancedFm", tr( "<p>Could not copy %1 to %2</p>").arg( src ).arg( dest ) ); | 510 | QMessageBox::message("AdvancedFm", tr( "<p>Could not copy %1 to %2</p>").arg( src ).arg( dest ) ); |
511 | return false; | 511 | return false; |
512 | } | 512 | } |
513 | 513 | ||
514 | return true; | 514 | return true; |
515 | } | 515 | } |
516 | 516 | ||
517 | 517 | ||
518 | bool AdvancedFm::copyFile( const QString & src, const QString & dest ) { | 518 | bool AdvancedFm::copyFile( const QString & src, const QString & dest ) { |
519 | if(QFileInfo(src).isDir()) { | 519 | if(QFileInfo(src).isDir()) { |
@@ -528,47 +528,47 @@ bool AdvancedFm::copyFile( const QString & src, const QString & dest ) { | |||
528 | 528 | ||
529 | 529 | ||
530 | bool success = true; | 530 | bool success = true; |
531 | struct stat status; | 531 | struct stat status; |
532 | QFile srcFile(src); | 532 | QFile srcFile(src); |
533 | QFile destFile(dest); | 533 | QFile destFile(dest); |
534 | int err=0; | 534 | int err=0; |
535 | int read_fd=0; | 535 | int read_fd=0; |
536 | int write_fd=0; | 536 | int write_fd=0; |
537 | struct stat stat_buf; | 537 | struct stat stat_buf; |
538 | off_t offset = 0; | 538 | off_t offset = 0; |
539 | if(!srcFile.open( IO_ReadOnly|IO_Raw)) { | 539 | if(!srcFile.open( IO_ReadOnly|IO_Raw)) { |
540 | // owarn << "open failed" << oendl; | 540 | // owarn << "open failed" << oendl; |
541 | return success = false; | 541 | return success = false; |
542 | } | 542 | } |
543 | read_fd = srcFile.handle(); | 543 | read_fd = srcFile.handle(); |
544 | if(read_fd != -1) { | 544 | if(read_fd != -1) { |
545 | fstat (read_fd, &stat_buf); | 545 | fstat (read_fd, &stat_buf); |
546 | if( !destFile.open( IO_WriteOnly|IO_Raw ) ) { | 546 | if( !destFile.open( IO_WriteOnly|IO_Raw ) ) { |
547 | // owarn << "destfile open failed" << oendl; | 547 | // owarn << "destfile open failed" << oendl; |
548 | return success = false; | 548 | return success = false; |
549 | } | 549 | } |
550 | write_fd = destFile.handle(); | 550 | write_fd = destFile.handle(); |
551 | if(write_fd != -1) { | 551 | if(write_fd != -1) { |
552 | err = sendfile(write_fd, read_fd, &offset, stat_buf.st_size); | 552 | err = sendfile(write_fd, read_fd, &offset, stat_buf.st_size); |
553 | if( err == -1) { | 553 | if( err == -1) { |
554 | QString msg; | 554 | QString msg; |
555 | switch(err) { | 555 | switch(err) { |
556 | case EBADF : msg = "The input file was not opened for reading or the output file was not opened for writing. "; | 556 | case EBADF : msg = "The input file was not opened for reading or the output file was not opened for writing. "; |
557 | case EINVAL: msg = "Descriptor is not valid or locked. "; | 557 | case EINVAL: msg = "Descriptor is not valid or locked. "; |
558 | case ENOMEM: msg = "Insufficient memory to read from in_fd."; | 558 | case ENOMEM: msg = "Insufficient memory to read from in_fd."; |
559 | case EIO: msg = "Unspecified error while reading from in_fd."; | 559 | case EIO: msg = "Unspecified error while reading from in_fd."; |
560 | }; | 560 | }; |
561 | success = false; | 561 | success = false; |
562 | // owarn << msg << oendl; | 562 | // owarn << msg << oendl; |
563 | } | 563 | } |
564 | } else { | 564 | } else { |
565 | success = false; | 565 | success = false; |
566 | } | 566 | } |
567 | } else { | 567 | } else { |
568 | success = false; | 568 | success = false; |
569 | } | 569 | } |
570 | srcFile.close(); | 570 | srcFile.close(); |
571 | destFile.close(); | 571 | destFile.close(); |
572 | // Set file permissions | 572 | // Set file permissions |
573 | if( stat( QFile::encodeName(src), &status ) == 0 ) { | 573 | if( stat( QFile::encodeName(src), &status ) == 0 ) { |
574 | chmod( QFile::encodeName(dest), status.st_mode ); | 574 | chmod( QFile::encodeName(dest), status.st_mode ); |
@@ -582,25 +582,25 @@ void AdvancedFm::runCommand() { | |||
582 | QDir *thisDir = CurrentDir(); | 582 | QDir *thisDir = CurrentDir(); |
583 | 583 | ||
584 | QString curFile; | 584 | QString curFile; |
585 | curFile = thisDir->canonicalPath() +"/"+ CurrentView()->currentItem()->text(0); | 585 | curFile = thisDir->canonicalPath() +"/"+ CurrentView()->currentItem()->text(0); |
586 | 586 | ||
587 | InputDialog *fileDlg; | 587 | InputDialog *fileDlg; |
588 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | 588 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); |
589 | fileDlg->setInputText(curFile); | 589 | fileDlg->setInputText(curFile); |
590 | fileDlg->exec(); | 590 | fileDlg->exec(); |
591 | //QString command; | 591 | //QString command; |
592 | 592 | ||
593 | if( fileDlg->result() == 1 ) { | 593 | if( fileDlg->result() == 1 ) { |
594 | // odebug << fileDlg->LineEdit1->text() << oendl; | 594 | // odebug << fileDlg->LineEdit1->text() << oendl; |
595 | QStringList command; | 595 | QStringList command; |
596 | 596 | ||
597 | command << "/bin/sh"; | 597 | command << "/bin/sh"; |
598 | command << "-c"; | 598 | command << "-c"; |
599 | command << fileDlg->LineEdit1->text(); | 599 | command << fileDlg->LineEdit1->text(); |
600 | Output *outDlg; | 600 | Output *outDlg; |
601 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); | 601 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); |
602 | QPEApplication::execDialog( outDlg ); | 602 | QPEApplication::execDialog( outDlg ); |
603 | qApp->processEvents(); | 603 | qApp->processEvents(); |
604 | 604 | ||
605 | } | 605 | } |
606 | } | 606 | } |
@@ -665,25 +665,25 @@ void AdvancedFm::mkSym() { | |||
665 | QString destName = thatDir->canonicalPath()+"/"+(*it); | 665 | QString destName = thatDir->canonicalPath()+"/"+(*it); |
666 | if(destName.right(1) == "/") { | 666 | if(destName.right(1) == "/") { |
667 | destName = destName.left( destName.length() -1); | 667 | destName = destName.left( destName.length() -1); |
668 | } | 668 | } |
669 | 669 | ||
670 | QString curFile = thisDir->canonicalPath()+"/"+(*it); | 670 | QString curFile = thisDir->canonicalPath()+"/"+(*it); |
671 | 671 | ||
672 | if( curFile.right(1) == "/") { | 672 | if( curFile.right(1) == "/") { |
673 | curFile = curFile.left( curFile.length() -1); | 673 | curFile = curFile.left( curFile.length() -1); |
674 | } | 674 | } |
675 | 675 | ||
676 | cmd = "ln -s "+curFile+" "+destName; | 676 | cmd = "ln -s "+curFile+" "+destName; |
677 | // odebug << cmd << oendl; | 677 | // odebug << cmd << oendl; |
678 | startProcess( (const QString)cmd ); | 678 | startProcess( (const QString)cmd ); |
679 | } | 679 | } |
680 | rePopulate(); | 680 | rePopulate(); |
681 | setOtherTabCurrent(); | 681 | setOtherTabCurrent(); |
682 | } | 682 | } |
683 | } | 683 | } |
684 | 684 | ||
685 | void AdvancedFm::doBeam() { | 685 | void AdvancedFm::doBeam() { |
686 | Ir ir; | 686 | Ir ir; |
687 | if(!ir.supported()) { | 687 | if(!ir.supported()) { |
688 | } else { | 688 | } else { |
689 | QStringList curFileList = getPath(); | 689 | QStringList curFileList = getPath(); |
@@ -715,76 +715,78 @@ void AdvancedFm::selectAll() { | |||
715 | void AdvancedFm::startProcess(const QString & cmd) { | 715 | void AdvancedFm::startProcess(const QString & cmd) { |
716 | QStringList command; | 716 | QStringList command; |
717 | OProcess *process; | 717 | OProcess *process; |
718 | process = new OProcess(); | 718 | process = new OProcess(); |
719 | connect(process,SIGNAL(processExited(Opie::Core::OProcess*)),this,SLOT(processEnded(Opie::Core::OProcess*))); | 719 | connect(process,SIGNAL(processExited(Opie::Core::OProcess*)),this,SLOT(processEnded(Opie::Core::OProcess*))); |
720 | connect(process,SIGNAL(receivedStderr(Opie::Core::OProcess*,char*,int)),this,SLOT(oprocessStderr(Opie::Core::OProcess*,char*,int))); | 720 | connect(process,SIGNAL(receivedStderr(Opie::Core::OProcess*,char*,int)),this,SLOT(oprocessStderr(Opie::Core::OProcess*,char*,int))); |
721 | 721 | ||
722 | command << "/bin/sh"; | 722 | command << "/bin/sh"; |
723 | command << "-c"; | 723 | command << "-c"; |
724 | command << cmd.latin1(); | 724 | command << cmd.latin1(); |
725 | *process << command; | 725 | *process << command; |
726 | if(!process->start(OProcess::NotifyOnExit, OProcess::All) ) | 726 | if(!process->start(OProcess::NotifyOnExit, OProcess::All) ) |
727 | odebug << "could not start process" << oendl; | 727 | odebug << "could not start process" << oendl; |
728 | } | 728 | } |
729 | 729 | ||
730 | void AdvancedFm::processEnded(OProcess *) { | 730 | void AdvancedFm::processEnded(OProcess *) { |
731 | rePopulate(); | 731 | rePopulate(); |
732 | } | 732 | } |
733 | 733 | ||
734 | void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int ) { | 734 | void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int ) { |
735 | // owarn << "received stderrt " << buflen << " bytes" << oendl; | 735 | // owarn << "received stderrt " << buflen << " bytes" << oendl; |
736 | 736 | ||
737 | QString lineStr = buffer; | 737 | QString lineStr = buffer; |
738 | QMessageBox::warning( this, tr("Error"), lineStr ,tr("Ok") ); | 738 | QMessageBox::warning( this, tr("Error"), lineStr ,tr("Ok") ); |
739 | } | 739 | } |
740 | 740 | ||
741 | bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) { | 741 | bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) { |
742 | if ( o->inherits( "QLineEdit" ) ) { | 742 | if ( o->inherits( "QLineEdit" ) ) { |
743 | if ( e->type() == QEvent::KeyPress ) { | 743 | if ( e->type() == QEvent::KeyPress ) { |
744 | QKeyEvent *ke = (QKeyEvent*)e; | 744 | QKeyEvent *ke = (QKeyEvent*)e; |
745 | if ( ke->key() == Key_Return || | 745 | if ( ke->key() == Key_Return || |
746 | ke->key() == Key_Enter ) { | 746 | ke->key() == Key_Enter ) { |
747 | okRename(); | 747 | okRename(); |
748 | return true; | 748 | return true; |
749 | } | 749 | } |
750 | else if ( ke->key() == Key_Escape ) { | 750 | else if ( ke->key() == Key_Escape ) { |
751 | cancelRename(); | 751 | cancelRename(); |
752 | return true; | 752 | return true; |
753 | } | 753 | } |
754 | } | 754 | } |
755 | else if ( e->type() == QEvent::FocusOut ) { | 755 | else if ( e->type() == QEvent::FocusOut ) { |
756 | cancelRename(); | 756 | cancelRename(); |
757 | return true; | 757 | return true; |
758 | } | 758 | } |
759 | } | 759 | } |
760 | /* if ( o->inherits( "QListView" ) ) { | 760 | if ( o->inherits( "QListView" ) ) { |
761 | if ( e->type() == QEvent::FocusIn ) { | 761 | if ( e->type() == QEvent::FocusIn ) { |
762 | // if( o == Local_View) { //keep track of which view | 762 | if( o == Local_View) { //keep track of which view |
763 | // qDebug("local view"); | 763 | whichTab = 1; |
764 | // whichTab = 1; | 764 | viewMenu->setItemChecked(viewMenu->idAt(0), true); |
765 | // } else { | 765 | viewMenu->setItemChecked(viewMenu->idAt(1), false); |
766 | // whichTab = 2; | 766 | } else { |
767 | // qDebug("remote view"); | 767 | whichTab = 2; |
768 | // } | 768 | viewMenu->setItemChecked(viewMenu->idAt(0), false); |
769 | viewMenu->setItemChecked(viewMenu->idAt(1), true); | ||
770 | } | ||
769 | } | 771 | } |
770 | OtherView()->setSelected( OtherView()->currentItem(), FALSE );//make sure there's correct selection | 772 | OtherView()->setSelected( OtherView()->currentItem(), FALSE );//make sure there's correct selection |
771 | } | 773 | } |
772 | */ | 774 | |
773 | return QWidget::eventFilter( o, e ); | 775 | return QWidget::eventFilter( o, e ); |
774 | } | 776 | } |
775 | 777 | ||
776 | 778 | ||
777 | void AdvancedFm::cancelRename() { | 779 | void AdvancedFm::cancelRename() { |
778 | // odebug << "cancel rename" << oendl; | 780 | // odebug << "cancel rename" << oendl; |
779 | QListView * view; | 781 | QListView * view; |
780 | view = CurrentView(); | 782 | view = CurrentView(); |
781 | 783 | ||
782 | bool resetFocus = view->viewport()->focusProxy() == renameBox; | 784 | bool resetFocus = view->viewport()->focusProxy() == renameBox; |
783 | delete renameBox; | 785 | delete renameBox; |
784 | renameBox = 0; | 786 | renameBox = 0; |
785 | if ( resetFocus ) { | 787 | if ( resetFocus ) { |
786 | view->viewport()->setFocusProxy( view); | 788 | view->viewport()->setFocusProxy( view); |
787 | view->setFocus(); | 789 | view->setFocus(); |
788 | } | 790 | } |
789 | } | 791 | } |
790 | 792 | ||