summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/advancedfm/advancedfm.cpp209
-rw-r--r--noncore/apps/advancedfm/advancedfm.h42
-rw-r--r--noncore/apps/advancedfm/advancedfmData.cpp56
3 files changed, 264 insertions, 43 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp
index 9edf7c1..d8bdff7 100644
--- a/noncore/apps/advancedfm/advancedfm.cpp
+++ b/noncore/apps/advancedfm/advancedfm.cpp
@@ -18,2 +18,3 @@
+#include <qpe/config.h>
#include <qpe/filemanager.h>
@@ -29,3 +30,6 @@
#include <qpe/resource.h>
+#include <qpe/menubutton.h>
+
+#include <qregexp.h>
#include <qtabwidget.h>
@@ -92,3 +96,3 @@ void AdvancedFm::cleanUp() {
void AdvancedFm::tabChanged(QWidget *w) {
- qDebug("tab changed %d",TabWidget->getCurrentTab());
+// qDebug("tab changed %d",TabWidget->getCurrentTab());
@@ -196,3 +200,3 @@ void AdvancedFm::populateLocalView() {
lstat( mydirent->d_name, &buf);
- qDebug(mydirent->d_name);
+// qDebug(mydirent->d_name);
fileL.sprintf("%s", mydirent->d_name);
@@ -295,3 +299,3 @@ void AdvancedFm::populateRemoteView() {
lstat( mydirent->d_name, &buf);
- qDebug(mydirent->d_name);
+// qDebug(mydirent->d_name);
fileL.sprintf("%s", mydirent->d_name);
@@ -409,3 +413,3 @@ void AdvancedFm::localListPressed( int mouse, QListViewItem *, const QPoint& , i
{
- qDebug("cancel rename");
+// qDebug("cancel rename");
cancelRename();
@@ -417,3 +421,3 @@ void AdvancedFm::localListPressed( int mouse, QListViewItem *, const QPoint& , i
menuTimer.start( 500, TRUE );
- qDebug("Start menu timer\n");
+// qDebug("Start menu timer\n");
break;
@@ -429,3 +433,3 @@ void AdvancedFm::remoteListPressed( int mouse, QListViewItem*, const QPoint&, in
{
- qDebug("cancel rename");
+// qDebug("cancel rename");
cancelRename();
@@ -436,3 +440,3 @@ void AdvancedFm::remoteListPressed( int mouse, QListViewItem*, const QPoint&, in
menuTimer.start( 500, TRUE );
- qDebug("Start menu timer");
+// qDebug("Start menu timer");
break;
@@ -482,3 +486,3 @@ void AdvancedFm::currentPathComboChanged() {
void AdvancedFm::fillCombo(const QString &currentPath) {
- qDebug("%d",TabWidget->getCurrentTab());
+// qDebug("%d",TabWidget->getCurrentTab());
if (TabWidget->getCurrentTab() == 0) {
@@ -525,3 +529,3 @@ QStringList AdvancedFm::getPath() {
strList << it.current()->text(0);
- qDebug(it.current()->text(0));
+// qDebug(it.current()->text(0));
}
@@ -535,3 +539,3 @@ QStringList AdvancedFm::getPath() {
strList << it.current()->text(0);
- qDebug(it.current()->text(0));
+// qDebug(it.current()->text(0));
}
@@ -877,3 +881,3 @@ void AdvancedFm::addToDocs() {
curFile = currentDir.canonicalPath()+"/"+(*it);
- qDebug(curFile);
+// qDebug(curFile);
DocLnk f;
@@ -887,3 +891,3 @@ void AdvancedFm::addToDocs() {
curFile = currentRemoteDir.canonicalPath()+"/"+(*it);
- qDebug(curFile);
+// qDebug(curFile);
@@ -899 +903,182 @@ void AdvancedFm::addToDocs() {
+
+void AdvancedFm::customDirsToMenu()
+{
+
+ Config cfg("AdvancedFm");
+ cfg.setGroup("Menu");
+
+ QStringList list = cfg.readListEntry( "CustomDir", ',');
+ menuButton->insertItems(list );
+
+// for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it )
+// {
+// customDirMenu->insertItem(*it );
+// }
+}
+
+void AdvancedFm::dirMenuSelected(int item)
+{
+ qDebug("menu item %d", item);
+ switch(item)
+ {
+
+ case -21:
+ case 0:
+ addCustomDir();
+ break;
+ case -22:
+ case 1:
+ removeCustomDir();
+ break;
+ default:
+ {
+// gotoCustomDir( menuButton->text(item));
+// gotoCustomDir( customDirMenu->text(item));
+ }
+ break;
+
+ };
+}
+
+void AdvancedFm::addCustomDir()
+{
+ Config cfg("AdvancedFm");
+ cfg.setGroup("Menu");
+ QString dir;
+ QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)',');
+
+ if (TabWidget->getCurrentTab() == 0)
+ {
+ dir = currentDir.canonicalPath();
+ }
+ else
+ {
+ dir = currentRemoteDir.canonicalPath();
+ }
+
+ bool addIt=true;
+ for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it )
+ {
+ if( dir == (*it))
+ {
+ addIt=false;
+ }
+ }
+ if(addIt)
+ {
+ menuButton->insertItem(dir);
+// customDirMenu->insertItem(dir);
+ list << dir;
+ }
+
+ cfg.writeEntry("CustomDir", list, ',');
+ cfg.write();
+}
+
+void AdvancedFm::removeCustomDir()
+{
+// qDebug("remove custom dir");
+ Config cfg("AdvancedFm");
+ cfg.setGroup("Menu");
+ QString dir;
+ QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)',');
+ QStringList list2;
+
+ if (TabWidget->getCurrentTab() == 0)
+ {
+ dir = currentDir.canonicalPath();
+ }
+ else
+ {
+ dir = currentRemoteDir.canonicalPath();
+ }
+ int ramble=2;
+// int ramble=-24;
+//first remove list
+ if(list.grep(dir,true).isEmpty())
+ {
+ QMessageBox::message("AdvancedFm",tr("Cannot remove current directory\nfrom bookmarks.\nIt is not bookmarked!!"));
+ }
+ else
+ {
+ for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it )
+ {
+ if((*it) != dir)//current item is not our current dir, so add it to temp list
+ {
+ list2 <<(*it);
+ }
+ else
+ {
+// customDirMenu->removeItem( ramble);
+ menuButton->remove( ramble);
+
+ }
+ ramble++;
+// ramble--;
+ }
+
+ cfg.writeEntry("CustomDir", list2, ',');
+ cfg.write();
+ }
+// customDirsToMenu();
+
+}
+
+void AdvancedFm::gotoCustomDir(const QString &dir)
+{
+// qDebug("gotoCustomDir(const QString &dir) " +dir );
+ QString curDir = dir;
+// if( curDir.isEmpty()) {
+// }
+ if( curDir == s_addBookmark)
+ {
+ addCustomDir();
+ }
+ if( curDir == s_removeBookmark)
+ {
+ removeCustomDir( );
+ }
+ else
+ {
+ if(QDir( curDir).exists() )
+ {
+ if (TabWidget->getCurrentTab() == 0)
+ {
+ currentDir.setPath( curDir );
+ chdir( curDir.latin1() );
+ currentDir.cd( curDir, TRUE);
+ populateLocalView();
+ }
+ else
+ {
+ currentRemoteDir.setPath( curDir );
+ chdir( curDir.latin1() );
+ currentRemoteDir.cd( curDir, TRUE);
+ populateRemoteView();
+ }
+ }
+ }
+// menuButton
+// qDebug("gotoCustomDir(const QString &dir) " +dir );
+// QString curDir = dir;
+// if(QDir( curDir).exists() )
+// {
+// if (TabWidget->getCurrentTab() == 0)
+// {
+// currentDir.setPath( curDir );
+// chdir( curDir.latin1() );
+// currentDir.cd( curDir, TRUE);
+// populateLocalView();
+// }
+// else
+// {
+// currentRemoteDir.setPath( curDir );
+// chdir( curDir.latin1() );
+// currentRemoteDir.cd( curDir, TRUE);
+// populateRemoteView();
+// }
+// }
+// menuButton->setLabel(" ");
+// menuButton
+}
diff --git a/noncore/apps/advancedfm/advancedfm.h b/noncore/apps/advancedfm/advancedfm.h
index 42775ee..7478dcb 100644
--- a/noncore/apps/advancedfm/advancedfm.h
+++ b/noncore/apps/advancedfm/advancedfm.h
@@ -46,2 +46,3 @@ class QListViewItem;
class QLineEdit;
+class MenuButton;
@@ -57,19 +58,2 @@ public:
~AdvancedFm();
-
- OTabWidget *TabWidget;
-// QTabWidget *TabWidget;
- QWidget *tab, *tab_2, *tab_3;
- QListView *Local_View, *Remote_View;
-
- QLineEdit *currentPathEdit;
- QPopupMenu *fileMenu, *localMenu, *remoteMenu, *viewMenu;
- QToolButton *homeButton, *docButton, *cdUpButton, *sdButton, *cfButton, *qpeDirButton;
-// QPushButton *homeButton, *docButton, *cdUpButton, *sdButton, *cfButton, *qpeDirButton;
- QDir currentDir, currentRemoteDir;
- QComboBox *currentPathCombo;
- QString filterStr;
- QListViewItem * item;
- bool b;
- QStringList fileSystemTypeList, fsList;
- int currentServerConfig;
protected slots:
@@ -116,2 +100,19 @@ protected slots:
protected:
+
+ OTabWidget *TabWidget;
+// QTabWidget *TabWidget;
+ QWidget *tab, *tab_2, *tab_3;
+ QListView *Local_View, *Remote_View;
+
+ QLineEdit *currentPathEdit;
+ QPopupMenu *fileMenu, *localMenu, *remoteMenu, *viewMenu /*, *customDirMenu*/;
+ QToolButton *homeButton, *docButton, *cdUpButton, *sdButton, *cfButton, *qpeDirButton;
+// QPushButton *homeButton, *docButton, *cdUpButton, *sdButton, *cfButton, *qpeDirButton;
+ QDir currentDir, currentRemoteDir;
+ QComboBox *currentPathCombo;
+ QString filterStr, s_addBookmark, s_removeBookmark;
+ QListViewItem * item;
+ bool b;
+ QStringList fileSystemTypeList, fsList;
+ int currentServerConfig;
bool zaurusDevice;
@@ -131,2 +132,3 @@ protected:
protected slots:
+ void dirMenuSelected(int);
void showFileMenu();
@@ -153,2 +155,3 @@ protected slots:
private:
+ MenuButton *menuButton;
QString oldName;
@@ -160,4 +163,9 @@ private:
void okRename();
+ void customDirsToMenu();
+ void addCustomDir();
+ void removeCustomDir();
+
private slots:
void processEnded();
+ void gotoCustomDir(const QString &);
};
diff --git a/noncore/apps/advancedfm/advancedfmData.cpp b/noncore/apps/advancedfm/advancedfmData.cpp
index 0966f02..bb80dc6 100644
--- a/noncore/apps/advancedfm/advancedfmData.cpp
+++ b/noncore/apps/advancedfm/advancedfmData.cpp
@@ -18,2 +18,4 @@
#include <qpe/resource.h>
+#include <qpe/menubutton.h>
+#include <qpe/config.h>
@@ -45,2 +47,3 @@ void AdvancedFm::init() {
viewMenu = new QPopupMenu( this );
+// customDirMenu = new QPopupMenu( this );
@@ -50,2 +53,12 @@ void AdvancedFm::init() {
menuBar->insertItem( tr( "View" ), viewMenu);
+// menuBar->insertItem( tr( "^" ), customDirMenu);
+
+ cdUpButton = new QToolButton( this,"cdUpButton");
+ cdUpButton->setPixmap(Resource::loadPixmap("up"));
+ cdUpButton->setFixedSize( QSize( 20, 20 ) );
+ layout->addMultiCellWidget( cdUpButton , 0, 0, 2, 2);
+
+ menuButton = new MenuButton(this);
+ menuButton->setFixedSize( QSize( 20, 20 ) );
+ layout->addMultiCellWidget( menuButton , 0, 0, 3, 3);
@@ -54,3 +67,3 @@ void AdvancedFm::init() {
qpeDirButton ->setFixedSize( QSize( 20, 20 ) );
- layout->addMultiCellWidget( qpeDirButton , 0, 0, 2, 2);
+ layout->addMultiCellWidget( qpeDirButton , 0, 0, 4, 4);
@@ -59,3 +72,3 @@ void AdvancedFm::init() {
cfButton ->setFixedSize( QSize( 20, 20 ) );
- layout->addMultiCellWidget( cfButton , 0, 0, 3, 3);
+ layout->addMultiCellWidget( cfButton , 0, 0, 5, 5);
@@ -64,8 +77,4 @@ void AdvancedFm::init() {
sdButton->setFixedSize( QSize( 20, 20 ) );
- layout->addMultiCellWidget( sdButton , 0, 0, 4, 4);
+ layout->addMultiCellWidget( sdButton , 0, 0, 6, 6);
- cdUpButton = new QToolButton( this,"cdUpButton");
- cdUpButton->setPixmap(Resource::loadPixmap("up"));
- cdUpButton ->setFixedSize( QSize( 20, 20 ) );
- layout->addMultiCellWidget( cdUpButton , 0, 0, 5, 5);
@@ -74,3 +83,3 @@ void AdvancedFm::init() {
docButton->setFixedSize( QSize( 20, 20 ) );
- layout->addMultiCellWidget( docButton, 0, 0, 6, 6);
+ layout->addMultiCellWidget( docButton, 0, 0, 7, 7);
@@ -79,3 +88,3 @@ void AdvancedFm::init() {
homeButton->setFixedSize( QSize( 20, 20 ) );
- layout->addMultiCellWidget( homeButton, 0, 0, 7, 7);
+ layout->addMultiCellWidget( homeButton, 0, 0, 8, 8);
@@ -101,2 +110,16 @@ void AdvancedFm::init() {
+ s_addBookmark = tr("Bookmark Directory");
+ s_removeBookmark = tr("Remove Current Directory from Bookmarks");
+
+ menuButton->setUseLabel(false);
+ menuButton->insertItem( s_addBookmark);
+ menuButton->insertItem( s_removeBookmark);
+ menuButton->insertSeparator();
+// menuButton->insertItem("");
+
+// customDirMenu->insertItem(tr("Add This Directory"));
+// customDirMenu->insertItem(tr("Remove This Directory"));
+// customDirMenu->insertSeparator();
+
+ customDirsToMenu();
@@ -104,3 +127,3 @@ void AdvancedFm::init() {
currentPathCombo->setEditable(TRUE);
- layout->addMultiCellWidget( currentPathCombo, 1, 1, 0, 7);
+ layout->addMultiCellWidget( currentPathCombo, 1, 1, 0, 8);
currentPathCombo->lineEdit()->setText( currentDir.canonicalPath());
@@ -109,3 +132,3 @@ void AdvancedFm::init() {
- layout->addMultiCellWidget( currentPathCombo, 1, 1, 0, 7);
+ layout->addMultiCellWidget( currentPathCombo, 1, 1, 0, 8);
@@ -114,3 +137,3 @@ void AdvancedFm::init() {
// TabWidget = new QTabWidget( this, "TabWidget" );
- layout->addMultiCellWidget( TabWidget, 2, 2, 0, 7);
+ layout->addMultiCellWidget( TabWidget, 2, 2, 0, 8);
@@ -216,3 +239,3 @@ void AdvancedFm::initConnections() {
connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) );
- connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) );
+ connect( homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) );
connect( currentPathCombo, SIGNAL( activated( const QString & ) ),
@@ -235,3 +258,3 @@ void AdvancedFm::initConnections() {
- connect(TabWidget,SIGNAL(currentChanged(QWidget *)),
+ connect( TabWidget,SIGNAL(currentChanged(QWidget *)),
this,SLOT(tabChanged(QWidget*)));
@@ -240,2 +263,7 @@ void AdvancedFm::initConnections() {
+ connect( menuButton, SIGNAL( selected(const QString &)), SLOT(gotoCustomDir(const QString&)));
+// connect( menuButton, SIGNAL( selected( int)), SLOT( dirMenuSelected(int)));
+
+// connect( customDirMenu, SIGNAL( activated(int)), this, SLOT( dirMenuSelected(int)));
+
}