author | drw <drw> | 2002-03-18 00:02:20 (UTC) |
---|---|---|
committer | drw <drw> | 2002-03-18 00:02:20 (UTC) |
commit | b02657a01fc513e099c2d66be48d5a7b46cf6074 (patch) (side-by-side diff) | |
tree | 1222fd77f10de1b1948b38bfb5fbe5656f8fa5c6 | |
parent | 378db8490c6c80ced939622605be1500fa126a2d (diff) | |
download | opie-b02657a01fc513e099c2d66be48d5a7b46cf6074.zip opie-b02657a01fc513e099c2d66be48d5a7b46cf6074.tar.gz opie-b02657a01fc513e099c2d66be48d5a7b46cf6074.tar.bz2 |
Combined file open & filebrowse into one dialog
-rw-r--r-- | core/apps/textedit/fileBrowser.cpp | 92 | ||||
-rw-r--r-- | core/apps/textedit/fileBrowser.h | 43 | ||||
-rw-r--r-- | core/apps/textedit/textedit.cpp | 108 | ||||
-rw-r--r-- | core/apps/textedit/textedit.h | 6 |
4 files changed, 118 insertions, 131 deletions
diff --git a/core/apps/textedit/fileBrowser.cpp b/core/apps/textedit/fileBrowser.cpp index 2e88067..92c15cb 100644 --- a/core/apps/textedit/fileBrowser.cpp +++ b/core/apps/textedit/fileBrowser.cpp @@ -16,5 +16,8 @@ #include <qpe/resource.h> +#include <qpe/fileselector.h> #include <qpe/qpeapplication.h> +#include <qwidgetstack.h> #include <qlistview.h> +#include <qcombo.h> #include <qpushbutton.h> @@ -25,3 +28,7 @@ - +static int u_id = 1; +static int get_unique_id() +{ + return u_id++; +} @@ -46,10 +53,2 @@ fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags - hideButton = new QPushButton( Resource::loadIconSet("s_hidden"),"",this,"hideButton"); - hideButton->setMinimumSize( QSize( 25, 25 ) ); - hideButton->setMaximumSize( QSize( 25, 25 ) ); - connect( hideButton,SIGNAL(toggled(bool)),this,SLOT( hideButtonPushed(bool)) ); - hideButton->setToggleButton(TRUE); - hideButton->setFlat(TRUE); - layout->addWidget( hideButton, 0, 1 ); - docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"",this,"docsButton"); @@ -59,3 +58,3 @@ fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags docButton->setFlat(TRUE); - layout->addWidget( docButton, 0, 2 ); + layout->addWidget( docButton, 0, 1 ); @@ -66,5 +65,7 @@ fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags homeButton->setFlat(TRUE); - layout->addWidget( homeButton, 0, 3 ); + layout->addWidget( homeButton, 0, 2 ); + + FileStack = new QWidgetStack( this ); - ListView = new QListView( this, "ListView" ); + ListView = new QListView( this, "ListView" ); ListView->setMinimumSize( QSize( 100, 25 ) ); @@ -80,9 +81,21 @@ fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags // ListView->setSelectionMode(QListView::Extended); - ListView->setAllColumnsShowFocus( TRUE ); - layout->addMultiCellWidget( ListView, 1, 1, 0, 3 ); - - // signals and slots connections - connect( ListView, SIGNAL(doubleClicked( QListViewItem*)), SLOT(listDoubleClicked(QListViewItem *)) ); connect( ListView, SIGNAL(pressed( 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" ) ); + SelectionCombo->insertItem( tr( "All files (incl. hidden)" ) ); + layout->addMultiCellWidget( SelectionCombo, 2, 2, 0, 2 ); + connect( SelectionCombo, SIGNAL( activated( const QString & ) ), + this, SLOT( selectionChanged( const QString & ) ) ); + currentDir.setPath(QDir::currentDirPath()); @@ -98,2 +111,7 @@ fileBrowser::~fileBrowser() +void fileBrowser::setFileView( int selection ) +{ + SelectionCombo->setCurrentItem( selection ); + selectionChanged( SelectionCombo->currentText() ); +} @@ -142,6 +160,2 @@ void fileBrowser::upDir() -void fileBrowser::listDoubleClicked(QListViewItem *selectedItem) -{ -} - // you may want to switch these 2 functions. I like single clicks @@ -218,13 +232,31 @@ void fileBrowser::docButtonPushed() { -void fileBrowser::hideButtonPushed(bool b) { - if (b) - currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); +void fileBrowser::selectionChanged( const QString &select ) +{ + if ( select == "Documents") + { + FileStack->raiseWidget( fileSelector ); + dirLabel->hide(); + docButton->hide(); + homeButton->hide(); + } else - currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); - -// chdir( QString(QPEApplication::documentDir()+"/text").latin1() ); -// currentDir.cd( QPEApplication::documentDir()+"/text", TRUE); - populateList(); - update(); + { + if ( select == "All files" ) + currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::All); + else + currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); + populateList(); + update(); + dirLabel->show(); + docButton->show(); + homeButton->show(); + FileStack->raiseWidget( ListView ); + } +} + +void fileBrowser::docOpen( const DocLnk &doc ) +{ + fileList.append( doc.file().latin1() ); + accept(); } diff --git a/core/apps/textedit/fileBrowser.h b/core/apps/textedit/fileBrowser.h index 50ed485..d8f0d0d 100644 --- a/core/apps/textedit/fileBrowser.h +++ b/core/apps/textedit/fileBrowser.h @@ -19,5 +19,5 @@ copyright Sun 02-17-2002 22:28:23 L. J. Potter ljp@llornkcor.com #include <qdialog.h> -#include <qfile.h> -#include <qdir.h> -#include <qstringlist.h> +#include <qfile.h> +#include <qdir.h> +#include <qstringlist.h> #include <qlabel.h> @@ -25,5 +25,7 @@ copyright Sun 02-17-2002 22:28:23 L. J. Potter ljp@llornkcor.com -class QVBoxLayout; -class QHBoxLayout; -class QGridLayout; +#include <qpe/filemanager.h> + +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; class QListView; @@ -31,5 +33,8 @@ class QListViewItem; class QPushButton; +class QComboBox; +class QWidgetStack; +class FileSelector; class fileBrowser : public QDialog -{ +{ Q_OBJECT @@ -41,2 +46,4 @@ public: + void setFileView( int ); + QPushButton *buttonOk, *buttonCancel, *homeButton, *docButton, *hideButton; @@ -50,14 +57,20 @@ public: QListViewItem * item; + QComboBox *SelectionCombo; + QWidgetStack *FileStack; + FileSelector *fileSelector; + public slots: void homeButtonPushed(); - void docButtonPushed(); - void hideButtonPushed(bool); + void docButtonPushed(); + private: -private slots: - void upDir(); - void listDoubleClicked(QListViewItem *); - void listClicked(QListViewItem *); - void OnOK(); -protected slots: +private slots: + void upDir(); + void listClicked( QListViewItem * ); + void selectionChanged( const QString & ); + void OnOK(); + void docOpen( const DocLnk & ); + +protected slots: diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp index 3a189cb..68ee1b4 100644 --- a/core/apps/textedit/textedit.cpp +++ b/core/apps/textedit/textedit.cpp @@ -51,2 +51,3 @@ #include <qcheckbox.h> +#include <qcombo.h> #include <unistd.h> @@ -227,10 +228,2 @@ void QpeEditor::find ( const QString &txt, bool caseSensitive, - - -static int u_id = 1; -static int get_unique_id() -{ - return u_id++; -} - static const int nfontsizes = 6; @@ -267,7 +260,2 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); -// a->addTo( bar ); - a->addTo( file ); - - a = new QAction( tr( "Browse" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); - connect( a, SIGNAL( activated() ), this, SLOT( newFileOpen() ) ); a->addTo( bar ); @@ -277,3 +265,2 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) connect( a, SIGNAL( activated() ), this, SLOT( save() ) ); -// a->addTo( bar ); file->insertSeparator(); @@ -300,9 +287,8 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) - a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); - connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) ); - edit->insertSeparator(); - a->addTo( bar ); - a->addTo( edit ); + a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); + connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) ); + edit->insertSeparator(); + a->addTo( bar ); + a->addTo( edit ); - int defsize; @@ -373,6 +359,6 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) - a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 ); - connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); - a->addTo( searchBar ); - a->addTo( edit ); + a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 ); + connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); + a->addTo( searchBar ); + a->addTo( edit ); @@ -382,23 +368,13 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) - edit->insertSeparator(); - a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); - connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) ); - a->addTo( edit ); - - searchBar->hide(); - - editorStack = new QWidgetStack( this ); - setCentralWidget( editorStack ); + edit->insertSeparator(); + a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); + connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) ); + a->addTo( edit ); - searchVisible = FALSE; + searchBar->hide(); - fileSelector = new FileSelector( "text/*", editorStack, "fileselector" , TRUE, TRUE); //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( openFile( const DocLnk & ) ) ); -// fileOpen(); - editor = new QpeEditor( editorStack ); + editor = new QpeEditor( this ); + setCentralWidget( editor ); editor->setFrameStyle( QFrame::Panel | QFrame::Sunken ); - editorStack->addWidget( editor, get_unique_id() ); connect( editor, SIGNAL( textChanged() ), this, SLOT( editorChanged() ) ); @@ -431,3 +407,3 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) } - + viewSelection = cfg.readNumEntry( "FileView", 0 ); } @@ -445,2 +421,3 @@ TextEdit::~TextEdit() cfg.writeEntry("Wrap",editor->wordWrap() == QMultiLineEdit::WidgetWidth); + cfg.writeEntry( "FileView", viewSelection ); } @@ -515,29 +492,4 @@ void TextEdit::fileOpen() { -// if ( !save() ) { -// if ( QMessageBox::critical( this, tr( "Out of space" ), -// tr( "Text Editor was unable to\n" -// "save your changes.\n" -// "Free some space and try again.\n" -// "\nContinue anyway?" ), -// QMessageBox::Yes|QMessageBox::Escape, -// QMessageBox::No|QMessageBox::Default ) -// != QMessageBox::Yes ) -// return; -// else { -// delete doc; -// doc = 0; -// } -// } - menu->hide(); - editBar->hide(); - searchBar->hide(); - clearWState (WState_Reserved1 ); - editorStack->raiseWidget( fileSelector ); - fileSelector->reread(); - updateCaption(); -} - -void TextEdit::newFileOpen() -{ browseForFiles=new fileBrowser(this,"Open File",TRUE,0, "*"); + browseForFiles->setFileView( viewSelection ); browseForFiles->showMaximized(); @@ -559,2 +511,3 @@ void TextEdit::newFileOpen() } + viewSelection = browseForFiles->SelectionCombo->currentItem(); } @@ -644,3 +597,2 @@ void TextEdit::newFile( const DocLnk &f ) clear(); - editorStack->raiseWidget( editor ); setWState (WState_Reserved1 ); @@ -654,2 +606,3 @@ void TextEdit::openFile( const QString &f ) { + bFromDocView = TRUE; @@ -684,6 +637,6 @@ void TextEdit::openFile( const DocLnk &f ) qDebug( "Cannot open file" ); - + //return; } - + fileNew(); @@ -707,3 +660,2 @@ void TextEdit::showEditTools() // clear(); - fileSelector->hide(); menu->show(); @@ -713,3 +665,2 @@ void TextEdit::showEditTools() // updateCaption(); - editorStack->raiseWidget( editor ); setWState (WState_Reserved1 ); @@ -888,11 +839,4 @@ void TextEdit::closeEvent( QCloseEvent *e ) { - if ( editorStack->visibleWidget() == fileSelector && !bFromDocView ) { - e->ignore(); - repaint(); -// fileRevert(); - - } else { - bFromDocView = FALSE; - e->accept(); - } + bFromDocView = FALSE; + e->accept(); } diff --git a/core/apps/textedit/textedit.h b/core/apps/textedit/textedit.h index e7e20e3..aca2933 100644 --- a/core/apps/textedit/textedit.h +++ b/core/apps/textedit/textedit.h @@ -60,3 +60,3 @@ public slots: void editorChanged(); - + protected: @@ -70,3 +70,2 @@ private slots: void fileOpen(); - void newFileOpen(); void changeStartConfig(bool); @@ -105,4 +104,2 @@ private: private: - QWidgetStack *editorStack; - FileSelector *fileSelector; fileSaver *fileSaveDlg; @@ -116,2 +113,3 @@ private: bool bFromDocView; + int viewSelection; QAction *zin, *zout; |