From 6d8bc516acf7a5995736423e838c987d08e69c09 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Tue, 17 May 2011 14:56:28 +0000 Subject: Ok, you can now open files, save files, save files from proxies and clients, and add new root items to files. Later I'll add some actual editing capabilities, should be really easy. --- src/gatscon/mainwnd.cpp | 59 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) (limited to 'src/gatscon/mainwnd.cpp') diff --git a/src/gatscon/mainwnd.cpp b/src/gatscon/mainwnd.cpp index 628988e..bddaf08 100644 --- a/src/gatscon/mainwnd.cpp +++ b/src/gatscon/mainwnd.cpp @@ -7,11 +7,15 @@ #include "connectdlg.h" #include "setupproxydlg.h" +#include #include MainWnd::MainWnd() { setupUi( this ); + + pMode = new QLabel( "Idle", this ); + statusBar()->addPermanentWidget( pMode ); } MainWnd::~MainWnd() @@ -23,11 +27,16 @@ void MainWnd::connect() ConnectDlg dlg( this ); if( dlg.exec() == QDialog::Accepted ) { + sCurFile.clear(); setCentralWidget( new ClientWidget( this, dlg.getHostname(), dlg.getPort() ) ); + pMode->setText( + QString("Client Mode: %1:%2").arg( QString(dlg.getHostname()) ). + arg( dlg.getPort() ) + ); } } @@ -37,11 +46,17 @@ void MainWnd::proxy() if( dlg.exec() == QDialog::Accepted ) { + sCurFile.clear(); setCentralWidget( new ProxyWidget( this, dlg.getPortIn(), dlg.getHostOut(), dlg.getPortOut() ) ); + pMode->setText( + QString("Proxy Mode: :%1 -> %2:%3").arg( dlg.getPortIn() ). + arg( QString(dlg.getHostOut()) ). + arg( dlg.getPortOut() ) + ); } } @@ -53,8 +68,52 @@ void MainWnd::open() if( sFile.isEmpty() ) return; + sCurFile = sFile; setCentralWidget( new FileWidget( this, sFile ) ); + pMode->setText( QString("File mode: %1").arg( sCurFile ) ); +} + +void MainWnd::newFile() +{ + sCurFile.clear(); + setCentralWidget( + new FileWidget( this ) + ); + pMode->setText( QString("File mode: ") ); +} + +void MainWnd::save() +{ + if( sCurFile.isEmpty() ) + { + saveAs(); + } + else + { + IoBase *pIo = dynamic_cast(centralWidget()); + if( !pIo ) + return; + + pIo->saveTo( sCurFile ); + } +} + +void MainWnd::saveAs() +{ + IoBase *pIo = dynamic_cast(centralWidget()); + if( !pIo ) + return; + + QString sFile = QFileDialog::getSaveFileName( + this, "GatsCon - save gats file" + ); + if( sFile.isEmpty() ) + return; + + pIo->saveTo( sFile ); + + sCurFile = sFile; } -- cgit v1.2.3