summaryrefslogtreecommitdiff
path: root/noncore/apps/advancedfm/advancedfm.cpp
Side-by-side diff
Diffstat (limited to 'noncore/apps/advancedfm/advancedfm.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/apps/advancedfm/advancedfm.cpp74
1 files changed, 50 insertions, 24 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp
index afb44f5..b4461cb 100644
--- a/noncore/apps/advancedfm/advancedfm.cpp
+++ b/noncore/apps/advancedfm/advancedfm.cpp
@@ -3,24 +3,25 @@
-------------------
** Created: Sat Mar 9 23:33:09 2002
copyright : (C) 2002 by ljp
email : ljp@llornkcor.com
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
#define DEVELOPERS_VERSION
#include "advancedfm.h"
+#include <opie2/odebug.h>
#include <qpe/qpeapplication.h>
#include <qpe/config.h>
#include <qpe/mimetype.h>
#include <qpe/applnk.h>
#include <qpe/resource.h>
#include <qpe/menubutton.h>
#include <qcombobox.h>
#include <qpopupmenu.h>
#include <qlistview.h>
#include <qmessagebox.h>
#include <qlineedit.h>
@@ -34,77 +35,94 @@
#include <mntent.h>
using namespace Opie::Ui;
AdvancedFm::AdvancedFm(QWidget *,const char*, WFlags )
: QMainWindow( ) {
init();
renameBox = 0;
unknownXpm = Resource::loadImage( "UnknownDocument" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() );
initConnections();
+
whichTab=1;
- rePopulate();
- currentPathCombo->setFocus();
+ populateView();
+// rePopulate();
+// currentPathCombo->setFocus();
channel = new QCopChannel( "QPE/Application/advancedfm", this );
connect( channel, SIGNAL(received(const QCString&,const QByteArray&)),
this, SLOT( qcopReceive(const QCString&,const QByteArray&)) );
+
+// if( CurrentView() == Local_View)
+// qDebug("LOCAL VIEW");
+// else
+// qDebug("REMOTE VIEW");
+ switchToLocalTab();
}
AdvancedFm::~AdvancedFm() {
}
void AdvancedFm::cleanUp() {
QString sfile=QDir::homeDirPath();
if(sfile.right(1) != "/")
sfile+="/._temp";
else
sfile+="._temp";
QFile file( sfile);
if(file.exists())
file.remove();
}
-void AdvancedFm::tabChanged(QWidget *) {
-// owarn << "tab changed" << oendl;
+void AdvancedFm::tabChanged(QWidget *wd) {
+ if(wd == tab)
+ odebug << "LOCAL VIEW SHOWN"<< oendl;
+ else if(wd == tab_2)
+ odebug<< "REMOTE VIEW SHOWN"<< oendl;
+
QString path = CurrentDir()->canonicalPath();
currentPathCombo->lineEdit()->setText( path );
- if(whichTab == 1) {
+ if ( TabWidget->currentWidget() == tab) {
+// if(whichTab == 1) {
viewMenu->setItemChecked(viewMenu->idAt(0), true);
viewMenu->setItemChecked(viewMenu->idAt(1), false);
} else {
viewMenu->setItemChecked(viewMenu->idAt(0), false);
viewMenu->setItemChecked(viewMenu->idAt(1), true);
}
QString fs= getFileSystemType( (const QString &) path);
setCaption(tr("AdvancedFm :: ")+fs+" :: "
+checkDiskSpace( (const QString &) path )+ tr(" kB free") );
chdir( path.latin1());
+ if( wd == Local_View) {
+ Remote_View->clearFocus();
+ } else {
+ Local_View->clearFocus();
+ }
+
}
void AdvancedFm::populateView() {
-// owarn << "PopulateView" << oendl;
QPixmap pm;
QListView *thisView = CurrentView();
QDir *thisDir = CurrentDir();
QString path = thisDir->canonicalPath();
-//owarn << "path is "+path << oendl;
thisView->clear();
thisDir->setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
thisDir->setMatchAllDirs(TRUE);
thisDir->setNameFilter(filterStr);
QString fileL, fileS, fileDate;
QString fs= getFileSystemType((const QString &) path);
setCaption(tr("AdvancedFm :: ")+fs+" :: "
+checkDiskSpace((const QString &) path)+ tr(" kB free") );
bool isDir=FALSE;
const QFileInfoList *list = thisDir->entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
QFileInfoListIterator it(*list);
QFileInfo *fi;
@@ -206,25 +224,30 @@ void AdvancedFm::rePopulate() {
// int tmpTab = whichTab;
// // odebug << "" << tmpTab << "" << oendl;
// for(int i =1; i < 3; i++) {
// TabWidget->setCurrentWidget(i - 1);
// populateView();
// }
// TabWidget->setCurrentWidget( tmpTab - 1);
}
void AdvancedFm::ListClicked(QListViewItem *selectedItem) {
-//owarn << "listclicked" << oendl;
+ if ( TabWidget->currentWidget() == tab)
+ qDebug("XXXXXXXXXXXXXXXXXXXXXXXX ListClicked local");
+ else
+ qDebug("XXXXXXXXXXXXXXXXXXXXXXXX ListClicked remote");
+
+
if(selectedItem) {
QString strItem=selectedItem->text(0);
// owarn << strItem << oendl;
QString strSize=selectedItem->text(1);
strSize=strSize.stripWhiteSpace();
bool isDirectory = false;
QString strItem2;
if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) {//if symlink
strItem2 = dealWithSymName((const QString&)strItem);
if(QDir(strItem2).exists() )
strItem = strItem2;
@@ -237,69 +260,72 @@ void AdvancedFm::ListClicked(QListViewItem *selectedItem) {
}
if( isDirectory ) {
CurrentDir()->cd( strItem, TRUE);
populateView();
CurrentView()->ensureItemVisible( CurrentView()->firstChild());
}
chdir( strItem.latin1());
}
}
void AdvancedFm::ListPressed( int mouse, QListViewItem *item, const QPoint& , int ) {
- dealWithSchmooSchmaa( item->listView());
+ Q_UNUSED(item);
switch (mouse) {
case 1:
{
if(renameBox != 0 ) {
cancelRename();
}
}
break;
+// case 2:
+// menuTimer.start( 50, TRUE );
+// break;
};
}
void AdvancedFm::switchToLocalTab() {
-//owarn << "switch to local view" << oendl;
TabWidget->setCurrentWidget(0);
Local_View->setFocus();
+
}
void AdvancedFm::switchToRemoteTab() {
-//owarn << "switch to local view" << oendl;
TabWidget->setCurrentWidget(1);
Remote_View->setFocus();
}
void AdvancedFm::readConfig() {
Config cfg("AdvancedFm");
}
void AdvancedFm::writeConfig() {
Config cfg("AdvancedFm");
}
void AdvancedFm::currentPathComboChanged() {
if(QDir( currentPathCombo->lineEdit()->text()).exists()) {
CurrentDir()->setPath( currentPathCombo->lineEdit()->text() );
populateView();
} else {
QMessageBox::message(tr("Note"),tr("That directory does not exist"));
}
}
void AdvancedFm::fillCombo(const QString &currentPath) {
- if ( whichTab == 1) {
+ if ( TabWidget->currentWidget() == tab) {
+// if ( whichTab == 1) {
currentPathCombo->lineEdit()->setText( currentPath);
if( localDirPathStringList.grep( currentPath,TRUE).isEmpty() ) {
currentPathCombo->clear();
localDirPathStringList.prepend( currentPath );
currentPathCombo->insertStringList( localDirPathStringList,-1);
}
} else {
currentPathCombo->lineEdit()->setText( currentPath);
if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) {
currentPathCombo->clear();
remoteDirPathStringList.prepend( currentPath );
currentPathCombo->insertStringList( remoteDirPathStringList,-1);
@@ -748,58 +774,67 @@ void AdvancedFm::gotoCustomDir(const QString &dir) {
// if(QDir( curDir).exists() )
// {
// thisDir->setPath( curDir );
// chdir( curDir.latin1() );
// thisDir->cd( curDir, TRUE);
// populateView();
// }
}
}
QDir *AdvancedFm::CurrentDir() {
+ if ( TabWidget->currentWidget() == tab)
+ qDebug("CurrentTab is Local");
+ else
+ qDebug("CurrentTab is Remote");
+
if ( whichTab == 1) {
return &currentDir;
} else {
return &currentRemoteDir;
}
}
QDir *AdvancedFm::OtherDir() {
+// if ( TabWidget->currentWidget() == tab) {
if ( whichTab == 1) {
return &currentRemoteDir;
} else {
return &currentDir;
}
}
QListView * AdvancedFm::CurrentView() {
+ if ( TabWidget->currentWidget() == tab)
+ odebug << "CurrentView local" << oendl;
+
+// if ( TabWidget->currentWidget() == tab) {
if ( whichTab == 1) {
-// owarn << "CurrentView Tab 1" << oendl;
return Local_View;
} else {
// owarn << "CurrentView Tab 2" << oendl;
return Remote_View;
}
}
QListView * AdvancedFm::OtherView() {
if ( whichTab == 1)
return Remote_View;
else
return Local_View;
}
void AdvancedFm::setOtherTabCurrent() {
-// owarn << "setOtherTabCurrent() " << whichTab << "" << oendl;
+ qDebug("setOtherTabCurrent() %d",whichTab);
if ( whichTab == 1) {
TabWidget->setCurrentWidget(1);
} else {
TabWidget->setCurrentWidget(0);
}
OtherView()->setFocus();
OtherView()->setSelected( CurrentView()->firstChild(), true);
}
void AdvancedFm::qcopReceive(const QCString &msg, const QByteArray &data) {
// odebug << "qcop message "+msg << oendl;
QDataStream stream ( data, IO_ReadOnly );
@@ -808,25 +843,25 @@ void AdvancedFm::qcopReceive(const QCString &msg, const QByteArray &data) {
QString file;
stream >> file;
gotoDirectory( (const QString &) file);
}
}
void AdvancedFm::setDocument(const QString &file) {
gotoDirectory( file);
}
void AdvancedFm::gotoDirectory(const QString &file) {
-// owarn << "goto dir "+file << oendl;
+ qDebug("goto dir "+file);
QString curDir = file;
QDir *thisDir = CurrentDir();
if(QDir( curDir).exists() ) {
thisDir->setPath( curDir );
chdir( curDir.latin1() );
thisDir->cd( curDir, TRUE);
populateView();
}
else if(QFileInfo(curDir).exists()) {
QFileInfo fileInfo(curDir);
curDir=fileInfo.dirPath();
if(QDir( curDir).exists() ) {
@@ -848,25 +883,16 @@ void AdvancedFm::findFile(const QString &fileName) {
if(it.current()->text(0) == fi.fileName()) {
it.current()->setSelected(true);
thisView->ensureItemVisible(it.current());
}
}
}
void AdvancedFm::slotSwitchMenu(int ) {
// odebug << "Switch " << item << "" << oendl;
// viewMenu->setItemChecked(item, true);
}
-void AdvancedFm::dealWithSchmooSchmaa(QWidget *w) {
- tabChanged( w);
- if( w == Local_View) {
- Remote_View->clearFocus();
- } else {
- Local_View->clearFocus();
- }
-}
-
void AdvancedFm::navigateToSelected() {
if( !CurrentView()->currentItem()) return;
doDirChange();
}