-rw-r--r-- | core/apps/textedit/fileBrowser.cpp | 84 | ||||
-rw-r--r-- | core/apps/textedit/fileBrowser.h | 17 | ||||
-rw-r--r-- | core/apps/textedit/textedit.cpp | 72 | ||||
-rw-r--r-- | core/apps/textedit/textedit.h | 4 |
4 files changed, 82 insertions, 95 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 @@ -15,7 +15,10 @@ #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> @@ -24,5 +27,9 @@ #include <unistd.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 ) @@ -45,12 +52,4 @@ fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags layout->addWidget( dirLabel, 0, 0 ); - 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"); docButton->setMinimumSize( QSize( 25, 25 ) ); @@ -58,5 +57,5 @@ fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) ); docButton->setFlat(TRUE); - layout->addWidget( docButton, 0, 2 ); + layout->addWidget( docButton, 0, 1 ); homeButton = new QPushButton( Resource::loadIconSet("home"),"",this,"homeButton"); @@ -65,5 +64,7 @@ fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) ); homeButton->setFlat(TRUE); - layout->addWidget( homeButton, 0, 3 ); + layout->addWidget( homeButton, 0, 2 ); + + FileStack = new QWidgetStack( this ); ListView = new QListView( this, "ListView" ); @@ -79,11 +80,23 @@ fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags // ListView->setMultiSelection(true); // 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()); currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden */| QDir::All); @@ -97,4 +110,9 @@ fileBrowser::~fileBrowser() } +void fileBrowser::setFileView( int selection ) +{ + SelectionCombo->setCurrentItem( selection ); + selectionChanged( SelectionCombo->currentText() ); +} void fileBrowser::populateList() @@ -141,8 +159,4 @@ void fileBrowser::upDir() } -void fileBrowser::listDoubleClicked(QListViewItem *selectedItem) -{ -} - // you may want to switch these 2 functions. I like single clicks void fileBrowser::listClicked(QListViewItem *selectedItem) @@ -217,14 +231,32 @@ 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); + { + if ( select == "All files" ) + currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::All); + 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(); + 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 @@ -24,4 +24,6 @@ copyright Sun 02-17-2002 22:28:23 L. J. Potter ljp@llornkcor.com #include <qstring.h> +#include <qpe/filemanager.h> + class QVBoxLayout; class QHBoxLayout; @@ -30,4 +32,7 @@ class QListView; class QListViewItem; class QPushButton; +class QComboBox; +class QWidgetStack; +class FileSelector; class fileBrowser : public QDialog @@ -40,4 +45,6 @@ public: ~fileBrowser(); + void setFileView( int ); + QPushButton *buttonOk, *buttonCancel, *homeButton, *docButton, *hideButton; QListView* ListView; @@ -49,15 +56,21 @@ public: QStringList fileList; QListViewItem * item; + QComboBox *SelectionCombo; + QWidgetStack *FileStack; + FileSelector *fileSelector; + public slots: void homeButtonPushed(); void docButtonPushed(); - void hideButtonPushed(bool); + private: private slots: void upDir(); - void listDoubleClicked(QListViewItem *); 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 @@ -50,4 +50,5 @@ #include <qwidgetstack.h> #include <qcheckbox.h> +#include <qcombo.h> #include <unistd.h> #include <sys/stat.h> @@ -226,12 +227,4 @@ 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; static const int fontsize[nfontsizes] = {8,10,12,14,18,24}; @@ -266,9 +259,4 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); 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 ); a->addTo( file ); @@ -276,5 +264,4 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) a = new QAction( tr( "Save" ), QPixmap(( const char** ) filesave_xpm ) , QString::null, 0, this, 0 ); connect( a, SIGNAL( activated() ), this, SLOT( save() ) ); -// a->addTo( bar ); file->insertSeparator(); a->addTo( file ); @@ -305,5 +292,4 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) a->addTo( edit ); - int defsize; bool defb, defi, wrap; @@ -388,18 +374,8 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) searchBar->hide(); - editorStack = new QWidgetStack( this ); - setCentralWidget( editorStack ); - - searchVisible = FALSE; - - 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() ) ); @@ -430,5 +406,5 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) fileOpen(); } - + viewSelection = cfg.readNumEntry( "FileView", 0 ); } @@ -444,4 +420,5 @@ TextEdit::~TextEdit() cfg.writeEntry("Italic",f.italic()); cfg.writeEntry("Wrap",editor->wordWrap() == QMultiLineEdit::WidgetWidth); + cfg.writeEntry( "FileView", viewSelection ); } @@ -514,31 +491,6 @@ void TextEdit::fileNew() 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(); if( browseForFiles->exec() != -1 ) { @@ -558,4 +510,5 @@ void TextEdit::newFileOpen() } } + viewSelection = browseForFiles->SelectionCombo->currentItem(); } delete browseForFiles; @@ -643,5 +596,4 @@ void TextEdit::newFile( const DocLnk &f ) nf.setType("text/plain"); clear(); - editorStack->raiseWidget( editor ); setWState (WState_Reserved1 ); editor->setFocus(); @@ -653,4 +605,5 @@ void TextEdit::newFile( const DocLnk &f ) void TextEdit::openFile( const QString &f ) { + bFromDocView = TRUE; DocLnk nf; @@ -706,5 +659,4 @@ void TextEdit::showEditTools() // close(); // clear(); - fileSelector->hide(); menu->show(); editBar->show(); @@ -712,5 +664,4 @@ void TextEdit::showEditTools() searchBar->show(); // updateCaption(); - editorStack->raiseWidget( editor ); setWState (WState_Reserved1 ); } @@ -887,14 +838,7 @@ void TextEdit::setDocument(const QString& fileref) void TextEdit::closeEvent( QCloseEvent *e ) { - if ( editorStack->visibleWidget() == fileSelector && !bFromDocView ) { - e->ignore(); - repaint(); -// fileRevert(); - - } else { bFromDocView = FALSE; e->accept(); } -} void TextEdit::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 @@ -69,5 +69,4 @@ private slots: void fileRevert(); void fileOpen(); - void newFileOpen(); void changeStartConfig(bool); bool save(); @@ -104,6 +103,4 @@ private: private: - QWidgetStack *editorStack; - FileSelector *fileSelector; fileSaver *fileSaveDlg; fileBrowser *browseForFiles; @@ -115,4 +112,5 @@ private: bool searchVisible; bool bFromDocView; + int viewSelection; QAction *zin, *zout; QString currentFileName; |