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 /core/apps/textedit/textedit.cpp | |
parent | 378db8490c6c80ced939622605be1500fa126a2d (diff) | |
download | opie-b02657a01fc513e099c2d66be48d5a7b46cf6074.zip opie-b02657a01fc513e099c2d66be48d5a7b46cf6074.tar.gz opie-b02657a01fc513e099c2d66be48d5a7b46cf6074.tar.bz2 |
Combined file open & filebrowse into one dialog
Diffstat (limited to 'core/apps/textedit/textedit.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/apps/textedit/textedit.cpp | 72 |
1 files changed, 8 insertions, 64 deletions
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() |