summaryrefslogtreecommitdiff
path: root/noncore
authorzecke <zecke>2002-10-08 16:37:37 (UTC)
committer zecke <zecke>2002-10-08 16:37:37 (UTC)
commit76fb8a57bf9fbae3a7073c8b0be1216f34adf99c (patch) (side-by-side diff)
tree3f486d66ce474039b1a0fc4ade770e6e8a7c32b3 /noncore
parentfaeb94a4000dc539577af465107b5d10903f92d6 (diff)
downloadopie-76fb8a57bf9fbae3a7073c8b0be1216f34adf99c.zip
opie-76fb8a57bf9fbae3a7073c8b0be1216f34adf99c.tar.gz
opie-76fb8a57bf9fbae3a7073c8b0be1216f34adf99c.tar.bz2
SzModem:
Make it compile remove = 0 from sendFile Add a Type to Sz so it could cover SX,SY too MetaFactory: take QCString name QString uiString so Carsten will be able to translate and users can switch Language without losing profiles Default It's aware of all Default/BuiltIn Plugins and adds them to the factory Common typedef bool BOOL TT is not using bool because it wasn't available at that time they use uint : 1... maybe we should change UINT_8 to Q_UINT8... MainWindow: give the factory to the config widget use Default IOLayer reload should take Profile not Config ConfigDialog: make use of Factory and do not do new MetaFactory.. i should make the c'tor private and add MainWindow as friend ProfileEditorDialog: Huge clean ups to the architecture. I still need to convert the widgets. Use the factory right
Diffstat (limited to 'noncore') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/common.h2
-rw-r--r--noncore/apps/opie-console/configdialog.cpp10
-rw-r--r--noncore/apps/opie-console/configdialog.h5
-rw-r--r--noncore/apps/opie-console/default.cpp65
-rw-r--r--noncore/apps/opie-console/default.h30
-rw-r--r--noncore/apps/opie-console/io_layer.h2
-rw-r--r--noncore/apps/opie-console/mainwindow.cpp4
-rw-r--r--noncore/apps/opie-console/metafactory.cpp76
-rw-r--r--noncore/apps/opie-console/metafactory.h60
-rw-r--r--noncore/apps/opie-console/opie-console.pro16
-rw-r--r--noncore/apps/opie-console/profile.cpp21
-rw-r--r--noncore/apps/opie-console/profile.h11
-rw-r--r--noncore/apps/opie-console/profiledialogwidget.cpp32
-rw-r--r--noncore/apps/opie-console/profiledialogwidget.h50
-rw-r--r--noncore/apps/opie-console/profileeditordialog.cpp239
-rw-r--r--noncore/apps/opie-console/profileeditordialog.h25
-rw-r--r--noncore/apps/opie-console/profileeditorplugins.h142
-rw-r--r--noncore/apps/opie-console/profilemanager.cpp6
-rw-r--r--noncore/apps/opie-console/sz_transfer.cpp2
-rw-r--r--noncore/apps/opie-console/sz_transfer.h12
20 files changed, 544 insertions, 266 deletions
diff --git a/noncore/apps/opie-console/common.h b/noncore/apps/opie-console/common.h
index ac0e2cf..979c2bd 100644
--- a/noncore/apps/opie-console/common.h
+++ b/noncore/apps/opie-console/common.h
@@ -28,3 +28,3 @@
#ifndef BOOL
-typedef int BOOL;
+typedef bool BOOL;
#endif
diff --git a/noncore/apps/opie-console/configdialog.cpp b/noncore/apps/opie-console/configdialog.cpp
index ee1ffb4..50512b6 100644
--- a/noncore/apps/opie-console/configdialog.cpp
+++ b/noncore/apps/opie-console/configdialog.cpp
@@ -31,4 +31,5 @@ Profile ConfigListItem::profile()const {
-ConfigDialog::ConfigDialog( const Profile::ValueList& lis, QWidget* parent )
- : ConfigureBase( parent, 0, TRUE )
+ConfigDialog::ConfigDialog( const Profile::ValueList& lis, MetaFactory* fa,
+ QWidget* parent )
+ : ConfigureBase( parent, 0, TRUE ), m_fact( fa )
{
@@ -73,3 +74,3 @@ void ConfigDialog::slotEdit() {
- ProfileEditorDialog dlg(new MetaFactory(), p);
+ ProfileEditorDialog dlg(m_fact, p);
@@ -92,3 +93,4 @@ void ConfigDialog::slotEdit() {
void ConfigDialog::slotAdd() {
- ProfileEditorDialog dlg(new MetaFactory());
+ qWarning("slotAdd");
+ ProfileEditorDialog dlg(m_fact);
diff --git a/noncore/apps/opie-console/configdialog.h b/noncore/apps/opie-console/configdialog.h
index a0c40d0..b81a004 100644
--- a/noncore/apps/opie-console/configdialog.h
+++ b/noncore/apps/opie-console/configdialog.h
@@ -8,2 +8,3 @@
+class MetaFactory;
class ConfigDialog : public ConfigureBase {
@@ -11,3 +12,3 @@ class ConfigDialog : public ConfigureBase {
public:
- ConfigDialog( const Profile::ValueList&, QWidget* parent = 0l);
+ ConfigDialog( const Profile::ValueList&, MetaFactory*, QWidget* parent = 0l);
~ConfigDialog();
@@ -19,2 +20,4 @@ protected slots:
void slotAdd();
+private:
+ MetaFactory* m_fact;
diff --git a/noncore/apps/opie-console/default.cpp b/noncore/apps/opie-console/default.cpp
new file mode 100644
index 0000000..78495d2
--- a/dev/null
+++ b/noncore/apps/opie-console/default.cpp
@@ -0,0 +1,65 @@
+#include "io_serial.h"
+#include "sz_transfer.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* ) {
+ return 0l;
+ }
+ 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&, QWidget* ) {
+ return 0l;
+ }
+
+};
+
+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 );
+
+}
+Default::~Default() {
+
+}
diff --git a/noncore/apps/opie-console/default.h b/noncore/apps/opie-console/default.h
new file mode 100644
index 0000000..ed78986
--- a/dev/null
+++ b/noncore/apps/opie-console/default.h
@@ -0,0 +1,30 @@
+#ifndef OPIE_DEFAULT_H
+#define OPIE_DEFAULT_H
+
+#include "metafactory.h"
+
+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* );
+};
+
+class MetaFactory;
+struct Default {
+public:
+ Default(MetaFactory* );
+ ~Default();
+};
+
+
+#endif
diff --git a/noncore/apps/opie-console/io_layer.h b/noncore/apps/opie-console/io_layer.h
index 2f1ceef..b891b2b 100644
--- a/noncore/apps/opie-console/io_layer.h
+++ b/noncore/apps/opie-console/io_layer.h
@@ -83,3 +83,3 @@ public slots:
*/
- virtual void reload( const Config& ) = 0;
+ virtual void reload( const Profile& ) = 0;
};
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp
index 31f1138..647a331 100644
--- a/noncore/apps/opie-console/mainwindow.cpp
+++ b/noncore/apps/opie-console/mainwindow.cpp
@@ -8,2 +8,3 @@
#include "configdialog.h"
+#include "default.h"
#include "metafactory.h"
@@ -15,2 +16,3 @@ MainWindow::MainWindow() {
m_factory = new MetaFactory();
+ Default def(m_factory);
m_sessions.setAutoDelete( TRUE );
@@ -158,3 +160,3 @@ void MainWindow::slotConfigure() {
qWarning("configure");
- ConfigDialog conf( manager()->all() );
+ ConfigDialog conf( manager()->all(), factory() );
conf.showMaximized();
diff --git a/noncore/apps/opie-console/metafactory.cpp b/noncore/apps/opie-console/metafactory.cpp
index b69d6da..077b418 100644
--- a/noncore/apps/opie-console/metafactory.cpp
+++ b/noncore/apps/opie-console/metafactory.cpp
@@ -8,14 +8,24 @@ MetaFactory::~MetaFactory() {
}
-void MetaFactory::addConfigWidgetFactory( const QString& str,
- const QString& name,
- configWidget wid) {
- m_namemap.insert ( str, name );
- m_confFact.insert( str, wid );
+void MetaFactory::addConnectionWidgetFactory( const QCString& name,
+ const QString& str,
+ configWidget wid) {
+ m_strings.insert( str, name );
+ m_conFact.insert( str, wid );
}
-void MetaFactory::addIOLayerFactory( const QString& str,
+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 QString& str,
+void MetaFactory::addFileTransferLayer( const QCString& name,
+ const QString& str,
filelayer lay) {
+ m_strings.insert(str, name );
m_fileFact.insert( str, lay );
@@ -30,6 +40,14 @@ QStringList MetaFactory::ioLayers()const {
}
-QStringList MetaFactory::configWidgets()const {
+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_confFact.begin(); it != m_confFact.end(); ++it ) {
+ for ( it = m_termFact.begin(); it != m_termFact.end(); ++it ) {
list << it.key();
@@ -62,15 +80,35 @@ IOLayer* MetaFactory::newIOLayer( const QString& str,const Profile& prof ) {
-ProfileEditorPlugin *MetaFactory::newConfigPlugin ( const QString& str, QWidget *parent, Profile *prof) {
- ProfileEditorPlugin *p = NULL;
- configWidget c;
+ProfileDialogWidget *MetaFactory::newConnectionPlugin ( const QString& str, QWidget *parent) {
+ ProfileDialogWidget* wid = 0l;
- c = m_confFact[str];
- if(c) p = c(parent, prof);
-
- return p;
+ 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 );
-QString MetaFactory::name( const QString& str ) {
- return m_namemap[str];
+ QMap<QString, configWidget>::Iterator it;
+ it = m_termFact.find( str );
+ if ( it != m_conFact.end() ) {
+ wid = (*(it.data() ) )(str,parent);
+ }
+ return wid;
+}
+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 216de03..3f7ddce 100644
--- a/noncore/apps/opie-console/metafactory.h
+++ b/noncore/apps/opie-console/metafactory.h
@@ -16,3 +16,3 @@
#include "profile.h"
-#include "profileeditorplugins.h"
+#include "profiledialogwidget.h"
@@ -20,3 +20,3 @@ class MetaFactory {
public:
- typedef ProfileEditorPlugin* (*configWidget)(QWidget* parent, Profile* prof);
+ typedef ProfileDialogWidget* (*configWidget)(const QString&, QWidget* parent);
typedef IOLayer* (*iolayer)(const Profile& );
@@ -27,22 +27,56 @@ public:
- void addConfigWidgetFactory( const QString&,
- const QString&,
- configWidget );
- void addIOLayerFactory(const QString&,
- iolayer );
- void addFileTransferLayer( const QString&,
+ /**
+ * 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 );
+
+ /* translated UI Strings */
QStringList ioLayers()const;
- QStringList configWidgets()const;
+ QStringList connectionWidgets()const;
+ QStringList terminalWidgets()const;
QStringList fileTransferLayers()const;
IOLayer* newIOLayer( const QString&,const Profile& );
- ProfileEditorPlugin *newConfigPlugin ( const QString&, QWidget*, Profile* );
+ ProfileDialogWidget *newConnectionPlugin ( const QString&, QWidget* );
+ ProfileDialogWidget* newTerminalPlugin( const QString&, QWidget* );
+
+ /*
+ * 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;
- QString name( const QString& );
private:
- QMap<QString, configWidget> m_confFact;
+ 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, QString> m_namemap;
};
diff --git a/noncore/apps/opie-console/opie-console.pro b/noncore/apps/opie-console/opie-console.pro
index 768e453..984072a 100644
--- a/noncore/apps/opie-console/opie-console.pro
+++ b/noncore/apps/opie-console/opie-console.pro
@@ -15,4 +15,2 @@ HEADERS = io_layer.h io_serial.h \
configdialog.h \
- profileeditordialog.h \
- profileeditorplugins.h \
emulation_layer.h \
@@ -25,3 +23,6 @@ HEADERS = io_layer.h io_serial.h \
widget_layer.h \
- transferdialog.h
+ transferdialog.h \
+ profiledialogwidget.h \
+ profileeditordialog.h \
+ default.h
@@ -29,3 +30,3 @@ SOURCES = io_layer.cpp io_serial.cpp \
file_layer.cpp sz_transfer.cpp \
- main.cpp \
+ main.cpp \
metafactory.cpp \
@@ -38,4 +39,2 @@ SOURCES = io_layer.cpp io_serial.cpp \
configdialog.cpp \
- profileeditordialog.cpp \
- profileeditorplugins.cpp \
emulation_layer.cpp \
@@ -47,3 +46,6 @@ SOURCES = io_layer.cpp io_serial.cpp \
widget_layer.cpp \
- transferdialog.cpp
+ transferdialog.cpp \
+ profiledialogwidget.cpp \
+ profileeditordialog.cpp \
+ default.cpp
diff --git a/noncore/apps/opie-console/profile.cpp b/noncore/apps/opie-console/profile.cpp
index c8f5eb0..1a94619 100644
--- a/noncore/apps/opie-console/profile.cpp
+++ b/noncore/apps/opie-console/profile.cpp
@@ -6,3 +6,4 @@ Profile::Profile() {
Profile::Profile( const QString& name,
- const QString& iolayerName,
+ const QCString& iolayerName,
+ const QCString& termName,
int background,
@@ -10,6 +11,5 @@ Profile::Profile( const QString& name,
int terminal )
- : m_name( name ), m_ioLayer( iolayerName ), m_back( background ),
- m_fore( foreground ), m_terminal( terminal )
-{
-}
+ : m_name( name ), m_ioLayer( iolayerName ), m_term( termName),
+ m_back( background ), m_fore( foreground ), m_terminal( terminal )
+{}
Profile::Profile( const Profile& prof )
@@ -30,2 +30,3 @@ Profile &Profile::operator=( const Profile& prof ) {
m_conf = prof.m_conf;
+ m_term = prof.m_term;
@@ -41,5 +42,8 @@ QString Profile::name()const {
}
-QString Profile::ioLayerName()const {
+QCString Profile::ioLayerName()const {
return m_ioLayer;
}
+QCString Profile::terminalName( )const {
+ return m_term;
+}
int Profile::foreground()const {
@@ -56,5 +60,8 @@ void Profile::setName( const QString& str ) {
}
-void Profile::setIOLayer( const QString& name ) {
+void Profile::setIOLayer( const QCString& name ) {
m_ioLayer = name;
}
+void Profile::setTerminalName( const QCString& str ) {
+ m_term = str;
+}
void Profile::setBackground( int back ) {
diff --git a/noncore/apps/opie-console/profile.h b/noncore/apps/opie-console/profile.h
index 5652ac5..78fe6ab 100644
--- a/noncore/apps/opie-console/profile.h
+++ b/noncore/apps/opie-console/profile.h
@@ -24,3 +24,4 @@ public:
Profile( const QString& name,
- const QString& iolayerName,
+ const QCString& iolayerName,
+ const QCString& termName,
int background,
@@ -34,3 +35,4 @@ public:
QString name()const;
- QString ioLayerName()const;
+ QCString ioLayerName()const;
+ QCString terminalName()const;
int foreground()const;
@@ -53,3 +55,4 @@ public:
void setName( const QString& );
- void setIOLayer( const QString& );
+ void setIOLayer( const QCString& );
+ void setTerminalName( const QCString& );
void setBackground( int back );
@@ -61,3 +64,3 @@ private:
QString m_name;
- QString m_ioLayer;
+ QCString m_ioLayer, m_term;
int m_back;
diff --git a/noncore/apps/opie-console/profiledialogwidget.cpp b/noncore/apps/opie-console/profiledialogwidget.cpp
new file mode 100644
index 0000000..24d59bf
--- a/dev/null
+++ b/noncore/apps/opie-console/profiledialogwidget.cpp
@@ -0,0 +1,32 @@
+#include "profiledialogwidget.h"
+
+ProfileDialogWidget::ProfileDialogWidget( const QString&, QWidget* parent,
+ const char* name )
+ : QWidget( parent, name ) {
+}
+ProfileDialogWidget::~ProfileDialogWidget() {
+}
+
+ProfileDialogTerminalWidget::ProfileDialogTerminalWidget( const QString& na,
+ QWidget* parent,
+ const char* name )
+ : ProfileDialogWidget( na, parent, name )
+{
+}
+ProfileDialogTerminalWidget::~ProfileDialogTerminalWidget() {
+}
+ProfileDialogWidget::Type ProfileDialogTerminalWidget::type()const {
+ return Terminal;
+}
+
+ProfileDialogConnectionWidget::ProfileDialogConnectionWidget( const QString& na,
+ QWidget* parent,
+ const char* name )
+ : ProfileDialogWidget(na, parent, name )
+{
+}
+ProfileDialogConnectionWidget::~ProfileDialogConnectionWidget() {
+}
+ProfileDialogWidget::Type ProfileDialogConnectionWidget::type()const {
+ return Connection;
+}
diff --git a/noncore/apps/opie-console/profiledialogwidget.h b/noncore/apps/opie-console/profiledialogwidget.h
new file mode 100644
index 0000000..5d279e6
--- a/dev/null
+++ b/noncore/apps/opie-console/profiledialogwidget.h
@@ -0,0 +1,50 @@
+#ifndef OPIE_PROFILE_DIALOG_WIDGET_H
+#define OPIE_PROFILE_DIALOG_WIDGET_H
+
+#include <qwidget.h>
+
+#include "profile.h"
+
+class ProfileDialogWidget : public QWidget {
+ Q_OBJECT
+public:
+ enum Type {
+ Connection,
+ Terminal
+ };
+ ProfileDialogWidget( const QString& name, QWidget* parent, const char* name = 0l);
+ ~ProfileDialogWidget();
+
+ /*
+ * load data from a Profile into
+ * the DialogWidget
+ */
+ virtual void load( const Profile& ) = 0;
+
+ /*
+ * save data into a profile
+ * from the DialogWidget
+ */
+ virtual void save( Profile& ) = 0;
+
+ virtual Type type()const = 0;
+};
+class ProfileDialogTerminalWidget : public ProfileDialogWidget {
+ Q_OBJECT
+public:
+ ProfileDialogTerminalWidget( const QString& name, QWidget* widget,
+ const char* name =0l);
+ ~ProfileDialogTerminalWidget();
+ Type type()const;
+};
+class ProfileDialogConnectionWidget : public ProfileDialogWidget {
+ Q_OBJECT
+public:
+ ProfileDialogConnectionWidget( const QString& name, QWidget* parent,
+ const char* name =0l);
+ ~ProfileDialogConnectionWidget();
+ Type type() const;
+
+};
+
+#endif
diff --git a/noncore/apps/opie-console/profileeditordialog.cpp b/noncore/apps/opie-console/profileeditordialog.cpp
index 3843943..061b1c2 100644
--- a/noncore/apps/opie-console/profileeditordialog.cpp
+++ b/noncore/apps/opie-console/profileeditordialog.cpp
@@ -1,11 +1,10 @@
+#include <qlayout.h>
+#include <qlineedit.h>
+#include <qlabel.h>
+#include <qmessagebox.h>
+#include <qstringlist.h>
+#include <qcombobox.h>
-#include <opie/otabwidget.h>
-#include "profileeditordialog.h"
-#include "qlayout.h"
-#include "qlineedit.h"
-#include "qlabel.h"
-#include "qmessagebox.h"
-#include "qstringlist.h"
-#include "qcombobox.h"
+#include <opie/otabwidget.h>
@@ -13,2 +12,15 @@
#include "metafactory.h"
+#include "profileeditordialog.h"
+
+namespace {
+ void setCurrent( const QString& str, QComboBox* bo ) {
+ for (uint i = 0; i < bo->count(); i++ ) {
+ if ( bo->text(i) == str ) {
+ bo->setCurrentItem( i );
+ }
+ }
+ }
+
+
+}
@@ -29,3 +41,3 @@ ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact )
// Default profile
- m_prof = Profile(QString::null, "serial", Profile::Black, Profile::White, Profile::VT102);
+ m_prof = Profile("New Profile", "serial", "default", Profile::Black, Profile::White, Profile::VT102);
@@ -44,2 +56,3 @@ void ProfileEditorDialog::initUI()
{
+ m_con = m_term = 0l;
@@ -49,86 +62,67 @@ void ProfileEditorDialog::initUI()
- QWidget *tabterm, *tabconn, *tabprof;
-
- tabprof = new QWidget(this);
- tabterm = new QWidget(this);
- tabconn = new QWidget(this);
-
- // for the time being: fake factory
-
- m_fact->addConfigWidgetFactory("serial", QObject::tr("Serial cable"), factory_serial);
- m_fact->addConfigWidgetFactory("irda", QObject::tr("IrDA port"), factory_irda);
- m_fact->addConfigWidgetFactory("modem", QObject::tr("Serial via modem"), factory_modem);
-
- // profile tab
-
- QLabel *name = new QLabel(QObject::tr("Profile name"), tabprof);
-
- name_line = new QLineEdit(tabprof);
-
- // connection tab, fixed part
-
- QLabel *device = new QLabel(QObject::tr("Device"), tabconn);
-
- device_box = new QComboBox(tabconn);
-
- QStringList w = m_fact->configWidgets();
- for(QStringList::Iterator it = w.begin(); it != w.end(); it++)
- device_box->insertItem(m_fact->name((*it)));
-
- // connection tab, factory part
- plugin_base = new QWidget(tabconn);
- plugin_layout = new QHBoxLayout(plugin_base, 0);
-
- plugin_plugin = m_fact->newConfigPlugin("serial", plugin_base, &m_prof);
- plugin_layout->add(plugin_plugin->widget());
-
- // connection tab, general part
+ QWidget *tabprof;
+
+ /* base tabs */
+ tabprof = new QWidget(this);
+ m_tabTerm = new QWidget(this);
+ m_tabCon = new QWidget(this);
+
+ /* base layout for tabs */
+ m_layCon = new QHBoxLayout( m_tabCon , 2 );
+ m_layTerm = new QHBoxLayout( m_tabTerm, 2 );
+
+ // profile tab
+
+ QLabel *name = new QLabel(QObject::tr("Profile name"), tabprof);
+ m_name = new QLineEdit(tabprof);
+ QLabel *con = new QLabel(tr("Connection"), tabprof );
+ QLabel *term = new QLabel(tr("Terminal"), tabprof );
+ m_conCmb = new QComboBox( tabprof );
+ m_termCmb = new QComboBox( tabprof );
+
+ // layouting
+ QVBoxLayout *vbox3 = new QVBoxLayout(tabprof, 2);
+ vbox3->add(name);
+ vbox3->add(m_name);
+ vbox3->add(con );
+ vbox3->add(m_conCmb );
+ vbox3->add(term );
+ vbox3->add(m_termCmb );
+ vbox3->addStretch(1);
+
+ tabWidget->addTab(tabprof, "", QObject::tr("Profile"));
+ tabWidget->addTab(m_tabCon, "", QObject::tr("Connection"));
+ tabWidget->addTab(m_tabTerm, "", QObject::tr("Terminal"));
+ tabWidget->setCurrentTab( tabprof );
+
+
+ // fill the comboboxes
+ QStringList list = m_fact->connectionWidgets();
+ QStringList::Iterator it;
+ for (it =list.begin(); it != list.end(); ++it ) {
+ m_conCmb->insertItem( (*it) );
+ }
+ list = m_fact->terminalWidgets();
+ for (it =list.begin(); it != list.end(); ++it ) {
+ m_termCmb->insertItem( (*it) );
+ }
+
+ // load profile values
+ m_name->setText(m_prof.name());
+ slotConActivated( m_fact->external(m_prof.ioLayerName() ) );
+ slotTermActivated( m_fact->external(m_prof.terminalName() ) );
+ setCurrent( m_fact->external(m_prof.ioLayerName() ), m_conCmb );
+ setCurrent( m_fact->external(m_prof.terminalName() ), m_termCmb );
+
+ qWarning("Layer: %s %s", m_prof.ioLayerName().data(),
+ m_fact->external(m_prof.ioLayerName() ).latin1() );
+ qWarning("Term: %s %s", m_prof.terminalName().data(),
+ m_fact->external(m_prof.terminalName() ).latin1() );
+
+ // signal and slots
+ connect(m_conCmb, SIGNAL(activated(const QString& ) ),
+ this, SLOT(slotConActivated(const QString&) ) );
+ connect(m_termCmb, SIGNAL(activated(const QString& ) ),
+ this, SLOT(slotTermActivated(const QString& ) ) );
- QWidget *conn_widget = plugin_plugin->connection_widget();
- conn_widget->reparent(tabconn, 0, QPoint(), true);
-
- // terminal tab
-
- QWidget *term_widget = plugin_plugin->terminal_widget();
- term_widget->reparent(tabterm, 0, QPoint(), true);
-
- // layouting
-
- QVBoxLayout *vbox3 = new QVBoxLayout(tabprof, 2);
- vbox3->add(name);
- vbox3->add(name_line);
- vbox3->addStretch(1);
-
- QVBoxLayout *vbox = new QVBoxLayout(tabconn, 2);
- vbox->add(device);
- vbox->add(device_box);
- vbox->add(plugin_base);
- vbox->add(conn_widget);
- vbox->setStretchFactor(device, 1);
- vbox->setStretchFactor(device_box, 1);
- vbox->setStretchFactor(plugin_base, 1);
- vbox->setStretchFactor(conn_widget, 7);
-
- QVBoxLayout *vbox2 = new QVBoxLayout(tabterm, 2);
- vbox2->add(term_widget);
-
- tabWidget->addTab(tabprof, "", QObject::tr("Profile"));
- tabWidget->addTab(tabconn, "", QObject::tr("Connection"));
- tabWidget->addTab(tabterm, "", QObject::tr("Terminal"));
- tabWidget->setCurrentTab( tabprof );
-
- // load profile values
- name_line->setText(m_prof.name());
- for(int i = 0; i < device_box->count(); i++)
- {
- device_box->setCurrentItem(i);
- if(prof_type() == m_prof.ioLayerName())
- {
- slotDevice(i);
- break;
- }
- }
-
- // signals
- connect(device_box, SIGNAL(activated(int)), SLOT(slotDevice(int)));
}
@@ -138,21 +132,5 @@ ProfileEditorDialog::~ProfileEditorDialog() {
}
-
-void ProfileEditorDialog::slotDevice(int id)
-{
- delete plugin_plugin;
-
- plugin_plugin = m_fact->newConfigPlugin(prof_type(), plugin_base, &m_prof);
- plugin_layout->add(plugin_plugin->widget());
-
- // Reload profile associated to device, including e.g. conn_device()
- // m_prof = plugin_plugin->profile()
- // or, keeping the profile name: m_prof->reload(plugin_plugin->profile())
-
- //plugin_plugin->show();
- plugin_plugin->widget()->show();
-}
-
void ProfileEditorDialog::accept()
{
- if(prof_name().isEmpty())
+ if(profName().isEmpty())
{
@@ -164,7 +142,10 @@ void ProfileEditorDialog::accept()
// Save profile and plugin profile
- if(plugin_plugin) plugin_plugin->save();
+ //if(plugin_plugin) plugin_plugin->save();
// Save general values
- m_prof.setName(prof_name());
- m_prof.setIOLayer(prof_type());
+ m_prof.setName(profName());
+ m_prof.setIOLayer( m_fact->internal(m_conCmb ->currentText() ) );
+ m_prof.setTerminalName( m_fact->internal(m_termCmb->currentText() ) );
+ qWarning("Term %s %s", m_fact->internal(m_termCmb->currentText() ).data(),
+ m_termCmb->currentText().latin1() );
@@ -174,16 +155,36 @@ void ProfileEditorDialog::accept()
-QString ProfileEditorDialog::prof_name()
+QString ProfileEditorDialog::profName()const
{
- return name_line->text();
+ return m_name->text();
}
-QString ProfileEditorDialog::prof_type()
+QCString ProfileEditorDialog::profType()const
{
- QStringList w = m_fact->configWidgets();
+ /*QStringList w = m_fact->configWidgets();
for(QStringList::Iterator it = w.begin(); it != w.end(); it++)
if(device_box->currentText() == m_fact->name((*it))) return (*it);
-
- return QString::null;
+ */
+ return QCString();
+}
+/*
+ * we need to switch the widget
+ */
+void ProfileEditorDialog::slotConActivated( const QString& str ) {
+ delete m_con;
+ m_con = m_fact->newConnectionPlugin( str, m_tabCon );
+
+ if (m_con )
+ m_layCon->addWidget( m_con );
+}
+/*
+ * we need to switch the widget
+ */
+void ProfileEditorDialog::slotTermActivated( const QString& str ) {
+ delete m_term;
+ m_term = m_fact->newTerminalPlugin( str, 0l );
+ qWarning("past");
+
+ if (m_term)
+ m_layTerm->addWidget( m_term );
}
-
diff --git a/noncore/apps/opie-console/profileeditordialog.h b/noncore/apps/opie-console/profileeditordialog.h
index 8e830f1..3b67bb3 100644
--- a/noncore/apps/opie-console/profileeditordialog.h
+++ b/noncore/apps/opie-console/profileeditordialog.h
@@ -14,3 +14,3 @@ class QComboBox;
class QLabel;
-class ProfileEditorPlugin;
+class ProfileDialogWidget;
@@ -22,7 +22,6 @@ public:
ProfileEditorDialog(MetaFactory* fact );
- ~ProfileEditorDialog();
+ ~ProfileEditorDialog();
Profile profile()const;
- QString prof_name();
- QString prof_type();
+
@@ -30,10 +29,12 @@ public slots:
void accept();
- void slotDevice(int id);
+private slots:
+ void slotConActivated(const QString& );
+ void slotTermActivated( const QString& );
private:
void initUI();
+ QString profName()const;
+ QCString profType()const;
MetaFactory* m_fact;
- EditBase* m_base;
- QTabWidget* m_tab;
QHBoxLayout* m_lay;
@@ -41,8 +42,8 @@ private:
- QLineEdit *name_line;
- QComboBox *device_box;
+ QLineEdit *m_name;
+ QComboBox *m_conCmb, *m_termCmb;
- QWidget *plugin_base;
- ProfileEditorPlugin *plugin_plugin;
- QHBoxLayout *plugin_layout;
+ QWidget *m_tabCon, *m_tabTerm;
+ ProfileDialogWidget* m_con, *m_term;
+ QHBoxLayout *m_layCon, *m_layTerm;
};
diff --git a/noncore/apps/opie-console/profileeditorplugins.h b/noncore/apps/opie-console/profileeditorplugins.h
index 591163a..4ca780e 100644
--- a/noncore/apps/opie-console/profileeditorplugins.h
+++ b/noncore/apps/opie-console/profileeditorplugins.h
@@ -5,3 +5,3 @@
-#include "qobject.h"
+#include <qobject.h>
@@ -11,72 +11,72 @@ class ProfileEditorPlugin : public QObject
{
- Q_OBJECT
- public:
- ProfileEditorPlugin(QWidget *parent, Profile *p);
-
- virtual ~ProfileEditorPlugin();
-
- virtual void save() = 0;
-
- virtual QWidget *widget() = 0;
-
- QWidget *connection_widget();
- QWidget *terminal_widget();
-
- public slots:
- void slotConnFlow(int id);
- void slotConnParity(int id);
- void slotConnSpeed(int id);
- void slotTermTerm(int id);
- void slotTermColour(int id);
- void slotTermFont(int id);
- void slotTermEcho(bool on);
- void slotTermWrap(bool on);
- void slotTermInbound(bool on);
- void slotTermOutbound(bool on);
-
- protected:
- QWidget *m_parent, *m_widget;
- Profile *m_profile;
-
- private:
- enum ParityIds
- {
- id_parity_odd,
- id_parity_even
- };
-
- enum FlowIds
- {
- id_flow_hw,
- id_flow_sw
- };
-
- enum SpeedIds
- {
- id_baud_115200,
- id_baud_57600,
- id_baud_38400,
- id_baud_19200,
- id_baud_9600
- };
-
- enum TermIds
- {
- id_term_vt100,
- id_term_vt220,
- id_term_ansi
- };
-
- enum ColourIds
- {
- id_term_black,
- id_term_white
- };
-
- enum FontIds
- {
- id_size_small,
- id_size_medium,
- id_size_large
- };
+ Q_OBJECT
+public:
+ ProfileEditorPlugin(QWidget *parent);
+
+ virtual ~ProfileEditorPlugin();
+
+ virtual void save() = 0;
+
+ virtual QWidget *widget() = 0;
+
+ QWidget *connection_widget();
+ QWidget *terminal_widget();
+
+public slots:
+ void slotConnFlow(int id);
+ void slotConnParity(int id);
+ void slotConnSpeed(int id);
+ void slotTermTerm(int id);
+ void slotTermColour(int id);
+ void slotTermFont(int id);
+ void slotTermEcho(bool on);
+ void slotTermWrap(bool on);
+ void slotTermInbound(bool on);
+ void slotTermOutbound(bool on);
+
+protected:
+ QWidget *m_parent, *m_widget;
+ Profile *m_profile;
+
+private:
+ enum ParityIds
+ {
+ id_parity_odd,
+ id_parity_even
+ };
+
+ enum FlowIds
+ {
+ id_flow_hw,
+ id_flow_sw
+ };
+
+ enum SpeedIds
+ {
+ id_baud_115200,
+ id_baud_57600,
+ id_baud_38400,
+ id_baud_19200,
+ id_baud_9600
+ };
+
+ enum TermIds
+ {
+ id_term_vt100,
+ id_term_vt220,
+ id_term_ansi
+ };
+
+ enum ColourIds
+ {
+ id_term_black,
+ id_term_white
+ };
+
+ enum FontIds
+ {
+ id_size_small,
+ id_size_medium,
+ id_size_large
+ };
};
diff --git a/noncore/apps/opie-console/profilemanager.cpp b/noncore/apps/opie-console/profilemanager.cpp
index 72a5117..6ad08b5 100644
--- a/noncore/apps/opie-console/profilemanager.cpp
+++ b/noncore/apps/opie-console/profilemanager.cpp
@@ -30,3 +30,4 @@ void ProfileManager::load() {
prof.setName( conf.readEntry("name") );
- prof.setIOLayer( conf.readEntry("iolayer") );
+ prof.setIOLayer( conf.readEntry("iolayer").utf8() );
+ prof.setTerminalName( conf.readEntry("term").utf8() );
prof.setBackground( conf.readNumEntry("back") );
@@ -67,3 +68,4 @@ void ProfileManager::save( ) {
conf.writeEntry( "name", (*it).name() );
- conf.writeEntry( "ioplayer", (*it).ioLayerName() );
+ conf.writeEntry( "ioplayer", QString::fromUtf8( (*it).ioLayerName() ) );
+ conf.writeEntry( "term", QString::fromUtf8( (*it).terminalName() ) );
conf.writeEntry( "back", (*it).background() );
diff --git a/noncore/apps/opie-console/sz_transfer.cpp b/noncore/apps/opie-console/sz_transfer.cpp
index de321ae..10f3f7a 100644
--- a/noncore/apps/opie-console/sz_transfer.cpp
+++ b/noncore/apps/opie-console/sz_transfer.cpp
@@ -5,3 +5,3 @@
-SzTransfer::SzTransfer(IOLayer *layer) : FileTransferLayer(layer)
+SzTransfer::SzTransfer(Type t, IOLayer *layer) : FileTransferLayer(layer), m_t(t)
{
diff --git a/noncore/apps/opie-console/sz_transfer.h b/noncore/apps/opie-console/sz_transfer.h
index 778d1d3..825680d 100644
--- a/noncore/apps/opie-console/sz_transfer.h
+++ b/noncore/apps/opie-console/sz_transfer.h
@@ -11,4 +11,9 @@ class SzTransfer : public FileTransferLayer {
public:
+ enum Type {
+ SZ=0,
+ SX,
+ SY
+ };
- SzTransfer( IOLayer * );
+ SzTransfer( Type t, IOLayer * );
~SzTransfer();
@@ -19,4 +24,4 @@ public slots:
*/
- void sendFile( const QString& file ) = 0;
- void sendFile( const QFile& ) = 0;
+ void sendFile( const QString& file ) ;
+ void sendFile( const QFile& );
@@ -29,2 +34,3 @@ private:
OProcess *proc;
+ Type m_t;