Diffstat (limited to 'noncore/apps/advancedfm/advancedfmMenu.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/advancedfm/advancedfmMenu.cpp | 591 |
1 files changed, 256 insertions, 335 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 | |||
@@ -48,11 +48,16 @@ | |||
48 | 48 | ||
49 | void AdvancedFm::doDirChange() | 49 | void AdvancedFm::doDirChange() { |
50 | { | 50 | QString pathItem = CurrentView()->currentItem()->text(0); |
51 | ListClicked( CurrentView()->currentItem()); | 51 | if( pathItem == "../") { |
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); |
@@ -60,7 +65,3 @@ void AdvancedFm::showMenuHidden() | |||
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); |
@@ -68,6 +69,4 @@ void AdvancedFm::showMenuHidden() | |||
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; |
@@ -75,18 +74,9 @@ void AdvancedFm::showMenuHidden() | |||
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 | } |
@@ -95,10 +85,9 @@ void AdvancedFm::showHidden() | |||
95 | 85 | ||
96 | QString AdvancedFm::dealWithSymName(const QString &fileName) | 86 | QString AdvancedFm::dealWithSymName(const QString &fileName) { |
97 | { | 87 | QString strItem = fileName; |
98 | QString strItem = fileName; | 88 | return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); |
99 | 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; |
@@ -113,4 +102,3 @@ void AdvancedFm::runThis() | |||
113 | 102 | ||
114 | if(curFile != "../") | 103 | if(curFile != "../") { |
115 | { | ||
116 | 104 | ||
@@ -118,3 +106,3 @@ void AdvancedFm::runThis() | |||
118 | QFileInfo fileInfo( path + "/" + curFile); | 106 | QFileInfo fileInfo( path + "/" + curFile); |
119 | qDebug( fileInfo.owner()); | 107 | // qDebug( fileInfo.owner()); |
120 | 108 | ||
@@ -126,5 +114,3 @@ void AdvancedFm::runThis() | |||
126 | e << curFile; | 114 | e << curFile; |
127 | } | 115 | } else { |
128 | else | ||
129 | { | ||
130 | curFile = path + "/" + curFile; | 116 | curFile = path + "/" + curFile; |
@@ -132,8 +118,5 @@ void AdvancedFm::runThis() | |||
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(); |
@@ -144,7 +127,6 @@ void AdvancedFm::runThis() | |||
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 |
@@ -157,4 +139,3 @@ void AdvancedFm::runText() | |||
157 | 139 | ||
158 | void AdvancedFm::makeDir() | 140 | void AdvancedFm::makeDir() { |
159 | { | ||
160 | InputDialog *fileDlg; | 141 | InputDialog *fileDlg; |
@@ -162,4 +143,3 @@ void AdvancedFm::makeDir() | |||
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(); |
@@ -171,4 +151,3 @@ void AdvancedFm::makeDir() | |||
171 | 151 | ||
172 | void AdvancedFm::doDelete() | 152 | void AdvancedFm::doDelete() { |
173 | { | ||
174 | QStringList curFileList = getPath(); | 153 | QStringList curFileList = getPath(); |
@@ -237,3 +216,3 @@ void AdvancedFm::doDelete() | |||
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 | ||
@@ -242,3 +221,3 @@ void AdvancedFm::doDelete() | |||
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()) |
@@ -254,11 +233,9 @@ void AdvancedFm::doDelete() | |||
254 | 233 | ||
255 | void AdvancedFm::filePerms() | 234 | void AdvancedFm::filePerms() { |
256 | { | 235 | QStringList curFileList = getPath(); |
257 | QStringList curFileList = getPath(); | 236 | QString filePath; |
258 | 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; |
@@ -268,26 +245,24 @@ void AdvancedFm::filePerms() | |||
268 | if( filePerm) | 245 | if( filePerm) |
269 | delete filePerm; | 246 | delete filePerm; |
270 | } | 247 | } |
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(); |
279 | 255 | ||
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)); | 263 | DocLnk lnk( (filePath+*it)); |
288 | DocLnk lnk( (filePath+*it)); | 264 | LnkProperties prop( &lnk ); |
289 | LnkProperties prop( &lnk ); | 265 | prop.showMaximized(); |
290 | prop.showMaximized(); | 266 | prop.exec(); |
291 | prop.exec(); | 267 | } |
292 | } | ||
293 | #endif | 268 | #endif |
@@ -296,4 +271,3 @@ void AdvancedFm::doProperties() | |||
296 | 271 | ||
297 | void AdvancedFm::upDir() | 272 | void AdvancedFm::upDir() { |
298 | { | ||
299 | QDir *thisDir = CurrentDir(); | 273 | QDir *thisDir = CurrentDir(); |
@@ -310,59 +284,54 @@ void AdvancedFm::upDir() | |||
310 | 284 | ||
311 | void AdvancedFm::copy() | 285 | void AdvancedFm::copy() { |
312 | { | 286 | qApp->processEvents(); |
313 | qApp->processEvents(); | 287 | QStringList curFileList = getPath(); |
314 | QStringList curFileList = getPath(); | ||
315 | 288 | ||
316 | QDir *thisDir = CurrentDir(); | 289 | QDir *thisDir = CurrentDir(); |
317 | QDir *thatDir = OtherDir(); | 290 | QDir *thatDir = OtherDir(); |
318 | |||
319 | bool doMsg=true; | ||
320 | int count=curFileList.count(); | ||
321 | if( count > 0) { | ||
322 | if(count > 1 ){ | ||
323 | QString msg; | ||
324 | msg=tr("Really copy\n%1 files?").arg(count); | ||
325 | switch ( QMessageBox::warning(this,tr("Copy"),msg | ||
326 | ,tr("Yes"),tr("No"),0,0,1) ) | ||
327 | { | ||
328 | case 0: | ||
329 | doMsg=false; | ||
330 | break; | ||
331 | case 1: | ||
332 | return; | ||
333 | break; | ||
334 | }; | ||
335 | } | ||
336 | 291 | ||
337 | QString curFile, item, destFile; | 292 | bool doMsg=true; |
338 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 293 | int count=curFileList.count(); |
339 | { | 294 | if( count > 0) { |
340 | item=(*it); | 295 | if(count > 1 ){ |
341 | if(item.find("->",0,TRUE)) //symlink | 296 | QString msg; |
342 | item = item.left(item.find("->",0,TRUE)); | 297 | msg=tr("Really copy\n%1 files?").arg(count); |
343 | 298 | switch ( QMessageBox::warning(this,tr("Copy"),msg | |
344 | curFile = thisDir->canonicalPath()+"/"+ item; | 299 | ,tr("Yes"),tr("No"),0,0,1) ) |
345 | destFile = thatDir->canonicalPath()+"/"+ item; | 300 | { |
346 | 301 | case 0: | |
347 | qDebug("Destination file is "+destFile); | 302 | doMsg=false; |
348 | qDebug("CurrentFile file is " + curFile); | 303 | break; |
349 | 304 | case 1: | |
350 | QFile f(destFile); | 305 | return; |
351 | if( f.exists()) | 306 | break; |
352 | { | 307 | }; |
353 | if(doMsg) | 308 | } |
354 | { | 309 | |
355 | switch ( QMessageBox::warning(this,tr("File Exists!"), | 310 | QString curFile, item, destFile; |
356 | tr("%1 exists. Ok to overwrite?").arg( item ), | 311 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
357 | tr("Yes"),tr("No"),0,0,1) ) | 312 | item=(*it); |
358 | { | 313 | if(item.find("->",0,TRUE)) //symlink |
359 | case 1: | 314 | item = item.left(item.find("->",0,TRUE)); |
360 | return; | 315 | |
361 | break; | 316 | curFile = thisDir->canonicalPath()+"/"+ item; |
362 | }; | 317 | destFile = thatDir->canonicalPath()+"/"+ item; |
363 | } | 318 | |
319 | // qDebug("Destination file is "+destFile); | ||
320 | // qDebug("CurrentFile file is " + curFile); | ||
321 | |||
322 | QFile f(destFile); | ||
323 | if( f.exists()) { | ||
324 | if(doMsg) { | ||
325 | switch ( QMessageBox::warning(this,tr("File Exists!"), | ||
326 | tr("%1 exists. Ok to overwrite?").arg( item ), | ||
327 | tr("Yes"),tr("No"),0,0,1) ) { | ||
328 | case 1: | ||
329 | return; | ||
330 | break; | ||
331 | }; | ||
332 | } | ||
364 | f.remove(); | 333 | f.remove(); |
365 | } | 334 | } |
366 | 335 | ||
367 | if( !copyFile( curFile, destFile) ) { | 336 | if( !copyFile( curFile, destFile) ) { |
368 | QMessageBox::message("AdvancedFm", | 337 | QMessageBox::message("AdvancedFm", |
@@ -370,6 +339,6 @@ void AdvancedFm::copy() | |||
370 | return; | 339 | return; |
371 | } | 340 | } |
372 | } | 341 | } |
373 | setOtherTabCurrent(); | 342 | rePopulate(); |
374 | populateView(); | 343 | setOtherTabCurrent(); |
375 | } | 344 | } |
@@ -377,15 +346,13 @@ void AdvancedFm::copy() | |||
377 | 346 | ||
378 | void AdvancedFm::copyAs() | 347 | void AdvancedFm::copyAs() { |
379 | { | 348 | qApp->processEvents(); |
380 | qApp->processEvents(); | ||
381 | 349 | ||
382 | QStringList curFileList = getPath(); | 350 | QStringList curFileList = getPath(); |
383 | QString curFile, item; | 351 | QString curFile, item; |
384 | InputDialog *fileDlg; | 352 | InputDialog *fileDlg; |
385 | 353 | ||
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; |
@@ -398,37 +365,33 @@ void AdvancedFm::copyAs() | |||
398 | 365 | ||
399 | if( fileDlg->result() == 1 ) | 366 | if( fileDlg->result() == 1 ) { |
400 | { | 367 | QString filename = fileDlg->LineEdit1->text(); |
401 | QString filename = fileDlg->LineEdit1->text(); | 368 | destFile = thatDir->canonicalPath()+"/"+filename; |
402 | destFile = thatDir->canonicalPath()+"/"+filename; | ||
403 | 369 | ||
404 | QFile f( destFile); | 370 | QFile f( destFile); |
405 | if( f.exists()) | 371 | if( f.exists()) { |
406 | { | 372 | switch (QMessageBox::warning(this,tr("File Exists!"), |
407 | switch (QMessageBox::warning(this,tr("File Exists!"), | 373 | item+tr("\nexists. Ok to overwrite?"), |
408 | item+tr("\nexists. Ok to overwrite?"), | 374 | tr("Yes"),tr("No"),0,0,1) ) { |
409 | tr("Yes"),tr("No"),0,0,1) ) | 375 | case 0: |
410 | { | 376 | f.remove(); |
411 | case 0: | 377 | break; |
412 | f.remove(); | 378 | case 1: |
413 | break; | 379 | return; |
414 | case 1: | 380 | break; |
415 | return; | 381 | }; |
416 | break; | 382 | } |
417 | }; | 383 | if( !copyFile( curFile, destFile) ) { |
418 | } | 384 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") |
419 | if( !copyFile( curFile, destFile) ) { | 385 | +curFile +tr("to\n")+destFile); |
420 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") | 386 | return; |
421 | +curFile +tr("to\n")+destFile); | 387 | } |
422 | return; | 388 | } |
423 | } | ||
424 | } | ||
425 | delete fileDlg; | 389 | delete fileDlg; |
426 | 390 | ||
427 | } | 391 | } |
428 | setOtherTabCurrent(); | 392 | rePopulate(); |
429 | populateView(); | 393 | setOtherTabCurrent(); |
430 | } | 394 | } |
431 | 395 | ||
432 | void AdvancedFm::copySameDir() | 396 | void AdvancedFm::copySameDir() { |
433 | { | ||
434 | qApp->processEvents(); | 397 | qApp->processEvents(); |
@@ -440,4 +403,3 @@ void AdvancedFm::copySameDir() | |||
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); |
@@ -449,4 +411,3 @@ void AdvancedFm::copySameDir() | |||
449 | 411 | ||
450 | if( fileDlg->result() == 1 ) | 412 | if( fileDlg->result() == 1 ) { |
451 | { | ||
452 | 413 | ||
@@ -456,4 +417,3 @@ void AdvancedFm::copySameDir() | |||
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"), |
@@ -476,3 +436,3 @@ void AdvancedFm::copySameDir() | |||
476 | 436 | ||
477 | qDebug("copy "+curFile+" as "+destFile); | 437 | // qDebug("copy "+curFile+" as "+destFile); |
478 | } | 438 | } |
@@ -483,4 +443,3 @@ void AdvancedFm::copySameDir() | |||
483 | 443 | ||
484 | void AdvancedFm::move() | 444 | void AdvancedFm::move() { |
485 | { | ||
486 | qApp->processEvents(); | 445 | qApp->processEvents(); |
@@ -488,4 +447,3 @@ void AdvancedFm::move() | |||
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; |
@@ -494,4 +452,3 @@ void AdvancedFm::move() | |||
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); |
@@ -502,3 +459,3 @@ void AdvancedFm::move() | |||
502 | destFile += item; | 459 | destFile += item; |
503 | qDebug("Destination file is "+destFile); | 460 | // qDebug("Destination file is "+destFile); |
504 | 461 | ||
@@ -508,3 +465,3 @@ void AdvancedFm::move() | |||
508 | curFile+= item; | 465 | curFile+= item; |
509 | qDebug("CurrentFile file is " + curFile); | 466 | // qDebug("CurrentFile file is " + curFile); |
510 | 467 | ||
@@ -520,10 +477,8 @@ void AdvancedFm::move() | |||
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; |
@@ -538,3 +493,3 @@ bool AdvancedFm::copyFile( const QString & src, const QString & dest ) | |||
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; |
@@ -545,3 +500,3 @@ bool AdvancedFm::copyFile( const QString & src, const QString & dest ) | |||
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; |
@@ -550,3 +505,3 @@ bool AdvancedFm::copyFile( const QString & src, const QString & dest ) | |||
550 | if(write_fd != -1) { | 505 | if(write_fd != -1) { |
551 | err =sendfile(write_fd, read_fd, &offset, stat_buf.st_size); | 506 | err = sendfile(write_fd, read_fd, &offset, stat_buf.st_size); |
552 | if( err == -1) { | 507 | if( err == -1) { |
@@ -560,3 +515,3 @@ bool AdvancedFm::copyFile( const QString & src, const QString & dest ) | |||
560 | success = false; | 515 | success = false; |
561 | qWarning(msg); | 516 | // qWarning(msg); |
562 | } | 517 | } |
@@ -578,18 +533,17 @@ bool AdvancedFm::copyFile( const QString & src, const QString & dest ) | |||
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; |
584 | curFile = thisDir->canonicalPath() +"/"+ CurrentView()->currentItem()->text(0); | 539 | curFile = thisDir->canonicalPath() +"/"+ CurrentView()->currentItem()->text(0); |
585 | 540 | ||
586 | InputDialog *fileDlg; | 541 | InputDialog *fileDlg; |
587 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | 542 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); |
588 | fileDlg->setInputText(curFile); | 543 | fileDlg->setInputText(curFile); |
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; |
@@ -605,40 +559,39 @@ void AdvancedFm::runCommand() | |||
605 | 559 | ||
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(); |
614 | if( thisView->currentItem()) | 568 | if( thisView->currentItem()) |
615 | curFile = thisDir->canonicalPath() +"/"+ thisView->currentItem()->text(0); | 569 | curFile = thisDir->canonicalPath() +"/"+ thisView->currentItem()->text(0); |
616 | 570 | ||
617 | InputDialog *fileDlg; | 571 | InputDialog *fileDlg; |
618 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | 572 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); |
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 | ||
634 | QStringList command; | 587 | QStringList command; |
635 | command << "/bin/sh"; | 588 | command << "/bin/sh"; |
636 | command << "-c"; | 589 | command << "-c"; |
637 | command << "stat -l "+ curFile; | 590 | command << "stat -l "+ curFile; |
638 | 591 | ||
639 | Output *outDlg; | 592 | Output *outDlg; |
640 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); | 593 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); |
641 | outDlg->showMaximized(); | 594 | outDlg->showMaximized(); |
642 | outDlg->exec(); | 595 | outDlg->exec(); |
643 | qApp->processEvents(); | 596 | qApp->processEvents(); |
644 | } | 597 | } |
@@ -646,4 +599,3 @@ void AdvancedFm::fileStatus() | |||
646 | 599 | ||
647 | void AdvancedFm::mkDir() | 600 | void AdvancedFm::mkDir() { |
648 | { | ||
649 | makeDir(); | 601 | makeDir(); |
@@ -651,4 +603,3 @@ void AdvancedFm::mkDir() | |||
651 | 603 | ||
652 | void AdvancedFm::rn() | 604 | void AdvancedFm::rn() { |
653 | { | ||
654 | renameIt(); | 605 | renameIt(); |
@@ -656,4 +607,3 @@ void AdvancedFm::rn() | |||
656 | 607 | ||
657 | void AdvancedFm::del() | 608 | void AdvancedFm::del() { |
658 | { | ||
659 | doDelete(); | 609 | doDelete(); |
@@ -661,8 +611,6 @@ void AdvancedFm::del() | |||
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(); |
@@ -670,8 +618,6 @@ void AdvancedFm::mkSym() | |||
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); |
@@ -681,4 +627,3 @@ void AdvancedFm::mkSym() | |||
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); |
@@ -687,7 +632,7 @@ void AdvancedFm::mkSym() | |||
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 | } |
@@ -695,4 +640,3 @@ void AdvancedFm::mkSym() | |||
695 | 640 | ||
696 | void AdvancedFm::doBeam() | 641 | void AdvancedFm::doBeam() { |
697 | { | ||
698 | Ir ir; | 642 | Ir ir; |
@@ -716,4 +660,3 @@ void AdvancedFm::doBeam() | |||
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") ); |
@@ -721,5 +664,3 @@ void AdvancedFm::fileBeamFinished( Ir *) | |||
721 | 664 | ||
722 | void AdvancedFm::selectAll() | 665 | void AdvancedFm::selectAll() { |
723 | { | ||
724 | // if (TabWidget->currentTab() == 0) { | ||
725 | QListView *thisView = CurrentView(); | 666 | QListView *thisView = CurrentView(); |
@@ -727,10 +668,5 @@ void AdvancedFm::selectAll() | |||
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; |
@@ -752,5 +688,3 @@ void AdvancedFm::startProcess(const QString & cmd) | |||
752 | 688 | ||
753 | void AdvancedFm::processEnded(OProcess *) | 689 | void AdvancedFm::processEnded(OProcess *) { |
754 | { | ||
755 | // populateLocalView(); | ||
756 | populateView(); | 690 | populateView(); |
@@ -758,23 +692,15 @@ void AdvancedFm::processEnded(OProcess *) | |||
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(); |
@@ -782,4 +708,3 @@ bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) | |||
782 | } | 708 | } |
783 | else if ( ke->key() == Key_Escape ) | 709 | else if ( ke->key() == Key_Escape ) { |
784 | { | ||
785 | cancelRename(); | 710 | cancelRename(); |
@@ -788,4 +713,3 @@ bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) | |||
788 | } | 713 | } |
789 | else if ( e->type() == QEvent::FocusOut ) | 714 | else if ( e->type() == QEvent::FocusOut ) { |
790 | { | ||
791 | cancelRename(); | 715 | cancelRename(); |
@@ -794,10 +718,13 @@ bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) | |||
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"); | 723 | } |
800 | 724 | else { | |
801 | } | 725 | whichTab=2; |
802 | } | 726 | } |
727 | } | ||
728 | OtherView()->setSelected( OtherView()->currentItem(), FALSE );//make sure there's correct selection | ||
729 | } | ||
803 | 730 | ||
@@ -807,5 +734,4 @@ bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) | |||
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; |
@@ -816,4 +742,3 @@ void AdvancedFm::cancelRename() | |||
816 | renameBox = 0; | 742 | renameBox = 0; |
817 | if ( resetFocus ) | 743 | if ( resetFocus ) { |
818 | { | ||
819 | view->viewport()->setFocusProxy( view); | 744 | view->viewport()->setFocusProxy( view); |
@@ -823,4 +748,4 @@ void AdvancedFm::cancelRename() | |||
823 | 748 | ||
824 | void AdvancedFm::doRename(QListView * view) | 749 | void AdvancedFm::doRename(QListView * view) { |
825 | { | 750 | if( !CurrentView()->currentItem()) return; |
826 | 751 | ||
@@ -844,3 +769,2 @@ void AdvancedFm::doRename(QListView * view) | |||
844 | renameBox->show(); | 769 | renameBox->show(); |
845 | |||
846 | } | 770 | } |
@@ -848,5 +772,5 @@ void AdvancedFm::doRename(QListView * view) | |||
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); |
@@ -856,22 +780,19 @@ void AdvancedFm::renameIt() | |||
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; | 785 | QListView * view = CurrentView(); |
862 | QListView * view = CurrentView(); | 786 | QString path = CurrentDir()->canonicalPath() + "/"; |
863 | QString path = CurrentDir()->canonicalPath() + "/"; | 787 | oldName = path + oldName; |
864 | oldName = path + oldName; | 788 | newName = path + newName; |
865 | newName = path + newName; | 789 | |
866 | 790 | if( rename( oldName.latin1(), newName.latin1())== -1) | |
867 | if( view->currentItem() == NULL) | 791 | QMessageBox::message(tr("Note"),tr("Could not rename")); |
868 | return; | 792 | else |
869 | if( rename( oldName.latin1(), newName.latin1())== -1) | 793 | oldName = ""; |
870 | QMessageBox::message(tr("Note"),tr("Could not rename")); | 794 | |
871 | else | 795 | view->takeItem( view->currentItem() ); |
872 | oldName = ""; | 796 | delete view->currentItem(); |
873 | 797 | populateView(); | |
874 | view->takeItem( view->currentItem() ); | ||
875 | delete view->currentItem(); | ||
876 | populateView(); | ||
877 | } | 798 | } |
@@ -879,3 +800,3 @@ void AdvancedFm::okRename() | |||
879 | void AdvancedFm::openSearch() { | 800 | void AdvancedFm::openSearch() { |
880 | 801 | QMessageBox::message(tr("Note"),tr("Not Yet Implemented")); | |
881 | } | 802 | } |