-rw-r--r-- | examples/applet/config.in | 2 | ||||
-rw-r--r-- | examples/applet/example.pro | 2 | ||||
-rw-r--r-- | examples/applet/simpleimpl.cpp | 96 | ||||
-rw-r--r-- | examples/applet/simpleimpl.h | 23 | ||||
-rw-r--r-- | examples/main-tab/config.in | 2 | ||||
-rw-r--r-- | examples/main-tab/example.pro | 2 | ||||
-rw-r--r-- | examples/main-tab/simple.cpp | 8 | ||||
-rw-r--r-- | examples/simple-icon/simple.cpp | 4 | ||||
-rw-r--r-- | examples/simple-main/simple.cpp | 3 | ||||
-rw-r--r-- | examples/simple-pim/config.in | 2 | ||||
-rw-r--r-- | examples/simple-pim/example.pro | 2 | ||||
-rw-r--r-- | examples/simple-pim/simple.cpp | 39 | ||||
-rw-r--r-- | examples/simple-pim/simple.h | 26 | ||||
-rw-r--r-- | examples/simple/simple.cpp | 4 | ||||
-rw-r--r-- | examples/todayplugin/config.in | 2 | ||||
-rw-r--r-- | examples/todayplugin/example.pro | 2 | ||||
-rw-r--r-- | examples/todayplugin/exampleplugin.h | 4 | ||||
-rw-r--r-- | examples/todayplugin/examplepluginimpl.h | 2 | ||||
-rw-r--r-- | examples/todayplugin/examplepluginwidget.cpp | 3 | ||||
-rw-r--r-- | examples/todayplugin/examplepluginwidget.h | 4 |
20 files changed, 76 insertions, 156 deletions
diff --git a/examples/applet/config.in b/examples/applet/config.in index 177de27..c3fb6dd 100644 --- a/examples/applet/config.in +++ b/examples/applet/config.in @@ -1,4 +1,4 @@ config APPLET_EXAMPLE boolean "Taskbar Applet Example" default "y" - depends ( LIBQPE || LIBQPE-X11 ) && EXAMPLES + depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIEUI2 &&EXAMPLES diff --git a/examples/applet/example.pro b/examples/applet/example.pro index 3efd31e..5ae540b 100644 --- a/examples/applet/example.pro +++ b/examples/applet/example.pro @@ -1,16 +1,16 @@ CONFIG += warn_on qt TEMPLATE = lib DESTDIR = $(OPIEDIR)/plugins/applets TARGET = example SOURCES = simpleimpl.cpp HEADERS = simpleimpl.h INCLUDEPATH += $(OPIEDIR)/include DEPENDSPATH += $(OPIEDIR)/include -LIBS += -lqpe +LIBS += -lqpe -lopieui2 include ( $(OPIEDIR)/include.pro ) diff --git a/examples/applet/simpleimpl.cpp b/examples/applet/simpleimpl.cpp index 82fc6e5..62d9bf7 100644 --- a/examples/applet/simpleimpl.cpp +++ b/examples/applet/simpleimpl.cpp @@ -1,40 +1,45 @@ + +#include "simpleimpl.h" + +#include <opie2/otaskbarapplet.h> + +#include <qpe/applnk.h> // for AppLnk +#include <qpe/resource.h> // for Resource loading + #include <qlabel.h> #include <qpainter.h> #include <qmessagebox.h> -#include <qpe/applnk.h> // for AppLnk -#include <qpe/resource.h> // for Resource loading -#include "simpleimpl.h" SimpleApplet::SimpleApplet(QWidget *parent) : QWidget( parent, "Simple Applet" ) { /* * we will load an Image, scale it for the right usage * remember your applet might be used by different * resolutions. * Then we will convert the image back to an Pixmap * and draw this Pimxap. We need to use Image because its * the only class that allows scaling. */ QImage image = Resource::loadImage("Tux"); /* * smooth scale to AppLnk smallIconSize for applest * smallIconSize gets adjusted to the resolution * so on some displays like SIMpad and a C-750 the smallIconSize * is greater than on a iPAQ h3870 */ image = image.smoothScale(AppLnk::smallIconSize(), AppLnk::smallIconSize() ); /* * now we need to convert the Image to a Pixmap cause these * can be drawn more easily */ m_pix = new QPixmap(); m_pix->convertFromImage( image ); /* * Now we will say that we don't want to be bigger than our * Pixmap @@ -42,121 +47,44 @@ SimpleApplet::SimpleApplet(QWidget *parent) setFixedHeight(AppLnk::smallIconSize() ); setFixedWidth( AppLnk::smallIconSize() ); } SimpleApplet::~SimpleApplet() { delete m_pix; } /* * here you would normal show or do something * useful. If you want to show a widget at the top left * of your icon you need to map your rect().topLeft() to * global with mapToGlobal(). Then you might also need to * move the widgets so it is visible */ void SimpleApplet::mousePressEvent(QMouseEvent* ) { QMessageBox::information(this, tr("No action taken"), tr("<qt>This Plugin does not yet support anything usefule aye.</qt>"), QMessageBox::Ok ); } void SimpleApplet::paintEvent( QPaintEvent* ) { QPainter p(this); /* simpy draw the pixmap from the start of this widget */ p.drawPixmap(0, 0, *m_pix ); } /* - * Here comes the implementation of the interface + * We need to add this symbol for the plugin exporter! */ -SimpleAppletImpl::SimpleAppletImpl() { -} -/* needed cause until it is only pure virtual */ -SimpleAppletImpl::~SimpleAppletImpl() { - /* - * we will delete our applets as well - * setAUtoDelete makes the QList free - * the objects behind the pointers - */ - m_applets.setAutoDelete( true ); - m_applets.clear(); -} - -/* - * For the taskbar interface return a Widget - */ -QWidget* SimpleAppletImpl::applet( QWidget* parent ) { - /* - * There are problems with ownership. So we add - * our ownlist and clear this; - */ - SimpleApplet* ap = new SimpleApplet( parent ); - m_applets.append( ap ); - - return ap; -} - -/* - * A small hint where the Applet Should be displayed - */ -int SimpleAppletImpl::position()const { +int SimpleApplet::position(){ return 1; } -/* - * Now the important QUnkownInterface method without - * this one your applet won't load - * @param uuid The uuid of the interface - * @param iface The pointer to the interface ptr - */ -QRESULT SimpleAppletImpl::queryInterface( const QUuid& uuid, QUnknownInterface** iface) { - /* set the pointer to the interface to 0 */ - *iface = 0; - - /* - * we check if we support the requested interface - * and then assign to the pointer. - * You may alos create another interface here so - * *iface = this is only in this simple case true you - * could also support more interfaces. - * But this example below is the most common use. - * Now the caller knows that the Interface Pointer - * is valid and the interface supported - */ - if ( uuid == IID_QUnknown ) - *iface = this; - else if ( uuid == IID_TaskbarApplet ) - *iface = this; - else - return QS_FALSE; - - if ( *iface ) - (*iface)->addRef(); - - return QS_OK; -} - /* - * Finally we need to export the Interface. - * CREATE_INSTANCE creates a interface and calls - * queryInterface for the QUnknownInterface once - * With out this function the applet can't be loaded. - * - * NOTE: If your applet does not load it's likely you've an - * unresolved symbol. Change the .pro TEMPLATE = lib to TEMPLATE= app - * and recompile. If the linker only complains about a missing - * main method the problem is more complex. In most cases it'll say - * you which symbols are missing and you can implement them. - * The main(int argc, char* argv[] ) does not need to be - * included in a library so it's ok that the linker complains + * Here comes the implementation of the interface */ -Q_EXPORT_INTERFACE() { - Q_CREATE_INSTANCE( SimpleAppletImpl ) -} - +EXPORT_OPIE_APPLET_v1( SimpleApplet )
\ No newline at end of file diff --git a/examples/applet/simpleimpl.h b/examples/applet/simpleimpl.h index f58e2af..90c632f 100644 --- a/examples/applet/simpleimpl.h +++ b/examples/applet/simpleimpl.h @@ -1,77 +1,58 @@ /* * You may use, modify and distribute without any limitation */ /** * Opie and Qtopia uses a component system called QCOM * which was first part of the Qt 3.0 API but was made * prviate during the betas. Opie and Qtopia still use it * and we're happy with it. * Every starts with the QUnknownInterface. It supports functions * for reference counting and the most important one * is for a query. Every QCOM interface got a global unique id ( GUID,UUID ) * query is used to see if a interface is supported by * a dynamic shared object ( dso / plugin ) * For tasks like loading Applications, InputMethods, Today, MenuButton, * Taskbar, Style, Email Client there are specefic Interfaces you * need to implement. The interfaces inherits from QUnknownInterface and * you'll need inherit from the interface. * As example we will use the Taskbar interface + * the OTaskBarAppletWrapper implements the factory for us */ #ifndef SIMPLE_OPIE_EXAMPLE_APPLET_H #define SIMPLE_OPIE_EXAMPLE_APPLET_H /* * The taskbar applet interfaces wants us to implement position() and applet() * additionally we need to implement add(), release() and queryInterface for QUnknownInterface * luckiy there is a macro for the reference counting * We provide an Implementation of the interface. */ #include <qwidget.h> #include <qlist.h> #include <qpe/taskbarappletinterface.h> /* * Because we only draw an Icon in a fixed width and height * we declare and define SimpleApplet here and you could use QLabel * setPixmap or use QWidget and draw yourself. * You might also want to reimplement mouse*Event to use some simple actions */ class SimpleApplet : public QWidget { Q_OBJECT public: SimpleApplet(QWidget *parent); ~SimpleApplet(); + static int position(); private: void mousePressEvent( QMouseEvent* ); void paintEvent( QPaintEvent* ); QPixmap *m_pix; }; -class SimpleAppletImpl : public TaskbarAppletInterface { -public: - - SimpleAppletImpl(); - virtual ~SimpleAppletImpl(); - - QRESULT queryInterface( const QUuid&, QUnknownInterface** ); - - QWidget *applet( QWidget* parent ); - int position()const; - - /* - * macro for reference countint - * if reference drops to zero - * delete this is called - */ - Q_REFCOUNT - -private: - QList<SimpleApplet> m_applets; -}; #endif diff --git a/examples/main-tab/config.in b/examples/main-tab/config.in index e021d59..3a67bcb 100644 --- a/examples/main-tab/config.in +++ b/examples/main-tab/config.in @@ -1,4 +1,4 @@ config MAIN_TAB_EXAMPLE boolean "Mainwindow with OTabWidget example" default "y" - depends ( LIBQPE || LIBQPE-X11 ) && EXAMPLES && LIBOPIE + depends ( LIBQPE || LIBQPE-X11 ) && EXAMPLES && LIBOPIEUI2 diff --git a/examples/main-tab/example.pro b/examples/main-tab/example.pro index 3cafc20..87abf22 100644 --- a/examples/main-tab/example.pro +++ b/examples/main-tab/example.pro @@ -1,17 +1,17 @@ CONFIG += qt warn_on quick-app TARGET = main-tab HEADERS = simple.h SOURCES = simple.cpp INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include # we now also include opie -LIBS += -lqpe -lopie +LIBS += -lqpe -lopieui2 include ( $(OPIEDIR)/include.pro ) diff --git a/examples/main-tab/simple.cpp b/examples/main-tab/simple.cpp index c5a6d5a..7edb557 100644 --- a/examples/main-tab/simple.cpp +++ b/examples/main-tab/simple.cpp @@ -1,73 +1,75 @@ #include <qaction.h> // action #include <qmenubar.h> // menubar #include <qtoolbar.h> // toolbar #include <qlabel.h> // a label #include <qpushbutton.h> // the header file for the QPushButton #include <qlayout.h> #include <qpe/qpeapplication.h> // the QPEApplication #include <qpe/resource.h> #include <qpe/sound.h> -#include <opie/oapplicationfactory.h> // a template + macro to save the main method and allow quick launching -#include <opie/otabwidget.h> +#include <opie2/oapplicationfactory.h> // a template + macro to save the main method and allow quick launching +#include <opie2/otabwidget.h> #include "simple.h" /* * implementation of simple */ /* * The factory is used for quicklaunching * It needs a constructor ( c'tor ) with at least QWidget, const char* and WFlags as parameter and a static QString appName() matching the TARGET of the .pro * * Depending on the global quick launch setting this will create * either a main method or one for our component plugin system */ +/* The OApplicationFactory is in the Opie::Core namespace */ +using namespace Opie::Core; OPIE_EXPORT_APP( OApplicationFactory<MainWindow> ) MainWindow::MainWindow(QWidget *parent, const char* name, WFlags fl ) : QMainWindow( parent, name, fl ) { setCaption(tr("My MainWindow") ); initUI(); /* * Tab widget as central */ - OTabWidget *tab = new OTabWidget(this); + Opie::Ui::OTabWidget *tab = new Opie::Ui::OTabWidget(this); connect(tab, SIGNAL(currentChanged(QWidget*) ), this, SLOT( slotCurrentChanged(QWidget*) ) ); setCentralWidget( tab ); Simple1 *simple1 = new Simple1( this ); tab->addTab( simple1, "new", tr("Simple1") ); tab->setCurrentTab( tr("Simple1") ); Simple2 *simple2 = new Simple2( this ); tab->addTab( simple2, "trash", tr("Simple2") ); m_oldCurrent = simple1; connect(m_fire, SIGNAL(activated() ), simple1, SLOT(slotFire() ) ); } MainWindow::~MainWindow() { // again nothing to delete because Qt takes care } void MainWindow::setDocument( const QString& /*str*/ ) { } void MainWindow::slotCurrentChanged( QWidget *wid) { disconnect(m_fire, SIGNAL(activated() ), m_oldCurrent, SLOT(slotFire() ) ); connect(m_fire, SIGNAL(activated() ), wid, SLOT(slotFire() ) ); m_oldCurrent = wid; } diff --git a/examples/simple-icon/simple.cpp b/examples/simple-icon/simple.cpp index 054ade8..fec1823 100644 --- a/examples/simple-icon/simple.cpp +++ b/examples/simple-icon/simple.cpp @@ -1,56 +1,56 @@ #include <qlabel.h> // a label #include <qpushbutton.h> // the header file for the QPushButton #include <qlayout.h> #include <qpe/qpeapplication.h> // the QPEApplication #include <qpe/resource.h> // for loading icon #include <qpe/sound.h> // for playing a sound -#include <opie/oapplicationfactory.h> // a template + macro to save the main method and allow quick launching +#include <opie2/oapplicationfactory.h> // a template + macro to save the main method and allow quick launching #include "simple.h" /* * implementation of simple */ /* * The factory is used for quicklaunching * It needs a constructor ( c'tor ) with at least QWidget, const char* and WFlags as parameter and a static QString appName() matching the TARGET of the .pro * * Depending on the global quick launch setting this will create * either a main method or one for our component plugin system */ - +using namespace Opie::Core; OPIE_EXPORT_APP( OApplicationFactory<Simple> ) Simple::Simple( QWidget* parent, const char* name, WFlags fl ) : QWidget( parent, name, fl ) { /* * sets the caption of this toplevel widget * put all translatable string into tr() */ setCaption(tr("My Simple Application") ); /* * A simple vertical layout * either call layout->setAutoAdd( true ) * or use layout->addWidget( wid ) to add widgets */ QVBoxLayout *layout = new QVBoxLayout( this ); layout->setSpacing( 8 ); layout->setMargin( 11 ); /* * creates a label * The first parameter is this widget so the Label is a child * of us and will be deleted when we're deleted. */ QLabel *lbl = new QLabel( this, "a name for the label" ); /* * Resource will search hard for a Pixmap in $OPIEDIR/pics * to find 'logo/opielogo' You need to pass the subdir * but not the ending */ lbl->setPixmap( Resource::loadPixmap("logo/opielogo") ); diff --git a/examples/simple-main/simple.cpp b/examples/simple-main/simple.cpp index 8de911f..cf00cc6 100644 --- a/examples/simple-main/simple.cpp +++ b/examples/simple-main/simple.cpp @@ -1,58 +1,59 @@ #include <qaction.h> // action #include <qmenubar.h> // menubar #include <qtoolbar.h> // toolbar #include <qlabel.h> // a label #include <qpushbutton.h> // the header file for the QPushButton #include <qlayout.h> #include <qpe/qpeapplication.h> // the QPEApplication #include <qpe/resource.h> -#include <opie/oapplicationfactory.h> // a template + macro to save the main method and allow quick launching +#include <opie2/oapplicationfactory.h> // a template + macro to save the main method and allow quick launching #include "simple.h" /* * implementation of simple */ /* * The factory is used for quicklaunching * It needs a constructor ( c'tor ) with at least QWidget, const char* and WFlags as parameter and a static QString appName() matching the TARGET of the .pro * * Depending on the global quick launch setting this will create * either a main method or one for our component plugin system */ +using namespace Opie::Core; OPIE_EXPORT_APP( OApplicationFactory<MainWindow> ) MainWindow::MainWindow(QWidget *parent, const char* name, WFlags fl ) : QMainWindow( parent, name, fl ) { setCaption(tr("My MainWindow") ); setIcon( Resource::loadPixmap("new") ); /* * out mainwindow should have a menubar * a toolbar, a mainwidget and use Resource * to get the IconSets */ /* * we initialize the GUI in a different methid */ initUI(); Simple *simple = new Simple( this ); setCentralWidget( simple ); /* * If you use signal and slots do not include the parameter * names inside * so SIGNAL(fooBar(int) ) and NOT SIGNAL(fooBar(int foo) ) */ /* * We connect the activation of our QAction * to the slot connected to the firebutton * We could also connect the signal to the clicked * signal of the button */ connect(m_fire, SIGNAL(activated() ), simple, SLOT(slotFire() ) ); diff --git a/examples/simple-pim/config.in b/examples/simple-pim/config.in index 5d80f21..aa1a426 100644 --- a/examples/simple-pim/config.in +++ b/examples/simple-pim/config.in @@ -1,4 +1,4 @@ config SIMPLE_PIM_EXAMPLE boolean "Mainwindow with PIM and QCOP usage" default "y" - depends ( LIBQPE || LIBQPE-X11 ) && EXAMPLES && LIBOPIE + depends ( LIBQPE || LIBQPE-X11 ) && EXAMPLES && LIBOPIEPIM2 diff --git a/examples/simple-pim/example.pro b/examples/simple-pim/example.pro index c3aab53..ebcdb2b 100644 --- a/examples/simple-pim/example.pro +++ b/examples/simple-pim/example.pro @@ -1,17 +1,17 @@ CONFIG += qt warn_on quick-app TARGET = simple-pim HEADERS = simple.h SOURCES = simple.cpp INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include # we now also include opie -LIBS += -lqpe -lopie +LIBS += -lqpe -lopiepim2 -lopieui2 include ( $(OPIEDIR)/include.pro ) diff --git a/examples/simple-pim/simple.cpp b/examples/simple-pim/simple.cpp index 029e71b..50905bf 100644 --- a/examples/simple-pim/simple.cpp +++ b/examples/simple-pim/simple.cpp @@ -1,85 +1,86 @@ #include <qaction.h> // action #include <qmenubar.h> // menubar #include <qtoolbar.h> // toolbar #include <qlabel.h> // a label #include <qpushbutton.h> // the header file for the QPushButton #include <qlayout.h> #include <qtimer.h> // we use it for the singleShot #include <qdatetime.h> // for QDate #include <qtextview.h> // a rich text widget #include <qdialog.h> #include <qwhatsthis.h> // for whats this #include <qpe/qpeapplication.h> // the QPEApplication #include <qpe/resource.h> #include <qpe/sound.h> #include <qpe/qcopenvelope_qws.h> #include <qpe/datebookmonth.h> #include <qpe/timestring.h> -#include <opie/oapplicationfactory.h> // a template + macro to save the main method and allow quick launching -#include <opie/otabwidget.h> -#include <opie/owait.h> +#include <opie2/oapplicationfactory.h> // a template + macro to save the main method and allow quick launching +#include <opie2/otabwidget.h> +#include <opie2/owait.h> #include "simple.h" /* * implementation of simple */ /* * The factory is used for quicklaunching * It needs a constructor ( c'tor ) with at least QWidget, const char* and WFlags as parameter and a static QString appName() matching the TARGET of the .pro * * Depending on the global quick launch setting this will create * either a main method or one for our component plugin system */ +using namespace Opie::Core; OPIE_EXPORT_APP( OApplicationFactory<MainWindow> ) MainWindow::MainWindow(QWidget *parent, const char* name, WFlags fl ) : QMainWindow( parent, name, fl ) { setCaption(tr("My MainWindow") ); m_desktopChannel = 0; m_loading = 0; initUI(); /* * Tab widget as central */ - m_tab = new OTabWidget(this); + m_tab = new Opie::Ui::OTabWidget(this); setCentralWidget( m_tab ); m_todoView = new PIMListView(m_tab, "Todo view" ); m_tab->addTab( m_todoView,"todo/TodoList", tr("Todos") ); m_dateView = new PIMListView(m_tab, "Datebook view" ); m_tab->addTab( m_dateView, "datebook/DateBook", tr("Events") ); /* now connect the actions */ /* * we connect the activated to our show * and on activation we will show a detailed * summary of the record */ connect(m_fire, SIGNAL(activated() ), this, SLOT(slotShow() ) ); /* * We will change the date */ connect(m_dateAction, SIGNAL(activated() ), this, SLOT(slotDate() ) ); /* * connect the show signal of the PIMListView * to a slot to show a dialog */ connect(m_todoView, SIGNAL(showRecord(const OPimRecord&) ), this, SLOT(slotShowRecord(const OPimRecord&) ) ); connect(m_dateView, SIGNAL(showRecord(const OPimRecord&) ), this, SLOT(slotShowRecord(const OPimRecord&) ) ); @@ -182,130 +183,130 @@ void MainWindow::slotLoad() { m_tb.load(); return slotLoadForDay( QDate::currentDate() ); } /* * prepare our answer machine the QCopChannel * QPE/Desktop will send "flushDone(QString)" when * the flush is done it emits a signal on receive */ m_desktopChannel = new QCopChannel("QPE/Desktop"); connect(m_desktopChannel, SIGNAL(received(const QCString&,const QByteArray&) ), this, SLOT(slotDesktopReceive(const QCString&,const QByteArray&) ) ); /* the numberof synced channels will be set to zero */ m_synced = 0; /* * We use {} around the QCopEnvelope because it sends its * data on destruction of QCopEnvelope with */ /* check again if not present increment synced*/ if ( QCopChannel::isRegistered("QPE/Application/todolist") ) { QCopEnvelope env("QPE/Application/todolist", "flush()" ); // env << data; but we do not have any parameters here }else m_synced++; if ( QCopChannel::isRegistered("QPE/Application/datebook") ) { QCopEnvelope env("QPE/Application/datebook", "flush()" ); }else m_synced++; /* we will provide a wait scrren */ - m_loading = new OWait(this, "wait screen" ); + m_loading = new Opie::Ui::OWait(this, "wait screen" ); } void MainWindow::slotDesktopReceive(const QCString& cmd, const QByteArray& data ) { /* the bytearray was filled with the QDataStream now * we open it read only to get the value(s) */ QDataStream stream(data, IO_ReadOnly ); /* * we're only interested in the flushDone */ if ( cmd == "flushDone(QString)" ) { QString appname; stream >> appname; // get the first argument out of stream if (appname == QString::fromLatin1("datebook") || appname == QString::fromLatin1("todolist") ) m_synced++; } /* * If we synced both we can go ahead * In future this is not needed anymore when we finally * implemented X-Ref and other PIM features */ if (m_synced >= 2 ) { delete m_loading; delete m_desktopChannel; /* now we finally can start doing the actual loading */ m_tb.load(); m_db.load(); { /* tell the applications to reload */ QCopEnvelope("QPE/Application/todolist", "reload()"); QCopEnvelope("QPE/Application/datebook", "reload()"); } slotLoadForDay( QDate::currentDate() ); } } /* overloaded member for shortcoming of libqpe */ void MainWindow::slotLoadForDay(int y, int m, int d) { /* year,month, day */ slotLoadForDay( QDate(y, m, d ) ); } void MainWindow::slotLoadForDay(const QDate& date) { /* all todos for today including the ones without dueDate */ m_todoView->set( m_tb.effectiveToDos(date, date ) ); m_dateView->set( m_db.effectiveEvents( date, date ) ); } /* we want to show the current record */ void MainWindow::slotShow() { /* we only added PIMListViews so we can safely cast */ PIMListView *view = static_cast<PIMListView*>(m_tab->currentWidget() ); /* ask the view to send a signal */ view->showCurrentRecord(); } /* as answer this slot will be called */ -void MainWindow::slotShowRecord( const OPimRecord& rec) { +void MainWindow::slotShowRecord( const Opie::OPimRecord& rec) { /* got a parent but still is a toplevel MODAL dialog */ QDialog* dia = new QDialog(this,"dialog",TRUE ); QVBoxLayout *box = new QVBoxLayout( dia ); dia->setCaption( tr("View Record") ); QTextView *view = new QTextView(dia ); view->setText( rec.toRichText() ); box->addWidget( view ); /* * execute via QPEApplication * this allows QPEApplication to make a sane decision * on the size */ dia->showMaximized(); QPEApplication::execDialog( dia ); delete dia; } void MainWindow::slotDate() { /* * called by the action we will show a Popup * at the current mouse position with a DateChooser * to select the day */ qWarning("slot Date"); QPopupMenu *menu = new QPopupMenu(); /* A Month to select a date from TRUE for auto close */ DateBookMonth *month = new DateBookMonth(menu, 0, true ); connect(month, SIGNAL(dateClicked(int,int,int) ), this, SLOT(slotLoadForDay(int,int,int) ) ); @@ -315,131 +316,131 @@ void MainWindow::slotDate() { menu->exec( QCursor::pos() ); /* * we do not need to delete month because * we delete its parent menu */ delete menu; } /* * An anonymous namespace this symbol is only available here * so truely private */ namespace { /* not static cause namespace does that what static would do */ const int RTTI = 5050; /* * every ListView got Items. we've special pim items * holding ownership and the pointer to a pim record * it can't hold a pimrecord directly because this * would introduce slicing... any break */ /* * A struct is a special class. Everything is public by * default. */ struct PIMListViewItem : public QListViewItem { /* *currently no hierachies are planed for the example * so only one constructor with a QListView as parent */ - PIMListViewItem( QListView*, OPimRecord* record ); + PIMListViewItem( QListView*, Opie::OPimRecord* record ); ~PIMListViewItem(); /* used by the QListViewItem to easily allow identifiying of different * items. Values greater than 1000 should be used */ int rtti()const; - OPimRecord* record()const; + Opie::OPimRecord* record()const; private: - OPimRecord* m_record; + Opie::OPimRecord* m_record; }; - PIMListViewItem::PIMListViewItem( QListView *p, OPimRecord* rec ) + PIMListViewItem::PIMListViewItem( QListView *p, Opie::OPimRecord* rec ) : QListViewItem(p), m_record( rec ) { } PIMListViewItem::~PIMListViewItem() { /* we've the onwership so we need to delete it */ delete m_record; } - OPimRecord* PIMListViewItem::record()const { + Opie::OPimRecord* PIMListViewItem::record()const { return m_record; } } PIMListView::PIMListView( QWidget* widget, const char* name, WFlags fl ) : QListView(widget, name, fl ) { addColumn("Summary"); } PIMListView::~PIMListView() { } -void PIMListView::set( OTodoAccess::List list ) { +void PIMListView::set( Opie::OPimTodoAccess::List list ) { /* clear first and then add new items */ clear(); - OTodoAccess::List::Iterator it; + Opie::OPimTodoAccess::List::Iterator it; for (it = list.begin(); it != list.end(); ++it ) { /* * make a new item which automatically gets added to the listview - * and call the copy c'tor to create a new OTodo + * and call the copy c'tor to create a new OPimTodo */ - PIMListViewItem *i = new PIMListViewItem(this, new OTodo( *it ) ); + PIMListViewItem *i = new PIMListViewItem(this, new Opie::OPimTodo( *it ) ); i->setText(0, (*it).summary() ); } } -void PIMListView::set( const OEffectiveEvent::ValueList& lst ) { +void PIMListView::set( const Opie::OEffectiveEvent::ValueList& lst ) { /* clear first and then add items */ clear(); - OEffectiveEvent::ValueList::ConstIterator it; + Opie::OEffectiveEvent::ValueList::ConstIterator it; for ( it = lst.begin(); it != lst.end(); ++it ) { - PIMListViewItem *i = new PIMListViewItem(this, new OEvent( (*it).event() ) ); + PIMListViewItem *i = new PIMListViewItem(this, new Opie::OPimEvent( (*it).event() ) ); i->setText( 0, PIMListView::makeString( (*it) ) ); } } void PIMListView::showCurrentRecord() { /* it could be possible that their is no currentItem */ if (!currentItem() ) return; /* * we only add PIMListViewItems so it is save * to do this case. If this would not be the case * use rtti() to check in a switch() case */ PIMListViewItem *item = static_cast<PIMListViewItem*>( currentItem() ); /* finally you see how to emit a signal */ emit showRecord( (*item->record() ) ); } -QString PIMListView::makeString( const OEffectiveEvent& ev ) { +QString PIMListView::makeString( const Opie::OEffectiveEvent& ev ) { QString str; str += ev.description(); if ( !ev.event().isAllDay() ) { if ( ev.startDate() != ev.endDate() ) { str += tr("Start ") + TimeString::timeString( ev.event().startDateTime().time() ); str += " - " + TimeString::longDateString( ev.startDate() ); str += tr("End ") + TimeString::timeString( ev.event().endDateTime().time() ); str += " - " + TimeString::longDateString( ev.endDate() ); }else{ str += tr("Time ") + TimeString::timeString( ev.startTime() ); str += " - " + TimeString::timeString( ev.endTime() ); } }else str += tr(" This is an All-Day Event"); return str; } diff --git a/examples/simple-pim/simple.h b/examples/simple-pim/simple.h index bf9ede7..2a6e8ce 100644 --- a/examples/simple-pim/simple.h +++ b/examples/simple-pim/simple.h @@ -1,95 +1,99 @@ /* * A Simple widget with a button to quit * */ /* * The below sequence is called a guard and guards * against multiple inclusion of header files * NOTE: you need to use unique names among the header files */ #ifndef QUIET_SIMPLE_DEMO_H #define QUIET_SIMPLE_DEMO_H #include <qmainwindow.h> // from this class we will inherit #include <qlistview.h> // A ListView for our PIM records -#include <opie/otodoaccess.h> -#include <opie/odatebookaccess.h> +#include <opie2/otodoaccess.h> +#include <opie2/odatebookaccess.h> class QPushButton; // forward declaration to not include the header. This can save time when compiling class QAction; class PIMListView; class QDate; class QCopChannel; +namespace Opie{ +namespace Ui { class OWait; class OTabWidget; +} +} /* * A mainwindow is a special QWidget it helps layouting * toolbar, statusbar, menubar. Got dockable areas * So in one sentence it is a MainWindow :) */ class MainWindow : public QMainWindow { Q_OBJECT public: static QString appName() { return QString::fromLatin1("simple-pim"); } MainWindow( QWidget* parent, const char* name, WFlags fl ); ~MainWindow(); public slots: void setDocument( const QString& ); private slots: void slotDesktopReceive( const QCString&, const QByteArray& ); void slotLoad(); void slotLoadForDay(int, int, int ); void slotLoadForDay(const QDate&); void slotShow(); void slotDate(); - void slotShowRecord( const OPimRecord& ); + void slotShowRecord( const Opie::OPimRecord& ); private: void initUI(); QAction *m_fire; QAction *m_dateAction; - OTabWidget* m_tab; + Opie::Ui::OTabWidget* m_tab; - OTodoAccess m_tb; - ODateBookAccess m_db; + Opie::OPimTodoAccess m_tb; + Opie::ODateBookAccess m_db; PIMListView *m_todoView; PIMListView *m_dateView; int m_synced; // a counter for synced objects.. QCopChannel *m_desktopChannel; - OWait *m_loading; + Opie::Ui::OWait *m_loading; }; /* * Instead of the simple QWidgets we will design * a new widget based on a QListView * it should show either Todos or EffectiveEvents */ class PIMListView : public QListView { Q_OBJECT public: PIMListView( QWidget* parent, const char* name, WFlags fl= 0 ); ~PIMListView(); - void set( OTodoAccess::List ); - void set( const OEffectiveEvent::ValueList& ); + void set( Opie::OPimTodoAccess::List ); + void set( const Opie::OEffectiveEvent::ValueList& ); void showCurrentRecord(); signals: - void showRecord( const OPimRecord& ); + void showRecord( const Opie::OPimRecord& ); private: - static QString makeString( const OEffectiveEvent& ev ); + static QString makeString( const Opie::OEffectiveEvent& ev ); }; #endif diff --git a/examples/simple/simple.cpp b/examples/simple/simple.cpp index a0bc308..faf13c9 100644 --- a/examples/simple/simple.cpp +++ b/examples/simple/simple.cpp @@ -1,54 +1,56 @@ #include <qlabel.h> // a label #include <qpushbutton.h> // the header file for the QPushButton #include <qlayout.h> #include <qpe/qpeapplication.h> // the QPEApplication -#include <opie/oapplicationfactory.h> // a template + macro to save the main method and allow quick launching +#include <opie2/oapplicationfactory.h> // a template + macro to save the main method and allow quick launching #include "simple.h" /* * implementation of simple */ /* * The factory is used for quicklaunching * It needs a constructor ( c'tor ) with at least QWidget, const char* and WFlags as parameter and a static QString appName() matching the TARGET of the .pro * * Depending on the global quick launch setting this will create * either a main method or one for our component plugin system */ +/* The OApplicationFactory is in Opie::Core */ +using namespace Opie::Core; OPIE_EXPORT_APP( OApplicationFactory<Simple> ) Simple::Simple( QWidget* parent, const char* name, WFlags fl ) : QWidget( parent, name, fl ) { /* * sets the caption of this toplevel widget * put all translatable string into tr() */ setCaption(tr("My Simple Application") ); /* * A simple vertical layout * either call layout->setAutoAdd( true ) * or use layout->addWidget( wid ) to add widgets */ QVBoxLayout *layout = new QVBoxLayout( this ); layout->setSpacing( 8 ); layout->setMargin( 11 ); /* * creates a label * The first parameter is this widget so the Label is a child * of us and will be deleted when we're deleted. */ QLabel *lbl = new QLabel( this, "a name for the label" ); lbl->setText( tr("Click on the button or follow the white rabbit") ); layout->addWidget( lbl ); /* creates a button as child of this widget */ m_button = new QPushButton(this); diff --git a/examples/todayplugin/config.in b/examples/todayplugin/config.in index 53004cb..0a6a573 100644 --- a/examples/todayplugin/config.in +++ b/examples/todayplugin/config.in @@ -1,5 +1,5 @@ config TODAY_EXAMPLE boolean "Opie-Today Plugin Example" default "n" - depends ( LIBQPE || LIBQPE-X11 ) && EXAMPLES && LIBOPIE + depends ( LIBQPE || LIBQPE-X11 ) && EXAMPLES && LIBOPIEUI2 diff --git a/examples/todayplugin/example.pro b/examples/todayplugin/example.pro index 4c8c942..f4bca36 100644 --- a/examples/todayplugin/example.pro +++ b/examples/todayplugin/example.pro @@ -1,17 +1,17 @@ TEMPLATE = lib CONFIG -= moc CONFIG += qt release # Input HEADERS = exampleplugin.h examplepluginimpl.h examplepluginwidget.h SOURCES = exampleplugin.cpp examplepluginimpl.cpp examplepluginwidget.cpp INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include -LIBS+= -lqpe -lopie +LIBS+= -lqpe -lopieui2 DESTDIR = $(OPIEDIR)/plugins/today TARGET = todayexampleplugin include ( $(OPIEDIR)/include.pro ) diff --git a/examples/todayplugin/exampleplugin.h b/examples/todayplugin/exampleplugin.h index a1df923..94f5b37 100644 --- a/examples/todayplugin/exampleplugin.h +++ b/examples/todayplugin/exampleplugin.h @@ -1,42 +1,42 @@ /* * exampleplugin.h * * email : harlekin@handhelds.org * */ #ifndef EXAMPLE_PLUGIN_H #define EXAMPLE_PLUGIN_H #include <qwidget.h> #include <qguardedptr.h> -#include <opie/todayplugininterface.h> -#include <opie/todayconfigwidget.h> +#include <opie2/todayplugininterface.h> +#include <opie2/todayconfigwidget.h> #include "examplepluginwidget.h" // implementation of the today plugin interface class ExamplePlugin : public TodayPluginObject { public: ExamplePlugin(); ~ExamplePlugin(); QString pluginName() const; double versionNumber() const; QString pixmapNameWidget() const; QWidget* widget(QWidget *); QString pixmapNameConfig() const; TodayConfigWidget* configWidget(QWidget *); QString appName() const; bool excludeFromRefresh() const; void refresh(); void reinitialize(); private: QGuardedPtr<ExamplePluginWidget> m_widget; }; #endif diff --git a/examples/todayplugin/examplepluginimpl.h b/examples/todayplugin/examplepluginimpl.h index 77ec4f6..31f8907 100644 --- a/examples/todayplugin/examplepluginimpl.h +++ b/examples/todayplugin/examplepluginimpl.h @@ -1,30 +1,30 @@ /* * examplepluginimpl.h * * email : harlekin@handhelds.org * */ #ifndef EXAMPLE_PLUGIN_IMPL_H #define EXAMPLE_PLUGIN_IMPL_H -#include <opie/todayplugininterface.h> +#include <opie2/todayplugininterface.h> class ExamplePlugin; class ExamplePluginImpl : public TodayPluginInterface{ public: ExamplePluginImpl(); virtual ~ExamplePluginImpl(); QRESULT queryInterface( const QUuid &, QUnknownInterface** ); Q_REFCOUNT virtual TodayPluginObject *guiPart(); private: ExamplePlugin *examplePlugin; }; #endif diff --git a/examples/todayplugin/examplepluginwidget.cpp b/examples/todayplugin/examplepluginwidget.cpp index d66a11a..10fd39a 100644 --- a/examples/todayplugin/examplepluginwidget.cpp +++ b/examples/todayplugin/examplepluginwidget.cpp @@ -1,58 +1,59 @@ /* * examplepluginwidget.cpp * * email : harlekin@handhelds.org * */ #include <qpe/config.h> #include <qpe/qcopenvelope_qws.h> #include "examplepluginwidget.h" + ExamplePluginWidget::ExamplePluginWidget( QWidget *parent, const char* name) : QWidget(parent, name ) { m_exampleLabel = 0l; m_layout = 0l; if ( m_exampleLabel ) { delete m_exampleLabel; } // since here a OClickableLabel is used, the plugin part will be clickable, and the actions // that should be triggered when clicked are defined in slotClicked() // of course also normal widgets can be used. - m_exampleLabel = new OClickableLabel( this ); + m_exampleLabel = new Opie::Ui::OClickableLabel( this ); connect( m_exampleLabel, SIGNAL( clicked() ), this, SLOT( slotClicked() ) ); if ( m_layout ) { delete m_layout; } m_layout = new QHBoxLayout( this ); m_layout->setAutoAdd( true ); readConfig(); getInfo(); } ExamplePluginWidget::~ExamplePluginWidget() { delete m_exampleLabel; delete m_layout; } void ExamplePluginWidget::readConfig() { // we dont have any config entries in this plugin // normally this method is used after today config was used } void ExamplePluginWidget::refresh() { } void ExamplePluginWidget::getInfo() { m_exampleLabel->setText( tr("Example text") ); } diff --git a/examples/todayplugin/examplepluginwidget.h b/examples/todayplugin/examplepluginwidget.h index eb3c660..70e717e 100644 --- a/examples/todayplugin/examplepluginwidget.h +++ b/examples/todayplugin/examplepluginwidget.h @@ -1,35 +1,35 @@ /* * examplepluginwidget.h * * email : harlekin@handhelds.org * */ #ifndef EXAMPLE_PLUGIN_WIDGET_H #define EXAMPLE_PLUGIN_WIDGET_H #include <qlayout.h> -#include <opie/oclickablelabel.h> +#include <opie2/oclickablelabel.h> class ExamplePluginWidget : public QWidget { Q_OBJECT public: ExamplePluginWidget( QWidget *parent, const char *name ); ~ExamplePluginWidget(); void refresh(); private slots: void slotClicked(); private: - OClickableLabel* m_exampleLabel; + Opie::Ui::OClickableLabel* m_exampleLabel; QHBoxLayout* m_layout; void readConfig(); void getInfo(); }; #endif |