author | zecke <zecke> | 2002-10-09 01:22:42 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-10-09 01:22:42 (UTC) |
commit | a74bf68065b94efaacb73736c7127ccb74474645 (patch) (side-by-side diff) | |
tree | d85c40d367a4922091cc1780d8e1228d38de22c8 | |
parent | 8c353ec8b86ee8f82cc25172fb69dd5fee65e848 (diff) | |
download | opie-a74bf68065b94efaacb73736c7127ccb74474645.zip opie-a74bf68065b94efaacb73736c7127ccb74474645.tar.gz opie-a74bf68065b94efaacb73736c7127ccb74474645.tar.bz2 |
PLANS:
move around some stuff to done, open to progress...
Default
add EmulationLayer stuff (vt102)
EmulationLayer tried to use WidgetLayer but this did not work out
KeyTrans make sure to load the Q*Dict first before accessing it!
ibotty please check if this was correct
MainWindow
make generation of Sessions possible
TabWidget
go back to QTabWidget for now... this is much more testedt and I
do not have to debug it. Besides that OTabWidget is a kewl widget
and we will take it as soon as Sessions are tested enough
TabWidget also implement setCurrent for sessions
Vt102 make it compile... const QByteArray != const QByteArray&
-rw-r--r-- | noncore/apps/opie-console/PLANS | 12 | ||||
-rw-r--r-- | noncore/apps/opie-console/default.cpp | 7 | ||||
-rw-r--r-- | noncore/apps/opie-console/default.h | 4 | ||||
-rw-r--r-- | noncore/apps/opie-console/emulation_layer.h | 2 | ||||
-rw-r--r-- | noncore/apps/opie-console/keytrans.cpp | 3 | ||||
-rw-r--r-- | noncore/apps/opie-console/mainwindow.cpp | 48 | ||||
-rw-r--r-- | noncore/apps/opie-console/mainwindow.h | 4 | ||||
-rw-r--r-- | noncore/apps/opie-console/metafactory.cpp | 25 | ||||
-rw-r--r-- | noncore/apps/opie-console/metafactory.h | 21 | ||||
-rw-r--r-- | noncore/apps/opie-console/profilemanager.cpp | 44 | ||||
-rw-r--r-- | noncore/apps/opie-console/profilemanager.h | 2 | ||||
-rw-r--r-- | noncore/apps/opie-console/session.cpp | 49 | ||||
-rw-r--r-- | noncore/apps/opie-console/session.h | 38 | ||||
-rw-r--r-- | noncore/apps/opie-console/tabwidget.cpp | 21 | ||||
-rw-r--r-- | noncore/apps/opie-console/tabwidget.h | 5 | ||||
-rw-r--r-- | noncore/apps/opie-console/vt102emulation.cpp | 2 | ||||
-rw-r--r-- | noncore/apps/opie-console/vt102emulation.h | 2 |
17 files changed, 248 insertions, 41 deletions
diff --git a/noncore/apps/opie-console/PLANS b/noncore/apps/opie-console/PLANS index 8f6b807..0ec45cb 100644 --- a/noncore/apps/opie-console/PLANS +++ b/noncore/apps/opie-console/PLANS @@ -1,34 +1,38 @@ can we please get a working serial connection for now? if that works i can test file transfers and stuff. -hash +sure. I finished the ConfigDialog and now doing the Profile->Session +stuff. Then you just need to click Open -zecke From a UNIX point of view we want to do something like minicom with a better GUI. It should feature some terminal emulation vt100/102, ansi, filetransfer via {x,y,z}modem, and some sort of session management. Besides this requirement we would like to be able to execute 'scripts' in a session. A script would just write to the TEmulation and then be sent via an IOlayer. Then we would like to send keys? Do we want that? We want a modular architecture which might support plugins in the future (Almost) DONE: Framework Serial IOLayer Saving and Restoring Profiles +ConfigDialog Framework +FilesendingLayer - hash TASKS in progress: Profile->Session and MainWidget --- Harlekin -FilesendingLayer - hash IOLayer - wazlaf -Configuration - josef TE - ibotty - -OPEN tasks: Session->Profile - hash Scripting - wazlaf + +OPEN tasks: +Irda ConfigWidget +BT ConfigWidget Keys - open IRDA-Layer - open Bluetooth-Layer - open diff --git a/noncore/apps/opie-console/default.cpp b/noncore/apps/opie-console/default.cpp index d9a0557..da6f3e2 100644 --- a/noncore/apps/opie-console/default.cpp +++ b/noncore/apps/opie-console/default.cpp @@ -1,67 +1,74 @@ #include "io_serial.h" #include "sz_transfer.h" #include "serialconfigwidget.h" #include "terminalwidget.h" +#include "vt102emulation.h" #include "default.h" extern "C" { // FILE Transfer Stuff FileTransferLayer* newSZTransfer(IOLayer* lay) { return new SzTransfer( SzTransfer::SZ, lay ); } FileTransferLayer* newSYTransfer(IOLayer* lay) { return new SzTransfer( SzTransfer::SY, lay ); } FileTransferLayer* newSXTransfer(IOLayer* lay) { return new SzTransfer( SzTransfer::SX, lay ); } // Layer stuff IOLayer* newSerialLayer( const Profile& prof) { return new IOSerial( prof ); } IOLayer* newBTLayer( const Profile& ) { return 0l; } IOLayer* newIrDaLayer( const Profile& ) { return 0l; } // Connection Widgets ProfileDialogWidget* newSerialWidget(const QString& str, QWidget* wid) { return new SerialConfigWidget(str, wid ); } ProfileDialogWidget* newIrDaWidget( const QString& str, QWidget* wid) { return newSerialWidget(str, wid); } ProfileDialogWidget* newBTWidget( const QString& str, QWidget* wid) { return newSerialWidget(str, wid ); } // Terminal Widget(s) ProfileDialogWidget* newTerminalWidget(const QString& na, QWidget* wid) { return new TerminalWidget(na, wid,0 ); } + // VT Emulations + EmulationLayer* newVT102( Widget* wid ) { + return new Vt102Emulation( wid ); + } + }; Default::Default( MetaFactory* fact ) { fact->addFileTransferLayer( "SZ", QObject::tr("Z-Modem"), newSZTransfer ); fact->addFileTransferLayer( "SY", QObject::tr("Y-Modem"), newSYTransfer ); fact->addFileTransferLayer( "SX", QObject::tr("X-Modem"), newSXTransfer ); fact->addIOLayerFactory( "serial", QObject::tr("Serial"), newSerialLayer ); fact->addIOLayerFactory( "irda", QObject::tr("Infrared"), newIrDaLayer ); fact->addIOLayerFactory( "bt", QObject::tr("Bluetooth"), newBTLayer ); fact->addConnectionWidgetFactory( "serial", QObject::tr("Serial"), newSerialWidget ); fact->addConnectionWidgetFactory( "irda", QObject::tr("Infrared"), newIrDaWidget ); fact->addConnectionWidgetFactory( "bt", QObject::tr("Bluetooth"), newBTWidget ); fact->addTerminalWidgetFactory( "default", QObject::tr("Default Terminal"), newTerminalWidget ); + fact->addEmulationLayer( "default", QObject::tr("Default Terminal"), newVT102 ); } Default::~Default() { } diff --git a/noncore/apps/opie-console/default.h b/noncore/apps/opie-console/default.h index ed78986..b9af898 100644 --- a/noncore/apps/opie-console/default.h +++ b/noncore/apps/opie-console/default.h @@ -1,30 +1,34 @@ #ifndef OPIE_DEFAULT_H #define OPIE_DEFAULT_H #include "metafactory.h" +class Widget; + extern "C" { FileTransferLayer* newSZTransfer(IOLayer*); FileTransferLayer* newSYTransfer(IOLayer*); FileTransferLayer* newSXTransfer(IOLayer*); IOLayer* newSerialLayer(const Profile&); IOLayer* newBTLayer(const Profile& ); IOLayer* newIrDaLayer(const Profile& ); ProfileDialogWidget* newSerialWidget(const QString&, QWidget* ); ProfileDialogWidget* newIrDaWidget (const QString&, QWidget* ); ProfileDialogWidget* newBTWidget (const QString&, QWidget* ); ProfileDialogWidget* newTerminalWidget(const QString&, QWidget* ); + + EmulationLayer* newVT102( Widget* ); }; class MetaFactory; struct Default { public: Default(MetaFactory* ); ~Default(); }; #endif diff --git a/noncore/apps/opie-console/emulation_layer.h b/noncore/apps/opie-console/emulation_layer.h index 0f54331..5781acc 100644 --- a/noncore/apps/opie-console/emulation_layer.h +++ b/noncore/apps/opie-console/emulation_layer.h @@ -5,49 +5,49 @@ /* -------------------------------------------------------------------------- */ /* */ /* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ /* */ /* This file is part of Konsole - an X terminal for KDE */ /* */ /* -------------------------------------------------------------------------- */ /* */ /* Ported Konsole to Qt/Embedded */ /* */ /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ /* */ /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ /* */ /* made to a layer between io_layer and widget */ /* */ /* Copyright (C) 2002 by opie developers <opie@handhelds.org> */ /* */ /* -------------------------------------------------------------------------- */ #ifndef EMULATION_LAYER_H #define EMULATION_LAYER_H -#include "widget.h" +#include "widget_layer.h" #include "screen.h" #include <qtimer.h> #include <stdio.h> #include <qtextcodec.h> #include "keytrans.h" class EmulationLayer : public QObject { Q_OBJECT public: EmulationLayer(Widget* gui); ~EmulationLayer(); public: virtual void setHistory(bool on); virtual bool history(); public slots: // signals incoming from Widget virtual void onImageSizeChange(int lines, int columns); virtual void onHistoryCursorChange(int cursor); virtual void onKeyPress(QKeyEvent*); diff --git a/noncore/apps/opie-console/keytrans.cpp b/noncore/apps/opie-console/keytrans.cpp index d569ae0..5ea192e 100644 --- a/noncore/apps/opie-console/keytrans.cpp +++ b/noncore/apps/opie-console/keytrans.cpp @@ -606,60 +606,63 @@ void KeyTransSymbols::defKeySyms() defKeySym("Underscore", Qt::Key_Underscore ); defKeySym("QuoteLeft", Qt::Key_QuoteLeft ); defKeySym("BraceLeft", Qt::Key_BraceLeft ); defKeySym("Bar", Qt::Key_Bar ); defKeySym("BraceRight", Qt::Key_BraceRight ); defKeySym("AsciiTilde", Qt::Key_AsciiTilde ); } KeyTransSymbols::KeyTransSymbols() { defModSyms(); defOprSyms(); defKeySyms(); } // Global material ----------------------------------------------------------- static int keytab_serial = 0; //FIXME: remove,localize static QIntDict<KeyTrans> * numb2keymap = 0L; static QDict<KeyTrans> * path2keymap = 0L; KeyTrans* KeyTrans::find(int numb) { + loadAll(); KeyTrans* res = numb2keymap->find(numb); return res ? res : numb2keymap->find(0); } KeyTrans* KeyTrans::find(const char* path) { + loadAll(); KeyTrans* res = path2keymap->find(path); return res ? res : numb2keymap->find(0); } int KeyTrans::count() { + loadAll(); return numb2keymap->count(); } void KeyTrans::addKeyTrans() { this->numb = keytab_serial ++; numb2keymap->insert(numb,this); path2keymap->insert(path,this); } void KeyTrans::loadAll() { if (!numb2keymap) numb2keymap = new QIntDict<KeyTrans>; if (!path2keymap) path2keymap = new QDict<KeyTrans>; if (!syms) syms = new KeyTransSymbols; defaultKeyTrans()->addKeyTrans(); QString path = QPEApplication::qpeDir() + "etc/keytabs"; QDir dir(path); diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp index 3531478..aeb3742 100644 --- a/noncore/apps/opie-console/mainwindow.cpp +++ b/noncore/apps/opie-console/mainwindow.cpp @@ -1,34 +1,36 @@ #include <qaction.h> #include <qmenubar.h> #include <qlabel.h> #include <qpopupmenu.h> #include <qtoolbar.h> +#include "profileeditordialog.h" #include "configdialog.h" #include "default.h" #include "metafactory.h" +#include "profile.h" #include "profilemanager.h" #include "mainwindow.h" #include "tabwidget.h" MainWindow::MainWindow() { m_factory = new MetaFactory(); Default def(m_factory); m_sessions.setAutoDelete( TRUE ); m_curSession = 0; m_manager = new ProfileManager( m_factory ); m_manager->load(); initUI(); populateProfiles(); } 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 ); m_sessionsPop= new QPopupMenu( this ); @@ -88,93 +90,127 @@ void MainWindow::initUI() { /* insert the submenu */ m_console->insertItem(tr("New from Profile"), m_sessionsPop, -1, 0); /* insert the connection menu */ m_bar->insertItem( tr("Connection"), m_console ); /* the settings menu */ m_bar->insertItem( tr("Settings"), m_settings ); /* * connect to the menu activation */ connect( m_sessionsPop, SIGNAL(activated( int ) ), this, SLOT(slotProfile( int ) ) ); m_consoleWindow = new TabWidget( this, "blah"); setCentralWidget( m_consoleWindow ); } ProfileManager* MainWindow::manager() { return m_manager; } - +TabWidget* MainWindow::tabWidget() { + return m_consoleWindow; +} void MainWindow::populateProfiles() { m_sessionsPop->clear(); Profile::ValueList list = manager()->all(); for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { m_sessionsPop->insertItem( (*it).name() ); } } MainWindow::~MainWindow() { delete m_factory; manager()->save(); } MetaFactory* MainWindow::factory() { return m_factory; } Session* MainWindow::currentSession() { return m_curSession; } QList<Session> MainWindow::sessions() { return m_sessions; } void MainWindow::slotNew() { qWarning("New Connection"); + ProfileEditorDialog dlg(factory() ); + int ret = dlg.exec(); + + if ( ret == QDialog::Accepted ) { + create( dlg.profile() ); + } } void MainWindow::slotConnect() { if ( currentSession() ) currentSession()->layer()->open(); } void MainWindow::slotDisconnect() { if ( currentSession() ) currentSession()->layer()->close(); } void MainWindow::slotTerminate() { if ( currentSession() ) currentSession()->layer()->close(); - delete m_curSession; - m_curSession = 0l; + + slotClose(); /* FIXME move to the next session */ } void MainWindow::slotConfigure() { qWarning("configure"); ConfigDialog conf( manager()->all(), factory() ); conf.showMaximized(); int ret = conf.exec(); if ( QDialog::Accepted == ret ) { qWarning("conf %d", conf.list().count() ); manager()->setProfiles( conf.list() ); populateProfiles(); } } - +/* + * we will remove + * this window from the tabwidget + * remove it from the list + * delete it + * and set the currentSession() + */ void MainWindow::slotClose() { -} + if (!currentSession() ) + return; -void MainWindow::slotProfile( int ) { + tabWidget()->remove( currentSession() ); + tabWidget()->setCurrent( m_sessions.first() ); + m_sessions.remove( m_curSession ); + delete m_curSession; + m_curSession = m_sessions.first(); +} +/* + * We will get the name + * Then the profile + * and then we will make a profile + */ +void MainWindow::slotProfile( int id) { + Profile prof = manager()->profile( m_sessionsPop->text( id) ); + create( prof ); +} +void MainWindow::create( const Profile& prof ) { + Session *ses = manager()->fromProfile( prof, tabWidget() ); + m_sessions.append( ses ); + tabWidget()->add( ses ); + m_curSession = ses; } diff --git a/noncore/apps/opie-console/mainwindow.h b/noncore/apps/opie-console/mainwindow.h index 36eb3a7..7ef9c26 100644 --- a/noncore/apps/opie-console/mainwindow.h +++ b/noncore/apps/opie-console/mainwindow.h @@ -1,84 +1,86 @@ #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 TabWidget; class ProfileManager; - +class Profile; 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(); /** * */ ProfileManager* manager(); + TabWidget* tabWidget(); private slots: void slotNew(); void slotConnect(); void slotDisconnect(); void slotTerminate(); void slotConfigure(); void slotClose(); void slotProfile(int); private: void initUI(); void populateProfiles(); + void create( const Profile& ); /** * the current session */ Session* m_curSession; /** * the session list */ QList<Session> m_sessions; /** * the metafactory */ MetaFactory* m_factory; ProfileManager* m_manager; TabWidget* m_consoleWindow; QToolBar* m_tool; QMenuBar* m_bar; QPopupMenu* m_console; QPopupMenu* m_settings; QPopupMenu* m_sessionsPop; QAction* m_connect; QAction* m_disconnect; diff --git a/noncore/apps/opie-console/metafactory.cpp b/noncore/apps/opie-console/metafactory.cpp index 4501ec2..02a9f9b 100644 --- a/noncore/apps/opie-console/metafactory.cpp +++ b/noncore/apps/opie-console/metafactory.cpp @@ -9,106 +9,131 @@ MetaFactory::~MetaFactory() { void MetaFactory::addConnectionWidgetFactory( const QCString& name, const QString& str, configWidget wid) { m_strings.insert( str, name ); m_conFact.insert( str, wid ); } void MetaFactory::addTerminalWidgetFactory( const QCString& name, const QString& str, configWidget wid ) { m_strings.insert( str, name ); m_termFact.insert( str, wid ); } void MetaFactory::addIOLayerFactory( const QCString& name, const QString& str, iolayer lay) { m_strings.insert( str, name ); m_layerFact.insert( str, lay ); } void MetaFactory::addFileTransferLayer( const QCString& name, const QString& str, filelayer lay) { m_strings.insert(str, name ); m_fileFact.insert( str, lay ); } +void MetaFactory::addEmulationLayer( const QCString& name, + const QString& str, + emulationLayer em) { + m_strings.insert(str, name ); + m_emu.insert( str, em ); +} 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::connectionWidgets()const { QStringList list; QMap<QString, configWidget>::ConstIterator it; for ( it = m_conFact.begin(); it != m_conFact.end(); ++it ) { list << it.key(); } return list; } QStringList MetaFactory::terminalWidgets()const { QStringList list; QMap<QString, configWidget>::ConstIterator it; for ( it = m_termFact.begin(); it != m_termFact.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; } +QStringList MetaFactory::emulationLayers()const { + QStringList list; + QMap<QString, emulationLayer>::ConstIterator it; + for ( it = m_emu.begin(); it != m_emu.end(); ++it ) { + list << it.key(); + } + return list; +} IOLayer* MetaFactory::newIOLayer( const QString& str,const Profile& prof ) { IOLayer* lay = 0l; QMap<QString, iolayer>::Iterator it; it = m_layerFact.find( str ); if ( it != m_layerFact.end() ) { lay = (*(it.data()))(prof); /* iolayer laye = it.data(); lay = (*laye )(conf);*/ } return lay; } ProfileDialogWidget *MetaFactory::newConnectionPlugin ( const QString& str, QWidget *parent) { ProfileDialogWidget* wid = 0l; QMap<QString, configWidget>::Iterator it; it = m_conFact.find( str ); if ( it != m_conFact.end() ) { wid = (*(it.data() ) )(str,parent); } return wid; } ProfileDialogWidget *MetaFactory::newTerminalPlugin( const QString& str, QWidget *parent) { if (str.isEmpty() ) return 0l; ProfileDialogWidget* wid = 0l; qWarning("new terminalPlugin %s %l", str.latin1(), parent ); QMap<QString, configWidget>::Iterator it; it = m_termFact.find( str ); if ( it != m_termFact.end() ) { wid = (*(it.data() ) )(str,parent); } return wid; } +EmulationLayer* MetaFactory::newEmulationLayer( const QString& str, Widget* wid) { + EmulationLayer* lay = 0l; + + QMap<QString, emulationLayer>::Iterator it; + it = m_emu.find( str ); + if ( it != m_emu.end() ) { + lay = (*(it.data() ) )(wid); + } + + return lay; +} QCString MetaFactory::internal( const QString& str )const { return m_strings[str]; } QString MetaFactory::external( const QCString& str )const { QMap<QString, QCString>::ConstIterator it; for ( it = m_strings.begin(); it != m_strings.end(); ++it ) { if ( it.data() == str ) return it.key(); } return QString::null; } diff --git a/noncore/apps/opie-console/metafactory.h b/noncore/apps/opie-console/metafactory.h index 3f7ddce..71c35a2 100644 --- a/noncore/apps/opie-console/metafactory.h +++ b/noncore/apps/opie-console/metafactory.h @@ -1,85 +1,106 @@ #ifndef OPIE_META_FACTORY_H #define OPIE_META_FACTORY_H /** * The MetaFactory is used to keep track of all IOLayers, FileTransferLayers and ConfigWidgets * and to instantiate these implementations on demand */ #include <qwidget.h> #include <qmap.h> #include <qpe/config.h> #include "io_layer.h" #include "file_layer.h" #include "profile.h" #include "profiledialogwidget.h" +#include "emulation_layer.h" +class Widget; class MetaFactory { public: typedef ProfileDialogWidget* (*configWidget)(const QString&, QWidget* parent); typedef IOLayer* (*iolayer)(const Profile& ); typedef FileTransferLayer* (*filelayer)(IOLayer*); + typedef EmulationLayer* (*emulationLayer)(Widget* ); MetaFactory(); ~MetaFactory(); /** * add a ProfileDialogWidget to the factory * name is the name shown to the user */ void addConnectionWidgetFactory( const QCString& internalName, const QString& uiString, configWidget ); void addTerminalWidgetFactory ( const QCString& internalName, const QString& name, configWidget ); /** * adds an IOLayer factory */ void addIOLayerFactory( const QCString&, const QString&, iolayer ); /** * adds a FileTransfer Layer */ void addFileTransferLayer( const QCString& name, const QString&, filelayer ); + /** + * adds a Factory for Emulation to the Layer.. + */ + void addEmulationLayer ( const QCString& name, + const QString& uiString, + emulationLayer ); + /* translated UI Strings */ QStringList ioLayers()const; QStringList connectionWidgets()const; + + /** + * Terminal Configuration widgets + */ QStringList terminalWidgets()const; QStringList fileTransferLayers()const; + QStringList emulationLayers()const; + + /** + * the generation... + */ IOLayer* newIOLayer( const QString&,const Profile& ); ProfileDialogWidget *newConnectionPlugin ( const QString&, QWidget* ); ProfileDialogWidget* newTerminalPlugin( const QString&, QWidget* ); + EmulationLayer* newEmulationLayer(const QString&, Widget* ); /* * internal takes the maybe translated * public QString and maps it to the internal * not translatable QCString */ QCString internal( const QString& )const; /* * external takes the internal name * it returns a translated name */ QString external( const QCString& )const; private: QMap<QString, QCString> m_strings; QMap<QString, configWidget> m_conFact; QMap<QString, configWidget> m_termFact; QMap<QString, iolayer> m_layerFact; QMap<QString, filelayer> m_fileFact; + QMap<QString, emulationLayer> m_emu; }; #endif diff --git a/noncore/apps/opie-console/profilemanager.cpp b/noncore/apps/opie-console/profilemanager.cpp index e66ebcc..dcf3cbd 100644 --- a/noncore/apps/opie-console/profilemanager.cpp +++ b/noncore/apps/opie-console/profilemanager.cpp @@ -1,88 +1,114 @@ #include <stdio.h> #include <stdlib.h> #include <qfile.h> +#include <qlayout.h> +#include <qwidgetstack.h> #include <qpe/config.h> +#include "widget.h" #include "metafactory.h" #include "profileconfig.h" #include "profilemanager.h" ProfileManager::ProfileManager( MetaFactory* fact ) : m_fact( fact ) { } ProfileManager::~ProfileManager() { } void ProfileManager::load() { m_list.clear(); qWarning("load"); ProfileConfig conf("opie-console-profiles"); QStringList groups = conf.groups(); QStringList::Iterator it; /* * for each profile */ for ( it = groups.begin(); it != groups.end(); ++it ) { qWarning("group " + (*it) ); conf.setGroup( (*it) ); Profile prof; prof.setName( conf.readEntry("name") ); prof.setIOLayer( conf.readEntry("iolayer").utf8() ); prof.setTerminalName( conf.readEntry("term").utf8() ); qWarning(" %s %s", conf.readEntry("iolayer").latin1(), prof.ioLayerName().data() ); prof.setBackground( conf.readNumEntry("back") ); prof.setForeground( conf.readNumEntry("fore") ); prof.setTerminal( conf.readNumEntry("terminal") ); prof.setConf( conf.items( (*it) ) ); /* now add it */ m_list.append( prof ); } } void ProfileManager::clear() { m_list.clear(); } Profile::ValueList ProfileManager::all()const { return m_list; } -Session* ProfileManager::fromProfile( const Profile& prof) { +/* + * Our goal is to create a Session + * We will load the the IOLayer and EmulationLayer + * from the factory + * we will generate a QWidgetStack + * add a dummy widget with layout + * add "Widget" to the layout + * add the dummy to the stack + * raise the dummy + * call session->connect(= + * this way we only need to reparent + * in TabWidget + */ +Session* ProfileManager::fromProfile( const Profile& prof, QWidget* parent) { Session* session = new Session(); session->setName( prof.name() ); - session->setIOLayer(m_fact->newIOLayer(prof.ioLayerName(), - prof) ); - /* - * FIXME - * load emulation - * load widget? - * set colors + fonts - */ + /* translate the internal name to the external */ + session->setIOLayer(m_fact->newIOLayer( m_fact->external(prof.ioLayerName()) , + prof) ); + + QWidgetStack *stack = new QWidgetStack(parent); + session->setWidgetStack( stack ); + QWidget* dummy = new QWidget(stack ); + QHBoxLayout* lay = new QHBoxLayout(dummy ); + stack->addWidget( dummy, 0 ); + stack->raiseWidget( 0 ); + Widget* wid = new Widget(dummy ); + lay->addWidget( wid ); + + session->setEmulationWidget( wid ); + session->setEmulationLayer( m_fact->newEmulationLayer( m_fact->external( prof.terminalName() ), + wid ) ); + session->connect(); + return session; } void ProfileManager::save( ) { QFile::remove( (QString(getenv("HOME") )+ "/Settings/opie-console-profiles.conf" ) ); ProfileConfig conf("opie-console-profiles"); Profile::ValueList::Iterator it; for (it = m_list.begin(); it != m_list.end(); ++it ) { conf.setGroup( (*it).name() ); conf.writeEntry( "name", (*it).name() ); conf.writeEntry( "iolayer", QString::fromUtf8( (*it).ioLayerName() ) ); conf.writeEntry( "term", QString::fromUtf8( (*it).terminalName() ) ); conf.writeEntry( "back", (*it).background() ); conf.writeEntry( "fore", (*it).foreground() ); conf.writeEntry( "terminal", (*it).terminal() ); /* now the config stuff */ QMap<QString, QString> map = (*it).conf(); QMap<QString, QString>::Iterator it; for ( it = map.begin(); it != map.end(); ++it ) { conf.writeEntry( it.key(), it.data() ); } } } void ProfileManager::setProfiles( const Profile::ValueList& list ) { m_list = list; diff --git a/noncore/apps/opie-console/profilemanager.h b/noncore/apps/opie-console/profilemanager.h index 1387247..33b7095 100644 --- a/noncore/apps/opie-console/profilemanager.h +++ b/noncore/apps/opie-console/profilemanager.h @@ -1,32 +1,32 @@ #ifndef OPIE_PROFILE_MANAGER_H #define OPIE_PROFILE_MANAGER_H #include <qlist.h> #include "session.h" #include "profile.h" class MetaFactory; class ConfigWidget; class ProfileManager { public: ProfileManager(MetaFactory*); ~ProfileManager(); void load(); Profile::ValueList all()const; void clear(); /** * also replaces the item */ void add( const Profile& prof ); void remove( const Profile& prof ); Profile profile(const QString& name )const; - Session* fromProfile( const Profile& ); + Session* fromProfile( const Profile& , QWidget* parent = 0l); void setProfiles( const Profile::ValueList& ); void save(); private: MetaFactory* m_fact; Profile::ValueList m_list; }; #endif diff --git a/noncore/apps/opie-console/session.cpp b/noncore/apps/opie-console/session.cpp index d32b340..42b0583 100644 --- a/noncore/apps/opie-console/session.cpp +++ b/noncore/apps/opie-console/session.cpp @@ -1,38 +1,81 @@ #include "io_layer.h" #include "file_layer.h" +#include "widget.h" +#include "emulation_layer.h" #include "session.h" + Session::Session() { m_widget = 0l; m_layer = 0l; + m_widLay = 0l; + m_emLay = 0l; } -Session::Session( const QString& na, QWidget* widget, IOLayer* lay) +Session::Session( const QString& na, QWidgetStack* widget, IOLayer* lay) : m_name( na ), m_widget( widget ), m_layer( lay ) { + m_widLay = 0l; + m_emLay = 0l; } Session::~Session() { delete m_layer; + delete m_emLay; delete m_widget; + /* the widget layer should be deleted by the m_widget */ } QString Session::name()const { return m_name; } -QWidget* Session::widget() { +QWidgetStack* Session::widgetStack() { return m_widget; } IOLayer* Session::layer() { return m_layer; } +EmulationLayer* Session::emulationLayer() { + return m_emLay; +} +Widget* Session::emulationWidget() { + return m_widLay; +} +void Session::connect() { + if ( !m_layer || !m_emLay ) + return; + + QObject::connect(m_layer, SIGNAL(received(const QByteArray&) ), + m_emLay, SLOT(onRcvBlock(const QByteArray&) ) ); + QObject::connect(m_emLay, SIGNAL(sndBlock(const QByteArray&) ), + m_layer, SLOT(send(const QByteArray&) ) ); +} +void Session::disconnect() { + if ( !m_layer || !m_emLay ) + return; + + QObject::disconnect(m_layer, SIGNAL(received(const QByteArray&) ), + m_emLay, SLOT(onRcvBlock(const QByteArray&) ) ); + QObject::disconnect(m_emLay, SIGNAL(sndBlock(const QByteArray&) ), + m_layer, SLOT(send(const QByteArray&) ) ); +} void Session::setName( const QString& na){ m_name = na; } -void Session::setWidget( QWidget* wid ) { +void Session::setWidgetStack( QWidgetStack* wid ) { delete m_widget; + /* the EmulationLayer was destroyed... */ + delete m_emLay; m_widget = wid; } void Session::setIOLayer( IOLayer* lay ) { delete m_layer; m_layer = lay; } +void Session::setEmulationLayer( EmulationLayer* lay ) { + delete m_emLay; + m_emLay = lay; +} +void Session::setEmulationWidget( Widget* lay ) { + delete m_widLay; + m_widLay = lay; +} diff --git a/noncore/apps/opie-console/session.h b/noncore/apps/opie-console/session.h index 44b5fc8..c3673fc 100644 --- a/noncore/apps/opie-console/session.h +++ b/noncore/apps/opie-console/session.h @@ -1,48 +1,74 @@ #ifndef OPIE_SESSION_H #define OPIE_SESSION_H -#include <qwidget.h> +#include <qwidgetstack.h> class IOLayer; +class EmulationLayer; +class Widget; /** * This is a Session. A session contains * a QWidget pointer and a IOLayer * Imagine a session like a collection of what * is needed to show your widget in a tab ;) */ class Session { public: /** * c'tor with widget and layer * ownership get's transfered */ Session(); - Session( const QString&, QWidget* widget, IOLayer* ); + Session( const QString&, QWidgetStack* widget, IOLayer* ); ~Session(); /** * return the name of the session */ QString name()const; /** - * return the widget + * return the widgetstack + * this is used to be semi modal + * for FileTransfer + * + * semi modal == SessionModal */ - QWidget* widget(); + QWidgetStack* widgetStack(); /** * return the layer */ IOLayer* layer(); - void setWidget( QWidget* widget ); + + EmulationLayer* emulationLayer(); + Widget* emulationWidget(); + + /* + * connects the data flow from + * the IOLayer to the EmulationLayer + */ + void connect(); + + /* + * disconnect the dataflow + * this will be done for ft + */ + void disconnect(); + + void setWidgetStack( QWidgetStack* widget ); + void setEmulationLayer( EmulationLayer* lay ); + void setEmulationWidget( Widget* lay ); void setIOLayer( IOLayer* ); void setName( const QString& ); private: QString m_name; - QWidget* m_widget; + QWidgetStack* m_widget; IOLayer* m_layer; + EmulationLayer* m_emLay; + Widget* m_widLay; }; #endif diff --git a/noncore/apps/opie-console/tabwidget.cpp b/noncore/apps/opie-console/tabwidget.cpp index 783bf13..cfaef91 100644 --- a/noncore/apps/opie-console/tabwidget.cpp +++ b/noncore/apps/opie-console/tabwidget.cpp @@ -1,34 +1,43 @@ #include "tabwidget.h" TabWidget::TabWidget( QWidget* parent, const char* name ) - : OTabWidget( parent, name ) { + : QTabWidget( parent, name ) { connect(this, SIGNAL( currentChanged(QWidget*) ), this, SLOT( slotCurChanged(QWidget*) ) ); } TabWidget::~TabWidget() { } void TabWidget::add( Session* ses ) { - if ( !ses->widget() ) return; - addTab( ses->widget(), "console/konsole", ses->name() ); - m_map.insert( ses->widget(), ses ); + if ( !ses->widgetStack() ) return; + qWarning("going to add it"); + //reparent( ses->widgetStack(), QPoint() ); + //addTab( ses->widgetStack(), "console/konsole", ses->name() ); + addTab( ses->widgetStack(), ses->name() ); + m_map.insert( ses->widgetStack(), ses ); } void TabWidget::remove( Session* ses ) { - m_map.remove( ses->widget() ); - removePage( ses->widget() ); + m_map.remove( ses->widgetStack() ); + removePage( ses->widgetStack() ); } void TabWidget::slotCurChanged( QWidget* wid ) { QMap<QWidget*, Session*>::Iterator it; it = m_map.find( wid ); if ( it == m_map.end() ) { return; } emit activated( it.data() ); } +void TabWidget::setCurrent( Session* ses ) { + if (!ses ) + return; + + showPage( ses->widgetStack() ); +} diff --git a/noncore/apps/opie-console/tabwidget.h b/noncore/apps/opie-console/tabwidget.h index a701488..42a00ec 100644 --- a/noncore/apps/opie-console/tabwidget.h +++ b/noncore/apps/opie-console/tabwidget.h @@ -1,28 +1,29 @@ #ifndef OPIE_TAB_WIDGET_H #define OPIE_TAB_WIDGET_H #include <qmap.h> -#include <opie/otabwidget.h> +#include <qtabwidget.h> #include "session.h" /** * This is our central tab widget * we can add sessions here */ -class TabWidget : public OTabWidget{ +class TabWidget : public QTabWidget{ Q_OBJECT public: TabWidget(QWidget *parent, const char* name ); ~TabWidget(); void add( Session* ); void remove( Session* ); + void setCurrent( Session* ); signals: void activated(Session* ses ); private slots: void slotCurChanged( QWidget* wid ); private: QMap<QWidget*, Session*> m_map; }; #endif diff --git a/noncore/apps/opie-console/vt102emulation.cpp b/noncore/apps/opie-console/vt102emulation.cpp index dc977f5..2220f4e 100644 --- a/noncore/apps/opie-console/vt102emulation.cpp +++ b/noncore/apps/opie-console/vt102emulation.cpp @@ -601,49 +601,49 @@ void Vt102Emulation::tau( int token, int p, int q ) /* ------------------------------------------------------------------------- */ /* */ /* Terminal to Host protocol */ /* */ /* ------------------------------------------------------------------------- */ /* Outgoing bytes originate from several sources: - Replies to Enquieries. - Mouse Events - Keyboard Events */ /*! */ void Vt102Emulation::sendString(const char* s) { QByteArray tmp; tmp.setRawData( s, strlen( s )); emit sndBlock( tmp); } -void Vt102Emulation::sendString(const QByteArray s) +void Vt102Emulation::sendString(const QByteArray& s) { emit sndBlock( s ); } // Replies ----------------------------------------------------------------- -- // This section copes with replies send as response to an enquiery control code. /*! */ void Vt102Emulation::reportCursorPosition() { char tmp[20]; sprintf(tmp,"\033[%d;%dR",scr->getCursorY()+1,scr->getCursorX()+1); sendString(tmp); } /* What follows here is rather obsolete and faked stuff. The correspondent enquieries are neverthenless issued. */ /*! */ diff --git a/noncore/apps/opie-console/vt102emulation.h b/noncore/apps/opie-console/vt102emulation.h index 018835e..a3d0ae6 100644 --- a/noncore/apps/opie-console/vt102emulation.h +++ b/noncore/apps/opie-console/vt102emulation.h @@ -65,49 +65,49 @@ public: public slots: // signals incoming from Widget void onKeyPress(QKeyEvent*); void onMouse(int cb, int cx, int cy); signals: void changeTitle(int,const QString&); void prevSession(); void nextSession(); public: void reset(); /** * receive a char from IOLayer */ void onRcvChar(int cc); /** * sends a list of bytes to the IOLayer */ - void sendString(const QByteArray); + void sendString(const QByteArray&); /** * @deprecated use QByteArray instead * see sendString() above */ void sendString(const char *); public: BOOL getMode (int m); void setMode (int m); void resetMode (int m); void saveMode (int m); void restoreMode(int m); void resetModes(); void setConnect(bool r); private: void resetToken(); #define MAXPBUF 80 void pushToToken(int cc); |