summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/main.cpp14
-rw-r--r--noncore/apps/opie-console/mainwindow.cpp62
-rw-r--r--noncore/apps/opie-console/mainwindow.h14
-rw-r--r--noncore/apps/opie-console/metafactory.cpp44
-rw-r--r--noncore/apps/opie-console/opie-console.pro12
-rw-r--r--noncore/apps/opie-console/session.cpp26
6 files changed, 164 insertions, 8 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 @@
1#include <qpe/qpeapplication.h> 1#include <qpe/qpeapplication.h>
2 2
3#include <mainwindow.h> 3#include "mainwindow.h"
4 4
5int main(int argc, char **argv) { 5int main(int argc, char **argv) {
6 QPEApplication app( argc, argv ); 6 QPEApplication app( argc, argv );
7 MainWindow* mw = new MainWindow(); 7
8 app.setMainWidget( mw ); 8 MainWindow mw;
9 9 mw.setCaption(QObject::tr("Opie console") );
10 app.showMainWidget( &mw );
11
10 app.exec(); 12 app.exec();
11 13
12 delete mw; 14
13 return 0; 15 return 0;
14} 16}
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 @@
1
2#include <qaction.h>
3#include <qmenubar.h>
4#include <qlabel.h>
5#include <qpopupmenu.h>
6#include <qtoolbar.h>
7
8#include "metafactory.h"
9#include "mainwindow.h"
10
11MainWindow::MainWindow()
12{
13 qWarning("c'tor");
14 m_factory = new MetaFactory();
15 m_sessions.setAutoDelete( TRUE );
16 m_curSession = 0l;
17
18 initUI();
19
20}
21void MainWindow::initUI() {
22 setToolBarsMovable( FALSE );
23
24 m_tool = new QToolBar( this );
25 m_tool->setHorizontalStretchable( TRUE );
26
27 m_bar = new QMenuBar( m_tool );
28 m_console = new QPopupMenu( this );
29
30 /*
31 * new Action for new sessions
32 */
33 QAction* a = new QAction();
34 a->setText( tr("New Connection") );
35 a->addTo( m_console );
36 connect(a, SIGNAL(activated() ),
37 this, SLOT(slotNew() ) );
38
39 a = new QAction();
40 a->setText( tr("New from Session") );
41
42 m_connect = new QAction();
43 m_connect->setText( tr("Connect") );
44 m_connect->addTo( m_console );
45 connect(m_connect, SIGNAL(activated() ),
46 this, SLOT(slotConnect() ) );
47
48 m_bar->insertItem( tr("Connection"), m_console );
49
50}
51MainWindow::~MainWindow() {
52 delete m_factory;
53}
54MetaFactory* MainWindow::factory() {
55 return m_factory;
56}
57Session* MainWindow::currentSession() {
58 return m_curSession;
59}
60QList<Session> MainWindow::sessions() {
61 return m_sessions;
62}
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
@@ -2,24 +2,27 @@
2#define OPIE_MAIN_WINDOW_H 2#define OPIE_MAIN_WINDOW_H
3 3
4#include <qmainwindow.h> 4#include <qmainwindow.h>
5#include <qlist.h> 5#include <qlist.h>
6 6
7#include "session.h" 7#include "session.h"
8 8
9/** 9/**
10 * this is the MainWindow of the new opie console 10 * this is the MainWindow of the new opie console
11 * it's also the dispatcher between the different 11 * it's also the dispatcher between the different
12 * actions supported by the gui 12 * actions supported by the gui
13 */ 13 */
14class QToolBar;
15class QMenuBar;
16class QAction;
14class MetaFactory; 17class MetaFactory;
15class MainWindow : public QMainWindow { 18class MainWindow : public QMainWindow {
16 Q_OBJECT 19 Q_OBJECT
17public: 20public:
18 MainWindow( ); 21 MainWindow( );
19 ~MainWindow(); 22 ~MainWindow();
20 23
21 /** 24 /**
22 * our factory to generate IOLayer and so on 25 * our factory to generate IOLayer and so on
23 * 26 *
24 */ 27 */
25 MetaFactory* factory(); 28 MetaFactory* factory();
@@ -27,31 +30,42 @@ public:
27 /** 30 /**
28 * A session contains a QWidget*, 31 * A session contains a QWidget*,
29 * an IOLayer* and some infos for us 32 * an IOLayer* and some infos for us
30 */ 33 */
31 Session* currentSession(); 34 Session* currentSession();
32 35
33 /** 36 /**
34 * the session list 37 * the session list
35 */ 38 */
36 QList<Session> sessions(); 39 QList<Session> sessions();
37 40
38private: 41private:
42 void initUI();
39 /** 43 /**
40 * the current session 44 * the current session
41 */ 45 */
42 Session* m_curSession; 46 Session* m_curSession;
43 47
44 /** 48 /**
45 * the session list 49 * the session list
46 */ 50 */
47 QList<Session> m_sessions; 51 QList<Session> m_sessions;
48 52
49 /** 53 /**
50 * the metafactory 54 * the metafactory
51 */ 55 */
52 MetaFactory* m_factory; 56 MetaFactory* m_factory;
53 57
58 QToolBar* m_tool;
59 QMenuBar* m_bar;
60 QPopupMenu* m_console;
61 QPopupMenu* m_settings;
62 QPopupMenu* m_newsession;
63 QAction* m_connect;
64 QAction* m_disconnect;
65 QAction* m_terminate;
66 QAction* m_set;
67
54}; 68};
55 69
56 70
57#endif 71#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 @@
1
2#include "metafactory.h"
3
4MetaFactory::MetaFactory() {
5}
6MetaFactory::~MetaFactory() {
7
8}
9void MetaFactory::addConfigWidgetFactory( const QString& str,
10 configWidget wid) {
11 m_confFact.insert( str, wid );
12}
13void MetaFactory::addIOLayerFactory( const QString& str,
14 iolayer lay) {
15 m_layerFact.insert( str, lay );
16}
17void MetaFactory::addFileTransferLayer( const QString& str,
18 filelayer lay) {
19 m_fileFact.insert( str, lay );
20}
21QStringList MetaFactory::ioLayers()const {
22 QStringList list;
23 QMap<QString, iolayer>::ConstIterator it;
24 for (it = m_layerFact.begin(); it != m_layerFact.end(); ++it ) {
25 list << it.key();
26 }
27 return list;
28}
29QStringList MetaFactory::configWidgets()const {
30 QStringList list;
31 QMap<QString, configWidget>::ConstIterator it;
32 for ( it = m_confFact.begin(); it != m_confFact.end(); ++it ) {
33 list << it.key();
34 }
35 return list;
36}
37QStringList MetaFactory::fileTransferLayers()const {
38 QStringList list;
39 QMap<QString, filelayer>::ConstIterator it;
40 for ( it = m_fileFact.begin(); it != m_fileFact.end(); ++it ) {
41 list << it.key();
42 }
43 return list;
44}
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 @@
1TEMPLATE = app 1TEMPLATE = app
2CONFIG = qt warn_on release 2CONFIG = qt warn_on release
3DESTDIR = $(OPIEDIR)/bin 3DESTDIR = $(OPIEDIR)/bin
4HEADERS = io_layer.h io_serial.h file_layer.h 4HEADERS = io_layer.h io_serial.h \
5SOURCES = io_layer.cpp io_serial.cpp file_layer.cpp main.cpp 5 file_layer.h \
6 metafactory.h \
7 session.h \
8 mainwindow.h
9SOURCES = io_layer.cpp io_serial.cpp \
10 file_layer.cpp main.cpp \
11 metafactory.cpp \
12 session.cpp \
13 mainwindow.cpp
6INTERFACES = 14INTERFACES =
7INCLUDEPATH += $(OPIEDIR)/include 15INCLUDEPATH += $(OPIEDIR)/include
8DEPENDPATH += $(OPIEDIR)/include 16DEPENDPATH += $(OPIEDIR)/include
9LIBS += -lqpe -lopie 17LIBS += -lqpe -lopie
10TARGET = opie-console 18TARGET = opie-console
11 19
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 @@
1
2
3#include "io_layer.h"
4#include "file_layer.h"
5#include "session.h"
6
7Session::Session( QWidget* widget, IOLayer* lay)
8 : m_widget( widget ), m_layer( lay )
9{
10}
11Session::~Session() {
12 delete m_layer;
13 delete m_widget;
14}
15QWidget* Session::widget() {
16 return m_widget;
17}
18IOLayer* Session::layer() {
19 return m_layer;
20}
21void Session::setWidget( QWidget* wid ) {
22 m_widget = wid;
23}
24void Session::setIOLayer( IOLayer* lay ) {
25 m_layer = lay;
26}