summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/io_layer.cpp2
-rw-r--r--noncore/apps/opie-console/io_layer.h5
-rw-r--r--noncore/apps/opie-console/io_serial.cpp21
-rw-r--r--noncore/apps/opie-console/io_serial.h10
-rw-r--r--noncore/apps/opie-console/mainwindow.cpp67
-rw-r--r--noncore/apps/opie-console/mainwindow.h11
-rw-r--r--noncore/apps/opie-console/metafactory.cpp16
-rw-r--r--noncore/apps/opie-console/metafactory.h8
-rw-r--r--noncore/apps/opie-console/opie-console.pro13
-rw-r--r--noncore/apps/opie-console/profile.cpp59
-rw-r--r--noncore/apps/opie-console/profile.h66
-rw-r--r--noncore/apps/opie-console/profileconfig.cpp35
-rw-r--r--noncore/apps/opie-console/profileconfig.h17
-rw-r--r--noncore/apps/opie-console/profilemanager.cpp62
-rw-r--r--noncore/apps/opie-console/profilemanager.h30
-rw-r--r--noncore/apps/opie-console/session.cpp16
-rw-r--r--noncore/apps/opie-console/session.h11
-rw-r--r--noncore/apps/opie-console/tabwidget.cpp28
-rw-r--r--noncore/apps/opie-console/tabwidget.h28
19 files changed, 472 insertions, 33 deletions
diff --git a/noncore/apps/opie-console/io_layer.cpp b/noncore/apps/opie-console/io_layer.cpp
index ca1deb8..563a252 100644
--- a/noncore/apps/opie-console/io_layer.cpp
+++ b/noncore/apps/opie-console/io_layer.cpp
@@ -1,14 +1,14 @@
#include "io_layer.h"
IOLayer::IOLayer()
: QObject()
{
}
-IOLayer::IOLayer(const Config &)
+IOLayer::IOLayer(const Profile &)
: QObject()
{
}
IOLayer::~IOLayer() {
}
diff --git a/noncore/apps/opie-console/io_layer.h b/noncore/apps/opie-console/io_layer.h
index 537c851..2f1ceef 100644
--- a/noncore/apps/opie-console/io_layer.h
+++ b/noncore/apps/opie-console/io_layer.h
@@ -1,59 +1,60 @@
#ifndef OPIE_IO_LAYER_H
#define OPIE_IO_LAYER_H
#include <qobject.h>
#include <qpe/config.h>
+#include "profile.h"
+
/**
* This is the base class for IO Layers
* It will used to sent and recv data( QByteArray )
* it
*/
-class Config;
class IOLayer : public QObject {
Q_OBJECT
public:
enum Error {
NoError = -1,
Refuse = 0,
CouldNotOpen =1,
ClosedUnexpected =2,
ClosedError =3,
Terminate = 4
/* add more errors here */
};
/**
* a small c'tor
*/
IOLayer();
/**
* create an IOLayer instance from a config file
* the currently set group stores the profile/session
* information
*/
- IOLayer( const Config& );
+ IOLayer( const Profile& );
/**
* destructor
*/
virtual ~IOLayer();
/**
* a small internal identifier
*/
virtual QString identifier() const = 0;
/**
* a short name
*/
virtual QString name() const = 0;
signals:
/**
* received input as QCString
*/
virtual void received( const QByteArray& ) = 0;
/**
* an error occured
* int for the error number
diff --git a/noncore/apps/opie-console/io_serial.cpp b/noncore/apps/opie-console/io_serial.cpp
index c9155d1..b495f39 100644
--- a/noncore/apps/opie-console/io_serial.cpp
+++ b/noncore/apps/opie-console/io_serial.cpp
@@ -1,151 +1,152 @@
#include <fcntl.h>
#include <termios.h>
#include <errno.h>
#include <unistd.h>
#include "io_serial.h"
-IOSerial::IOSerial(const Config &config) : IOLayer(config) {
+IOSerial::IOSerial(const Profile &config) : IOLayer(config) {
m_fd = 0;
reload(config);
}
IOSerial::~IOSerial() {
if (m_fd) {
close();
}
}
void IOSerial::send(const QByteArray &data) {
if (m_fd) {
write(m_fd, data.data(), data.size());
} else {
emit error(Refuse, tr("Not connected"));
}
}
void IOSerial::close() {
if (m_fd) {
delete m_read;
delete m_error;
::close(m_fd);
m_fd = 0;
} else {
emit error(Refuse, tr("Not connected"));
}
}
bool IOSerial::open() {
if (!m_fd) {
struct termios tty;
m_fd = ::open(m_device, O_RDWR | O_NOCTTY | O_NONBLOCK);
if (m_fd < 0) {
emit error(CouldNotOpen, strerror(errno));
return FALSE;
}
tcgetattr(m_fd, &tty);
/* Baud rate */
- int speed = getBaud(m_baud);
+ int speed = baud(m_baud);
if (speed == -1) {
emit error(Refuse, tr("Invalid baud rate"));
}
cfsetospeed(&tty, speed);
cfsetispeed(&tty, speed);
/* Take care of Space / Mark parity */
if (m_dbits == 7 && (m_parity == ParitySpace || m_parity == ParityMark)) {
m_dbits = 8;
}
-
+
/* Data bits */
switch (m_dbits) {
case 5: tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS5; break;
case 6: tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS6; break;
case 7: tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS7; break;
case 8: tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS8; break;
+ default: break;
}
-
+
/* Raw, no echo mode */
tty.c_iflag = IGNBRK;
tty.c_lflag = 0;
tty.c_oflag = 0;
tty.c_cflag |= CLOCAL | CREAD;
/* Stop bits */
if (m_sbits == 2) {
tty.c_cflag |= CSTOPB;
} else {
tty.c_cflag &= ~CSTOPB;
}
-
+
tty.c_cc[VMIN] = 1;
tty.c_cc[VTIME] = 5;
/* Flow control */
if (m_flow & FlowSW)
tty.c_iflag |= IXON | IXOFF;
else
tty.c_iflag &= ~(IXON|IXOFF|IXANY);
-
+
if (m_flow & FlowHW)
tty.c_cflag |= CRTSCTS;
else
tty.c_cflag &= ~CRTSCTS;
-
+
/* Parity */
tty.c_cflag &= ~(PARENB | PARODD);
if (m_parity & ParityEven)
tty.c_cflag |= PARENB;
else if (m_parity & ParityOdd)
tty.c_cflag |= (PARENB | PARODD);
-
+
/* Set the changes */
tcsetattr(m_fd, TCSANOW, &tty);
/* Notifications on read & errors */
m_read = new QSocketNotifier(m_fd, QSocketNotifier::Read, this);
m_error = new QSocketNotifier(m_fd, QSocketNotifier::Exception, this);
connect(m_read, SIGNAL(activated(int)), this, SLOT(dataArrived()));
connect(m_error, SIGNAL(activated(int)), this, SLOT(errorOccured()));
return TRUE;
} else {
emit error(Refuse, tr("Device is already connected"));
return FALSE;
}
}
-void IOSerial::reload(const Config &config) {
+void IOSerial::reload(const Profile &config) {
m_device = config.readEntry("Device", SERIAL_DEFAULT_DEVICE);
m_baud = config.readNumEntry("Baud", SERIAL_DEFAULT_BAUD);
m_parity = config.readNumEntry("Parity", SERIAL_DEFAULT_PARITY);
m_dbits = config.readNumEntry("DataBits", SERIAL_DEFAULT_DBITS);
m_sbits = config.readNumEntry("StopBits", SERIAL_DEFAULT_SBITS);
m_flow = config.readNumEntry("Flow", SERIAL_DEFAULT_FLOW);
}
-int IOSerial::getBaud(int baud) const {
+int IOSerial::baud(int baud) const {
switch (baud) {
case 300: return B300; break;
case 600: return B600; break;
case 1200: return B1200; break;
case 2400: return B2400; break;
case 4800: return B4800; break;
case 9600: return B9600; break;
case 19200: return B19200; break;
case 38400: return B38400; break;
case 57600: return B57600; break;
case 115200: return B115200; break;
}
return -1;
}
void IOSerial::errorOccured() {
emit error(ClosedUnexpected, strerror(errno));
close();
}
void IOSerial::dataArrived() {
QByteArray array;
char buf[4096];
diff --git a/noncore/apps/opie-console/io_serial.h b/noncore/apps/opie-console/io_serial.h
index 1d34411..521dac6 100644
--- a/noncore/apps/opie-console/io_serial.h
+++ b/noncore/apps/opie-console/io_serial.h
@@ -8,56 +8,56 @@
#define SERIAL_DEFAULT_DEVICE "/dev/ttyS0"
#define SERIAL_DEFAULT_BAUD 9600
#define SERIAL_DEFAULT_PARITY 0
#define SERIAL_DEFAULT_DBITS 8
#define SERIAL_DEFAULT_SBITS 1
#define SERIAL_DEFAULT_FLOW 0
/* IOSerial implements a RS232 IO Layer */
class IOSerial : public IOLayer {
Q_OBJECT
public:
enum Parity {
ParityNone = 0,
ParityEven,
ParityOdd,
ParitySpace,
ParityMark
};
enum Flow {
FlowHW = 0x01,
FlowSW = 0x02
};
-
- IOSerial(const Config &);
+
+ IOSerial(const Profile &);
~IOSerial();
-
+
QString identifier() const;
QString name() const;
signals:
void received(const QByteArray &);
void error(int, const QString &);
public slots:
void send(const QByteArray &);
bool open();
void close();
- void reload(const Config &);
+ void reload(const Profile &);
protected:
- int getBaud(int baud) const;
+ int baud(int baud) const;
protected slots:
void dataArrived();
void errorOccured();
protected:
QSocketNotifier *m_read;
QSocketNotifier *m_error;
QString m_device;
int m_baud;
int m_parity;
int m_dbits;
int m_sbits;
int m_flow;
int m_fd;
};
#endif /* OPIE_IO_SERIAL */
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp
index e9b5eda..1ae4a20 100644
--- a/noncore/apps/opie-console/mainwindow.cpp
+++ b/noncore/apps/opie-console/mainwindow.cpp
@@ -1,62 +1,123 @@
#include <qaction.h>
#include <qmenubar.h>
#include <qlabel.h>
#include <qpopupmenu.h>
#include <qtoolbar.h>
#include "metafactory.h"
#include "mainwindow.h"
MainWindow::MainWindow() {
m_factory = new MetaFactory();
m_sessions.setAutoDelete( TRUE );
- m_curSession = -1;
+ m_curSession = 0;
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 );
+ m_sessionsPop= new QPopupMenu( this );
+ m_settings = 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") );
+
+ /*
+ * connect action
+ */
m_connect = new QAction();
m_connect->setText( tr("Connect") );
m_connect->addTo( m_console );
connect(m_connect, SIGNAL(activated() ),
this, SLOT(slotConnect() ) );
+
+ /*
+ * disconnect action
+ */
+ m_disconnect = new QAction();
+ m_disconnect->setText( tr("Disconnect") );
+ m_disconnect->addTo( m_console );
+ connect(m_disconnect, SIGNAL(activated() ),
+ this, SLOT(slotDisconnect() ) );
+
+ /*
+ * terminate action
+ */
+ m_terminate = new QAction();
+ m_terminate->setText( tr("Terminate") );
+ m_terminate->addTo( m_console );
+ connect(m_disconnect, SIGNAL(activated() ),
+ this, SLOT(slotTerminate() ) );
+
+ /*
+ * the settings action
+ */
+ m_setProfiles = new QAction();
+ m_setProfiles->setText( tr("Configure Profiles") );
+ m_setProfiles->addTo( m_settings );
+ connect( m_setProfiles, SIGNAL(activated() ),
+ this, SLOT(slotConfigure() ) );
+
+ /* 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 );
+
}
MainWindow::~MainWindow() {
delete m_factory;
}
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");
+}
+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;
+ /* FIXME move to the next session */
+}
+void MainWindow::slotConfigure() {
+ qWarning("configure");
+}
diff --git a/noncore/apps/opie-console/mainwindow.h b/noncore/apps/opie-console/mainwindow.h
index db3a653..b6a8419 100644
--- a/noncore/apps/opie-console/mainwindow.h
+++ b/noncore/apps/opie-console/mainwindow.h
@@ -17,58 +17,63 @@ 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();
-protected slots:
+
+private slots:
void slotNew();
void slotConnect();
+ void slotDisconnect();
+ void slotTerminate();
+ void slotConfigure();
+
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;
+ QPopupMenu* m_sessionsPop;
QAction* m_connect;
QAction* m_disconnect;
QAction* m_terminate;
- QAction* m_set;
+ QAction* m_setProfiles;
};
#endif
diff --git a/noncore/apps/opie-console/metafactory.cpp b/noncore/apps/opie-console/metafactory.cpp
index bef6ec7..754f34c 100644
--- a/noncore/apps/opie-console/metafactory.cpp
+++ b/noncore/apps/opie-console/metafactory.cpp
@@ -1,44 +1,58 @@
-
+#include <qpe/config.h>
#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;
}
+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;
+}
diff --git a/noncore/apps/opie-console/metafactory.h b/noncore/apps/opie-console/metafactory.h
index aae9391..bdd2ad2 100644
--- a/noncore/apps/opie-console/metafactory.h
+++ b/noncore/apps/opie-console/metafactory.h
@@ -1,43 +1,45 @@
#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"
class MetaFactory {
public:
typedef QWidget* (*configWidget)(QWidget* parent);
- typedef IOLayer* (*iolayer)(const Config& );
+ typedef IOLayer* (*iolayer)(const Profile& );
typedef FileTransferLayer* (*filelayer)(IOLayer*);
-
+
MetaFactory();
~MetaFactory();
void addConfigWidgetFactory( const QString&,
configWidget );
void addIOLayerFactory(const QString&,
iolayer );
void addFileTransferLayer( const QString&,
filelayer );
QStringList ioLayers()const;
QStringList configWidgets()const;
QStringList fileTransferLayers()const;
+ IOLayer* newIOLayer( const QString&,const Profile& );
+
private:
QMap<QString, configWidget> m_confFact;
QMap<QString, iolayer> m_layerFact;
QMap<QString, filelayer> m_fileFact;
};
#endif
diff --git a/noncore/apps/opie-console/opie-console.pro b/noncore/apps/opie-console/opie-console.pro
index 4a1180f..e045a48 100644
--- a/noncore/apps/opie-console/opie-console.pro
+++ b/noncore/apps/opie-console/opie-console.pro
@@ -1,19 +1,28 @@
TEMPLATE = app
CONFIG = qt warn_on release
DESTDIR = $(OPIEDIR)/bin
HEADERS = io_layer.h io_serial.h \
file_layer.h \
metafactory.h \
session.h \
- mainwindow.h
+ mainwindow.h \
+ profile.h \
+ profileconfig.h \
+ profilemanager.h \
+ configwidget.h \
+ tabwidget.h
SOURCES = io_layer.cpp io_serial.cpp \
file_layer.cpp main.cpp \
metafactory.cpp \
session.cpp \
- mainwindow.cpp
+ mainwindow.cpp \
+ profile.cpp \
+ profileconfig.cpp \
+ profilemanager.cpp \
+ tabwidget.cpp
INTERFACES =
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include
LIBS += -lqpe -lopie
TARGET = opie-console
diff --git a/noncore/apps/opie-console/profile.cpp b/noncore/apps/opie-console/profile.cpp
new file mode 100644
index 0000000..b730218
--- a/dev/null
+++ b/noncore/apps/opie-console/profile.cpp
@@ -0,0 +1,59 @@
+#include "profile.h"
+
+Profile::Profile() {
+
+}
+Profile::Profile( const QString& name,
+ const QString& iolayerName,
+ int background,
+ int foreground,
+ int terminal )
+ : m_name( name ), m_ioLayer( iolayerName ), m_back( background ),
+ m_fore( foreground ), m_terminal( terminal )
+{
+}
+Profile::Profile( const Profile& prof )
+{
+ (*this) = prof;
+}
+Profile &Profile::operator=( const Profile& prof ) {
+ m_name = prof.m_name;
+ m_ioLayer = prof.m_ioLayer;
+ m_back = prof.m_back;
+ m_fore = prof.m_fore;
+ m_terminal = prof.m_terminal;
+
+ return *this;
+}
+Profile::~Profile() {
+}
+QString Profile::name()const {
+ return m_name;
+}
+QString Profile::ioLayerName()const {
+ return m_ioLayer;
+}
+int Profile::foreground()const {
+ return m_fore;
+}
+int Profile::background()const {
+ return m_back;
+}
+int Profile::terminal()const {
+ return m_terminal;
+}
+void Profile::setName( const QString& str ) {
+ m_name = str;
+}
+void Profile::setIOLayer( const QString& name ) {
+ m_ioLayer = name;
+}
+void Profile::setBackground( int back ) {
+ m_back = back;
+}
+void Profile::setForeground( int fore ) {
+ m_fore = fore;
+}
+void Profile::setTerminal( int term ) {
+ m_terminal = term;
+}
diff --git a/noncore/apps/opie-console/profile.h b/noncore/apps/opie-console/profile.h
new file mode 100644
index 0000000..8adc0bd
--- a/dev/null
+++ b/noncore/apps/opie-console/profile.h
@@ -0,0 +1,66 @@
+#ifndef OPIE_PROFILE_H
+#define OPIE_PROFILE_H
+
+#include <qmap.h>
+#include <qstring.h>
+#include <qstringlist.h>
+#include <qvaluelist.h>
+/**
+ * A session will be generated from a saved
+ * profile. A profile contains the iolayername
+ * a name.
+ * We can generate a Session from a Profile
+ * No configuration is contained here....
+ */
+class Profile {
+public:
+ typedef QValueList<Profile> ValueList;
+ enum Color { Black = 0,
+ White,
+ Gray };
+ enum Terminal {VT102 = 0 };
+ enum Font { Micro = 0, Small, Medium };
+ Profile();
+ Profile( const QString& name,
+ const QString& iolayerName,
+ int background,
+ int foreground,
+ int terminal);
+ Profile( const Profile& );
+ Profile &operator=( const Profile& );
+
+ ~Profile();
+ QString name()const;
+ QString ioLayerName()const;
+ int foreground()const;
+ int background()const;
+ int terminal()const;
+
+ /*
+ * config stuff
+ */
+ QMap<QString, QString> conf();
+ void clearConf();
+ void writeEntry( const QString& key, const QString& value );
+ void writeEntry( const QString& key, int num );
+ void writeEntry( const QString& key, bool b );
+ void writeEntry( const QString& key, const QStringList&, const QChar& );
+ QString readEntry( const QString& key, const QString& deflt = QString::null)const;
+ int readNumEntry( const QString& key, int = -1 )const;
+ bool readBoolEntry( const QString& key, bool = FALSE )const;
+
+ void setName( const QString& );
+ void setIOLayer( const QString& );
+ void setBackground( int back );
+ void setForeground( int fore );
+ void setTerminal( int term );
+private:
+ QMap<QString, QString> m_conf;
+ QString m_name;
+ QString m_ioLayer;
+ int m_back;
+ int m_fore;
+ int m_terminal;
+};
+
+#endif
diff --git a/noncore/apps/opie-console/profileconfig.cpp b/noncore/apps/opie-console/profileconfig.cpp
new file mode 100644
index 0000000..8b16920
--- a/dev/null
+++ b/noncore/apps/opie-console/profileconfig.cpp
@@ -0,0 +1,35 @@
+
+#include "profileconfig.h"
+
+ProfileConfig::ProfileConfig( const QString& prof )
+ : Config( prof )
+{
+}
+ProfileConfig::~ProfileConfig() {
+
+}
+QStringList ProfileConfig::groups()const {
+ QStringList list;
+ QMap<QString, ConfigGroup>::ConstIterator it;
+ it= Config::groups.begin();
+
+ for (; it != Config::groups.end(); ++it )
+ list << it.key();
+
+
+ return list;
+
+}
+void ProfileConfig::clearAll() {
+ QMap<QString, ConfigGroup>::ConstIterator it;
+ it = Config::groups.begin();
+
+ for ( ; it != Config::groups.end(); ++it )
+ clearGroup( it.key() );
+}
+void ProfileConfig::clearGroup( const QString& str ) {
+ QString cur =git.key();
+ setGroup( str );
+ Config::clearGroup();
+ setGroup( cur );
+}
diff --git a/noncore/apps/opie-console/profileconfig.h b/noncore/apps/opie-console/profileconfig.h
new file mode 100644
index 0000000..e2e149c
--- a/dev/null
+++ b/noncore/apps/opie-console/profileconfig.h
@@ -0,0 +1,17 @@
+
+#ifndef OPIE_PROFILE_CONFIG_H
+#define OPIE_PROFILE_CONFIG_H
+
+#include <qpe/config.h>
+#include <qstringlist.h>
+
+class ProfileConfig : public Config {
+public:
+ ProfileConfig( const QString& prof );
+ ~ProfileConfig();
+ QStringList groups()const;
+ void clearGroup( const QString& );
+ void clearAll();
+
+};
+#endif
diff --git a/noncore/apps/opie-console/profilemanager.cpp b/noncore/apps/opie-console/profilemanager.cpp
new file mode 100644
index 0000000..db36686
--- a/dev/null
+++ b/noncore/apps/opie-console/profilemanager.cpp
@@ -0,0 +1,62 @@
+
+#include <qpe/config.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();
+ ProfileConfig conf("opie-console-profiles");
+ QStringList groups = conf.groups();
+ QStringList::Iterator it;
+
+ /*
+ * for each profile
+ */
+ /*
+ * QAsciiDict Parsing FIXME
+ */
+ for ( it = groups.begin(); it != groups.end(); ++it ) {
+ conf.setGroup( (*it) );
+ Profile prof;
+ prof.setName( conf.readEntry("name") );
+ prof.setIOLayer( conf.readEntry("iolayer") );
+ prof.setBackground( conf.readNumEntry("back") );
+ prof.setForeground( conf.readNumEntry("fore") );
+ prof.setTerminal( conf.readNumEntry("terminal") );
+
+ m_list.append( prof );
+ }
+
+}
+Profile::ValueList ProfileManager::all()const {
+ return m_list;
+}
+Session* ProfileManager::fromProfile( const Profile& prof) {
+ Session* session = new Session();
+ session->setName( prof.name() );
+ session->setIOLayer(m_fact->newIOLayer(prof.ioLayerName(),
+ prof) );
+ /*
+ * FIXME
+ * load emulation
+ * load widget
+ * set colors + fonts
+ */
+ return session;
+}
+void ProfileManager::save( ) {
+ m_list.clear();
+ ProfileConfig conf("opie-console-profiles");
+ Session* se= 0l;
+ // FIXME save
+}
diff --git a/noncore/apps/opie-console/profilemanager.h b/noncore/apps/opie-console/profilemanager.h
new file mode 100644
index 0000000..d4d0fd0
--- a/dev/null
+++ b/noncore/apps/opie-console/profilemanager.h
@@ -0,0 +1,30 @@
+#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 );
+ Session* fromProfile( const Profile& );
+ 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 4198fdc..d32b340 100644
--- a/noncore/apps/opie-console/session.cpp
+++ b/noncore/apps/opie-console/session.cpp
@@ -1,26 +1,38 @@
#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() {
+ m_widget = 0l;
+ m_layer = 0l;
+}
+Session::Session( const QString& na, QWidget* widget, IOLayer* lay)
+ : m_name( na ), m_widget( widget ), m_layer( lay )
{
}
Session::~Session() {
delete m_layer;
delete m_widget;
}
+QString Session::name()const {
+ return m_name;
+}
QWidget* Session::widget() {
return m_widget;
}
IOLayer* Session::layer() {
return m_layer;
}
+void Session::setName( const QString& na){
+ m_name = na;
+}
void Session::setWidget( QWidget* wid ) {
+ delete m_widget;
m_widget = wid;
}
void Session::setIOLayer( IOLayer* lay ) {
+ delete m_layer;
m_layer = lay;
}
diff --git a/noncore/apps/opie-console/session.h b/noncore/apps/opie-console/session.h
index 3978e1b..44b5fc8 100644
--- a/noncore/apps/opie-console/session.h
+++ b/noncore/apps/opie-console/session.h
@@ -1,39 +1,48 @@
#ifndef OPIE_SESSION_H
#define OPIE_SESSION_H
#include <qwidget.h>
class IOLayer;
/**
* 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( QWidget* widget, IOLayer* );
+ Session();
+ Session( const QString&, QWidget* widget, IOLayer* );
~Session();
/**
+ * return the name of the session
+ */
+ QString name()const;
+
+ /**
* return the widget
*/
QWidget* widget();
/**
* return the layer
*/
IOLayer* layer();
void setWidget( QWidget* widget );
void setIOLayer( IOLayer* );
+ void setName( const QString& );
private:
+ QString m_name;
QWidget* m_widget;
IOLayer* m_layer;
+
};
#endif
diff --git a/noncore/apps/opie-console/tabwidget.cpp b/noncore/apps/opie-console/tabwidget.cpp
new file mode 100644
index 0000000..6091aa2
--- a/dev/null
+++ b/noncore/apps/opie-console/tabwidget.cpp
@@ -0,0 +1,28 @@
+
+#include "tabwidget.h"
+
+TabWidget::TabWidget( QWidget* parent, const char* 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(), ses->name() );
+ m_map.insert( ses->widget(), ses );
+}
+void TabWidget::remove( Session* ses ) {
+ m_map.remove( ses->widget() );
+ removePage( ses->widget() );
+}
+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() );
+}
diff --git a/noncore/apps/opie-console/tabwidget.h b/noncore/apps/opie-console/tabwidget.h
new file mode 100644
index 0000000..d5d4be3
--- a/dev/null
+++ b/noncore/apps/opie-console/tabwidget.h
@@ -0,0 +1,28 @@
+#ifndef OPIE_TAB_WIDGET_H
+#define OPIE_TAB_WIDGET_H
+
+#include <qmap.h>
+#include <qtabwidget.h>
+
+#include "session.h"
+/**
+ * This is our central tab widget
+ * we can add sessions here
+ */
+class TabWidget : QTabWidget{
+ Q_OBJECT
+public:
+ TabWidget(QWidget *parent, const char* name );
+ ~TabWidget();
+ void add( Session* );
+ void remove( Session* );
+
+signals:
+ void activated(Session* ses );
+private slots:
+ void slotCurChanged( QWidget* wid );
+private:
+ QMap<QWidget*, Session*> m_map;
+};
+
+#endif