summaryrefslogtreecommitdiff
path: root/core
authorllornkcor <llornkcor>2002-03-18 01:43:17 (UTC)
committer llornkcor <llornkcor>2002-03-18 01:43:17 (UTC)
commitd9290bfa0b37c3026dbe0ffbd88663379df44fa2 (patch) (side-by-side diff)
tree45d17ef84edc8543cdfe1f7b659c76fd36a54311 /core
parent4c0bbc662731b8d3e61f43735fd6131746da306f (diff)
downloadopie-d9290bfa0b37c3026dbe0ffbd88663379df44fa2.zip
opie-d9290bfa0b37c3026dbe0ffbd88663379df44fa2.tar.gz
opie-d9290bfa0b37c3026dbe0ffbd88663379df44fa2.tar.bz2
added a popupmenu to filedialog
Diffstat (limited to 'core') (more/less context) (show whitespace changes)
-rw-r--r--core/apps/textedit/fileBrowser.cpp104
-rw-r--r--core/apps/textedit/fileBrowser.h8
-rw-r--r--core/apps/textedit/textedit.pro6
3 files changed, 112 insertions, 6 deletions
diff --git a/core/apps/textedit/fileBrowser.cpp b/core/apps/textedit/fileBrowser.cpp
index 8cb7c38..1fdf9d9 100644
--- a/core/apps/textedit/fileBrowser.cpp
+++ b/core/apps/textedit/fileBrowser.cpp
@@ -3,37 +3,44 @@
** Created: Fri Dec 14 08:16:46 2001
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
****************************************************************************/
#include "fileBrowser.h"
+#include "inputDialog.h"
+
#include <qpe/config.h>
#include <qpe/resource.h>
#include <qpe/fileselector.h>
#include <qpe/qpeapplication.h>
#include <qwidgetstack.h>
#include <qlistview.h>
#include <qcombo.h>
#include <qpushbutton.h>
#include <qfile.h>
#include <qmessagebox.h>
#include <qlayout.h>
#include <unistd.h>
+#include <qpopupmenu.h>
+#include <qlineedit.h>
+
+#include <unistd.h>
+#include <stdlib.h>
static int u_id = 1;
static int get_unique_id()
{
return u_id++;
}
fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags fl , const QString filter )
: QDialog( parent, name, modal, fl )
{
if ( !name )
setName( "fileBrowser" );
@@ -72,25 +79,30 @@ fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags
ListView->addColumn( tr( "Name" ) );
ListView->setColumnWidth(0,120);
ListView->setSorting( 2, FALSE);
ListView->addColumn( tr( "Size" ) );
ListView->setColumnWidth(1,-1);
ListView->addColumn( "Date",-1);
// ListView->addColumn( tr( "" ) );
ListView->setColumnWidthMode(0,QListView::Manual);
ListView->setColumnAlignment(1,QListView::AlignRight);
ListView->setColumnAlignment(2,QListView::AlignRight);
ListView->setAllColumnsShowFocus( TRUE );
- connect( ListView, SIGNAL(pressed( QListViewItem*)), SLOT(listClicked(QListViewItem *)) );
+ QPEApplication::setStylusOperation( ListView->viewport(),QPEApplication::RightOnHold);
+ connect( ListView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
+ this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) );
+
+ connect( ListView, SIGNAL( clicked( QListViewItem*)), SLOT(listClicked(QListViewItem *)) );
+
FileStack->addWidget( ListView, get_unique_id() );
fileSelector = new FileSelector( "text/*", FileStack, "fileselector" , FALSE, FALSE); //buggy
// connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( showEditTools() ) );
// connect( fileSelector, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) );
connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( docOpen( const DocLnk & ) ) );
layout->addMultiCellWidget( FileStack, 1, 1, 0, 2 );
SelectionCombo = new QComboBox( FALSE, this, "SelectionCombo" );
SelectionCombo->setMinimumSize( QSize( 200, 25 ) );
SelectionCombo->insertItem( tr( "Documents" ) );
SelectionCombo->insertItem( tr( "All files" ) );
@@ -263,12 +275,102 @@ void fileBrowser::selectionChanged( const QString &select )
dirLabel->show();
docButton->show();
homeButton->show();
FileStack->raiseWidget( ListView );
}
}
void fileBrowser::docOpen( const DocLnk &doc )
{
fileList.append( doc.file().latin1() );
accept();
}
+
+void fileBrowser::ListPressed( int mouse, QListViewItem *item, const QPoint &point, int i)
+{
+ switch (mouse) {
+ case 1:
+ break;
+ case 2:
+ showListMenu(item);
+ break;
+ };
+}
+
+void fileBrowser::showListMenu(QListViewItem *item) {
+
+ QPopupMenu m;// = new QPopupMenu( Local_View );
+ if( item->text(0).find("/",0,TRUE))
+ m.insertItem( tr( "Change Directory" ), this, SLOT( doCd() ));
+ else
+ m.insertItem( tr( "Make Directory" ), this, SLOT( makDir() ));
+ m.insertItem( tr( "Rename" ), this, SLOT( localRename() ));
+ m.insertSeparator();
+ m.insertItem( tr( "Delete" ), this, SLOT( localDelete() ));
+ m.exec( QCursor::pos() );
+
+}
+
+void fileBrowser::doCd() {
+ listClicked( ListView->currentItem());
+}
+
+void fileBrowser::makDir() {
+ InputDialog *fileDlg;
+ fileDlg = new InputDialog(this,"Make Directory",TRUE, 0);
+ fileDlg->exec();
+ if( fileDlg->result() == 1 ) {
+ QString filename = fileDlg->LineEdit1->text();
+ currentDir.mkdir( currentDir.canonicalPath()+"/"+filename);
+ }
+ populateList();
+}
+
+void fileBrowser::localRename() {
+ QString curFile = ListView->currentItem()->text(0);
+ InputDialog *fileDlg;
+ fileDlg = new InputDialog(this,"Rename",TRUE, 0);
+ fileDlg->inputText = curFile;
+ fileDlg->exec();
+ if( fileDlg->result() == 1 ) {
+ QString oldname = currentDir.canonicalPath() + "/" + curFile;
+ QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist";
+ if( rename(oldname.latin1(), newName.latin1())== -1)
+ QMessageBox::message("Note","Could not rename");
+ }
+ populateList();
+}
+
+void fileBrowser::localDelete() {
+ QString f = ListView->currentItem()->text(0);
+ if(QDir(f).exists() ) {
+ switch ( QMessageBox::warning(this,"Delete","Do you really want to delete\n"+f+
+ " ?\nIt must be empty","Yes","No",0,0,1) ) {
+ case 0: {
+ f=currentDir.canonicalPath()+"/"+f;
+ QString cmd="rmdir "+f;
+ system( cmd.latin1());
+ populateList();
+ }
+ break;
+ case 1:
+ // exit
+ break;
+ };
+
+ } else {
+ switch ( QMessageBox::warning(this,"Delete","Do you really want to delete\n"+f
+ +" ?","Yes","No",0,0,1) ) {
+ case 0: {
+ f=currentDir.canonicalPath()+"/"+f;
+ QString cmd="rm "+f;
+ system( cmd.latin1());
+ populateList();
+ }
+ break;
+ case 1:
+ // exit
+ break;
+ };
+ }
+
+}
diff --git a/core/apps/textedit/fileBrowser.h b/core/apps/textedit/fileBrowser.h
index d8f0d0d..4f765dd 100644
--- a/core/apps/textedit/fileBrowser.h
+++ b/core/apps/textedit/fileBrowser.h
@@ -25,24 +25,25 @@ copyright Sun 02-17-2002 22:28:23 L. J. Potter ljp@llornkcor.com
#include <qpe/filemanager.h>
class QVBoxLayout;
class QHBoxLayout;
class QGridLayout;
class QListView;
class QListViewItem;
class QPushButton;
class QComboBox;
class QWidgetStack;
class FileSelector;
+class QPoint;
class fileBrowser : public QDialog
{
Q_OBJECT
public:
void populateList();
fileBrowser( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ,const QString filter=0);
~fileBrowser();
void setFileView( int );
@@ -53,25 +54,30 @@ public:
QString selectedFileName, filterStr;
QDir currentDir;
QFile file;
QStringList fileList;
QListViewItem * item;
QComboBox *SelectionCombo;
QWidgetStack *FileStack;
FileSelector *fileSelector;
public slots:
void homeButtonPushed();
void docButtonPushed();
-
+ void ListPressed( int, QListViewItem *, const QPoint&, int);
+ void showListMenu(QListViewItem*);
+ void doCd();
+ void makDir();
+ void localRename();
+ void localDelete();
private:
private slots:
void upDir();
void listClicked( QListViewItem * );
void selectionChanged( const QString & );
void OnOK();
void docOpen( const DocLnk & );
protected slots:
protected:
diff --git a/core/apps/textedit/textedit.pro b/core/apps/textedit/textedit.pro
index 2c25d43..f019bf7 100644
--- a/core/apps/textedit/textedit.pro
+++ b/core/apps/textedit/textedit.pro
@@ -1,16 +1,14 @@
TEMPLATE = app
CONFIG += qt warn_on release
DESTDIR = $(OPIEDIR)/bin
-
-HEADERS = textedit.h fileBrowser.h fontDialog.h fileSaver.h filePermissions.h
-
-SOURCES = main.cpp textedit.cpp fileBrowser.cpp fontDialog.cpp fileSaver.cpp filePermissions.cpp
+HEADERS = textedit.h fileBrowser.h fontDialog.h fileSaver.h filePermissions.h inputDialog.h
+SOURCES = main.cpp textedit.cpp fileBrowser.cpp fontDialog.cpp fileSaver.cpp filePermissions.cpp inputDialog.cpp
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include
LIBS += -lqpe
TARGET = textedit
TRANSLATIONS = ../i18n/de/textedit.ts