summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2003-03-02 18:59:21 (UTC)
committer mickeyl <mickeyl>2003-03-02 18:59:21 (UTC)
commit6657040ae54afb2f2378f4db7bfc9e616e6d7b83 (patch) (side-by-side diff)
tree96617a7e6664c71c20f8ec9bd6a4cca779d54dea
parente1761268c8820ff24dcb73dbcd4b82bc1e1e34a1 (diff)
downloadopie-6657040ae54afb2f2378f4db7bfc9e616e6d7b83.zip
opie-6657040ae54afb2f2378f4db7bfc9e616e6d7b83.tar.gz
opie-6657040ae54afb2f2378f4db7bfc9e616e6d7b83.tar.bz2
use filedialogs before loading and saving sessions and logs
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/wellenreiter/gui/mainwindow.cpp62
-rw-r--r--noncore/net/wellenreiter/gui/mainwindow.h3
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
@@ -23,6 +23,7 @@
#include <qcombobox.h>
#include <qdatastream.h>
#include <qfile.h>
+#include <qfileinfo.h>
#include <qiconset.h>
#include <qmenubar.h>
#include <qmessagebox.h>
@@ -33,8 +34,10 @@
#ifdef QWS
#include <qpe/resource.h>
+#include <opie/ofiledialog.h>
#else
#include "resource.h"
+#include <qfiledialog.h>
#endif
WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * name, WFlags f )
@@ -102,11 +105,11 @@ WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * n
QMenuBar* mb = menuBar();
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() ) );
QPopupMenu* file = new QPopupMenu( mb );
@@ -198,9 +201,45 @@ void WellenreiterMainWindow::demoAddStations()
mw->netView()->addNewItem( "adhoc", "ELAN", "00:B0:8E:E7:56:E2", false, 3, 20 );
}
+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 );
if ( f.open(IO_WriteOnly) )
{
@@ -213,12 +252,15 @@ void WellenreiterMainWindow::fileSaveLog()
{
qDebug( "Problem saving log to file '%s'", (const char*) fname );
}
-
+ }
}
void WellenreiterMainWindow::fileSaveSession()
{
- const QString fname( "/tmp/session.xml" );
+ QString fname = getFileName( true );
+ if ( !fname.isEmpty() )
+ {
+
QFile f( fname );
if ( f.open(IO_WriteOnly) )
{
@@ -232,12 +274,14 @@ void WellenreiterMainWindow::fileSaveSession()
qDebug( "Problem saving session to file '%s'", (const char*) fname );
}
}
+}
void WellenreiterMainWindow::fileLoadSession()
{
- const QString fname( "/tmp/session.xml" );
+ QString fname = getFileName( false );
+ if ( !fname.isEmpty() )
+ {
QFile f( fname );
-
if ( f.open(IO_ReadOnly) )
{
QDataStream t( &f );
@@ -249,7 +293,7 @@ void WellenreiterMainWindow::fileLoadSession()
{
qDebug( "Problem loading session from file '%s'", (const char*) fname );
}
-
+ }
}
void WellenreiterMainWindow::closeEvent( QCloseEvent* e )
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
@@ -46,6 +46,9 @@ class WellenreiterMainWindow: public QMainWindow
protected:
virtual void closeEvent( QCloseEvent* );
+ private:
+ QString getFileName( bool save );
+
public slots:
void showConfigure();
void demoAddStations();