summaryrefslogtreecommitdiff
path: root/libopie2
Side-by-side diff
Diffstat (limited to 'libopie2') (more/less context) (show whitespace changes)
-rw-r--r--libopie2/examples/opieui/opieui.pro4
-rw-r--r--libopie2/examples/opieui/osplitter_example/.cvsignore6
-rw-r--r--libopie2/examples/opieui/osplitter_example/osplitter_example.cpp32
-rw-r--r--libopie2/examples/opieui/osplitter_example/osplitter_example.h20
-rw-r--r--libopie2/examples/opieui/osplitter_example/osplitter_example.pro13
-rw-r--r--libopie2/examples/opieui/osplitter_example/osplitter_mail.cpp82
-rw-r--r--libopie2/examples/opieui/osplitter_example/osplitter_mail.h49
-rw-r--r--libopie2/examples/opieui/osplitter_example/osplitter_mail.pro12
-rw-r--r--libopie2/examples/opieui/owidgetstack_example/.cvsignore6
-rw-r--r--libopie2/examples/opieui/owidgetstack_example/owidgetstack_example.cpp132
-rw-r--r--libopie2/examples/opieui/owidgetstack_example/owidgetstack_example.h28
-rw-r--r--libopie2/examples/opieui/owidgetstack_example/owidgetstack_example.pro13
-rw-r--r--libopie2/opiecore/oapplicationfactory.h293
13 files changed, 689 insertions, 1 deletions
diff --git a/libopie2/examples/opieui/opieui.pro b/libopie2/examples/opieui/opieui.pro
index ad66f47..853ac50 100644
--- a/libopie2/examples/opieui/opieui.pro
+++ b/libopie2/examples/opieui/opieui.pro
@@ -1,3 +1,5 @@
TEMPLATE = subdirs
-SUBDIRS = olistviewdemo
+SUBDIRS = olistviewdemo owidgetstack_example osplitter_example
+
+
diff --git a/libopie2/examples/opieui/osplitter_example/.cvsignore b/libopie2/examples/opieui/osplitter_example/.cvsignore
new file mode 100644
index 0000000..8f7300c
--- a/dev/null
+++ b/libopie2/examples/opieui/osplitter_example/.cvsignore
@@ -0,0 +1,6 @@
+Makefile*
+moc*
+*moc
+*.o
+~*
+
diff --git a/libopie2/examples/opieui/osplitter_example/osplitter_example.cpp b/libopie2/examples/opieui/osplitter_example/osplitter_example.cpp
new file mode 100644
index 0000000..7ba0f0d
--- a/dev/null
+++ b/libopie2/examples/opieui/osplitter_example/osplitter_example.cpp
@@ -0,0 +1,32 @@
+#include "osplitter_example.h"
+
+/* OPIE */
+
+#include <opie2/osplitter.h>
+#include <qpe/qpeapplication.h>
+#include <opie2/oapplicationfactory.h>
+
+/* QT*/
+#include <qdir.h>
+#include <qlayout.h>
+
+using namespace Opie;
+
+OPIE_EXPORT_APP( OApplicationFactory<OSplitterExample> )
+
+OSplitterExample::OSplitterExample( QWidget *w,const char* n,WFlags f )
+ : QWidget( w, n, f ){
+ QVBoxLayout * lay = new QVBoxLayout(this);
+ OSplitter * splitter = new OSplitter( Horizontal, this );
+ lay->addWidget( splitter );
+
+ OFileSelector *selector = new OFileSelector( splitter, OFileSelector::FileSelector,
+ OFileSelector::Normal, QDir::homeDirPath(),
+ QString::null );
+ splitter->addWidget( selector, "zoom", tr("Selector 1") );
+
+ selector = new OFileSelector( splitter, OFileSelector::FileSelector, OFileSelector::Normal,
+ QDir::homeDirPath(), QString::null );
+ splitter->addWidget( selector, "zoom", tr("Selector 2") );
+
+}
diff --git a/libopie2/examples/opieui/osplitter_example/osplitter_example.h b/libopie2/examples/opieui/osplitter_example/osplitter_example.h
new file mode 100644
index 0000000..176ad62
--- a/dev/null
+++ b/libopie2/examples/opieui/osplitter_example/osplitter_example.h
@@ -0,0 +1,20 @@
+/*
+ * May be used, copied and modified wihtout any limitation
+ */
+
+#ifndef OSPlitter_EXAMPLE_H
+#define OSPlitter_EXAMPLE_H
+
+#include <qvbox.h>
+#include <opie2/ofileselector.h>
+
+class OSplitterExample : public QWidget {
+ Q_OBJECT
+public:
+ static QString appName() { return QString::fromLatin1("osplitter_example"); }
+ OSplitterExample( QWidget *parent, const char* name, WFlags fl );
+
+};
+
+
+#endif
diff --git a/libopie2/examples/opieui/osplitter_example/osplitter_example.pro b/libopie2/examples/opieui/osplitter_example/osplitter_example.pro
new file mode 100644
index 0000000..224a1ee
--- a/dev/null
+++ b/libopie2/examples/opieui/osplitter_example/osplitter_example.pro
@@ -0,0 +1,13 @@
+CONFIG = qt warn_on
+TEMPLATE = app
+TARGET = osplitter_example
+
+HEADERS = osplitter_example.h
+SOURCES = osplitter_example.cpp
+
+INCLUDEPATH += $(OPIEDIR)/include
+DEPENDSPATH += $(OPIEDIR)/include
+
+LIBS += -lqpe -lopieui2
+
+include ( $(OPIEDIR)/include.pro )
diff --git a/libopie2/examples/opieui/osplitter_example/osplitter_mail.cpp b/libopie2/examples/opieui/osplitter_example/osplitter_mail.cpp
new file mode 100644
index 0000000..4eaf3a9
--- a/dev/null
+++ b/libopie2/examples/opieui/osplitter_example/osplitter_mail.cpp
@@ -0,0 +1,82 @@
+
+#include <qstring.h>
+#include <qlabel.h>
+#include <qheader.h>
+#include <qlayout.h>
+
+#include <qpe/qpeapplication.h>
+#include <opie/oapplicationfactory.h>
+
+#include "../osplitter.h"
+
+#include "osplitter_mail.h"
+
+
+OPIE_EXPORT_APP( OApplicationFactory<ListViews> )
+
+class Folder {
+ int dummy;
+};
+
+// -----------------------------------------------------------------
+
+ListViews::ListViews( QWidget* p, const char* name, WFlags fl )
+ : QWidget( p, name, fl ) {
+ qApp->installEventFilter( this );
+ m_lstFolders.setAutoDelete( true );
+ QHBoxLayout *lay = new QHBoxLayout(this);
+
+ m_splitter = new OSplitter( Horizontal, this, "SPlitter 1" );
+ lay->addWidget( m_splitter );
+ connect(m_splitter, SIGNAL(sizeChange(bool, const QSize& ) ),
+ this, SLOT(slotSizeChange(bool, const QSize& ) ) );
+
+ m_overview = new QListView( m_splitter );
+ m_overview->header()->setClickEnabled( FALSE );
+ m_overview->addColumn( tr("Folder") );
+ m_overview->setMaximumWidth( 200 );
+ m_splitter->addWidget( m_overview, "zoom", tr("Folder Overview") );
+ m_splitter->setSizeChange( 300 );
+
+ /* OSplitter starts with the small mode */
+ m_messages = 0;
+ m_message = m_attach = 0;
+
+ splitti = new OSplitter( Vertical, m_splitter, "Splitti2" );
+ splitti->setSizeChange( 300 );
+ splitti->setSizePolicy( QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding ) );
+
+ QLabel *lbl = new QLabel(splitti);
+ lbl->setTextFormat ( Qt::RichText );
+ lbl->setText("<br><br><b>Test Test Test</b><br><br><p>Fooooo hjhh</p>");
+
+ m_messages = new QListView( splitti );
+ m_messages->addColumn(" Messages ");
+
+ folder1 = new QListView( splitti );
+ folder1->addColumn( "Messages 2 " );
+
+ splitti->addWidget(m_messages, "mail", tr("Mails") );
+ splitti->addWidget(folder1, "folder", tr("Folder") );
+ splitti->addWidget( lbl, "logo", tr("Label") );
+ m_message = lbl;
+
+ m_splitter->addWidget( splitti );
+
+}
+
+
+ListViews::~ListViews() {
+
+}
+
+
+bool ListViews::eventFilter( QObject* obj, QEvent* ev ) {
+ if (!obj->isWidgetType() )
+ return false;
+ if ( ev->type() == QEvent::MouseButtonRelease ) {
+ qWarning(" name %s, class %s", obj->name(), obj->className() );
+ }
+
+ return false;
+}
diff --git a/libopie2/examples/opieui/osplitter_example/osplitter_mail.h b/libopie2/examples/opieui/osplitter_example/osplitter_mail.h
new file mode 100644
index 0000000..b7e7efe
--- a/dev/null
+++ b/libopie2/examples/opieui/osplitter_example/osplitter_mail.h
@@ -0,0 +1,49 @@
+/*
+ * You may use, modify and distribute this code without any limitation
+ */
+
+/*
+ * Header file for a more complete email client like
+ * layout
+ */
+
+#ifndef OPIE_SPLITTER_MAIL_EXAMPLE_H
+#define OPIE_SPLITTER_MAIL_EXAMPLE_H
+
+#include <qwidget.h>
+#include <qlist.h>
+#include <qlistview.h>
+
+class Folder;
+class QLabel;
+
+class OSplitter;
+class ListViews : public QWidget {
+ Q_OBJECT
+public:
+ static QString appName() { return QString::fromLatin1("osplitter-mail"); }
+ ListViews( QWidget* parent, const char * name, WFlags fl );
+ ~ListViews();
+
+ bool eventFilter( QObject* , QEvent* );
+private:
+ void initFolders();
+ void initFolder( Folder *folder, unsigned int &count );
+
+ QListView *m_messages, *m_overview;
+ QLabel *m_message, *m_attach;
+ QList<QListView> m_folders; // used in tab mode
+ QList<Folder> m_lstFolders;
+ bool m_mode : 1; // bitfield
+ OSplitter *m_splitter;
+ OSplitter *splitti;
+ QListView *folder1;
+#if 0
+//private slots:
+// void slotFolderChanged( QListViewItem* );
+// void slotMessageChanged();
+// void slotSizeChange( bool, const QSize& );
+#endif
+};
+
+#endif
diff --git a/libopie2/examples/opieui/osplitter_example/osplitter_mail.pro b/libopie2/examples/opieui/osplitter_example/osplitter_mail.pro
new file mode 100644
index 0000000..ec6e626
--- a/dev/null
+++ b/libopie2/examples/opieui/osplitter_example/osplitter_mail.pro
@@ -0,0 +1,12 @@
+CONFIG += qt warn_on
+TEMPLATE = app
+TARGET = osplitter-mail
+
+INCLUDEPATH += $(OPIEDIR)/include
+DEPENDSPATH += $(OPIEDIR)/include
+
+HEADERS = osplitter_mail.h
+SOURCES = osplitter_mail.cpp
+
+LIBS += -lqpe -lopie
+include ( $(OPIEDIR)/include.pro )
diff --git a/libopie2/examples/opieui/owidgetstack_example/.cvsignore b/libopie2/examples/opieui/owidgetstack_example/.cvsignore
new file mode 100644
index 0000000..8f7300c
--- a/dev/null
+++ b/libopie2/examples/opieui/owidgetstack_example/.cvsignore
@@ -0,0 +1,6 @@
+Makefile*
+moc*
+*moc
+*.o
+~*
+
diff --git a/libopie2/examples/opieui/owidgetstack_example/owidgetstack_example.cpp b/libopie2/examples/opieui/owidgetstack_example/owidgetstack_example.cpp
new file mode 100644
index 0000000..b1c5e70
--- a/dev/null
+++ b/libopie2/examples/opieui/owidgetstack_example/owidgetstack_example.cpp
@@ -0,0 +1,132 @@
+/*
+ * You may use, modify and distribute this example without any limitation
+ */
+
+#include "owidgetstack_example.h"
+
+/* OPIE */
+#include <opie2/oapplicationfactory.h>
+#include <opie2/owidgetstack.h>
+#include <qpe/resource.h>
+
+/* QT */
+#include <qaction.h>
+#include <qtoolbar.h>
+#include <qpopupmenu.h>
+#include <qmenubar.h>
+#include <qlayout.h>
+#include <qlabel.h>
+#include <qpushbutton.h>
+#include <qsignalmapper.h>
+
+using namespace Opie;
+
+OPIE_EXPORT_APP( OApplicationFactory<StackExample> )
+
+StackExample::StackExample( QWidget* parent, const char* name, WFlags fl )
+ : QMainWindow( parent, name, fl )
+{
+ m_stack = new OWidgetStack( this );
+ setCentralWidget( m_stack );
+
+ /* nice Signal Mapper ;) */
+ QSignalMapper *sm = new QSignalMapper(this);
+ connect(sm, SIGNAL(mapped(int) ), m_stack, SLOT(raiseWidget(int)) );
+
+ /* toolbar first but this should be known from the other examples */
+ setToolBarsMovable( false );
+
+ /* only a menubar here */
+ QToolBar* holder = new QToolBar( this );
+ holder->setHorizontalStretchable( true );
+
+ QMenuBar *bar = new QMenuBar( holder );
+ QPopupMenu *menu = new QPopupMenu( this );
+
+ QAction* a = new QAction( tr("Show MainWidget"), Resource::loadPixmap("zoom"),
+ QString::null, 0, this, 0 );
+ sm->setMapping(a, 1 );
+ connect(a, SIGNAL(activated() ),
+ sm, SLOT(map() ) );
+ a->addTo( menu );
+
+ a = new QAction( tr("Show Details Small"), Resource::loadPixmap("zoom"),
+ QString::null, 0, this, 0 );
+ sm->setMapping(a, 2 );
+ connect(a, SIGNAL(activated() ),
+ sm, SLOT(map() ) );
+ a->addTo( menu );
+
+ a = new QAction( tr("Show Details More"), Resource::loadPixmap("zoom"),
+ QString::null, 0, this, 0 );
+ sm->setMapping(a, 3 );
+ connect(a, SIGNAL(activated() ),
+ sm, SLOT(map() ) );
+ a->addTo( menu );
+
+ a = new QAction( tr("Show Details All"), Resource::loadPixmap("zoom"),
+ QString::null, 0, this, 0 );
+ sm->setMapping(a, 4 );
+ connect(a, SIGNAL(activated() ),
+ sm, SLOT(map() ) );
+
+ bar->insertItem( tr("Actions"), menu );
+
+ /* now the gui */
+
+ /* first widget, main widget */
+ QWidget * wid = new QWidget( m_stack );
+ QGridLayout *grid = new QGridLayout(wid, 2, 2 );
+
+ QPushButton *btn = new QPushButton( tr("Show Details Small"), wid, "details1" );
+ sm->setMapping(btn, 2 );
+ connect(btn, SIGNAL(clicked()), sm, SLOT(map() ) );
+ grid->addWidget( btn, 0, 0 );
+
+ btn = new QPushButton( tr("Show Details Medium"), wid, "details2");
+ sm->setMapping(btn, 3 );
+ connect(btn, SIGNAL(clicked()), sm, SLOT(map() ) );
+ grid->addWidget( btn, 0, 1 );
+
+ btn = new QPushButton( tr("Show Details All"), wid, "details3");
+ sm->setMapping(btn, 4 );
+ connect(btn, SIGNAL(clicked()), sm, SLOT(map() ) );
+ grid->addWidget( btn, 1, 1 );
+
+ m_stack->addWidget( wid, 1 );
+ m_main = wid;
+
+ QLabel *lbl = new QLabel(m_stack );
+ lbl->setText(tr("Only small Details are shown here. Määh") );
+ m_stack->addWidget( lbl, 2 );
+
+ lbl = new QLabel( m_stack );
+ lbl->setText( tr("Some more details....Wo ist das Schaf?") );
+ m_stack->addWidget( lbl, 3 );
+
+ lbl = new QLabel( m_stack );
+ lbl->setText( tr("<qt>Ne nicht in Bayerisch Gmain sondern in Berlin<br>Vermiss und meine Augen werden nicht eckig, da mein Bildschirm abgerundet ist<br>Es lebe Hamburg Süd,weiss du, verstehst du? ;)<br>Susi ist dOOf, es lebe die Ofenecke...", "hard to translate that") );
+ m_stack->addWidget( lbl, 4 );
+
+
+ /* THE signal mapper does all the magic */
+ m_stack->raiseWidget( m_main );
+}
+
+
+StackExample::~StackExample() {
+
+}
+
+
+
+void StackExample::closeEvent( QCloseEvent* ev) {
+ /* if the close even came when we displayed a details */
+ if (m_stack->visibleWidget() != m_main ) {
+ m_stack->raiseWidget( m_main );
+ ev->ignore();
+ return;
+ }
+
+ ev->accept();
+}
diff --git a/libopie2/examples/opieui/owidgetstack_example/owidgetstack_example.h b/libopie2/examples/opieui/owidgetstack_example/owidgetstack_example.h
new file mode 100644
index 0000000..aea85cb
--- a/dev/null
+++ b/libopie2/examples/opieui/owidgetstack_example/owidgetstack_example.h
@@ -0,0 +1,28 @@
+/*
+ * You may use, modify and distribute this example without any limitation
+ */
+
+#ifndef O_STACK_EXAMPLE_SIMPLE_H
+#define O_STACK_EXAMPLE_SIMPLE_H
+
+#include <qmainwindow.h>
+#include <opie2/owidgetstack.h>
+
+using namespace Opie;
+
+class StackExample : public QMainWindow {
+ Q_OBJECT
+public:
+ StackExample( QWidget* paren, const char* name, WFlags fl );
+ ~StackExample();
+ static QString appName() { return QString::fromLatin1("owidgetstack-example"); }
+
+protected:
+ void closeEvent( QCloseEvent* e );
+private:
+ OWidgetStack* m_stack;
+ QWidget* m_main;
+
+};
+
+#endif
diff --git a/libopie2/examples/opieui/owidgetstack_example/owidgetstack_example.pro b/libopie2/examples/opieui/owidgetstack_example/owidgetstack_example.pro
new file mode 100644
index 0000000..395a4fb
--- a/dev/null
+++ b/libopie2/examples/opieui/owidgetstack_example/owidgetstack_example.pro
@@ -0,0 +1,13 @@
+CONFIG += qt warn_on
+TEMPLATE = app
+TARGET = owidgetstack-example
+
+SOURCES = owidgetstack_example.cpp
+HEADERS = owidgetstack_example.h
+
+INCLUDEPATH += $(OPIEDIR)/include
+DEPENDSPATH += $(OPIEDIR)/include
+
+LIBS += -lqpe -lopieui2
+
+include ( $(OPIEDIR)/include.pro )
diff --git a/libopie2/opiecore/oapplicationfactory.h b/libopie2/opiecore/oapplicationfactory.h
new file mode 100644
index 0000000..6e10552
--- a/dev/null
+++ b/libopie2/opiecore/oapplicationfactory.h
@@ -0,0 +1,293 @@
+/*
+                 This file is part of the Opie Project
+              Copyright (C) Holger Freyther <zecke@handhelds.org>
+ =.
+ .=l.
+           .>+-=
+ _;:,     .>    :=|. This program is free software; you can
+.> <`_,   >  .   <= redistribute it and/or modify it under
+:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
+.="- .-=="i,     .._ License as published by the Free Software
+ - .   .-<_>     .<> Foundation; either version 2 of the License,
+     ._= =}       : or (at your option) any later version.
+    .%`+i>       _;_.
+    .i_,=:_.      -<s. This program is distributed in the hope that
+     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
+    : ..    .:,     . . . without even the implied warranty of
+    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
+  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
+..}^=.=       =       ; Library General Public License for more
+++=   -.     .`     .: details.
+ :     =  ...= . :.=-
+ -.   .:....=;==+<; You should have received a copy of the GNU
+  -_. . .   )=.  = Library General Public License along with
+    --        :-=` this library; see the file COPYING.LIB.
+ If not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/*
+ This work is derived from:
+ ----
+ The Loki Library
+ Copyright (c) 2001 by Andrei Alexandrescu
+ This code accompanies the book:
+ Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
+ Patterns Applied". Copyright (c) 2001. Addison-Wesley.
+ Permission to use, copy, modify, distribute and sell this software for any
+ purpose is hereby granted without fee, provided that the above copyright
+ notice appear in all copies and that both that copyright notice and this
+ permission notice appear in supporting documentation.
+ The author or Addison-Welsey Longman make no representations about the
+ suitability of this software for any purpose. It is provided "as is"
+ without express or implied warranty.
+ ----
+
+ And KGenericFactor et all from Simon Hausmann <tronical@kde.org>
+
+*/
+
+#include <qstring.h>
+#include <qmetaobject.h>
+
+#include <qtopia/qcom.h>
+#include <qtopia/applicationinterface.h>
+
+namespace Opie {
+ struct NullType;
+
+ template <class T, class U>
+ struct Typelist
+ {
+ typedef T Head;
+ typedef U Tail;
+ };
+ template<
+ typename T1 = NullType, typename T2 = NullType, typename T3 = NullType,
+ typename T4 = NullType, typename T5 = NullType, typename T6 = NullType,
+ typename T7 = NullType, typename T8 = NullType, typename T9 = NullType,
+ typename T10 = NullType, typename T11 = NullType, typename T12 = NullType,
+ typename T13 = NullType, typename T14 = NullType, typename T15 = NullType,
+ typename T16 = NullType, typename T17 = NullType, typename T18 = NullType
+ >
+ struct MakeTypelist{
+ private:
+ typedef typename MakeTypelist
+ <
+ T2 , T3 , T4 ,
+ T5 , T6 , T7 ,
+ T8 , T9 , T10,
+ T11, T12, T13,
+ T14, T15, T16,
+ T17, T18
+ >
+ ::Result TailResult;
+
+public:
+ typedef Typelist<T1, TailResult> Result;
+};
+
+template<>
+struct MakeTypelist<>
+{
+ typedef NullType Result;
+};
+
+}
+
+/**
+ * To allow your application to be quick launched some one needs
+ * to create the QWidget.
+ * This is this factory. Make surce your widget has static QString Widget::appName()
+ * as one of its functions.
+ *
+ * This template takes one QWidget and initialized it in the form of
+ * MyWidget::MyWidget( QWidget* parent, const char* name, WFlags f );
+ *
+ * To use it on your app do that:
+ * typedef OApplicationFactory<MyWidget> MyFactory;
+ * OPIE_EXPORT_APP( MyFactory )
+ *
+ */
+template <class Product>
+struct OApplicationFactory : public ApplicationInterface {
+ QRESULT queryInterface( const QUuid &uuid, QUnknownInterface **iface ) {
+ *iface = 0;
+ if ( uuid == IID_QUnknown ) *iface = this;
+ else if ( uuid == IID_QtopiaApplication ) *iface = this;
+ else return QS_FALSE;
+ (*iface)->addRef();
+ return QS_OK;
+ }
+
+ /*
+ *
+ */
+ virtual QWidget *createMainWindow( const QString& appName, QWidget* parent,
+ const char* name, Qt::WFlags f ) {
+ if (appName == Product::appName() )
+ return new Product(parent, name, f );
+ else
+ return 0l;
+ }
+
+ virtual QStringList applications()const {
+ QStringList list;
+ list << Product::appName() ;
+
+ return list;
+ }
+ Q_REFCOUNT
+
+};
+
+
+/* Internal */
+
+template< class Product >
+struct OPrivate {
+ inline static QWidget *multiFactory( const QString& appName, QWidget* parent,
+ const char* name, Qt::WFlags fl ) {
+ if ( appName == Product::appName() )
+ return new Product( parent, name, fl );
+ else
+ return 0;
+ }
+
+ inline static QStringList multiString( const QStringList& _list ) {
+ QStringList list = _list;
+ list << Product::appName();
+ return list;
+ }
+};
+
+template <>
+struct OPrivate<Opie::NullType > {
+ inline static QWidget* multiFactory ( const QString& , QWidget* ,
+ const char* , Qt::WFlags ) {
+ return 0l;
+ }
+ inline static QStringList multiString( const QStringList& _list ) {
+ return _list;
+ }
+};
+
+/*
+template <>
+struct OPrivate <Opie::NullType, Opie::NullType > {
+ inline static QWidget* multiFactory( const QString& , QWidget* ,
+ const char* , Qt::WFlags ) {
+ return 0l;
+ }
+
+ inline static QStringList multiString( const QStringList& _list ) {
+ return _list;
+ }
+};
+*/
+
+template <class Product, class ProductListTail>
+struct OPrivate< Opie::Typelist<Product, ProductListTail> > {
+ inline static QWidget* multiFactory( const QString& appName, QWidget* parent,
+ const char* name, Qt::WFlags fl) {
+ QWidget* wid = OPrivate<Product>::multiFactory( appName, parent, name, fl );
+
+ if (!wid )
+ wid = OPrivate<ProductListTail>::multiFactory( appName, parent, name, fl );
+
+ return wid;
+ }
+
+ inline static QStringList multiString( const QStringList& _list ) {
+ QStringList list = _list;
+
+ list = OPrivate<Product>::multiString( list );
+ list = OPrivate<ProductListTail>::multiString( list );
+
+ return list;
+ }
+};
+
+
+
+
+
+
+
+
+/* Internal END */
+
+/*
+ * If you want to export more than one Widget use that function
+ * Make sure all your Widgets provide the appName() static method
+ * otherwise you'll get a compiler error
+ *
+ * typedef Opie::MakeTypeList<MyWidget, MyDialog, MyMediaPlayer >::Result MyTypes;
+ * OPIE_EXPORT_APP( OApplicationFactory<MyTypes> )
+ */
+
+template<class Product, class ProductListTail>
+struct OApplicationFactory< Opie::Typelist<Product, ProductListTail > >
+ : ApplicationInterface {
+ QRESULT queryInterface( const QUuid &uuid, QUnknownInterface **iface ) {
+ *iface = 0;
+ if ( uuid == IID_QUnknown ) *iface = this;
+ else if ( uuid ==IID_QtopiaApplication ) *iface = this;
+ else return QS_FALSE;
+ (*iface)->addRef();
+ return QS_OK;
+ }
+
+ QWidget* createMainWindow ( const QString& appName, QWidget* parent,
+ const char* name, Qt::WFlags fl ) {
+ qWarning("StringList is %s", applications().join(":").latin1() );
+ return OPrivate< Opie::Typelist<Product, ProductListTail > >::multiFactory( appName, parent, name, fl );
+ }
+
+ QStringList applications()const {
+ QStringList _list;
+ return OPrivate< Opie::Typelist<Product, ProductListTail> >::multiString( _list );
+ }
+
+ Q_REFCOUNT
+};
+
+
+/* If the library version should be build */
+#ifdef OPIE_APP_INTERFACE
+#define OPIE_EXPORT_APP( factory ) Q_EXPORT_INTERFACE() { Q_CREATE_INSTANCE( factory ) }
+#else
+
+#include <qpe/qpeapplication.h>
+
+#define OPIE_EXPORT_APP( Factory ) \
+int main( int argc, char **argv ) { \
+ QPEApplication a(argc, argv ); \
+ QWidget *mw = 0;\
+\
+ /* method from TT */ \
+ QString executableName = QString::fromLatin1( argv[0] ); \
+ executableName = executableName.right(executableName.length() \
+ - executableName.findRev('/') - 1); \
+ \
+ Factory f; \
+ QStringList list = f.applications(); \
+ if (list.contains(executableName) ) \
+ mw = f.createMainWindow(executableName, 0, 0, 0 ); \
+ else \
+ mw = f.createMainWindow( list[0], 0, 0, 0 ); \
+\
+ if( mw ) { \
+ if ( mw->metaObject()->slotNames().contains("setDocument(const QString&)" ) ) \
+ a.showMainDocumentWidget( mw ); \
+ else \
+ a.showMainWidget( mw ); \
+\
+ int rv = a.exec(); \
+ delete mw; \
+ return rv; \
+ }else \
+ return -1; \
+}
+#endif