-rw-r--r-- | noncore/net/wellenreiter/gui/mainwindow.cpp | 62 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/mainwindow.h | 3 |
2 files changed, 56 insertions, 9 deletions
diff --git a/noncore/net/wellenreiter/gui/mainwindow.cpp b/noncore/net/wellenreiter/gui/mainwindow.cpp index 0ef89d4..9065351 100644 --- a/noncore/net/wellenreiter/gui/mainwindow.cpp +++ b/noncore/net/wellenreiter/gui/mainwindow.cpp @@ -25,2 +25,3 @@ #include <qfile.h> +#include <qfileinfo.h> #include <qiconset.h> @@ -35,4 +36,6 @@ #include <qpe/resource.h> +#include <opie/ofiledialog.h> #else #include "resource.h" +#include <qfiledialog.h> #endif @@ -104,7 +107,7 @@ WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * n QPopupMenu* fileSave = new QPopupMenu( mb ); - fileSave->insertItem( "&Session", this, SLOT( fileSaveSession() ) ); - fileSave->insertItem( "&Log", this, SLOT( fileSaveLog() ) ); + fileSave->insertItem( "&Session...", this, SLOT( fileSaveSession() ) ); + fileSave->insertItem( "&Log...", this, SLOT( fileSaveLog() ) ); QPopupMenu* fileLoad = new QPopupMenu( mb ); - fileLoad->insertItem( "&Session", this, SLOT( fileLoadSession() ) ); + fileLoad->insertItem( "&Session...", this, SLOT( fileLoadSession() ) ); //fileLoad->insertItem( "&Log", this, SLOT( fileLoadLog() ) ); @@ -200,5 +203,41 @@ void WellenreiterMainWindow::demoAddStations() +QString WellenreiterMainWindow::getFileName( bool save ) +{ + QMap<QString, QStringList> map; + map.insert( tr("All"), QStringList() ); + QStringList text; + text << "text/*"; + map.insert(tr("Text"), text ); + text << "*"; + map.insert(tr("All"), text ); + + QString str; + if ( save ) + { + #ifdef QWS + str = OFileDialog::getSaveFileName( 2, "/", QString::null, map ); + #else + str = QFileDialog::getSaveFileName(); + #endif + if ( str.isEmpty() || QFileInfo(str).isDir() ) + return ""; + } + else + { + #ifdef QWS + str = OFileDialog::getOpenFileName( 2, "/", QString::null, map ); + #else + str = QFileDialog::getOpenFileName(); + #endif + if ( str.isEmpty() || !QFile(str).exists() || QFileInfo(str).isDir() ) + return ""; + } + return str; +} + void WellenreiterMainWindow::fileSaveLog() { - const QString fname( "/tmp/log.txt" ); + QString fname = getFileName( true ); + if ( !fname.isEmpty() ) + { QFile f( fname ); @@ -215,3 +254,3 @@ void WellenreiterMainWindow::fileSaveLog() } - + } } @@ -220,3 +259,6 @@ void WellenreiterMainWindow::fileSaveSession() { - const QString fname( "/tmp/session.xml" ); + QString fname = getFileName( true ); + if ( !fname.isEmpty() ) + { + QFile f( fname ); @@ -234,2 +276,3 @@ void WellenreiterMainWindow::fileSaveSession() } +} @@ -237,5 +280,6 @@ void WellenreiterMainWindow::fileLoadSession() { - const QString fname( "/tmp/session.xml" ); + QString fname = getFileName( false ); + if ( !fname.isEmpty() ) + { QFile f( fname ); - if ( f.open(IO_ReadOnly) ) @@ -251,3 +295,3 @@ void WellenreiterMainWindow::fileLoadSession() } - + } } diff --git a/noncore/net/wellenreiter/gui/mainwindow.h b/noncore/net/wellenreiter/gui/mainwindow.h index 59f259d..850a343 100644 --- a/noncore/net/wellenreiter/gui/mainwindow.h +++ b/noncore/net/wellenreiter/gui/mainwindow.h @@ -48,2 +48,5 @@ class WellenreiterMainWindow: public QMainWindow + private: + QString getFileName( bool save ); + public slots: |