author | llornkcor <llornkcor> | 2003-09-08 22:22:00 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2003-09-08 22:22:00 (UTC) |
commit | e485a3bd44b3cc70280e03eb8a7958a5252cdd6a (patch) (unidiff) | |
tree | cce07d76c2a9060a774898af46e7c8dc8c7b3403 /noncore/apps/advancedfm/advancedfmMenu.cpp | |
parent | b3299bab3370865e0e498fd2f7f84f3abbd17e77 (diff) | |
download | opie-e485a3bd44b3cc70280e03eb8a7958a5252cdd6a.zip opie-e485a3bd44b3cc70280e03eb8a7958a5252cdd6a.tar.gz opie-e485a3bd44b3cc70280e03eb8a7958a5252cdd6a.tar.bz2 |
changes for osplitter functionality
Diffstat (limited to 'noncore/apps/advancedfm/advancedfmMenu.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/apps/advancedfm/advancedfmMenu.cpp | 317 |
1 files changed, 119 insertions, 198 deletions
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp index 544350c..c0be948 100644 --- a/noncore/apps/advancedfm/advancedfmMenu.cpp +++ b/noncore/apps/advancedfm/advancedfmMenu.cpp | |||
@@ -46,61 +46,50 @@ | |||
46 | #include <fcntl.h> | 46 | #include <fcntl.h> |
47 | 47 | ||
48 | 48 | ||
49 | void AdvancedFm::doDirChange() | 49 | void AdvancedFm::doDirChange() { |
50 | { | 50 | QString pathItem = CurrentView()->currentItem()->text(0); |
51 | if( pathItem == "../") { | ||
51 | ListClicked( CurrentView()->currentItem()); | 52 | ListClicked( CurrentView()->currentItem()); |
53 | } else { | ||
54 | if( pathItem.find(" -> ",0,TRUE) != -1) | ||
55 | pathItem = dealWithSymName((const QString&)pathItem)+"/"; | ||
56 | // qWarning(pathItem); | ||
57 | gotoDirectory( CurrentDir()->path()+"/"+pathItem.left( pathItem.length() - 1) ); | ||
58 | } | ||
52 | } | 59 | } |
53 | 60 | ||
54 | void AdvancedFm::showMenuHidden() | 61 | void AdvancedFm::showMenuHidden() { |
55 | { | 62 | if (b) { |
56 | if (b) | ||
57 | { | ||
58 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 63 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
59 | OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 64 | OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
60 | fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); | 65 | fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); |
61 | // b=FALSE; | 66 | } else { |
62 | |||
63 | } | ||
64 | else | ||
65 | { | ||
66 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 67 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
67 | OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 68 | OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
68 | fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); | 69 | fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); |
69 | // b=TRUE; | ||
70 | } | 70 | } |
71 | rePopulate(); | 71 | rePopulate(); |
72 | // if(b) qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<< true"); | ||
73 | b = !b; | 72 | b = !b; |
74 | } | 73 | } |
75 | 74 | ||
76 | void AdvancedFm::showHidden() | 75 | void AdvancedFm::showHidden() { |
77 | { | 76 | if (b) { |
78 | if (b) | ||
79 | { | ||
80 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 77 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
81 | OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 78 | OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
82 | // fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); | 79 | } else { |
83 | // b=FALSE; | ||
84 | |||
85 | } | ||
86 | else | ||
87 | { | ||
88 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 80 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
89 | OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 81 | OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
90 | // fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); | ||
91 | // b=TRUE; | ||
92 | } | 82 | } |
93 | rePopulate(); | 83 | rePopulate(); |
94 | } | 84 | } |
95 | 85 | ||
96 | QString AdvancedFm::dealWithSymName(const QString &fileName) | 86 | QString AdvancedFm::dealWithSymName(const QString &fileName) { |
97 | { | ||
98 | QString strItem = fileName; | 87 | QString strItem = fileName; |
99 | return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); | 88 | return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); |
100 | } | 89 | } |
101 | 90 | ||
102 | void AdvancedFm::runThis() | 91 | void AdvancedFm::runThis() { |
103 | { | 92 | if( !CurrentView()->currentItem()) return; |
104 | QString fs; | 93 | QString fs; |
105 | QDir *thisDir = CurrentDir(); | 94 | QDir *thisDir = CurrentDir(); |
106 | 95 | ||
@@ -111,12 +100,11 @@ void AdvancedFm::runThis() | |||
111 | 100 | ||
112 | curFile = dealWithSymName((const QString&)curFile); | 101 | curFile = dealWithSymName((const QString&)curFile); |
113 | 102 | ||
114 | if(curFile != "../") | 103 | if(curFile != "../") { |
115 | { | ||
116 | 104 | ||
117 | fs = getFileSystemType((const QString &) path); | 105 | fs = getFileSystemType((const QString &) path); |
118 | QFileInfo fileInfo( path + "/" + curFile); | 106 | QFileInfo fileInfo( path + "/" + curFile); |
119 | qDebug( fileInfo.owner()); | 107 | // qDebug( fileInfo.owner()); |
120 | 108 | ||
121 | if( (fileInfo.permission( QFileInfo::ExeUser) | 109 | if( (fileInfo.permission( QFileInfo::ExeUser) |
122 | | fileInfo.permission( QFileInfo::ExeGroup) | 110 | | fileInfo.permission( QFileInfo::ExeGroup) |
@@ -124,29 +112,23 @@ void AdvancedFm::runThis() | |||
124 | | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { | 112 | | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { |
125 | QCopEnvelope e("QPE/System", "execute(QString)" ); | 113 | QCopEnvelope e("QPE/System", "execute(QString)" ); |
126 | e << curFile; | 114 | e << curFile; |
127 | } | 115 | } else { |
128 | else | ||
129 | { | ||
130 | curFile = path + "/" + curFile; | 116 | curFile = path + "/" + curFile; |
131 | DocLnk nf(curFile); | 117 | DocLnk nf(curFile); |
132 | QString execStr = nf.exec(); | 118 | QString execStr = nf.exec(); |
133 | qDebug( execStr); | 119 | // qDebug( execStr); |
134 | if( execStr.isEmpty() ) | 120 | if( execStr.isEmpty() ) { |
135 | { | 121 | } else { |
136 | } | ||
137 | else | ||
138 | { | ||
139 | nf.execute(); | 122 | nf.execute(); |
140 | } | 123 | } |
141 | } | 124 | } |
142 | } | 125 | } |
143 | } | 126 | } |
144 | 127 | ||
145 | void AdvancedFm::runText() | 128 | void AdvancedFm::runText() { |
146 | { | 129 | if( !CurrentView()->currentItem()) return; |
147 | QString curFile = CurrentView()->currentItem()->text(0); | 130 | QString curFile = CurrentView()->currentItem()->text(0); |
148 | if(curFile != "../") | 131 | if(curFile != "../") { |
149 | { | ||
150 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink | 132 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink |
151 | curFile = dealWithSymName((const QString&)curFile); | 133 | curFile = dealWithSymName((const QString&)curFile); |
152 | curFile = CurrentDir()->canonicalPath()+"/"+curFile; | 134 | curFile = CurrentDir()->canonicalPath()+"/"+curFile; |
@@ -155,13 +137,11 @@ void AdvancedFm::runText() | |||
155 | } | 137 | } |
156 | } | 138 | } |
157 | 139 | ||
158 | void AdvancedFm::makeDir() | 140 | void AdvancedFm::makeDir() { |
159 | { | ||
160 | InputDialog *fileDlg; | 141 | InputDialog *fileDlg; |
161 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); | 142 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); |
162 | fileDlg->exec(); | 143 | fileDlg->exec(); |
163 | if( fileDlg->result() == 1 ) | 144 | if( fileDlg->result() == 1 ) { |
164 | { | ||
165 | QDir *thisDir = CurrentDir(); | 145 | QDir *thisDir = CurrentDir(); |
166 | QString filename = fileDlg->LineEdit1->text(); | 146 | QString filename = fileDlg->LineEdit1->text(); |
167 | thisDir->mkdir( thisDir->canonicalPath()+"/"+filename); | 147 | thisDir->mkdir( thisDir->canonicalPath()+"/"+filename); |
@@ -169,8 +149,7 @@ void AdvancedFm::makeDir() | |||
169 | populateView(); | 149 | populateView(); |
170 | } | 150 | } |
171 | 151 | ||
172 | void AdvancedFm::doDelete() | 152 | void AdvancedFm::doDelete() { |
173 | { | ||
174 | QStringList curFileList = getPath(); | 153 | QStringList curFileList = getPath(); |
175 | bool doMsg=true; | 154 | bool doMsg=true; |
176 | int count = curFileList.count(); | 155 | int count = curFileList.count(); |
@@ -235,12 +214,12 @@ void AdvancedFm::doDelete() | |||
235 | QFile file(f); | 214 | QFile file(f); |
236 | QFileInfo fi(myFile); | 215 | QFileInfo fi(myFile); |
237 | if( fi.fileName().find("../",0,TRUE)==-1) { | 216 | if( fi.fileName().find("../",0,TRUE)==-1) { |
238 | qDebug("remove link files "+myFile); | 217 | // qDebug("remove link files "+myFile); |
239 | 218 | ||
240 | // DocLnk lnk(f); | 219 | // DocLnk lnk(f); |
241 | DocLnk *lnk; | 220 | DocLnk *lnk; |
242 | lnk = new DocLnk(f); | 221 | lnk = new DocLnk(f); |
243 | qDebug("Deleting doclnk " + lnk->linkFile()); | 222 | // qDebug("Deleting doclnk " + lnk->linkFile()); |
244 | if(lnk->isValid()) | 223 | if(lnk->isValid()) |
245 | lnk->removeLinkFile(); | 224 | lnk->removeLinkFile(); |
246 | // delete lnk; | 225 | // delete lnk; |
@@ -252,15 +231,13 @@ void AdvancedFm::doDelete() | |||
252 | populateView(); | 231 | populateView(); |
253 | } | 232 | } |
254 | 233 | ||
255 | void AdvancedFm::filePerms() | 234 | void AdvancedFm::filePerms() { |
256 | { | ||
257 | QStringList curFileList = getPath(); | 235 | QStringList curFileList = getPath(); |
258 | QString filePath; | 236 | QString filePath; |
259 | 237 | ||
260 | filePath = CurrentDir()->canonicalPath()+"/"; | 238 | filePath = CurrentDir()->canonicalPath()+"/"; |
261 | 239 | ||
262 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 240 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
263 | { | ||
264 | filePermissions *filePerm; | 241 | filePermissions *filePerm; |
265 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); | 242 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); |
266 | filePerm->showMaximized(); | 243 | filePerm->showMaximized(); |
@@ -271,8 +248,7 @@ void AdvancedFm::filePerms() | |||
271 | populateView(); | 248 | populateView(); |
272 | } | 249 | } |
273 | 250 | ||
274 | void AdvancedFm::doProperties() | 251 | void AdvancedFm::doProperties() { |
275 | { | ||
276 | #if defined(QT_QWS_OPIE) | 252 | #if defined(QT_QWS_OPIE) |
277 | 253 | ||
278 | QStringList curFileList = getPath(); | 254 | QStringList curFileList = getPath(); |
@@ -280,11 +256,10 @@ void AdvancedFm::doProperties() | |||
280 | QString filePath; | 256 | QString filePath; |
281 | filePath = CurrentDir()->canonicalPath()+"/"; | 257 | filePath = CurrentDir()->canonicalPath()+"/"; |
282 | 258 | ||
283 | qDebug("%d",curFileList.count()); | 259 | // qDebug("%d",curFileList.count()); |
284 | 260 | ||
285 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 261 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
286 | { | 262 | // qDebug((filePath+*it)); |
287 | qDebug((filePath+*it)); | ||
288 | DocLnk lnk( (filePath+*it)); | 263 | DocLnk lnk( (filePath+*it)); |
289 | LnkProperties prop( &lnk ); | 264 | LnkProperties prop( &lnk ); |
290 | prop.showMaximized(); | 265 | prop.showMaximized(); |
@@ -294,8 +269,7 @@ void AdvancedFm::doProperties() | |||
294 | 269 | ||
295 | } | 270 | } |
296 | 271 | ||
297 | void AdvancedFm::upDir() | 272 | void AdvancedFm::upDir() { |
298 | { | ||
299 | QDir *thisDir = CurrentDir(); | 273 | QDir *thisDir = CurrentDir(); |
300 | QString current = thisDir->canonicalPath(); | 274 | QString current = thisDir->canonicalPath(); |
301 | QDir dir(current); | 275 | QDir dir(current); |
@@ -308,8 +282,7 @@ void AdvancedFm::upDir() | |||
308 | update(); | 282 | update(); |
309 | } | 283 | } |
310 | 284 | ||
311 | void AdvancedFm::copy() | 285 | void AdvancedFm::copy() { |
312 | { | ||
313 | qApp->processEvents(); | 286 | qApp->processEvents(); |
314 | QStringList curFileList = getPath(); | 287 | QStringList curFileList = getPath(); |
315 | 288 | ||
@@ -335,8 +308,7 @@ void AdvancedFm::copy() | |||
335 | } | 308 | } |
336 | 309 | ||
337 | QString curFile, item, destFile; | 310 | QString curFile, item, destFile; |
338 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 311 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
339 | { | ||
340 | item=(*it); | 312 | item=(*it); |
341 | if(item.find("->",0,TRUE)) //symlink | 313 | if(item.find("->",0,TRUE)) //symlink |
342 | item = item.left(item.find("->",0,TRUE)); | 314 | item = item.left(item.find("->",0,TRUE)); |
@@ -344,18 +316,15 @@ void AdvancedFm::copy() | |||
344 | curFile = thisDir->canonicalPath()+"/"+ item; | 316 | curFile = thisDir->canonicalPath()+"/"+ item; |
345 | destFile = thatDir->canonicalPath()+"/"+ item; | 317 | destFile = thatDir->canonicalPath()+"/"+ item; |
346 | 318 | ||
347 | qDebug("Destination file is "+destFile); | 319 | // qDebug("Destination file is "+destFile); |
348 | qDebug("CurrentFile file is " + curFile); | 320 | // qDebug("CurrentFile file is " + curFile); |
349 | 321 | ||
350 | QFile f(destFile); | 322 | QFile f(destFile); |
351 | if( f.exists()) | 323 | if( f.exists()) { |
352 | { | 324 | if(doMsg) { |
353 | if(doMsg) | ||
354 | { | ||
355 | switch ( QMessageBox::warning(this,tr("File Exists!"), | 325 | switch ( QMessageBox::warning(this,tr("File Exists!"), |
356 | tr("%1 exists. Ok to overwrite?").arg( item ), | 326 | tr("%1 exists. Ok to overwrite?").arg( item ), |
357 | tr("Yes"),tr("No"),0,0,1) ) | 327 | tr("Yes"),tr("No"),0,0,1) ) { |
358 | { | ||
359 | case 1: | 328 | case 1: |
360 | return; | 329 | return; |
361 | break; | 330 | break; |
@@ -370,13 +339,12 @@ void AdvancedFm::copy() | |||
370 | return; | 339 | return; |
371 | } | 340 | } |
372 | } | 341 | } |
342 | rePopulate(); | ||
373 | setOtherTabCurrent(); | 343 | setOtherTabCurrent(); |
374 | populateView(); | ||
375 | } | 344 | } |
376 | } | 345 | } |
377 | 346 | ||
378 | void AdvancedFm::copyAs() | 347 | void AdvancedFm::copyAs() { |
379 | { | ||
380 | qApp->processEvents(); | 348 | qApp->processEvents(); |
381 | 349 | ||
382 | QStringList curFileList = getPath(); | 350 | QStringList curFileList = getPath(); |
@@ -386,8 +354,7 @@ void AdvancedFm::copyAs() | |||
386 | QDir *thisDir = CurrentDir(); | 354 | QDir *thisDir = CurrentDir(); |
387 | QDir *thatDir = OtherDir(); | 355 | QDir *thatDir = OtherDir(); |
388 | 356 | ||
389 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 357 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
390 | { | ||
391 | QString destFile; | 358 | QString destFile; |
392 | item=(*it); | 359 | item=(*it); |
393 | curFile = thisDir->canonicalPath()+"/"+(*it); | 360 | curFile = thisDir->canonicalPath()+"/"+(*it); |
@@ -396,18 +363,15 @@ void AdvancedFm::copyAs() | |||
396 | fileDlg->setInputText((const QString &) destFile ); | 363 | fileDlg->setInputText((const QString &) destFile ); |
397 | fileDlg->exec(); | 364 | fileDlg->exec(); |
398 | 365 | ||
399 | if( fileDlg->result() == 1 ) | 366 | if( fileDlg->result() == 1 ) { |
400 | { | ||
401 | QString filename = fileDlg->LineEdit1->text(); | 367 | QString filename = fileDlg->LineEdit1->text(); |
402 | destFile = thatDir->canonicalPath()+"/"+filename; | 368 | destFile = thatDir->canonicalPath()+"/"+filename; |
403 | 369 | ||
404 | QFile f( destFile); | 370 | QFile f( destFile); |
405 | if( f.exists()) | 371 | if( f.exists()) { |
406 | { | ||
407 | switch (QMessageBox::warning(this,tr("File Exists!"), | 372 | switch (QMessageBox::warning(this,tr("File Exists!"), |
408 | item+tr("\nexists. Ok to overwrite?"), | 373 | item+tr("\nexists. Ok to overwrite?"), |
409 | tr("Yes"),tr("No"),0,0,1) ) | 374 | tr("Yes"),tr("No"),0,0,1) ) { |
410 | { | ||
411 | case 0: | 375 | case 0: |
412 | f.remove(); | 376 | f.remove(); |
413 | break; | 377 | break; |
@@ -425,12 +389,11 @@ void AdvancedFm::copyAs() | |||
425 | delete fileDlg; | 389 | delete fileDlg; |
426 | 390 | ||
427 | } | 391 | } |
392 | rePopulate(); | ||
428 | setOtherTabCurrent(); | 393 | setOtherTabCurrent(); |
429 | populateView(); | ||
430 | } | 394 | } |
431 | 395 | ||
432 | void AdvancedFm::copySameDir() | 396 | void AdvancedFm::copySameDir() { |
433 | { | ||
434 | qApp->processEvents(); | 397 | qApp->processEvents(); |
435 | QStringList curFileList = getPath(); | 398 | QStringList curFileList = getPath(); |
436 | QString curFile, item, destFile; | 399 | QString curFile, item, destFile; |
@@ -438,8 +401,7 @@ void AdvancedFm::copySameDir() | |||
438 | 401 | ||
439 | QDir *thisDir = CurrentDir(); | 402 | QDir *thisDir = CurrentDir(); |
440 | 403 | ||
441 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 404 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
442 | { | ||
443 | item=(*it); | 405 | item=(*it); |
444 | curFile = thisDir->canonicalPath()+"/"+ item; | 406 | curFile = thisDir->canonicalPath()+"/"+ item; |
445 | 407 | ||
@@ -447,15 +409,13 @@ void AdvancedFm::copySameDir() | |||
447 | fileDlg->setInputText((const QString &) destFile ); | 409 | fileDlg->setInputText((const QString &) destFile ); |
448 | fileDlg->exec(); | 410 | fileDlg->exec(); |
449 | 411 | ||
450 | if( fileDlg->result() == 1 ) | 412 | if( fileDlg->result() == 1 ) { |
451 | { | ||
452 | 413 | ||
453 | QString filename = fileDlg->LineEdit1->text(); | 414 | QString filename = fileDlg->LineEdit1->text(); |
454 | destFile = thisDir->canonicalPath()+"/"+filename; | 415 | destFile = thisDir->canonicalPath()+"/"+filename; |
455 | 416 | ||
456 | QFile f(destFile); | 417 | QFile f(destFile); |
457 | if( f.exists()) | 418 | if( f.exists()) { |
458 | { | ||
459 | switch (QMessageBox::warning(this,tr("Delete"), | 419 | switch (QMessageBox::warning(this,tr("Delete"), |
460 | destFile+tr(" already exists.\nDo you really want to delete it?"), | 420 | destFile+tr(" already exists.\nDo you really want to delete it?"), |
461 | tr("Yes"),tr("No"),0,0,1) ) { | 421 | tr("Yes"),tr("No"),0,0,1) ) { |
@@ -474,39 +434,36 @@ void AdvancedFm::copySameDir() | |||
474 | return; | 434 | return; |
475 | } | 435 | } |
476 | 436 | ||
477 | qDebug("copy "+curFile+" as "+destFile); | 437 | // qDebug("copy "+curFile+" as "+destFile); |
478 | } | 438 | } |
479 | delete fileDlg; | 439 | delete fileDlg; |
480 | } | 440 | } |
481 | populateView(); | 441 | populateView(); |
482 | } | 442 | } |
483 | 443 | ||
484 | void AdvancedFm::move() | 444 | void AdvancedFm::move() { |
485 | { | ||
486 | qApp->processEvents(); | 445 | qApp->processEvents(); |
487 | 446 | ||
488 | QStringList curFileList = getPath(); | 447 | QStringList curFileList = getPath(); |
489 | if( curFileList.count() > 0) | 448 | if( curFileList.count() > 0) { |
490 | { | ||
491 | QString curFile, destFile, item; | 449 | QString curFile, destFile, item; |
492 | 450 | ||
493 | QDir *thisDir = CurrentDir(); | 451 | QDir *thisDir = CurrentDir(); |
494 | QDir *thatDir = OtherDir(); | 452 | QDir *thatDir = OtherDir(); |
495 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 453 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
496 | { | ||
497 | item=(*it); | 454 | item=(*it); |
498 | QString destFile = thatDir->canonicalPath(); | 455 | QString destFile = thatDir->canonicalPath(); |
499 | 456 | ||
500 | if(destFile.right(1).find("/",0,TRUE) == -1) | 457 | if(destFile.right(1).find("/",0,TRUE) == -1) |
501 | destFile+="/"; | 458 | destFile+="/"; |
502 | destFile += item; | 459 | destFile += item; |
503 | qDebug("Destination file is "+destFile); | 460 | // qDebug("Destination file is "+destFile); |
504 | 461 | ||
505 | curFile = thisDir->canonicalPath(); | 462 | curFile = thisDir->canonicalPath(); |
506 | if(curFile.right(1).find("/",0,TRUE) == -1) | 463 | if(curFile.right(1).find("/",0,TRUE) == -1) |
507 | curFile +="/"; | 464 | curFile +="/"; |
508 | curFile+= item; | 465 | curFile+= item; |
509 | qDebug("CurrentFile file is " + curFile); | 466 | // qDebug("CurrentFile file is " + curFile); |
510 | 467 | ||
511 | QFile f( curFile); | 468 | QFile f( curFile); |
512 | if( f.exists()) { | 469 | if( f.exists()) { |
@@ -519,13 +476,11 @@ void AdvancedFm::move() | |||
519 | } | 476 | } |
520 | 477 | ||
521 | } | 478 | } |
522 | populateView(); | 479 | rePopulate(); |
523 | setOtherTabCurrent(); | 480 | setOtherTabCurrent(); |
524 | populateView(); | ||
525 | } | 481 | } |
526 | 482 | ||
527 | bool AdvancedFm::copyFile( const QString & src, const QString & dest ) | 483 | bool AdvancedFm::copyFile( const QString & src, const QString & dest ) { |
528 | { | ||
529 | bool success = true; | 484 | bool success = true; |
530 | struct stat status; | 485 | struct stat status; |
531 | QFile srcFile(src); | 486 | QFile srcFile(src); |
@@ -536,14 +491,14 @@ bool AdvancedFm::copyFile( const QString & src, const QString & dest ) | |||
536 | struct stat stat_buf; | 491 | struct stat stat_buf; |
537 | off_t offset = 0; | 492 | off_t offset = 0; |
538 | if(!srcFile.open( IO_ReadOnly|IO_Raw)) { | 493 | if(!srcFile.open( IO_ReadOnly|IO_Raw)) { |
539 | qWarning("open failed"); | 494 | // qWarning("open failed"); |
540 | return success = false; | 495 | return success = false; |
541 | } | 496 | } |
542 | read_fd = srcFile.handle(); | 497 | read_fd = srcFile.handle(); |
543 | if(read_fd != -1) { | 498 | if(read_fd != -1) { |
544 | fstat (read_fd, &stat_buf); | 499 | fstat (read_fd, &stat_buf); |
545 | if( !destFile.open( IO_WriteOnly|IO_Raw ) ) { | 500 | if( !destFile.open( IO_WriteOnly|IO_Raw ) ) { |
546 | qWarning("destfile open failed"); | 501 | // qWarning("destfile open failed"); |
547 | return success = false; | 502 | return success = false; |
548 | } | 503 | } |
549 | write_fd = destFile.handle(); | 504 | write_fd = destFile.handle(); |
@@ -558,7 +513,7 @@ bool AdvancedFm::copyFile( const QString & src, const QString & dest ) | |||
558 | case EIO: msg = "Unspecified error while reading from in_fd."; | 513 | case EIO: msg = "Unspecified error while reading from in_fd."; |
559 | }; | 514 | }; |
560 | success = false; | 515 | success = false; |
561 | qWarning(msg); | 516 | // qWarning(msg); |
562 | } | 517 | } |
563 | } else { | 518 | } else { |
564 | success = false; | 519 | success = false; |
@@ -576,8 +531,8 @@ bool AdvancedFm::copyFile( const QString & src, const QString & dest ) | |||
576 | return success; | 531 | return success; |
577 | } | 532 | } |
578 | 533 | ||
579 | void AdvancedFm::runCommand() | 534 | void AdvancedFm::runCommand() { |
580 | { | 535 | if( !CurrentView()->currentItem()) return; |
581 | QDir *thisDir = CurrentDir(); | 536 | QDir *thisDir = CurrentDir(); |
582 | 537 | ||
583 | QString curFile; | 538 | QString curFile; |
@@ -589,9 +544,8 @@ void AdvancedFm::runCommand() | |||
589 | fileDlg->exec(); | 544 | fileDlg->exec(); |
590 | //QString command; | 545 | //QString command; |
591 | 546 | ||
592 | if( fileDlg->result() == 1 ) | 547 | if( fileDlg->result() == 1 ) { |
593 | { | 548 | // qDebug(fileDlg->LineEdit1->text()); |
594 | qDebug(fileDlg->LineEdit1->text()); | ||
595 | QStringList command; | 549 | QStringList command; |
596 | 550 | ||
597 | command << "/bin/sh"; | 551 | command << "/bin/sh"; |
@@ -606,8 +560,8 @@ void AdvancedFm::runCommand() | |||
606 | } | 560 | } |
607 | } | 561 | } |
608 | 562 | ||
609 | void AdvancedFm::runCommandStd() | 563 | void AdvancedFm::runCommandStd() { |
610 | { | 564 | if( !CurrentView()->currentItem()) return; |
611 | QString curFile; | 565 | QString curFile; |
612 | QDir *thisDir = CurrentDir(); | 566 | QDir *thisDir = CurrentDir(); |
613 | QListView *thisView = CurrentView(); | 567 | QListView *thisView = CurrentView(); |
@@ -619,15 +573,14 @@ void AdvancedFm::runCommandStd() | |||
619 | fileDlg->setInputText(curFile); | 573 | fileDlg->setInputText(curFile); |
620 | fileDlg->exec(); | 574 | fileDlg->exec(); |
621 | 575 | ||
622 | if( fileDlg->result() == 1 ) | 576 | if( fileDlg->result() == 1 ) { |
623 | { | ||
624 | qApp->processEvents(); | 577 | qApp->processEvents(); |
625 | startProcess( (const QString)fileDlg->LineEdit1->text().latin1()); | 578 | startProcess( (const QString)fileDlg->LineEdit1->text().latin1()); |
626 | } | 579 | } |
627 | } | 580 | } |
628 | 581 | ||
629 | void AdvancedFm::fileStatus() | 582 | void AdvancedFm::fileStatus() { |
630 | { | 583 | if( !CurrentView()->currentItem()) return; |
631 | QString curFile; | 584 | QString curFile; |
632 | curFile = CurrentView()->currentItem()->text(0); | 585 | curFile = CurrentView()->currentItem()->text(0); |
633 | 586 | ||
@@ -644,57 +597,48 @@ void AdvancedFm::fileStatus() | |||
644 | } | 597 | } |
645 | 598 | ||
646 | 599 | ||
647 | void AdvancedFm::mkDir() | 600 | void AdvancedFm::mkDir() { |
648 | { | ||
649 | makeDir(); | 601 | makeDir(); |
650 | } | 602 | } |
651 | 603 | ||
652 | void AdvancedFm::rn() | 604 | void AdvancedFm::rn() { |
653 | { | ||
654 | renameIt(); | 605 | renameIt(); |
655 | } | 606 | } |
656 | 607 | ||
657 | void AdvancedFm::del() | 608 | void AdvancedFm::del() { |
658 | { | ||
659 | doDelete(); | 609 | doDelete(); |
660 | } | 610 | } |
661 | 611 | ||
662 | void AdvancedFm::mkSym() | 612 | void AdvancedFm::mkSym() { |
663 | { | ||
664 | QString cmd; | 613 | QString cmd; |
665 | QStringList curFileList = getPath(); | 614 | QStringList curFileList = getPath(); |
666 | if( curFileList.count() > 0) | 615 | if( curFileList.count() > 0) { |
667 | { | ||
668 | QDir *thisDir = CurrentDir(); | 616 | QDir *thisDir = CurrentDir(); |
669 | QDir * thatDir = OtherDir(); | 617 | QDir * thatDir = OtherDir(); |
670 | 618 | ||
671 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 619 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
672 | { | ||
673 | 620 | ||
674 | QString destName = thatDir->canonicalPath()+"/"+(*it); | 621 | QString destName = thatDir->canonicalPath()+"/"+(*it); |
675 | if(destName.right(1) == "/") | 622 | if(destName.right(1) == "/") { |
676 | { | ||
677 | destName = destName.left( destName.length() -1); | 623 | destName = destName.left( destName.length() -1); |
678 | } | 624 | } |
679 | 625 | ||
680 | QString curFile = thisDir->canonicalPath()+"/"+(*it); | 626 | QString curFile = thisDir->canonicalPath()+"/"+(*it); |
681 | 627 | ||
682 | if( curFile.right(1) == "/") | 628 | if( curFile.right(1) == "/") { |
683 | { | ||
684 | curFile = curFile.left( curFile.length() -1); | 629 | curFile = curFile.left( curFile.length() -1); |
685 | } | 630 | } |
686 | 631 | ||
687 | cmd = "ln -s "+curFile+" "+destName; | 632 | cmd = "ln -s "+curFile+" "+destName; |
688 | qDebug(cmd); | 633 | // qDebug(cmd); |
689 | startProcess( (const QString)cmd ); | 634 | startProcess( (const QString)cmd ); |
690 | } | 635 | } |
636 | rePopulate(); | ||
691 | setOtherTabCurrent(); | 637 | setOtherTabCurrent(); |
692 | populateView(); | ||
693 | } | 638 | } |
694 | } | 639 | } |
695 | 640 | ||
696 | void AdvancedFm::doBeam() | 641 | void AdvancedFm::doBeam() { |
697 | { | ||
698 | Ir ir; | 642 | Ir ir; |
699 | if(!ir.supported()) { | 643 | if(!ir.supported()) { |
700 | } else { | 644 | } else { |
@@ -714,25 +658,17 @@ void AdvancedFm::doBeam() | |||
714 | } | 658 | } |
715 | } | 659 | } |
716 | 660 | ||
717 | void AdvancedFm::fileBeamFinished( Ir *) | 661 | void AdvancedFm::fileBeamFinished( Ir *) { |
718 | { | ||
719 | QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); | 662 | QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); |
720 | } | 663 | } |
721 | 664 | ||
722 | void AdvancedFm::selectAll() | 665 | void AdvancedFm::selectAll() { |
723 | { | ||
724 | // if (TabWidget->currentTab() == 0) { | ||
725 | QListView *thisView = CurrentView(); | 666 | QListView *thisView = CurrentView(); |
726 | thisView->selectAll(true); | 667 | thisView->selectAll(true); |
727 | thisView->setSelected( thisView->firstChild(),false); | 668 | thisView->setSelected( thisView->firstChild(),false); |
728 | // } else { | ||
729 | // Remote_View->selectAll(true); | ||
730 | // Remote_View->setSelected( Remote_View->firstChild(),false); | ||
731 | // } | ||
732 | } | 669 | } |
733 | 670 | ||
734 | void AdvancedFm::startProcess(const QString & cmd) | 671 | void AdvancedFm::startProcess(const QString & cmd) { |
735 | { | ||
736 | QStringList command; | 672 | QStringList command; |
737 | OProcess *process; | 673 | OProcess *process; |
738 | process = new OProcess(); | 674 | process = new OProcess(); |
@@ -750,79 +686,68 @@ void AdvancedFm::startProcess(const QString & cmd) | |||
750 | qDebug("could not start process"); | 686 | qDebug("could not start process"); |
751 | } | 687 | } |
752 | 688 | ||
753 | void AdvancedFm::processEnded(OProcess *) | 689 | void AdvancedFm::processEnded(OProcess *) { |
754 | { | ||
755 | // populateLocalView(); | ||
756 | populateView(); | 690 | populateView(); |
757 | } | 691 | } |
758 | 692 | ||
759 | void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int buflen) { | 693 | void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int ) { |
760 | qWarning("received stderrt %d bytes", buflen); | 694 | // qWarning("received stderrt %d bytes", buflen); |
761 | 695 | ||
762 | QString lineStr = buffer; | 696 | QString lineStr = buffer; |
763 | // lineStr=lineStr.left(lineStr.length()-1); | ||
764 | QMessageBox::warning( this, tr("Error"), lineStr ,tr("Ok") ); | 697 | QMessageBox::warning( this, tr("Error"), lineStr ,tr("Ok") ); |
765 | |||
766 | // OutputEdit->append(lineStr); | ||
767 | // OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); | ||
768 | } | 698 | } |
769 | 699 | ||
770 | bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) | 700 | bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) { |
771 | { | 701 | if ( o->inherits( "QLineEdit" ) ) { |
772 | if ( o->inherits( "QLineEdit" ) ) | 702 | if ( e->type() == QEvent::KeyPress ) { |
773 | { | ||
774 | if ( e->type() == QEvent::KeyPress ) | ||
775 | { | ||
776 | QKeyEvent *ke = (QKeyEvent*)e; | 703 | QKeyEvent *ke = (QKeyEvent*)e; |
777 | if ( ke->key() == Key_Return || | 704 | if ( ke->key() == Key_Return || |
778 | ke->key() == Key_Enter ) | 705 | ke->key() == Key_Enter ) { |
779 | { | ||
780 | okRename(); | 706 | okRename(); |
781 | return true; | 707 | return true; |
782 | } | 708 | } |
783 | else if ( ke->key() == Key_Escape ) | 709 | else if ( ke->key() == Key_Escape ) { |
784 | { | ||
785 | cancelRename(); | 710 | cancelRename(); |
786 | return true; | 711 | return true; |
787 | } | 712 | } |
788 | } | 713 | } |
789 | else if ( e->type() == QEvent::FocusOut ) | 714 | else if ( e->type() == QEvent::FocusOut ) { |
790 | { | ||
791 | cancelRename(); | 715 | cancelRename(); |
792 | return true; | 716 | return true; |
793 | } | 717 | } |
794 | } | 718 | } |
795 | if ( o->inherits( "QListView" ) ) | 719 | if ( o->inherits( "QListView" ) ) { |
796 | { | 720 | if ( e->type() == QEvent::FocusIn ) { |
797 | if ( e->type() == QEvent::FocusOut ) | 721 | if( o == Local_View) { //keep track of which view |
798 | { | 722 | whichTab=1; |
799 | printf("focusIn\n"); | ||
800 | |||
801 | } | 723 | } |
724 | else { | ||
725 | whichTab=2; | ||
726 | } | ||
727 | } | ||
728 | OtherView()->setSelected( OtherView()->currentItem(), FALSE );//make sure there's correct selection | ||
802 | } | 729 | } |
803 | 730 | ||
804 | return QWidget::eventFilter( o, e ); | 731 | return QWidget::eventFilter( o, e ); |
805 | } | 732 | } |
806 | 733 | ||
807 | 734 | ||
808 | void AdvancedFm::cancelRename() | 735 | void AdvancedFm::cancelRename() { |
809 | { | 736 | // qDebug("cancel rename"); |
810 | qDebug("cancel rename"); | ||
811 | QListView * view; | 737 | QListView * view; |
812 | view = CurrentView(); | 738 | view = CurrentView(); |
813 | 739 | ||
814 | bool resetFocus = view->viewport()->focusProxy() == renameBox; | 740 | bool resetFocus = view->viewport()->focusProxy() == renameBox; |
815 | delete renameBox; | 741 | delete renameBox; |
816 | renameBox = 0; | 742 | renameBox = 0; |
817 | if ( resetFocus ) | 743 | if ( resetFocus ) { |
818 | { | ||
819 | view->viewport()->setFocusProxy( view); | 744 | view->viewport()->setFocusProxy( view); |
820 | view->setFocus(); | 745 | view->setFocus(); |
821 | } | 746 | } |
822 | } | 747 | } |
823 | 748 | ||
824 | void AdvancedFm::doRename(QListView * view) | 749 | void AdvancedFm::doRename(QListView * view) { |
825 | { | 750 | if( !CurrentView()->currentItem()) return; |
826 | 751 | ||
827 | QRect r = view->itemRect( view->currentItem( )); | 752 | QRect r = view->itemRect( view->currentItem( )); |
828 | r = QRect( view->viewportToContents( r.topLeft() ), r.size() ); | 753 | r = QRect( view->viewportToContents( r.topLeft() ), r.size() ); |
@@ -842,30 +767,26 @@ void AdvancedFm::doRename(QListView * view) | |||
842 | view->viewport()->setFocusProxy( renameBox ); | 767 | view->viewport()->setFocusProxy( renameBox ); |
843 | renameBox->setFocus(); | 768 | renameBox->setFocus(); |
844 | renameBox->show(); | 769 | renameBox->show(); |
845 | |||
846 | } | 770 | } |
847 | 771 | ||
848 | 772 | ||
849 | void AdvancedFm::renameIt() | 773 | void AdvancedFm::renameIt() { |
850 | { | 774 | if( !CurrentView()->currentItem()) return; |
851 | QListView *thisView = CurrentView(); | 775 | QListView *thisView = CurrentView(); |
852 | oldName = thisView->currentItem()->text(0); | 776 | oldName = thisView->currentItem()->text(0); |
853 | doRename( thisView ); | 777 | doRename( thisView ); |
854 | populateView(); | 778 | populateView(); |
855 | } | 779 | } |
856 | 780 | ||
857 | void AdvancedFm::okRename() | 781 | void AdvancedFm::okRename() { |
858 | { | 782 | if( !CurrentView()->currentItem()) return; |
859 | QString newName = renameBox->text(); | 783 | QString newName = renameBox->text(); |
860 | cancelRename(); | 784 | cancelRename(); |
861 | // int tabs=0; | ||
862 | QListView * view = CurrentView(); | 785 | QListView * view = CurrentView(); |
863 | QString path = CurrentDir()->canonicalPath() + "/"; | 786 | QString path = CurrentDir()->canonicalPath() + "/"; |
864 | oldName = path + oldName; | 787 | oldName = path + oldName; |
865 | newName = path + newName; | 788 | newName = path + newName; |
866 | 789 | ||
867 | if( view->currentItem() == NULL) | ||
868 | return; | ||
869 | if( rename( oldName.latin1(), newName.latin1())== -1) | 790 | if( rename( oldName.latin1(), newName.latin1())== -1) |
870 | QMessageBox::message(tr("Note"),tr("Could not rename")); | 791 | QMessageBox::message(tr("Note"),tr("Could not rename")); |
871 | else | 792 | else |
@@ -877,5 +798,5 @@ void AdvancedFm::okRename() | |||
877 | } | 798 | } |
878 | 799 | ||
879 | void AdvancedFm::openSearch() { | 800 | void AdvancedFm::openSearch() { |
880 | 801 | QMessageBox::message(tr("Note"),tr("Not Yet Implemented")); | |
881 | } | 802 | } |