-rw-r--r-- | noncore/apps/advancedfm/advancedfm.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp index 9cb9aba..3bfec7d 100644 --- a/noncore/apps/advancedfm/advancedfm.cpp +++ b/noncore/apps/advancedfm/advancedfm.cpp | |||
@@ -252,261 +252,260 @@ void AdvancedFm::ListClicked(QListViewItem *selectedItem) { | |||
252 | CurrentDir()->cd( strItem, TRUE); | 252 | CurrentDir()->cd( strItem, TRUE); |
253 | populateView(); | 253 | populateView(); |
254 | CurrentView()->ensureItemVisible( CurrentView()->firstChild()); | 254 | CurrentView()->ensureItemVisible( CurrentView()->firstChild()); |
255 | } | 255 | } |
256 | chdir( strItem.latin1()); | 256 | chdir( strItem.latin1()); |
257 | } | 257 | } |
258 | } | 258 | } |
259 | 259 | ||
260 | void AdvancedFm::ListPressed( int mouse, QListViewItem *item, const QPoint& , int ) { | 260 | void AdvancedFm::ListPressed( int mouse, QListViewItem *item, const QPoint& , int ) { |
261 | Q_UNUSED(item); | 261 | Q_UNUSED(item); |
262 | switch (mouse) { | 262 | switch (mouse) { |
263 | case 1: | 263 | case 1: |
264 | { | 264 | { |
265 | if(renameBox != 0 ) { | 265 | if(renameBox != 0 ) { |
266 | cancelRename(); | 266 | cancelRename(); |
267 | } | 267 | } |
268 | } | 268 | } |
269 | break; | 269 | break; |
270 | // case 2: | 270 | // case 2: |
271 | // menuTimer.start( 50, TRUE ); | 271 | // menuTimer.start( 50, TRUE ); |
272 | // break; | 272 | // break; |
273 | }; | 273 | }; |
274 | } | 274 | } |
275 | 275 | ||
276 | 276 | ||
277 | void AdvancedFm::refreshCurrentTab() { | 277 | void AdvancedFm::refreshCurrentTab() { |
278 | populateView(); | 278 | populateView(); |
279 | // if ( TabWidget->currentWidget() == tab) { | 279 | // if ( TabWidget->currentWidget() == tab) { |
280 | 280 | ||
281 | } | 281 | } |
282 | 282 | ||
283 | void AdvancedFm::switchToLocalTab() { | 283 | void AdvancedFm::switchToLocalTab() { |
284 | TabWidget->setCurrentWidget(0); | 284 | TabWidget->setCurrentWidget(0); |
285 | Local_View->setFocus(); | 285 | Local_View->setFocus(); |
286 | whichTab = 1; | 286 | whichTab = 1; |
287 | } | 287 | } |
288 | 288 | ||
289 | void AdvancedFm::switchToRemoteTab() { | 289 | void AdvancedFm::switchToRemoteTab() { |
290 | TabWidget->setCurrentWidget(1); | 290 | TabWidget->setCurrentWidget(1); |
291 | Remote_View->setFocus(); | 291 | Remote_View->setFocus(); |
292 | whichTab = 2; | 292 | whichTab = 2; |
293 | } | 293 | } |
294 | 294 | ||
295 | void AdvancedFm::currentPathComboChanged() { | 295 | void AdvancedFm::currentPathComboChanged() { |
296 | if(QDir( currentPathCombo->lineEdit()->text()).exists()) { | 296 | if(QDir( currentPathCombo->lineEdit()->text()).exists()) { |
297 | CurrentDir()->setPath( currentPathCombo->lineEdit()->text() ); | 297 | CurrentDir()->setPath( currentPathCombo->lineEdit()->text() ); |
298 | populateView(); | 298 | populateView(); |
299 | } else { | 299 | } else { |
300 | QMessageBox::message(tr("Note"),tr("That directory does not exist")); | 300 | QMessageBox::message(tr("Note"),tr("That directory does not exist")); |
301 | } | 301 | } |
302 | } | 302 | } |
303 | 303 | ||
304 | void AdvancedFm::fillCombo(const QString ¤tPath) { | 304 | void AdvancedFm::fillCombo(const QString ¤tPath) { |
305 | 305 | ||
306 | if ( TabWidget->currentWidget() == tab) { | 306 | if ( TabWidget->currentWidget() == tab) { |
307 | // if ( whichTab == 1) { | 307 | // if ( whichTab == 1) { |
308 | currentPathCombo->lineEdit()->setText( currentPath); | 308 | currentPathCombo->lineEdit()->setText( currentPath); |
309 | if( localDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { | 309 | if( localDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { |
310 | currentPathCombo->clear(); | 310 | currentPathCombo->clear(); |
311 | localDirPathStringList.prepend( currentPath ); | 311 | localDirPathStringList.prepend( currentPath ); |
312 | currentPathCombo->insertStringList( localDirPathStringList,-1); | 312 | currentPathCombo->insertStringList( localDirPathStringList,-1); |
313 | } | 313 | } |
314 | } else { | 314 | } else { |
315 | currentPathCombo->lineEdit()->setText( currentPath); | 315 | currentPathCombo->lineEdit()->setText( currentPath); |
316 | if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { | 316 | if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { |
317 | currentPathCombo->clear(); | 317 | currentPathCombo->clear(); |
318 | remoteDirPathStringList.prepend( currentPath ); | 318 | remoteDirPathStringList.prepend( currentPath ); |
319 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); | 319 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); |
320 | } | 320 | } |
321 | } | 321 | } |
322 | } | 322 | } |
323 | 323 | ||
324 | void AdvancedFm::currentPathComboActivated(const QString & currentPath) { | 324 | void AdvancedFm::currentPathComboActivated(const QString & currentPath) { |
325 | chdir( currentPath.latin1() ); | 325 | chdir( currentPath.latin1() ); |
326 | CurrentDir()->cd( currentPath, TRUE); | 326 | CurrentDir()->cd( currentPath, TRUE); |
327 | populateView(); | 327 | populateView(); |
328 | update(); | 328 | update(); |
329 | } | 329 | } |
330 | 330 | ||
331 | QStringList AdvancedFm::getPath() { | 331 | QStringList AdvancedFm::getPath() { |
332 | QStringList strList; | 332 | QStringList strList; |
333 | QListView *thisView=CurrentView(); | 333 | QListView *thisView=CurrentView(); |
334 | QList<QListViewItem> * getSelectedItems( QListView * thisView ); | 334 | QList<QListViewItem> * getSelectedItems( QListView * thisView ); |
335 | QListViewItemIterator it( thisView ); | 335 | QListViewItemIterator it( thisView ); |
336 | for ( ; it.current(); ++it ) { | 336 | for ( ; it.current(); ++it ) { |
337 | if ( it.current()->isSelected() ) { | 337 | if ( it.current()->isSelected() ) { |
338 | strList << it.current()->text(0); | 338 | strList << it.current()->text(0); |
339 | // odebug << it.current()->text(0) << oendl; | 339 | // odebug << it.current()->text(0) << oendl; |
340 | } | 340 | } |
341 | } | 341 | } |
342 | return strList; | 342 | return strList; |
343 | } | 343 | } |
344 | 344 | ||
345 | void AdvancedFm::changeTo(QString dir) { | 345 | void AdvancedFm::changeTo(QString dir) { |
346 | chdir( dir.latin1()); | 346 | chdir( dir.latin1()); |
347 | CurrentDir()->cd(dir, TRUE); | 347 | CurrentDir()->cd(dir, TRUE); |
348 | populateView(); | 348 | populateView(); |
349 | update(); | 349 | update(); |
350 | } | 350 | } |
351 | 351 | ||
352 | void AdvancedFm::homeButtonPushed() { | 352 | void AdvancedFm::homeButtonPushed() { |
353 | changeTo(QDir::homeDirPath()); | 353 | changeTo(QDir::homeDirPath()); |
354 | } | 354 | } |
355 | 355 | ||
356 | void AdvancedFm::docButtonPushed() { | 356 | void AdvancedFm::docButtonPushed() { |
357 | changeTo(QPEApplication::documentDir()); | 357 | changeTo(QPEApplication::documentDir()); |
358 | } | 358 | } |
359 | 359 | ||
360 | void AdvancedFm::SDButtonPushed() { | 360 | void AdvancedFm::SDButtonPushed() { |
361 | changeTo("/mnt/card");// this can change so fix | 361 | changeTo("/mnt/card");// this can change so fix |
362 | } | 362 | } |
363 | 363 | ||
364 | void AdvancedFm::CFButtonPushed() { | 364 | void AdvancedFm::CFButtonPushed() { |
365 | if(zaurusDevice) | 365 | if(zaurusDevice) |
366 | changeTo("/mnt/cf"); //zaurus | 366 | changeTo("/mnt/cf"); //zaurus |
367 | else | 367 | else |
368 | changeTo("/mnt/hda"); //ipaq | 368 | changeTo("/mnt/hda"); //ipaq |
369 | } | 369 | } |
370 | 370 | ||
371 | void AdvancedFm::QPEButtonPushed() { | 371 | void AdvancedFm::QPEButtonPushed() { |
372 | changeTo(QPEApplication::qpeDir()); | 372 | changeTo(QPEApplication::qpeDir()); |
373 | } | 373 | } |
374 | 374 | ||
375 | void AdvancedFm::doAbout() { | 375 | void AdvancedFm::doAbout() { |
376 | QMessageBox::message("AdvancedFm",tr("<P>Advanced FileManager is copyright 2002-2003 by L.J.Potter<llornkcor@handhelds.org> and is licensed by the GPL</P>")); | 376 | QMessageBox::message("AdvancedFm",tr("<P>Advanced FileManager is copyright 2002-2003 by L.J.Potter<llornkcor@handhelds.org> and is licensed by the GPL</P>")); |
377 | } | 377 | } |
378 | 378 | ||
379 | void AdvancedFm::keyPressEvent( QKeyEvent *e) { | 379 | void AdvancedFm::keyPressEvent( QKeyEvent *e) { |
380 | qDebug("keypressevent"); | 380 | Q_UNUSED(e); |
381 | } | 381 | } |
382 | 382 | ||
383 | void AdvancedFm::keyReleaseEvent( QKeyEvent *e) { | 383 | void AdvancedFm::keyReleaseEvent( QKeyEvent *e) { |
384 | qDebug("key release"); | ||
385 | if( CurrentView()->hasFocus() ) | 384 | if( CurrentView()->hasFocus() ) |
386 | e->ignore(); | 385 | e->ignore(); |
387 | if( e->key() == Key_Left ) | 386 | if( e->key() == Key_Left ) |
388 | upDir(); | 387 | upDir(); |
389 | else if( e->key() == Key_Return || e->key() == Key_Enter) | 388 | else if( e->key() == Key_Return || e->key() == Key_Enter) |
390 | navigateToSelected(); | 389 | navigateToSelected(); |
391 | else if( e->key() == Key_Tab) | 390 | else if( e->key() == Key_Tab) |
392 | setOtherTabCurrent(); | 391 | setOtherTabCurrent(); |
393 | else if( e->key() == Key_Delete ) | 392 | else if( e->key() == Key_Delete ) |
394 | del(); | 393 | del(); |
395 | else if( e->key() == Key_A) | 394 | else if( e->key() == Key_A) |
396 | copyAs(); | 395 | copyAs(); |
397 | else if( e->key() == Key_C) | 396 | else if( e->key() == Key_C) |
398 | copy(); | 397 | copy(); |
399 | else if( e->key() == Key_E) | 398 | else if( e->key() == Key_E) |
400 | runThis(); | 399 | runThis(); |
401 | else if( e->key() == Key_G) | 400 | else if( e->key() == Key_G) |
402 | currentPathCombo->lineEdit()->setFocus(); | 401 | currentPathCombo->lineEdit()->setFocus(); |
403 | else if( e->key() == Key_H ) | 402 | else if( e->key() == Key_H ) |
404 | showHidden(); | 403 | showHidden(); |
405 | else if( e->key() == Key_I) | 404 | else if( e->key() == Key_I) |
406 | fileStatus(); | 405 | fileStatus(); |
407 | else if( e->key() == Key_M) | 406 | else if( e->key() == Key_M) |
408 | move(); | 407 | move(); |
409 | else if( e->key() == Key_N ) | 408 | else if( e->key() == Key_N ) |
410 | mkDir(); | 409 | mkDir(); |
411 | else if( e->key() == Key_P) | 410 | else if( e->key() == Key_P) |
412 | filePerms(); | 411 | filePerms(); |
413 | else if( e->key() == Key_R ) | 412 | else if( e->key() == Key_R ) |
414 | rn(); | 413 | rn(); |
415 | else if( e->key() == Key_U ) | 414 | else if( e->key() == Key_U ) |
416 | upDir(); | 415 | upDir(); |
417 | else if( e->key() == Key_1) | 416 | else if( e->key() == Key_1) |
418 | switchToLocalTab(); | 417 | switchToLocalTab(); |
419 | else if( e->key() == Key_2) | 418 | else if( e->key() == Key_2) |
420 | switchToRemoteTab(); | 419 | switchToRemoteTab(); |
421 | else if( e->key() == Key_3) | 420 | else if( e->key() == Key_3) |
422 | CFButtonPushed(); | 421 | CFButtonPushed(); |
423 | else if( e->key() == Key_4) | 422 | else if( e->key() == Key_4) |
424 | SDButtonPushed(); | 423 | SDButtonPushed(); |
425 | else if( e->key() == Key_5 ) | 424 | else if( e->key() == Key_5 ) |
426 | homeButtonPushed(); | 425 | homeButtonPushed(); |
427 | else if( e->key() == Key_6 ) | 426 | else if( e->key() == Key_6 ) |
428 | docButtonPushed(); | 427 | docButtonPushed(); |
429 | else | 428 | else |
430 | e->accept(); | 429 | e->accept(); |
431 | } | 430 | } |
432 | 431 | ||
433 | 432 | ||
434 | void AdvancedFm::parsetab(const QString &fileName) { | 433 | void AdvancedFm::parsetab(const QString &fileName) { |
435 | 434 | ||
436 | fileSystemTypeList.clear(); | 435 | fileSystemTypeList.clear(); |
437 | fsList.clear(); | 436 | fsList.clear(); |
438 | struct mntent *me; | 437 | struct mntent *me; |
439 | FILE *mntfp = setmntent( fileName.latin1(), "r" ); | 438 | FILE *mntfp = setmntent( fileName.latin1(), "r" ); |
440 | if ( mntfp ) { | 439 | if ( mntfp ) { |
441 | while ( (me = getmntent( mntfp )) != 0 ) { | 440 | while ( (me = getmntent( mntfp )) != 0 ) { |
442 | QString deviceName = me->mnt_fsname; | 441 | QString deviceName = me->mnt_fsname; |
443 | QString filesystemType = me->mnt_type; | 442 | QString filesystemType = me->mnt_type; |
444 | QString mountDir = me->mnt_dir; | 443 | QString mountDir = me->mnt_dir; |
445 | if(deviceName != "none") { | 444 | if(deviceName != "none") { |
446 | if( fsList.contains(filesystemType) == 0 | 445 | if( fsList.contains(filesystemType) == 0 |
447 | & filesystemType.find("proc",0,TRUE) == -1 | 446 | & filesystemType.find("proc",0,TRUE) == -1 |
448 | & filesystemType.find("cramfs",0,TRUE) == -1 | 447 | & filesystemType.find("cramfs",0,TRUE) == -1 |
449 | & filesystemType.find("auto",0,TRUE) == -1) | 448 | & filesystemType.find("auto",0,TRUE) == -1) |
450 | fsList << filesystemType; | 449 | fsList << filesystemType; |
451 | fileSystemTypeList << mountDir+"::"+filesystemType; | 450 | fileSystemTypeList << mountDir+"::"+filesystemType; |
452 | } | 451 | } |
453 | } | 452 | } |
454 | } | 453 | } |
455 | endmntent( mntfp ); | 454 | endmntent( mntfp ); |
456 | } | 455 | } |
457 | 456 | ||
458 | QString AdvancedFm::getFileSystemType(const QString ¤tText) { | 457 | QString AdvancedFm::getFileSystemType(const QString ¤tText) { |
459 | parsetab("/etc/mtab"); //why did TT forget filesystem type? | 458 | parsetab("/etc/mtab"); //why did TT forget filesystem type? |
460 | QString current = currentText;//.right( currentText.length()-1); | 459 | QString current = currentText;//.right( currentText.length()-1); |
461 | QString baseFs; | 460 | QString baseFs; |
462 | for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) { | 461 | for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) { |
463 | QString temp = (*it); | 462 | QString temp = (*it); |
464 | QString path = temp.left(temp.find("::",0,TRUE) ); | 463 | QString path = temp.left(temp.find("::",0,TRUE) ); |
465 | path = path.right( path.length()-1); | 464 | path = path.right( path.length()-1); |
466 | if(path.isEmpty()) baseFs = temp.right( temp.length() - temp.find("::",0,TRUE) - 2); | 465 | if(path.isEmpty()) baseFs = temp.right( temp.length() - temp.find("::",0,TRUE) - 2); |
467 | if( current.find( path,0,TRUE) != -1 && !path.isEmpty()) { | 466 | if( current.find( path,0,TRUE) != -1 && !path.isEmpty()) { |
468 | return temp.right( temp.length() - temp.find("::",0,TRUE) - 2); | 467 | return temp.right( temp.length() - temp.find("::",0,TRUE) - 2); |
469 | } | 468 | } |
470 | } | 469 | } |
471 | return baseFs; | 470 | return baseFs; |
472 | } | 471 | } |
473 | 472 | ||
474 | QString AdvancedFm::getDiskSpace( const QString &path) { | 473 | QString AdvancedFm::getDiskSpace( const QString &path) { |
475 | struct statfs fss; | 474 | struct statfs fss; |
476 | if ( !statfs( path.latin1(), &fss ) ) { | 475 | if ( !statfs( path.latin1(), &fss ) ) { |
477 | int blkSize = fss.f_bsize; | 476 | int blkSize = fss.f_bsize; |
478 | // int totalBlks = fs.f_blocks; | 477 | // int totalBlks = fs.f_blocks; |
479 | int availBlks = fss.f_bavail; | 478 | int availBlks = fss.f_bavail; |
480 | 479 | ||
481 | long mult = blkSize / 1024; | 480 | long mult = blkSize / 1024; |
482 | long div = 1024 / blkSize; | 481 | long div = 1024 / blkSize; |
483 | if ( !mult ) mult = 1; | 482 | if ( !mult ) mult = 1; |
484 | if ( !div ) div = 1; | 483 | if ( !div ) div = 1; |
485 | 484 | ||
486 | return QString::number(availBlks * mult / div); | 485 | return QString::number(availBlks * mult / div); |
487 | } | 486 | } |
488 | return ""; | 487 | return ""; |
489 | } | 488 | } |
490 | 489 | ||
491 | 490 | ||
492 | void AdvancedFm::showFileMenu() { | 491 | void AdvancedFm::showFileMenu() { |
493 | QString curApp; | 492 | QString curApp; |
494 | curApp = CurrentView()->currentItem()->text(0); | 493 | curApp = CurrentView()->currentItem()->text(0); |
495 | 494 | ||
496 | MimeType mt(curApp); | 495 | MimeType mt(curApp); |
497 | const AppLnk* app = mt.application(); | 496 | const AppLnk* app = mt.application(); |
498 | QFile fi(curApp); | 497 | QFile fi(curApp); |
499 | QPopupMenu *m = new QPopupMenu(0); | 498 | QPopupMenu *m = new QPopupMenu(0); |
500 | QPopupMenu *n = new QPopupMenu(0); | 499 | QPopupMenu *n = new QPopupMenu(0); |
501 | // QPopupMenu *o = new QPopupMenu(0); | 500 | // QPopupMenu *o = new QPopupMenu(0); |
502 | m->insertItem(tr("Show Hidden Files"),this,SLOT(showHidden())); | 501 | m->insertItem(tr("Show Hidden Files"),this,SLOT(showHidden())); |
503 | 502 | ||
504 | if ( QFileInfo(fi).isDir()) { | 503 | if ( QFileInfo(fi).isDir()) { |
505 | m->insertSeparator(); | 504 | m->insertSeparator(); |
506 | m->insertItem(tr("Change Directory"),this,SLOT(doDirChange())); | 505 | m->insertItem(tr("Change Directory"),this,SLOT(doDirChange())); |
507 | } else { | 506 | } else { |
508 | 507 | ||
509 | if (app) | 508 | if (app) |
510 | m->insertItem(app->pixmap(),tr("Open in " + app->name()),this,SLOT(runThis())); | 509 | m->insertItem(app->pixmap(),tr("Open in " + app->name()),this,SLOT(runThis())); |
511 | else if(QFileInfo(fi).isExecutable() ) //damn opie doesnt like this | 510 | else if(QFileInfo(fi).isExecutable() ) //damn opie doesnt like this |
512 | m->insertItem(tr("Execute"),this,SLOT(runThis())); | 511 | m->insertItem(tr("Execute"),this,SLOT(runThis())); |
@@ -688,136 +687,137 @@ void AdvancedFm::removeCustomDir() { | |||
688 | 687 | ||
689 | } | 688 | } |
690 | 689 | ||
691 | void AdvancedFm::gotoCustomDir(const QString &dir) { | 690 | void AdvancedFm::gotoCustomDir(const QString &dir) { |
692 | // odebug << "gotoCustomDir(const QString &dir) " +dir << oendl; | 691 | // odebug << "gotoCustomDir(const QString &dir) " +dir << oendl; |
693 | // QString curDir = dir; | 692 | // QString curDir = dir; |
694 | // QDir *thisDir = CurrentDir(); | 693 | // QDir *thisDir = CurrentDir(); |
695 | // if( curDir.isEmpty()) { | 694 | // if( curDir.isEmpty()) { |
696 | // } | 695 | // } |
697 | if( dir == s_addBookmark) { | 696 | if( dir == s_addBookmark) { |
698 | addCustomDir(); | 697 | addCustomDir(); |
699 | } | 698 | } |
700 | if( dir == s_removeBookmark) { | 699 | if( dir == s_removeBookmark) { |
701 | removeCustomDir( ); | 700 | removeCustomDir( ); |
702 | } else { | 701 | } else { |
703 | gotoDirectory( dir); | 702 | gotoDirectory( dir); |
704 | // if(QDir( curDir).exists() ) | 703 | // if(QDir( curDir).exists() ) |
705 | // { | 704 | // { |
706 | // thisDir->setPath( curDir ); | 705 | // thisDir->setPath( curDir ); |
707 | // chdir( curDir.latin1() ); | 706 | // chdir( curDir.latin1() ); |
708 | // thisDir->cd( curDir, TRUE); | 707 | // thisDir->cd( curDir, TRUE); |
709 | // populateView(); | 708 | // populateView(); |
710 | // } | 709 | // } |
711 | } | 710 | } |
712 | } | 711 | } |
713 | 712 | ||
714 | QDir *AdvancedFm::CurrentDir() { | 713 | QDir *AdvancedFm::CurrentDir() { |
715 | if ( whichTab == 1) { | 714 | if ( whichTab == 1) { |
716 | // qDebug("CurrentTab is Local"); | 715 | // qDebug("CurrentTab is Local"); |
717 | return ¤tDir; | 716 | return ¤tDir; |
718 | } else { | 717 | } else { |
719 | // qDebug("CurrentTab is Remote"); | 718 | // qDebug("CurrentTab is Remote"); |
720 | return ¤tRemoteDir; | 719 | return ¤tRemoteDir; |
721 | } | 720 | } |
722 | } | 721 | } |
723 | 722 | ||
724 | QDir *AdvancedFm::OtherDir() { | 723 | QDir *AdvancedFm::OtherDir() { |
725 | // if ( TabWidget->currentWidget() == tab) { | 724 | // if ( TabWidget->currentWidget() == tab) { |
726 | if ( whichTab == 1) { | 725 | if ( whichTab == 1) { |
727 | return ¤tRemoteDir; | 726 | return ¤tRemoteDir; |
728 | } else { | 727 | } else { |
729 | return ¤tDir; | 728 | return ¤tDir; |
730 | } | 729 | } |
731 | } | 730 | } |
732 | 731 | ||
733 | QListView * AdvancedFm::CurrentView() { | 732 | QListView * AdvancedFm::CurrentView() { |
734 | // if ( TabWidget->currentWidget() == tab) { | 733 | // if ( TabWidget->currentWidget() == tab) { |
735 | if ( whichTab == 1) { | 734 | if ( whichTab == 1) { |
736 | // qDebug("CurrentView: local"); | 735 | // qDebug("CurrentView: local"); |
737 | return Local_View; | 736 | return Local_View; |
738 | } else { | 737 | } else { |
739 | // owarn << "CurrentView Tab 2" << oendl; | 738 | // owarn << "CurrentView Tab 2" << oendl; |
740 | // qDebug("CurrentView: remote"); | 739 | // qDebug("CurrentView: remote"); |
741 | return Remote_View; | 740 | return Remote_View; |
742 | } | 741 | } |
743 | } | 742 | } |
744 | 743 | ||
745 | QListView * AdvancedFm::OtherView() { | 744 | QListView * AdvancedFm::OtherView() { |
746 | if ( whichTab == 1) | 745 | if ( whichTab == 1) |
747 | return Remote_View; | 746 | return Remote_View; |
748 | else | 747 | else |
749 | return Local_View; | 748 | return Local_View; |
750 | } | 749 | } |
751 | 750 | ||
752 | void AdvancedFm::setOtherTabCurrent() { | 751 | void AdvancedFm::setOtherTabCurrent() { |
753 | // qDebug("setOtherTabCurrent() %d",whichTab); | 752 | // qDebug("setOtherTabCurrent() %d",whichTab); |
754 | if ( whichTab == 1) { | 753 | if ( whichTab == 1) { |
755 | TabWidget->setCurrentWidget(1); | 754 | TabWidget->setCurrentWidget(1); |
756 | } else { | 755 | } else { |
757 | TabWidget->setCurrentWidget(0); | 756 | TabWidget->setCurrentWidget(0); |
758 | } | 757 | } |
759 | OtherView()->setFocus(); | 758 | OtherView()->setFocus(); |
760 | OtherView()->setSelected( CurrentView()->firstChild(), true); | 759 | OtherView()->setSelected( CurrentView()->firstChild(), true); |
761 | } | 760 | } |
762 | 761 | ||
763 | void AdvancedFm::qcopReceive(const QCString &msg, const QByteArray &data) { | 762 | void AdvancedFm::qcopReceive(const QCString &msg, const QByteArray &data) { |
764 | // odebug << "qcop message "+msg << oendl; | 763 | // odebug << "qcop message "+msg << oendl; |
765 | QDataStream stream ( data, IO_ReadOnly ); | 764 | QDataStream stream ( data, IO_ReadOnly ); |
766 | if ( msg == "openDirectory(QString)" ) { | 765 | if ( msg == "openDirectory(QString)" ) { |
767 | // odebug << "received" << oendl; | 766 | // odebug << "received" << oendl; |
768 | QString file; | 767 | QString file; |
769 | stream >> file; | 768 | stream >> file; |
770 | gotoDirectory( (const QString &) file); | 769 | gotoDirectory( (const QString &) file); |
771 | } | 770 | } |
772 | } | 771 | } |
773 | 772 | ||
774 | void AdvancedFm::setDocument(const QString &file) { | 773 | void AdvancedFm::setDocument(const QString &file) { |
775 | gotoDirectory( file); | 774 | gotoDirectory( file); |
776 | 775 | ||
777 | } | 776 | } |
778 | 777 | ||
779 | void AdvancedFm::gotoDirectory(const QString &file) { | 778 | void AdvancedFm::gotoDirectory(const QString &file) { |
780 | // qDebug("goto dir "+file); | 779 | // qDebug("goto dir "+file); |
781 | QString curDir = file; | 780 | QString curDir = file; |
782 | QDir *thisDir = CurrentDir(); | 781 | QDir *thisDir = CurrentDir(); |
783 | if(QDir( curDir).exists() ) { | 782 | if(QDir( curDir).exists() ) { |
784 | thisDir->setPath( curDir ); | 783 | thisDir->setPath( curDir ); |
785 | chdir( curDir.latin1() ); | 784 | chdir( curDir.latin1() ); |
786 | thisDir->cd( curDir, TRUE); | 785 | thisDir->cd( curDir, TRUE); |
787 | populateView(); | 786 | populateView(); |
788 | } | 787 | } |
789 | else if(QFileInfo(curDir).exists()) { | 788 | else if(QFileInfo(curDir).exists()) { |
790 | QFileInfo fileInfo(curDir); | 789 | QFileInfo fileInfo(curDir); |
791 | curDir=fileInfo.dirPath(); | 790 | curDir=fileInfo.dirPath(); |
792 | if(QDir( curDir).exists() ) { | 791 | if(QDir( curDir).exists() ) { |
793 | thisDir->setPath( curDir ); | 792 | thisDir->setPath( curDir ); |
794 | chdir( curDir.latin1() ); | 793 | chdir( curDir.latin1() ); |
795 | thisDir->cd( curDir, TRUE); | 794 | thisDir->cd( curDir, TRUE); |
796 | populateView(); | 795 | populateView(); |
797 | } | 796 | } |
798 | findFile(file); | 797 | findFile(file); |
799 | } | 798 | } |
800 | 799 | ||
801 | } | 800 | } |
802 | 801 | ||
803 | void AdvancedFm::findFile(const QString &fileName) { | 802 | void AdvancedFm::findFile(const QString &fileName) { |
804 | QFileInfo fi(fileName); | 803 | QFileInfo fi(fileName); |
805 | QListView *thisView = CurrentView(); | 804 | QListView *thisView = CurrentView(); |
806 | QListViewItemIterator it( thisView ); | 805 | QListViewItemIterator it( thisView ); |
807 | for ( ; it.current(); ++it ) { | 806 | for ( ; it.current(); ++it ) { |
808 | if(it.current()->text(0) == fi.fileName()) { | 807 | if(it.current()->text(0) == fi.fileName()) { |
809 | it.current()->setSelected(true); | 808 | it.current()->setSelected(true); |
810 | thisView->ensureItemVisible(it.current()); | 809 | thisView->ensureItemVisible(it.current()); |
811 | } | 810 | } |
812 | } | 811 | } |
813 | } | 812 | } |
814 | 813 | ||
815 | void AdvancedFm::slotSwitchMenu(int item) { | 814 | void AdvancedFm::slotSwitchMenu(int item) { |
815 | Q_UNUSED(item); | ||
816 | // qDebug( "Switch %d",item); | 816 | // qDebug( "Switch %d",item); |
817 | // viewMenu->setItemChecked(item, true); | 817 | // viewMenu->setItemChecked(item, true); |
818 | } | 818 | } |
819 | 819 | ||
820 | void AdvancedFm::navigateToSelected() { | 820 | void AdvancedFm::navigateToSelected() { |
821 | if( !CurrentView()->currentItem()) return; | 821 | if( !CurrentView()->currentItem()) return; |
822 | doDirChange(); | 822 | doDirChange(); |
823 | } | 823 | } |