-rw-r--r-- | noncore/apps/opie-console/main.cpp | 10 | ||||
-rw-r--r-- | noncore/apps/opie-console/mainwindow.cpp | 62 | ||||
-rw-r--r-- | noncore/apps/opie-console/mainwindow.h | 14 | ||||
-rw-r--r-- | noncore/apps/opie-console/metafactory.cpp | 44 | ||||
-rw-r--r-- | noncore/apps/opie-console/opie-console.pro | 12 | ||||
-rw-r--r-- | noncore/apps/opie-console/session.cpp | 26 |
6 files changed, 162 insertions, 6 deletions
diff --git a/noncore/apps/opie-console/main.cpp b/noncore/apps/opie-console/main.cpp index cf8bf05..4b5107e 100644 --- a/noncore/apps/opie-console/main.cpp +++ b/noncore/apps/opie-console/main.cpp @@ -1,14 +1,16 @@ #include <qpe/qpeapplication.h> -#include <mainwindow.h> +#include "mainwindow.h" int main(int argc, char **argv) { QPEApplication app( argc, argv ); - MainWindow* mw = new MainWindow(); - app.setMainWidget( mw ); + + MainWindow mw; + mw.setCaption(QObject::tr("Opie console") ); + app.showMainWidget( &mw ); app.exec(); - delete mw; + return 0; } diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp new file mode 100644 index 0000000..b6b2a2e --- a/dev/null +++ b/noncore/apps/opie-console/mainwindow.cpp @@ -0,0 +1,62 @@ + +#include <qaction.h> +#include <qmenubar.h> +#include <qlabel.h> +#include <qpopupmenu.h> +#include <qtoolbar.h> + +#include "metafactory.h" +#include "mainwindow.h" + +MainWindow::MainWindow() +{ + qWarning("c'tor"); + m_factory = new MetaFactory(); + m_sessions.setAutoDelete( TRUE ); + m_curSession = 0l; + + initUI(); + +} +void MainWindow::initUI() { + setToolBarsMovable( FALSE ); + + m_tool = new QToolBar( this ); + m_tool->setHorizontalStretchable( TRUE ); + + m_bar = new QMenuBar( m_tool ); + m_console = new QPopupMenu( this ); + + /* + * new Action for new sessions + */ + QAction* a = new QAction(); + a->setText( tr("New Connection") ); + a->addTo( m_console ); + connect(a, SIGNAL(activated() ), + this, SLOT(slotNew() ) ); + + a = new QAction(); + a->setText( tr("New from Session") ); + + m_connect = new QAction(); + m_connect->setText( tr("Connect") ); + m_connect->addTo( m_console ); + connect(m_connect, SIGNAL(activated() ), + this, SLOT(slotConnect() ) ); + + m_bar->insertItem( tr("Connection"), m_console ); + +} +MainWindow::~MainWindow() { + delete m_factory; +} +MetaFactory* MainWindow::factory() { + return m_factory; +} +Session* MainWindow::currentSession() { + return m_curSession; +} +QList<Session> MainWindow::sessions() { + return m_sessions; +} diff --git a/noncore/apps/opie-console/mainwindow.h b/noncore/apps/opie-console/mainwindow.h index 7786c95..3d1e1c8 100644 --- a/noncore/apps/opie-console/mainwindow.h +++ b/noncore/apps/opie-console/mainwindow.h @@ -1,57 +1,71 @@ #ifndef OPIE_MAIN_WINDOW_H #define OPIE_MAIN_WINDOW_H #include <qmainwindow.h> #include <qlist.h> #include "session.h" /** * this is the MainWindow of the new opie console * it's also the dispatcher between the different * actions supported by the gui */ +class QToolBar; +class QMenuBar; +class QAction; class MetaFactory; class MainWindow : public QMainWindow { Q_OBJECT public: MainWindow( ); ~MainWindow(); /** * our factory to generate IOLayer and so on * */ MetaFactory* factory(); /** * A session contains a QWidget*, * an IOLayer* and some infos for us */ Session* currentSession(); /** * the session list */ QList<Session> sessions(); private: + void initUI(); /** * the current session */ Session* m_curSession; /** * the session list */ QList<Session> m_sessions; /** * the metafactory */ MetaFactory* m_factory; + QToolBar* m_tool; + QMenuBar* m_bar; + QPopupMenu* m_console; + QPopupMenu* m_settings; + QPopupMenu* m_newsession; + QAction* m_connect; + QAction* m_disconnect; + QAction* m_terminate; + QAction* m_set; + }; #endif diff --git a/noncore/apps/opie-console/metafactory.cpp b/noncore/apps/opie-console/metafactory.cpp new file mode 100644 index 0000000..bef6ec7 --- a/dev/null +++ b/noncore/apps/opie-console/metafactory.cpp @@ -0,0 +1,44 @@ + +#include "metafactory.h" + +MetaFactory::MetaFactory() { +} +MetaFactory::~MetaFactory() { + +} +void MetaFactory::addConfigWidgetFactory( const QString& str, + configWidget wid) { + m_confFact.insert( str, wid ); +} +void MetaFactory::addIOLayerFactory( const QString& str, + iolayer lay) { + m_layerFact.insert( str, lay ); +} +void MetaFactory::addFileTransferLayer( const QString& str, + filelayer lay) { + m_fileFact.insert( str, lay ); +} +QStringList MetaFactory::ioLayers()const { + QStringList list; + QMap<QString, iolayer>::ConstIterator it; + for (it = m_layerFact.begin(); it != m_layerFact.end(); ++it ) { + list << it.key(); + } + return list; +} +QStringList MetaFactory::configWidgets()const { + QStringList list; + QMap<QString, configWidget>::ConstIterator it; + for ( it = m_confFact.begin(); it != m_confFact.end(); ++it ) { + list << it.key(); + } + return list; +} +QStringList MetaFactory::fileTransferLayers()const { + QStringList list; + QMap<QString, filelayer>::ConstIterator it; + for ( it = m_fileFact.begin(); it != m_fileFact.end(); ++it ) { + list << it.key(); + } + return list; +} diff --git a/noncore/apps/opie-console/opie-console.pro b/noncore/apps/opie-console/opie-console.pro index 5b6fdc3..4a1180f 100644 --- a/noncore/apps/opie-console/opie-console.pro +++ b/noncore/apps/opie-console/opie-console.pro @@ -1,11 +1,19 @@ TEMPLATE = app CONFIG = qt warn_on release DESTDIR = $(OPIEDIR)/bin -HEADERS = io_layer.h io_serial.h file_layer.h -SOURCES = io_layer.cpp io_serial.cpp file_layer.cpp main.cpp +HEADERS = io_layer.h io_serial.h \ + file_layer.h \ + metafactory.h \ + session.h \ + mainwindow.h +SOURCES = io_layer.cpp io_serial.cpp \ + file_layer.cpp main.cpp \ + metafactory.cpp \ + session.cpp \ + mainwindow.cpp INTERFACES = INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe -lopie TARGET = opie-console diff --git a/noncore/apps/opie-console/session.cpp b/noncore/apps/opie-console/session.cpp new file mode 100644 index 0000000..4198fdc --- a/dev/null +++ b/noncore/apps/opie-console/session.cpp @@ -0,0 +1,26 @@ + + +#include "io_layer.h" +#include "file_layer.h" +#include "session.h" + +Session::Session( QWidget* widget, IOLayer* lay) + : m_widget( widget ), m_layer( lay ) +{ +} +Session::~Session() { + delete m_layer; + delete m_widget; +} +QWidget* Session::widget() { + return m_widget; +} +IOLayer* Session::layer() { + return m_layer; +} +void Session::setWidget( QWidget* wid ) { + m_widget = wid; +} +void Session::setIOLayer( IOLayer* lay ) { + m_layer = lay; +} |