summaryrefslogtreecommitdiff
path: root/noncore/apps/advancedfm/advancedfm.cpp
Unidiff
Diffstat (limited to 'noncore/apps/advancedfm/advancedfm.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/apps/advancedfm/advancedfm.cpp345
1 files changed, 158 insertions, 187 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp
index 91318f1..2fc4b49 100644
--- a/noncore/apps/advancedfm/advancedfm.cpp
+++ b/noncore/apps/advancedfm/advancedfm.cpp
@@ -40,6 +40,8 @@
40#include <qmessagebox.h> 40#include <qmessagebox.h>
41#include <qlineedit.h> 41#include <qlineedit.h>
42 42
43#include <qpe/qpemessagebox.h>
44
43#include <sys/stat.h> 45#include <sys/stat.h>
44#include <time.h> 46#include <time.h>
45#include <dirent.h> 47#include <dirent.h>
@@ -67,8 +69,7 @@ AdvancedFm::~AdvancedFm() {
67} 69}
68 70
69 71
70void AdvancedFm::cleanUp() 72void AdvancedFm::cleanUp() {
71{
72 QString sfile=QDir::homeDirPath(); 73 QString sfile=QDir::homeDirPath();
73 if(sfile.right(1) != "/") 74 if(sfile.right(1) != "/")
74 sfile+="/._temp"; 75 sfile+="/._temp";
@@ -79,44 +80,41 @@ void AdvancedFm::cleanUp()
79 file.remove(); 80 file.remove();
80} 81}
81 82
82void AdvancedFm::tabChanged(QWidget *w) 83void AdvancedFm::tabChanged(QWidget *) {
83{ 84// qWarning("tab changed");
84 if( w == tab)
85 whichTab = 1;
86 else
87 whichTab = 2;
88
89// qDebug("tab changed %d", whichTab );
90
91 QString path = CurrentDir()->canonicalPath(); 85 QString path = CurrentDir()->canonicalPath();
92 currentPathCombo->lineEdit()->setText( path ); 86 currentPathCombo->lineEdit()->setText( path );
93 87
94 viewMenu->setItemChecked(viewMenu->idAt(0),TRUE); 88 if(whichTab == 1) {
95 viewMenu->setItemChecked(viewMenu->idAt(1),FALSE); 89 viewMenu->setItemChecked(viewMenu->idAt(0), true);
90 viewMenu->setItemChecked(viewMenu->idAt(1), false);
91 } else {
92 viewMenu->setItemChecked(viewMenu->idAt(0), false);
93 viewMenu->setItemChecked(viewMenu->idAt(1), true);
94 }
96 95
97 QString fs= getFileSystemType( (const QString &) path); 96 QString fs= getFileSystemType( (const QString &) path);
98 97
99 setCaption("AdvancedFm :: "+fs+" :: " 98 setCaption(tr("AdvancedFm :: ")+fs+" :: "
100 +checkDiskSpace( (const QString &) path )+ " kB free" ); 99 +checkDiskSpace( (const QString &) path )+ tr(" kB free") );
101 chdir( path.latin1()); 100 chdir( path.latin1());
102} 101}
103 102
104 103
105void AdvancedFm::populateView() 104void AdvancedFm::populateView() {
106{
107 QPixmap pm; 105 QPixmap pm;
108 QListView *thisView = CurrentView(); 106 QListView *thisView = CurrentView();
109 QDir *thisDir = CurrentDir(); 107 QDir *thisDir = CurrentDir();
110 QString path = thisDir->canonicalPath(); 108 QString path = thisDir->canonicalPath();
111 109// qWarning("path is "+path);
112 thisView->clear(); 110 thisView->clear();
113 thisDir->setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 111 thisDir->setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
114 thisDir->setMatchAllDirs(TRUE); 112 thisDir->setMatchAllDirs(TRUE);
115 thisDir->setNameFilter(filterStr); 113 thisDir->setNameFilter(filterStr);
116 QString fileL, fileS, fileDate; 114 QString fileL, fileS, fileDate;
117 QString fs= getFileSystemType((const QString &) path); 115 QString fs= getFileSystemType((const QString &) path);
118 setCaption("AdvancedFm :: "+fs+" :: " 116 setCaption(tr("AdvancedFm :: ")+fs+" :: "
119 +checkDiskSpace((const QString &) path)+" kB free" ); 117 +checkDiskSpace((const QString &) path)+ tr(" kB free") );
120 bool isDir=FALSE; 118 bool isDir=FALSE;
121 const QFileInfoList *list = thisDir->entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); 119 const QFileInfoList *list = thisDir->entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
122 QFileInfoListIterator it(*list); 120 QFileInfoListIterator it(*list);
@@ -133,6 +131,7 @@ void AdvancedFm::populateView()
133 fileL = fi->fileName(); 131 fileL = fi->fileName();
134 fileDate= fi->lastModified().toString(); 132 fileDate= fi->lastModified().toString();
135 if( QDir(QDir::cleanDirPath( path +"/"+fileL)).exists() ) { 133 if( QDir(QDir::cleanDirPath( path +"/"+fileL)).exists() ) {
134// if(fileL == "..")
136 fileL+="/"; 135 fileL+="/";
137 isDir=TRUE; 136 isDir=TRUE;
138 } 137 }
@@ -211,45 +210,44 @@ void AdvancedFm::populateView()
211 fillCombo( (const QString &) path ); 210 fillCombo( (const QString &) path );
212} 211}
213 212
214void AdvancedFm::rePopulate() 213void AdvancedFm::rePopulate() {
215{
216 int tmpTab = whichTab;
217 qDebug("%d", tmpTab);
218
219 for(int i =1; i < 3; i++)
220 {
221 TabWidget->setCurrentWidget(i - 1);
222 populateView(); 214 populateView();
223 } 215 setOtherTabCurrent();
224 TabWidget->setCurrentWidget( tmpTab - 1); 216 populateView();
217
218// int tmpTab = whichTab;
219// // qDebug("%d", tmpTab);
220
221// for(int i =1; i < 3; i++) {
222// TabWidget->setCurrentWidget(i - 1);
223// populateView();
224// }
225// TabWidget->setCurrentWidget( tmpTab - 1);
225} 226}
226 227
227void AdvancedFm::ListClicked(QListViewItem *selectedItem) 228void AdvancedFm::ListClicked(QListViewItem *selectedItem) {
228{ 229//qWarning("listclicked");
229 if(selectedItem) 230 if(selectedItem) {
230 {
231 QString strItem=selectedItem->text(0); 231 QString strItem=selectedItem->text(0);
232// qWarning(strItem);
232 QString strSize=selectedItem->text(1); 233 QString strSize=selectedItem->text(1);
233 strSize=strSize.stripWhiteSpace(); 234 strSize=strSize.stripWhiteSpace();
234 bool isDirectory = false; 235 bool isDirectory = false;
235 QString strItem2; 236 QString strItem2;
236 237
237 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 )//if symlink 238 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) {//if symlink
238 {
239 strItem2 = dealWithSymName((const QString&)strItem); 239 strItem2 = dealWithSymName((const QString&)strItem);
240 if(QDir(strItem2).exists() ) 240 if(QDir(strItem2).exists() )
241 strItem = strItem2; 241 strItem = strItem2;
242 } 242 }
243 243
244 if( strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) 244 if( strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) {
245 {
246 245
247 if(QDir(strItem).exists()) 246 if(QDir(strItem).exists())
248 isDirectory = true; 247 isDirectory = true;
249 } 248 }
250 249
251 if( isDirectory ) 250 if( isDirectory ) {
252 {
253 CurrentDir()->cd( strItem, TRUE); 251 CurrentDir()->cd( strItem, TRUE);
254 populateView(); 252 populateView();
255 CurrentView()->ensureItemVisible( CurrentView()->firstChild()); 253 CurrentView()->ensureItemVisible( CurrentView()->firstChild());
@@ -258,12 +256,12 @@ void AdvancedFm::ListClicked(QListViewItem *selectedItem)
258 } 256 }
259} 257}
260 258
261void AdvancedFm::ListPressed( int mouse, QListViewItem *, const QPoint& , int ) { 259void AdvancedFm::ListPressed( int mouse, QListViewItem *item, const QPoint& , int ) {
260 dealWithSchmooSchmaa( item->listView());
262 switch (mouse) { 261 switch (mouse) {
263 case 1: 262 case 1:
264 { 263 {
265 if(renameBox != 0 ) 264 if(renameBox != 0 ) {
266 {
267 cancelRename(); 265 cancelRename();
268 } 266 }
269 } 267 }
@@ -274,59 +272,48 @@ void AdvancedFm::ListPressed( int mouse, QListViewItem *, const QPoint& , int )
274 }; 272 };
275} 273}
276 274
277void AdvancedFm::switchToLocalTab() 275
278{ 276void AdvancedFm::switchToLocalTab() {
277//qWarning("switch to local view");
279 TabWidget->setCurrentWidget(0); 278 TabWidget->setCurrentWidget(0);
280 Local_View->setFocus(); 279 Local_View->setFocus();
281} 280}
282 281
283void AdvancedFm::switchToRemoteTab() 282void AdvancedFm::switchToRemoteTab() {
284{ 283//qWarning("switch to local view");
285 TabWidget->setCurrentWidget(1); 284 TabWidget->setCurrentWidget(1);
286 Remote_View->setFocus(); 285 Remote_View->setFocus();
287} 286}
288 287
289void AdvancedFm::readConfig() 288void AdvancedFm::readConfig() {
290{
291 Config cfg("AdvancedFm"); 289 Config cfg("AdvancedFm");
292} 290}
293 291
294void AdvancedFm::writeConfig() 292void AdvancedFm::writeConfig() {
295{
296 Config cfg("AdvancedFm"); 293 Config cfg("AdvancedFm");
297} 294}
298 295
299void AdvancedFm::currentPathComboChanged() 296void AdvancedFm::currentPathComboChanged() {
300{ 297 if(QDir( currentPathCombo->lineEdit()->text()).exists()) {
301 if(QDir( currentPathCombo->lineEdit()->text()).exists())
302 {
303 CurrentDir()->setPath( currentPathCombo->lineEdit()->text() ); 298 CurrentDir()->setPath( currentPathCombo->lineEdit()->text() );
304 populateView(); 299 populateView();
305 } 300 } else {
306 else
307 {
308 QMessageBox::message(tr("Note"),tr("That directory does not exist")); 301 QMessageBox::message(tr("Note"),tr("That directory does not exist"));
309 } 302 }
310} 303}
311 304
312void AdvancedFm::fillCombo(const QString &currentPath) 305void AdvancedFm::fillCombo(const QString &currentPath) {
313{ 306
314// qDebug("%d",TabWidget->currentTab()); 307 if ( whichTab == 1) {
315 if ( whichTab == 1)
316 {
317 currentPathCombo->lineEdit()->setText( currentPath); 308 currentPathCombo->lineEdit()->setText( currentPath);
318 if( localDirPathStringList.grep( currentPath,TRUE).isEmpty() ) 309 if( localDirPathStringList.grep( currentPath,TRUE).isEmpty() ) {
319 {
320 currentPathCombo->clear(); 310 currentPathCombo->clear();
321 localDirPathStringList.prepend( currentPath ); 311 localDirPathStringList.prepend( currentPath );
322 currentPathCombo->insertStringList( localDirPathStringList,-1); 312 currentPathCombo->insertStringList( localDirPathStringList,-1);
323 } 313 }
324 } 314 } else {
325 else
326 {
327 currentPathCombo->lineEdit()->setText( currentPath); 315 currentPathCombo->lineEdit()->setText( currentPath);
328 if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) 316 if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) {
329 {
330 currentPathCombo->clear(); 317 currentPathCombo->clear();
331 remoteDirPathStringList.prepend( currentPath ); 318 remoteDirPathStringList.prepend( currentPath );
332 currentPathCombo->insertStringList( remoteDirPathStringList,-1); 319 currentPathCombo->insertStringList( remoteDirPathStringList,-1);
@@ -334,24 +321,20 @@ void AdvancedFm::fillCombo(const QString &currentPath)
334 } 321 }
335} 322}
336 323
337void AdvancedFm::currentPathComboActivated(const QString & currentPath) 324void AdvancedFm::currentPathComboActivated(const QString & currentPath) {
338{
339 chdir( currentPath.latin1() ); 325 chdir( currentPath.latin1() );
340 CurrentDir()->cd( currentPath, TRUE); 326 CurrentDir()->cd( currentPath, TRUE);
341 populateView(); 327 populateView();
342 update(); 328 update();
343} 329}
344 330
345QStringList AdvancedFm::getPath() 331QStringList AdvancedFm::getPath() {
346{
347 QStringList strList; 332 QStringList strList;
348 QListView *thisView=CurrentView(); 333 QListView *thisView=CurrentView();
349 QList<QListViewItem> * getSelectedItems( QListView * thisView ); 334 QList<QListViewItem> * getSelectedItems( QListView * thisView );
350 QListViewItemIterator it( thisView ); 335 QListViewItemIterator it( thisView );
351 for ( ; it.current(); ++it ) 336 for ( ; it.current(); ++it ) {
352 { 337 if ( it.current()->isSelected() ) {
353 if ( it.current()->isSelected() )
354 {
355 strList << it.current()->text(0); 338 strList << it.current()->text(0);
356// qDebug(it.current()->text(0)); 339// qDebug(it.current()->text(0));
357 } 340 }
@@ -359,8 +342,7 @@ QStringList AdvancedFm::getPath()
359 return strList; 342 return strList;
360} 343}
361 344
362void AdvancedFm::homeButtonPushed() 345void AdvancedFm::homeButtonPushed() {
363{
364 QString current = QDir::homeDirPath(); 346 QString current = QDir::homeDirPath();
365 chdir( current.latin1() ); 347 chdir( current.latin1() );
366 CurrentDir()->cd( current, TRUE); 348 CurrentDir()->cd( current, TRUE);
@@ -368,8 +350,7 @@ void AdvancedFm::homeButtonPushed()
368 update(); 350 update();
369} 351}
370 352
371void AdvancedFm::docButtonPushed() 353void AdvancedFm::docButtonPushed() {
372{
373 QString current = QPEApplication::documentDir(); 354 QString current = QPEApplication::documentDir();
374 chdir( current.latin1() ); 355 chdir( current.latin1() );
375 CurrentDir()->cd( current, TRUE); 356 CurrentDir()->cd( current, TRUE);
@@ -377,8 +358,7 @@ void AdvancedFm::docButtonPushed()
377 update(); 358 update();
378} 359}
379 360
380void AdvancedFm::SDButtonPushed() 361void AdvancedFm::SDButtonPushed() {
381{
382 QString current = "/mnt/card";// this can change so fix 362 QString current = "/mnt/card";// this can change so fix
383 chdir( current.latin1() ); 363 chdir( current.latin1() );
384 CurrentDir()->cd( current, TRUE); 364 CurrentDir()->cd( current, TRUE);
@@ -386,8 +366,7 @@ void AdvancedFm::SDButtonPushed()
386 update(); 366 update();
387} 367}
388 368
389void AdvancedFm::CFButtonPushed() 369void AdvancedFm::CFButtonPushed() {
390{
391 QString current; 370 QString current;
392 if(zaurusDevice) 371 if(zaurusDevice)
393 current= "/mnt/cf"; //zaurus 372 current= "/mnt/cf"; //zaurus
@@ -400,20 +379,31 @@ void AdvancedFm::CFButtonPushed()
400} 379}
401 380
402 381
403void AdvancedFm::doAbout() 382void AdvancedFm::doAbout() {
404{
405 QMessageBox::message("AdvancedFm",tr("Advanced FileManager\n" 383 QMessageBox::message("AdvancedFm",tr("Advanced FileManager\n"
406 "is copyright 2002-2003 by\n" 384 "is copyright 2002-2003 by\n"
407 "L.J.Potter<llornkcor@handhelds.org>\n" 385 "L.J.Potter<llornkcor@handhelds.org>\n"
408 "and is licensed by the GPL")); 386 "and is licensed by the GPL"));
409} 387}
410 388
411void AdvancedFm::keyPressEvent( QKeyEvent *e) 389void AdvancedFm::keyPressEvent( QKeyEvent *e) {
412{ 390// qWarning("key %d", e->key());
413// e->accept(); 391// if( CurrentView()->hasFocus() )
414 if( CurrentView()->hasFocus() )
415 { 392 {
416 switch ( e->key() ) { 393 switch ( e->key() ) {
394 case Key_Left:
395 upDir();
396 break;
397 case Key_Next:
398 break;
399 case Key_Return:
400 case Key_Enter:
401 navigateToSelected();
402 break;
403 case Key_Tab: {
404 setOtherTabCurrent();
405 }
406 break;
417 case Key_Delete: 407 case Key_Delete:
418 del(); 408 del();
419 break; 409 break;
@@ -484,15 +474,13 @@ void AdvancedFm::keyPressEvent( QKeyEvent *e)
484 } 474 }
485} 475}
486 476
487void AdvancedFm::keyReleaseEvent( QKeyEvent *e) 477void AdvancedFm::keyReleaseEvent( QKeyEvent *e) {
488{
489 if( CurrentView()->hasFocus() ) 478 if( CurrentView()->hasFocus() )
490 e->ignore(); 479 e->ignore();
491} 480}
492 481
493 482
494void AdvancedFm::QPEButtonPushed() 483void AdvancedFm::QPEButtonPushed() {
495{
496 QString current = QPEApplication::qpeDir(); 484 QString current = QPEApplication::qpeDir();
497 chdir( current.latin1() ); 485 chdir( current.latin1() );
498 CurrentDir()->cd( current, TRUE); 486 CurrentDir()->cd( current, TRUE);
@@ -500,22 +488,18 @@ void AdvancedFm::QPEButtonPushed()
500 update(); 488 update();
501} 489}
502 490
503void AdvancedFm::parsetab(const QString &fileName) 491void AdvancedFm::parsetab(const QString &fileName) {
504{
505 492
506 fileSystemTypeList.clear(); 493 fileSystemTypeList.clear();
507 fsList.clear(); 494 fsList.clear();
508 struct mntent *me; 495 struct mntent *me;
509 FILE *mntfp = setmntent( fileName.latin1(), "r" ); 496 FILE *mntfp = setmntent( fileName.latin1(), "r" );
510 if ( mntfp ) 497 if ( mntfp ) {
511 { 498 while ( (me = getmntent( mntfp )) != 0 ) {
512 while ( (me = getmntent( mntfp )) != 0 )
513 {
514 QString deviceName = me->mnt_fsname; 499 QString deviceName = me->mnt_fsname;
515 QString filesystemType = me->mnt_type; 500 QString filesystemType = me->mnt_type;
516 QString mountDir = me->mnt_dir; 501 QString mountDir = me->mnt_dir;
517 if(deviceName != "none") 502 if(deviceName != "none") {
518 {
519 if( fsList.contains(filesystemType) == 0 503 if( fsList.contains(filesystemType) == 0
520 & filesystemType.find("proc",0,TRUE) == -1 504 & filesystemType.find("proc",0,TRUE) == -1
521 & filesystemType.find("cramfs",0,TRUE) == -1 505 & filesystemType.find("cramfs",0,TRUE) == -1
@@ -528,8 +512,7 @@ void AdvancedFm::parsetab(const QString &fileName)
528 endmntent( mntfp ); 512 endmntent( mntfp );
529} 513}
530 514
531QString AdvancedFm::getFileSystemType(const QString &currentText) 515QString AdvancedFm::getFileSystemType(const QString &currentText) {
532{
533 parsetab("/etc/mtab"); //why did TT forget filesystem type? 516 parsetab("/etc/mtab"); //why did TT forget filesystem type?
534 QString current = currentText;//.right( currentText.length()-1); 517 QString current = currentText;//.right( currentText.length()-1);
535 QString baseFs; 518 QString baseFs;
@@ -545,8 +528,7 @@ QString AdvancedFm::getFileSystemType(const QString &currentText)
545 return baseFs; 528 return baseFs;
546} 529}
547 530
548QString AdvancedFm::getDiskSpace( const QString &path) 531QString AdvancedFm::getDiskSpace( const QString &path) {
549{
550 struct statfs fss; 532 struct statfs fss;
551 if ( !statfs( path.latin1(), &fss ) ) { 533 if ( !statfs( path.latin1(), &fss ) ) {
552 int blkSize = fss.f_bsize; 534 int blkSize = fss.f_bsize;
@@ -564,8 +546,7 @@ QString AdvancedFm::getDiskSpace( const QString &path)
564} 546}
565 547
566 548
567void AdvancedFm::showFileMenu() 549void AdvancedFm::showFileMenu() {
568{
569 QString curApp; 550 QString curApp;
570 curApp = CurrentView()->currentItem()->text(0); 551 curApp = CurrentView()->currentItem()->text(0);
571 552
@@ -577,13 +558,10 @@ void AdvancedFm::showFileMenu()
577 // QPopupMenu *o = new QPopupMenu(0); 558 // QPopupMenu *o = new QPopupMenu(0);
578 m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); 559 m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() ));
579 560
580 if ( QFileInfo(fi).isDir() ) 561 if ( QFileInfo(fi).isDir() ) {
581 {
582 m->insertSeparator(); 562 m->insertSeparator();
583 m->insertItem( tr( "Change Directory" ), this, SLOT( doDirChange() )); 563 m->insertItem( tr( "Change Directory" ), this, SLOT( doDirChange() ));
584 } 564 } else {
585 else
586 {
587 565
588 if ( app ) 566 if ( app )
589 m->insertItem( app->pixmap(), tr( "Open in " 567 m->insertItem( app->pixmap(), tr( "Open in "
@@ -634,18 +612,15 @@ void AdvancedFm::showFileMenu()
634} 612}
635 613
636 614
637void AdvancedFm::cancelMenuTimer() 615void AdvancedFm::cancelMenuTimer() {
638{ 616
639// qDebug("selectionChanged: cancel menu timer");
640 if( menuTimer.isActive() ) 617 if( menuTimer.isActive() )
641 menuTimer.stop(); 618 menuTimer.stop();
642} 619}
643 620
644QString AdvancedFm::checkDiskSpace(const QString &path) 621QString AdvancedFm::checkDiskSpace(const QString &path) {
645{
646 struct statfs fss; 622 struct statfs fss;
647 if ( !statfs( path.latin1(), &fss ) ) 623 if ( !statfs( path.latin1(), &fss ) ) {
648 {
649 int blkSize = fss.f_bsize; 624 int blkSize = fss.f_bsize;
650// int totalBlks = fs.f_blocks; 625// int totalBlks = fs.f_blocks;
651 int availBlks = fss.f_bavail; 626 int availBlks = fss.f_bavail;
@@ -661,8 +636,7 @@ QString AdvancedFm::checkDiskSpace(const QString &path)
661 return ""; 636 return "";
662} 637}
663 638
664void AdvancedFm::addToDocs() 639void AdvancedFm::addToDocs() {
665{
666 QStringList strListPaths = getPath(); 640 QStringList strListPaths = getPath();
667 QDir *thisDir = CurrentDir(); 641 QDir *thisDir = CurrentDir();
668 642
@@ -682,8 +656,7 @@ void AdvancedFm::addToDocs()
682} 656}
683 657
684 658
685void AdvancedFm::customDirsToMenu() 659void AdvancedFm::customDirsToMenu() {
686{
687 660
688 Config cfg("AdvancedFm"); 661 Config cfg("AdvancedFm");
689 cfg.setGroup("Menu"); 662 cfg.setGroup("Menu");
@@ -697,9 +670,7 @@ void AdvancedFm::customDirsToMenu()
697// } 670// }
698} 671}
699 672
700void AdvancedFm::dirMenuSelected(int item) 673void AdvancedFm::dirMenuSelected(int item) {
701{
702 qDebug("menu item %d", item);
703 switch(item) 674 switch(item)
704 { 675 {
705 676
@@ -721,8 +692,7 @@ void AdvancedFm::dirMenuSelected(int item)
721 }; 692 };
722} 693}
723 694
724void AdvancedFm::addCustomDir() 695void AdvancedFm::addCustomDir() {
725{
726 Config cfg("AdvancedFm"); 696 Config cfg("AdvancedFm");
727 cfg.setGroup("Menu"); 697 cfg.setGroup("Menu");
728 QString dir; 698 QString dir;
@@ -731,15 +701,12 @@ void AdvancedFm::addCustomDir()
731 dir = CurrentDir()->canonicalPath(); 701 dir = CurrentDir()->canonicalPath();
732 702
733 bool addIt=true; 703 bool addIt=true;
734 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) 704 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
735 { 705 if( dir == (*it)) {
736 if( dir == (*it))
737 {
738 addIt=false; 706 addIt=false;
739 } 707 }
740 } 708 }
741 if(addIt) 709 if(addIt) {
742 {
743 menuButton->insertItem(dir); 710 menuButton->insertItem(dir);
744// customDirMenu->insertItem(dir); 711// customDirMenu->insertItem(dir);
745 list << dir; 712 list << dir;
@@ -749,8 +716,7 @@ void AdvancedFm::addCustomDir()
749 cfg.write(); 716 cfg.write();
750} 717}
751 718
752void AdvancedFm::removeCustomDir() 719void AdvancedFm::removeCustomDir() {
753{
754// qDebug("remove custom dir"); 720// qDebug("remove custom dir");
755 Config cfg("AdvancedFm"); 721 Config cfg("AdvancedFm");
756 cfg.setGroup("Menu"); 722 cfg.setGroup("Menu");
@@ -761,21 +727,15 @@ void AdvancedFm::removeCustomDir()
761 int ramble=2; 727 int ramble=2;
762// int ramble=-24; 728// int ramble=-24;
763//first remove list 729//first remove list
764 if(list.grep(dir,true).isEmpty()) 730 if(list.grep(dir,true).isEmpty()) {
765 {
766 QMessageBox::message(tr( "AdvancedFm" ), 731 QMessageBox::message(tr( "AdvancedFm" ),
767 tr("Cannot remove current directory\nfrom bookmarks.\nIt is not bookmarked!")); 732 tr("Cannot remove current directory\nfrom bookmarks.\nIt is not bookmarked!"));
768 } 733 } else {
769 else 734 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
770 { 735 if((*it) != dir) {
771 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) 736//current item is not our current dir, so add it to temp list
772 {
773 if((*it) != dir)//current item is not our current dir, so add it to temp list
774 {
775 list2 <<(*it); 737 list2 <<(*it);
776 } 738 } else {
777 else
778 {
779// customDirMenu->removeItem( ramble); 739// customDirMenu->removeItem( ramble);
780 menuButton->remove( ramble); 740 menuButton->remove( ramble);
781 741
@@ -791,23 +751,18 @@ void AdvancedFm::removeCustomDir()
791 751
792} 752}
793 753
794void AdvancedFm::gotoCustomDir(const QString &dir) 754void AdvancedFm::gotoCustomDir(const QString &dir) {
795{
796// qDebug("gotoCustomDir(const QString &dir) " +dir ); 755// qDebug("gotoCustomDir(const QString &dir) " +dir );
797// QString curDir = dir; 756// QString curDir = dir;
798// QDir *thisDir = CurrentDir(); 757// QDir *thisDir = CurrentDir();
799// if( curDir.isEmpty()) { 758// if( curDir.isEmpty()) {
800// } 759// }
801 if( dir == s_addBookmark) 760 if( dir == s_addBookmark) {
802 {
803 addCustomDir(); 761 addCustomDir();
804 } 762 }
805 if( dir == s_removeBookmark) 763 if( dir == s_removeBookmark) {
806 {
807 removeCustomDir( ); 764 removeCustomDir( );
808 } 765 } else {
809 else
810 {
811 gotoDirectory( dir); 766 gotoDirectory( dir);
812// if(QDir( curDir).exists() ) 767// if(QDir( curDir).exists() )
813// { 768// {
@@ -819,59 +774,56 @@ void AdvancedFm::gotoCustomDir(const QString &dir)
819 } 774 }
820} 775}
821 776
822QDir *AdvancedFm::CurrentDir() 777QDir *AdvancedFm::CurrentDir() {
823{ 778
824 if ( whichTab == 1) 779 if ( whichTab == 1) {
825 {
826 return &currentDir; 780 return &currentDir;
827 } 781 } else {
828 else
829 {
830 return &currentRemoteDir; 782 return &currentRemoteDir;
831 } 783 }
832} 784}
833 785
834QDir *AdvancedFm::OtherDir() 786QDir *AdvancedFm::OtherDir() {
835{ 787 if ( whichTab == 1) {
836 if ( whichTab == 1)
837 {
838 return &currentRemoteDir; 788 return &currentRemoteDir;
839 } 789 } else {
840 else
841 {
842 return &currentDir; 790 return &currentDir;
843 } 791 }
844} 792}
845 793
846QListView * AdvancedFm::CurrentView() 794QListView * AdvancedFm::CurrentView() {
847{ 795 if ( whichTab == 1) {
848 if ( whichTab == 1) 796// qWarning("CurrentView Tab 1");
849 return Local_View; 797 return Local_View;
850 else 798 } else {
799// qWarning("CurrentView Tab 2");
851 return Remote_View; 800 return Remote_View;
852} 801}
802}
853 803
854QListView * AdvancedFm::OtherView() 804QListView * AdvancedFm::OtherView() {
855{
856 if ( whichTab == 1) 805 if ( whichTab == 1)
857 return Remote_View; 806 return Remote_View;
858 else 807 else
859 return Local_View; 808 return Local_View;
860} 809}
861 810
862void AdvancedFm::setOtherTabCurrent() 811void AdvancedFm::setOtherTabCurrent() {
863{ 812// qWarning("setOtherTabCurrent()");
864 if ( whichTab == 1) 813 if ( whichTab == 1) {
865 TabWidget->setCurrentWidget(1); 814 TabWidget->setCurrentWidget(1);
866 else 815 } else {
867 TabWidget->setCurrentWidget(0); 816 TabWidget->setCurrentWidget(0);
868} 817}
818 OtherView()->setFocus();
819 OtherView()->setSelected( CurrentView()->firstChild(), true);
820}
869 821
870void AdvancedFm::qcopReceive(const QCString &msg, const QByteArray &data) { 822void AdvancedFm::qcopReceive(const QCString &msg, const QByteArray &data) {
871 qDebug("qcop message "+msg ); 823// qDebug("qcop message "+msg );
872 QDataStream stream ( data, IO_ReadOnly ); 824 QDataStream stream ( data, IO_ReadOnly );
873 if ( msg == "openDirectory(QString)" ) { 825 if ( msg == "openDirectory(QString)" ) {
874 qDebug("received"); 826// qDebug("received");
875 QString file; 827 QString file;
876 stream >> file; 828 stream >> file;
877 gotoDirectory( (const QString &) file); 829 gotoDirectory( (const QString &) file);
@@ -884,7 +836,7 @@ void AdvancedFm::qcopReceive(const QCString &msg, const QByteArray &data) {
884 } 836 }
885 837
886void AdvancedFm::gotoDirectory(const QString &file) { 838void AdvancedFm::gotoDirectory(const QString &file) {
887 839// qWarning("goto dir "+file);
888 QString curDir = file; 840 QString curDir = file;
889 QDir *thisDir = CurrentDir(); 841 QDir *thisDir = CurrentDir();
890 if(QDir( curDir).exists() ) { 842 if(QDir( curDir).exists() ) {
@@ -918,3 +870,22 @@ void AdvancedFm::findFile(const QString &fileName) {
918 } 870 }
919 } 871 }
920} 872}
873
874void AdvancedFm::slotSwitchMenu(int ) {
875// qDebug("Switch %d", item);
876 // viewMenu->setItemChecked(item, true);
877}
878
879void AdvancedFm::dealWithSchmooSchmaa(QWidget *w) {
880 tabChanged( w);
881 if( w == Local_View) {
882 Remote_View->clearFocus();
883 } else {
884 Local_View->clearFocus();
885 }
886}
887
888void AdvancedFm::navigateToSelected() {
889 if( !CurrentView()->currentItem()) return;
890 doDirChange();
891}