summaryrefslogtreecommitdiff
path: root/examples
Unidiff
Diffstat (limited to 'examples') (more/less context) (ignore whitespace changes)
-rw-r--r--examples/applet/applet.pro2
-rw-r--r--examples/applet/config.in2
-rw-r--r--examples/applet/simpleimpl.cpp25
-rw-r--r--examples/inputmethod/config.in2
-rw-r--r--examples/inputmethod/exampleboardimpl.cpp5
-rw-r--r--examples/inputmethod/inputmethod.pro2
-rw-r--r--examples/main-tab/config.in2
-rw-r--r--examples/main-tab/main-tab.pro2
-rw-r--r--examples/main-tab/opie-simple.control2
-rw-r--r--examples/main-tab/simple.cpp11
-rw-r--r--examples/menuapplet/config.in2
-rw-r--r--examples/menuapplet/example.cpp9
-rw-r--r--examples/menuapplet/menuapplet.pro2
-rw-r--r--examples/opieui/config.in2
-rw-r--r--examples/opieui/owidgetstack_example/owidgetstack_example.cpp14
-rw-r--r--examples/opieui/owidgetstack_example/owidgetstack_example.pro2
-rw-r--r--examples/simple-icon/config.in2
-rw-r--r--examples/simple-icon/opie-simple.control2
-rw-r--r--examples/simple-icon/simple.cpp5
-rw-r--r--examples/simple-main/config.in2
-rw-r--r--examples/simple-main/opie-simple.control2
-rw-r--r--examples/simple-main/simple.cpp8
-rw-r--r--examples/simple-pim/opie-simple.control2
-rw-r--r--examples/simple-pim/simple.cpp8
24 files changed, 47 insertions, 70 deletions
diff --git a/examples/applet/applet.pro b/examples/applet/applet.pro
index 6890141..1daf1b2 100644
--- a/examples/applet/applet.pro
+++ b/examples/applet/applet.pro
@@ -1,16 +1,16 @@
1CONFIG += warn_on qt 1CONFIG += warn_on qt
2 2
3TEMPLATE = lib 3TEMPLATE = lib
4DESTDIR = $(OPIEDIR)/plugins/applets 4DESTDIR = $(OPIEDIR)/plugins/applets
5TARGET = example 5TARGET = example
6 6
7SOURCES = simpleimpl.cpp 7SOURCES = simpleimpl.cpp
8HEADERS = simpleimpl.h 8HEADERS = simpleimpl.h
9 9
10INCLUDEPATH += $(OPIEDIR)/include 10INCLUDEPATH += $(OPIEDIR)/include
11DEPENDSPATH += $(OPIEDIR)/include 11DEPENDSPATH += $(OPIEDIR)/include
12 12
13LIBS += -lqpe -lopieui2 13LIBS += -lqpe -lopiecore2 -lopieui2
14 14
15 15
16include( $(OPIEDIR)/include.pro ) 16include( $(OPIEDIR)/include.pro )
diff --git a/examples/applet/config.in b/examples/applet/config.in
index f6a5d20..0d4d800 100644
--- a/examples/applet/config.in
+++ b/examples/applet/config.in
@@ -1,4 +1,4 @@
1 config APPLET_EXAMPLE 1 config APPLET_EXAMPLE
2 boolean "Taskbar Applet Example" 2 boolean "Taskbar Applet Example"
3 default "y" 3 default "y"
4 depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2UI && EXAMPLES 4 depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && LIBOPIE2UI && EXAMPLES
diff --git a/examples/applet/simpleimpl.cpp b/examples/applet/simpleimpl.cpp
index ff651ca..d7e2db9 100644
--- a/examples/applet/simpleimpl.cpp
+++ b/examples/applet/simpleimpl.cpp
@@ -1,91 +1,74 @@
1 1
2#include "simpleimpl.h" 2#include "simpleimpl.h"
3 3
4#include <opie2/oresource.h> // for OResource loading
4#include <opie2/otaskbarapplet.h> 5#include <opie2/otaskbarapplet.h>
5 6
6#include <qpe/applnk.h> // for AppLnk 7#include <qpe/applnk.h> // for AppLnk
7#include <qpe/resource.h> // for Resource loading
8 8
9#include <qlabel.h> 9#include <qlabel.h>
10#include <qpainter.h> 10#include <qpainter.h>
11#include <qmessagebox.h> 11#include <qmessagebox.h>
12 12
13 13
14 14
15 15
16SimpleApplet::SimpleApplet(QWidget *parent) 16SimpleApplet::SimpleApplet(QWidget *parent)
17 : QWidget( parent, "Simple Applet" ) { 17 : QWidget( parent, "Simple Applet" ) {
18/* 18/*
19 * we will load an Image, scale it for the right usage 19 * we will load an Pixmap, scaled for the right usage
20 * remember your applet might be used by different 20 * remember your applet might be used by different
21 * resolutions. 21 * resolutions.
22 * Then we will convert the image back to an Pixmap
23 * and draw this Pimxap. We need to use Image because its
24 * the only class that allows scaling.
25 */ 22 */
26 23
27 QImage image = Resource::loadImage("Tux"); 24 m_pix = new QPixmap( Opie::Core::OResource::loadPixmap("Tux", Opie::Core::OResource::SmallIcon) );
28 /*
29 * smooth scale to AppLnk smallIconSize for applest
30 * smallIconSize gets adjusted to the resolution
31 * so on some displays like SIMpad and a C-750 the smallIconSize
32 * is greater than on a iPAQ h3870
33 */
34 image = image.smoothScale(AppLnk::smallIconSize(), AppLnk::smallIconSize() );
35
36 /*
37 * now we need to convert the Image to a Pixmap cause these
38 * can be drawn more easily
39 */
40 m_pix = new QPixmap();
41 m_pix->convertFromImage( image );
42 25
43 /* 26 /*
44 * Now we will say that we don't want to be bigger than our 27 * Now we will say that we don't want to be bigger than our
45 * Pixmap 28 * Pixmap
46 */ 29 */
47 setFixedHeight(AppLnk::smallIconSize() ); 30 setFixedHeight( AppLnk::smallIconSize() );
48 setFixedWidth( AppLnk::smallIconSize() ); 31 setFixedWidth( AppLnk::smallIconSize() );
49 32
50} 33}
51 34
52SimpleApplet::~SimpleApplet() { 35SimpleApplet::~SimpleApplet() {
53 delete m_pix; 36 delete m_pix;
54} 37}
55 38
56 39
57/* 40/*
58 * here you would normal show or do something 41 * here you would normal show or do something
59 * useful. If you want to show a widget at the top left 42 * useful. If you want to show a widget at the top left
60 * of your icon you need to map your rect().topLeft() to 43 * of your icon you need to map your rect().topLeft() to
61 * global with mapToGlobal(). Then you might also need to 44 * global with mapToGlobal(). Then you might also need to
62 * move the widgets so it is visible 45 * move the widgets so it is visible
63 */ 46 */
64void SimpleApplet::mousePressEvent(QMouseEvent* ) { 47void SimpleApplet::mousePressEvent(QMouseEvent* ) {
65 QMessageBox::information(this, tr("No action taken"), 48 QMessageBox::information(this, tr("No action taken"),
66 tr("<qt>This Plugin does not yet support anything usefule aye.</qt>"), 49 tr("<qt>This Plugin does not yet support anything usefule aye.</qt>"),
67 QMessageBox::Ok ); 50 QMessageBox::Ok );
68 51
69} 52}
70 53
71void SimpleApplet::paintEvent( QPaintEvent* ) { 54void SimpleApplet::paintEvent( QPaintEvent* ) {
72 QPainter p(this); 55 QPainter p(this);
73 56
74 /* simpy draw the pixmap from the start of this widget */ 57 /* simpy draw the pixmap from the start of this widget */
75 p.drawPixmap(0, 0, *m_pix ); 58 p.drawPixmap(0, 0, *m_pix );
76} 59}
77 60
78/* 61/*
79 * We need to add this symbol for the plugin exporter! 62 * We need to add this symbol for the plugin exporter!
80 */ 63 */
81int SimpleApplet::position(){ 64int SimpleApplet::position(){
82 return 1; 65 return 1;
83} 66}
84 67
85 68
86 69
87/* 70/*
88 * Here comes the implementation of the interface 71 * Here comes the implementation of the interface
89 */ 72 */
90EXPORT_OPIE_APPLET_v1( SimpleApplet ) 73EXPORT_OPIE_APPLET_v1( SimpleApplet )
91 74
diff --git a/examples/inputmethod/config.in b/examples/inputmethod/config.in
index c0aa7e8..85b9725 100644
--- a/examples/inputmethod/config.in
+++ b/examples/inputmethod/config.in
@@ -1,4 +1,4 @@
1 config EXAMPLE_BOARD 1 config EXAMPLE_BOARD
2 boolean "Input Method Example" 2 boolean "Input Method Example"
3 default "y" 3 default "y"
4 depends ( LIBQPE || LIBQPE-X11 ) && EXAMPLES 4 depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && EXAMPLES
diff --git a/examples/inputmethod/exampleboardimpl.cpp b/examples/inputmethod/exampleboardimpl.cpp
index 36989a2..6c7196b 100644
--- a/examples/inputmethod/exampleboardimpl.cpp
+++ b/examples/inputmethod/exampleboardimpl.cpp
@@ -1,157 +1,158 @@
1#include <qwidget.h> 1#include <qwidget.h>
2#include <qcheckbox.h> 2#include <qcheckbox.h>
3#include <qlabel.h> 3#include <qlabel.h>
4#include <qsignalmapper.h> 4#include <qsignalmapper.h>
5#include <qpushbutton.h> 5#include <qpushbutton.h>
6#include <qpe/resource.h> 6
7#include <opie2/oresource.h>
7 8
8#include "exampleboardimpl.h" 9#include "exampleboardimpl.h"
9 10
10ExampleBoard::ExampleBoard(QWidget* par, WFlags fl ) 11ExampleBoard::ExampleBoard(QWidget* par, WFlags fl )
11 : QHBox(par, "name", fl ) 12 : QHBox(par, "name", fl )
12{ 13{
13 QCheckBox *box1 = new QCheckBox(tr("Alt"),this); 14 QCheckBox *box1 = new QCheckBox(tr("Alt"),this);
14 connect(box1,SIGNAL(toggled(bool)), 15 connect(box1,SIGNAL(toggled(bool)),
15 this,SLOT(slotAlt(bool))); 16 this,SLOT(slotAlt(bool)));
16 m_alt = box1; 17 m_alt = box1;
17 box1 = new QCheckBox(tr("Shift"),this ); 18 box1 = new QCheckBox(tr("Shift"),this );
18 connect(box1,SIGNAL(toggled(bool)), 19 connect(box1,SIGNAL(toggled(bool)),
19 this,SLOT(slotShift(bool))); 20 this,SLOT(slotShift(bool)));
20 m_shi = box1; 21 m_shi = box1;
21 box1 = new QCheckBox(tr("Ctrl","Control Shortcut on keyboard"),this ); 22 box1 = new QCheckBox(tr("Ctrl","Control Shortcut on keyboard"),this );
22 connect(box1,SIGNAL(toggled(bool)), 23 connect(box1,SIGNAL(toggled(bool)),
23 this,SLOT(slotCtrl(bool))); 24 this,SLOT(slotCtrl(bool)));
24 m_ctrl = box1; 25 m_ctrl = box1;
25 26
26 QSignalMapper *map = new QSignalMapper(this); 27 QSignalMapper *map = new QSignalMapper(this);
27 QPushButton *btn = new QPushButton("a",this); 28 QPushButton *btn = new QPushButton("a",this);
28 map->setMapping(btn,0); 29 map->setMapping(btn,0);
29 connect(btn,SIGNAL(clicked()),map,SLOT(map())); 30 connect(btn,SIGNAL(clicked()),map,SLOT(map()));
30 31
31 btn = new QPushButton("b",this); 32 btn = new QPushButton("b",this);
32 map->setMapping(btn,1); 33 map->setMapping(btn,1);
33 connect(btn,SIGNAL(clicked()),map,SLOT(map())); 34 connect(btn,SIGNAL(clicked()),map,SLOT(map()));
34 35
35 btn = new QPushButton("c",this); 36 btn = new QPushButton("c",this);
36 map->setMapping(btn,2); 37 map->setMapping(btn,2);
37 connect(btn,SIGNAL(clicked()),map,SLOT(map())); 38 connect(btn,SIGNAL(clicked()),map,SLOT(map()));
38 39
39 connect(map,SIGNAL(mapped(int)), 40 connect(map,SIGNAL(mapped(int)),
40 this,SLOT(slotKey(int))); 41 this,SLOT(slotKey(int)));
41 resetState(); 42 resetState();
42} 43}
43 44
44ExampleBoard::~ExampleBoard(){ 45ExampleBoard::~ExampleBoard(){
45} 46}
46 47
47void ExampleBoard::resetState(){ 48void ExampleBoard::resetState(){
48 m_state = 0; 49 m_state = 0;
49 m_shi->setChecked(false); 50 m_shi->setChecked(false);
50 m_ctrl->setChecked(false); 51 m_ctrl->setChecked(false);
51 m_alt->setChecked(false); 52 m_alt->setChecked(false);
52} 53}
53 54
54 void ExampleBoard::slotKey(int _ke){ 55 void ExampleBoard::slotKey(int _ke){
55 int ke = _ke + 0x61; // 0 + 65 = 0x41 == A 56 int ke = _ke + 0x61; // 0 + 65 = 0x41 == A
56 if(m_state & ShiftButton ) 57 if(m_state & ShiftButton )
57 ke -= 0x20; 58 ke -= 0x20;
58 59
59 /* 60 /*
60 * Send the key 61 * Send the key
61 * ke is the unicode 62 * ke is the unicode
62 * _ke + 0x41 is the keycode 63 * _ke + 0x41 is the keycode
63 * m_state Normally the state 64 * m_state Normally the state
64 * down/up 65 * down/up
65 * auto repeat 66 * auto repeat
66 */ 67 */
67 emit key(ke, _ke +0x41,m_state,true,false); 68 emit key(ke, _ke +0x41,m_state,true,false);
68 emit key(ke, _ke + 0x41,m_state,false,false); 69 emit key(ke, _ke + 0x41,m_state,false,false);
69} 70}
70 71
71void ExampleBoard::slotShift(bool b){ 72void ExampleBoard::slotShift(bool b){
72 if(b) 73 if(b)
73 m_state |= ShiftButton; 74 m_state |= ShiftButton;
74 else 75 else
75 m_state &= ~ShiftButton; 76 m_state &= ~ShiftButton;
76} 77}
77 78
78void ExampleBoard::slotAlt(bool b){ 79void ExampleBoard::slotAlt(bool b){
79 if(b) 80 if(b)
80 m_state |= AltButton; 81 m_state |= AltButton;
81 else 82 else
82 m_state &= ~AltButton; 83 m_state &= ~AltButton;
83} 84}
84 85
85void ExampleBoard::slotCtrl(bool b){ 86void ExampleBoard::slotCtrl(bool b){
86 if(b) 87 if(b)
87 m_state |= ControlButton; 88 m_state |= ControlButton;
88 else 89 else
89 m_state &= ~ControlButton; 90 m_state &= ~ControlButton;
90} 91}
91 92
92 93
93 94
94ExampleboardImpl::ExampleboardImpl() 95ExampleboardImpl::ExampleboardImpl()
95 : m_pickboard(0), m_icn(0) 96 : m_pickboard(0), m_icn(0)
96{ 97{
97} 98}
98 99
99ExampleboardImpl::~ExampleboardImpl() 100ExampleboardImpl::~ExampleboardImpl()
100{ 101{
101 delete m_pickboard; 102 delete m_pickboard;
102 delete m_icn; 103 delete m_icn;
103} 104}
104 105
105QWidget *ExampleboardImpl::inputMethod( QWidget *parent, Qt::WFlags f ) 106QWidget *ExampleboardImpl::inputMethod( QWidget *parent, Qt::WFlags f )
106{ 107{
107 if ( !m_pickboard ) 108 if ( !m_pickboard )
108 m_pickboard = new ExampleBoard( parent, f ); 109 m_pickboard = new ExampleBoard( parent, f );
109 return m_pickboard; 110 return m_pickboard;
110} 111}
111 112
112void ExampleboardImpl::resetState() 113void ExampleboardImpl::resetState()
113{ 114{
114 if ( m_pickboard ) 115 if ( m_pickboard )
115 m_pickboard->resetState(); 116 m_pickboard->resetState();
116} 117}
117 118
118QPixmap *ExampleboardImpl::icon() 119QPixmap *ExampleboardImpl::icon()
119{ 120{
120 if ( !m_icn ) 121 if ( !m_icn )
121 m_icn = new QPixmap(Resource::loadPixmap("Tux")); 122 m_icn = new QPixmap(Opie::Core::OResource::loadPixmap("Tux", Opie::Core::OResource::SmallIcon));
122 return m_icn; 123 return m_icn;
123} 124}
124 125
125QString ExampleboardImpl::name() 126QString ExampleboardImpl::name()
126{ 127{
127 return QObject::tr("Example Input"); 128 return QObject::tr("Example Input");
128} 129}
129 130
130void ExampleboardImpl::onKeyPress( QObject *receiver, const char *slot ) 131void ExampleboardImpl::onKeyPress( QObject *receiver, const char *slot )
131{ 132{
132 if ( m_pickboard ) 133 if ( m_pickboard )
133 QObject::connect( m_pickboard, SIGNAL(key(ushort,ushort,ushort,bool,bool)), receiver, slot ); 134 QObject::connect( m_pickboard, SIGNAL(key(ushort,ushort,ushort,bool,bool)), receiver, slot );
134} 135}
135 136
136#ifndef QT_NO_COMPONENT 137#ifndef QT_NO_COMPONENT
137QRESULT ExampleboardImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) 138QRESULT ExampleboardImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface )
138{ 139{
139 *iface = 0; 140 *iface = 0;
140 if ( uuid == IID_QUnknown ) 141 if ( uuid == IID_QUnknown )
141 *iface = this; 142 *iface = this;
142 else if ( uuid == IID_InputMethod ) 143 else if ( uuid == IID_InputMethod )
143 *iface = this; 144 *iface = this;
144 else 145 else
145 return QS_FALSE; 146 return QS_FALSE;
146 147
147 if ( *iface ) 148 if ( *iface )
148 (*iface)->addRef(); 149 (*iface)->addRef();
149 return QS_OK; 150 return QS_OK;
150} 151}
151 152
152Q_EXPORT_INTERFACE() 153Q_EXPORT_INTERFACE()
153{ 154{
154 Q_CREATE_INSTANCE( ExampleboardImpl ) 155 Q_CREATE_INSTANCE( ExampleboardImpl )
155} 156}
156#endif 157#endif
157 158
diff --git a/examples/inputmethod/inputmethod.pro b/examples/inputmethod/inputmethod.pro
index ea98dd5..56881ff 100644
--- a/examples/inputmethod/inputmethod.pro
+++ b/examples/inputmethod/inputmethod.pro
@@ -1,12 +1,12 @@
1 TEMPLATE= lib 1 TEMPLATE= lib
2 CONFIG += qt plugin warn_on 2 CONFIG += qt plugin warn_on
3 HEADERS= exampleboardimpl.h 3 HEADERS= exampleboardimpl.h
4 SOURCES= exampleboardimpl.cpp 4 SOURCES= exampleboardimpl.cpp
5 TARGET = example_board 5 TARGET = example_board
6 DESTDIR = $(OPIEDIR)/plugins/inputmethods 6 DESTDIR = $(OPIEDIR)/plugins/inputmethods
7INCLUDEPATH += $(OPIEDIR)/include 7INCLUDEPATH += $(OPIEDIR)/include
8DEPENDPATH += ../../launcher 8DEPENDPATH += ../../launcher
9LIBS += -lqpe 9LIBS += -lqpe -lopiecore2
10 VERSION = 1.0.0 10 VERSION = 1.0.0
11 11
12include( $(OPIEDIR)/include.pro ) 12include( $(OPIEDIR)/include.pro )
diff --git a/examples/main-tab/config.in b/examples/main-tab/config.in
index a40df56..640679e 100644
--- a/examples/main-tab/config.in
+++ b/examples/main-tab/config.in
@@ -1,4 +1,4 @@
1 config MAIN_TAB_EXAMPLE 1 config MAIN_TAB_EXAMPLE
2 boolean "Mainwindow with OTabWidget example" 2 boolean "Mainwindow with OTabWidget example"
3 default "y" 3 default "y"
4 depends ( LIBQPE || LIBQPE-X11 ) && EXAMPLES && LIBOPIE2UI 4 depends ( LIBQPE || LIBQPE-X11 ) && EXAMPLES && LIBOPIE2CORE && LIBOPIE2UI
diff --git a/examples/main-tab/main-tab.pro b/examples/main-tab/main-tab.pro
index a0df875..033a028 100644
--- a/examples/main-tab/main-tab.pro
+++ b/examples/main-tab/main-tab.pro
@@ -1,17 +1,17 @@
1CONFIG += qt warn_on quick-app 1CONFIG += qt warn_on quick-app
2 2
3 3
4TARGET = main-tab 4TARGET = main-tab
5 5
6HEADERS = simple.h 6HEADERS = simple.h
7SOURCES = simple.cpp 7SOURCES = simple.cpp
8 8
9 9
10INCLUDEPATH += $(OPIEDIR)/include 10INCLUDEPATH += $(OPIEDIR)/include
11DEPENDPATH += $(OPIEDIR)/include 11DEPENDPATH += $(OPIEDIR)/include
12 12
13 13
14# we now also include opie 14# we now also include opie
15LIBS += -lqpe -lopieui2 15LIBS += -lqpe -lopiecore2 -lopieui2
16 16
17include( $(OPIEDIR)/include.pro ) 17include( $(OPIEDIR)/include.pro )
diff --git a/examples/main-tab/opie-simple.control b/examples/main-tab/opie-simple.control
index 8525a94..2046281 100644
--- a/examples/main-tab/opie-simple.control
+++ b/examples/main-tab/opie-simple.control
@@ -1,9 +1,9 @@
1Package: opie-main-tab-example 1Package: opie-main-tab-example
2Files: bin/main-tab apps/Examples/main-tab.desktop 2Files: bin/main-tab apps/Examples/main-tab.desktop
3Priority: optional 3Priority: optional
4Section: opie/examples 4Section: opie/examples
5Maintainer: Holger 'zecke' Freyther <zecke@handhelds.org> 5Maintainer: Holger 'zecke' Freyther <zecke@handhelds.org>
6Architecture: arm 6Architecture: arm
7Depends: task-opie-minimal, opie-pics 7Depends: task-opie-minimal, libopiecore2, libopieui2, opie-pics
8Description: A simple example 8Description: A simple example
9Version: $QPE_VERSION$EXTRAVERSION 9Version: $QPE_VERSION$EXTRAVERSION
diff --git a/examples/main-tab/simple.cpp b/examples/main-tab/simple.cpp
index 7edb557..1e2d028 100644
--- a/examples/main-tab/simple.cpp
+++ b/examples/main-tab/simple.cpp
@@ -1,213 +1,212 @@
1#include <qaction.h> // action 1#include <qaction.h> // action
2#include <qmenubar.h> // menubar 2#include <qmenubar.h> // menubar
3#include <qtoolbar.h> // toolbar 3#include <qtoolbar.h> // toolbar
4#include <qlabel.h> // a label 4#include <qlabel.h> // a label
5#include <qpushbutton.h> // the header file for the QPushButton 5#include <qpushbutton.h> // the header file for the QPushButton
6#include <qlayout.h> 6#include <qlayout.h>
7 7
8#include <qpe/qpeapplication.h> // the QPEApplication 8#include <qpe/qpeapplication.h> // the QPEApplication
9#include <qpe/resource.h>
10#include <qpe/sound.h> 9#include <qpe/sound.h>
11 10
12#include <opie2/oapplicationfactory.h> // a template + macro to save the main method and allow quick launching 11#include <opie2/oapplicationfactory.h> // a template + macro to save the main method and allow quick launching
12#include <opie2/oresource.h>
13#include <opie2/otabwidget.h> 13#include <opie2/otabwidget.h>
14 14
15#include "simple.h" 15#include "simple.h"
16 16
17/* 17/*
18 * implementation of simple 18 * implementation of simple
19 */ 19 */
20 20
21/* 21/*
22 * The factory is used for quicklaunching 22 * The factory is used for quicklaunching
23 * 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 23 * 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
24 * 24 *
25 * Depending on the global quick launch setting this will create 25 * Depending on the global quick launch setting this will create
26 * either a main method or one for our component plugin system 26 * either a main method or one for our component plugin system
27 */ 27 */
28 28
29/* The OApplicationFactory is in the Opie::Core namespace */ 29/* The OApplicationFactory is in the Opie::Core namespace */
30using namespace Opie::Core; 30using namespace Opie::Core;
31OPIE_EXPORT_APP( OApplicationFactory<MainWindow> ) 31OPIE_EXPORT_APP( OApplicationFactory<MainWindow> )
32 32
33MainWindow::MainWindow(QWidget *parent, const char* name, WFlags fl ) 33MainWindow::MainWindow(QWidget *parent, const char* name, WFlags fl )
34 : QMainWindow( parent, name, fl ) { 34 : QMainWindow( parent, name, fl ) {
35 setCaption(tr("My MainWindow") ); 35 setCaption(tr("My MainWindow") );
36 36
37 initUI(); 37 initUI();
38 38
39 39
40 /* 40 /*
41 * Tab widget as central 41 * Tab widget as central
42 */ 42 */
43 Opie::Ui::OTabWidget *tab = new Opie::Ui::OTabWidget(this); 43 Opie::Ui::OTabWidget *tab = new Opie::Ui::OTabWidget(this);
44 connect(tab, SIGNAL(currentChanged(QWidget*) ), 44 connect(tab, SIGNAL(currentChanged(QWidget*) ),
45 this, SLOT( slotCurrentChanged(QWidget*) ) ); 45 this, SLOT( slotCurrentChanged(QWidget*) ) );
46 setCentralWidget( tab ); 46 setCentralWidget( tab );
47 47
48 Simple1 *simple1 = new Simple1( this ); 48 Simple1 *simple1 = new Simple1( this );
49 tab->addTab( simple1, "new", tr("Simple1") ); 49 tab->addTab( simple1, "new", tr("Simple1") );
50 tab->setCurrentTab( tr("Simple1") ); 50 tab->setCurrentTab( tr("Simple1") );
51 51
52 Simple2 *simple2 = new Simple2( this ); 52 Simple2 *simple2 = new Simple2( this );
53 tab->addTab( simple2, "trash", tr("Simple2") ); 53 tab->addTab( simple2, "trash", tr("Simple2") );
54 54
55 m_oldCurrent = simple1; 55 m_oldCurrent = simple1;
56 56
57 connect(m_fire, SIGNAL(activated() ), 57 connect(m_fire, SIGNAL(activated() ),
58 simple1, SLOT(slotFire() ) ); 58 simple1, SLOT(slotFire() ) );
59} 59}
60 60
61MainWindow::~MainWindow() { 61MainWindow::~MainWindow() {
62 // again nothing to delete because Qt takes care 62 // again nothing to delete because Qt takes care
63} 63}
64 64
65 65
66void MainWindow::setDocument( const QString& /*str*/ ) { 66void MainWindow::setDocument( const QString& /*str*/ ) {
67} 67}
68void MainWindow::slotCurrentChanged( QWidget *wid) { 68void MainWindow::slotCurrentChanged( QWidget *wid) {
69 disconnect(m_fire, SIGNAL(activated() ), 69 disconnect(m_fire, SIGNAL(activated() ),
70 m_oldCurrent, SLOT(slotFire() ) ); 70 m_oldCurrent, SLOT(slotFire() ) );
71 connect(m_fire, SIGNAL(activated() ), 71 connect(m_fire, SIGNAL(activated() ),
72 wid, SLOT(slotFire() ) ); 72 wid, SLOT(slotFire() ) );
73 73
74 m_oldCurrent = wid; 74 m_oldCurrent = wid;
75} 75}
76 76
77void MainWindow::initUI() { 77void MainWindow::initUI() {
78 78
79 setToolBarsMovable( false ); 79 setToolBarsMovable( false );
80 80
81 QToolBar *menuBarHolder = new QToolBar( this ); 81 QToolBar *menuBarHolder = new QToolBar( this );
82 82
83 menuBarHolder->setHorizontalStretchable( true ); 83 menuBarHolder->setHorizontalStretchable( true );
84 QMenuBar *mb = new QMenuBar( menuBarHolder ); 84 QMenuBar *mb = new QMenuBar( menuBarHolder );
85 QToolBar *tb = new QToolBar( this ); 85 QToolBar *tb = new QToolBar( this );
86 86
87 QPopupMenu *fileMenu = new QPopupMenu( this ); 87 QPopupMenu *fileMenu = new QPopupMenu( this );
88 88
89 89
90 QAction *a = new QAction( tr("Quit"), Resource::loadIconSet("quit_icon"), 90 QAction *a = new QAction( tr("Quit"), Opie::Core::OResource::loadPixmap("quit_icon", Opie::Core::OResource::SmallIcon),
91 QString::null, 0, this, "quit_action" ); 91 QString::null, 0, this, "quit_action" );
92 /* 92 /*
93 * Connect quit to the QApplication quit slot 93 * Connect quit to the QApplication quit slot
94 */ 94 */
95 connect(a, SIGNAL(activated() ), 95 connect(a, SIGNAL(activated() ),
96 qApp, SLOT(quit() ) ); 96 qApp, SLOT(quit() ) );
97 a->addTo( fileMenu ); 97 a->addTo( fileMenu );
98 98
99 a = new QAction(tr("Fire"), 99 a = new QAction(tr("Fire"), Opie::Core::OResource::loadPixmap("new", Opie::Core::OResource::SmallIcon),
100 Resource::loadIconSet("new"),
101 QString::null, 0, this, "fire_button"); 100 QString::null, 0, this, "fire_button");
102 101
103 /* see the power? */ 102 /* see the power? */
104 a->addTo( fileMenu ); 103 a->addTo( fileMenu );
105 a->addTo( tb ); 104 a->addTo( tb );
106 m_fire = a; 105 m_fire = a;
107 106
108 107
109 mb->insertItem(tr("File"), fileMenu ); 108 mb->insertItem(tr("File"), fileMenu );
110 109
111} 110}
112 111
113Simple1::Simple1( QWidget* parent, const char* name, WFlags fl ) 112Simple1::Simple1( QWidget* parent, const char* name, WFlags fl )
114 : QWidget( parent, name, fl ) { 113 : QWidget( parent, name, fl ) {
115 114
116 QVBoxLayout *layout = new QVBoxLayout( this ); 115 QVBoxLayout *layout = new QVBoxLayout( this );
117 layout->setSpacing( 8 ); 116 layout->setSpacing( 8 );
118 layout->setMargin( 11 ); 117 layout->setMargin( 11 );
119 118
120 119
121 QLabel *lbl = new QLabel( this, "a name for the label" ); 120 QLabel *lbl = new QLabel( this, "a name for the label" );
122 lbl->setText( tr("Click on the button or follow the white rabbit") ); 121 lbl->setText( tr("Click on the button or follow the white rabbit") );
123 layout->addWidget( lbl ); 122 layout->addWidget( lbl );
124 123
125 124
126 m_button = new QPushButton(this); 125 m_button = new QPushButton(this);
127 126
128 127
129 m_button->setText( tr("Fire", "translatable quit string" ) ); 128 m_button->setText( tr("Fire", "translatable quit string" ) );
130 layout->addWidget( m_button ); 129 layout->addWidget( m_button );
131 130
132 131
133 connect( m_button, SIGNAL(clicked() ), 132 connect( m_button, SIGNAL(clicked() ),
134 this, SLOT( slotFire() ) ); 133 this, SLOT( slotFire() ) );
135} 134}
136 135
137Simple1::~Simple1() { 136Simple1::~Simple1() {
138 137
139} 138}
140 139
141void Simple1::slotFire() { 140void Simple1::slotFire() {
142 /* 141 /*
143 * NOTE: Simple is now a child window of MainWindow 142 * NOTE: Simple is now a child window of MainWindow
144 * close will hide() Simple and not delete it. But as 143 * close will hide() Simple and not delete it. But as
145 * the mainwindow is shown all children will be shown as well 144 * the mainwindow is shown all children will be shown as well
146 */ 145 */
147 close(); 146 close();
148} 147}
149 148
150 149
151Simple2::Simple2( QWidget* parent, const char* name, WFlags fl ) 150Simple2::Simple2( QWidget* parent, const char* name, WFlags fl )
152 : QWidget( parent, name, fl ) { 151 : QWidget( parent, name, fl ) {
153 152
154 /* 153 /*
155 * sets the caption of this toplevel widget 154 * sets the caption of this toplevel widget
156 * put all translatable string into tr() 155 * put all translatable string into tr()
157 */ 156 */
158 setCaption(tr("My Simple Application") ); 157 setCaption(tr("My Simple Application") );
159 158
160 /* 159 /*
161 * A simple vertical layout 160 * A simple vertical layout
162 * either call layout->setAutoAdd( true ) 161 * either call layout->setAutoAdd( true )
163 * or use layout->addWidget( wid ) to add widgets 162 * or use layout->addWidget( wid ) to add widgets
164 */ 163 */
165 QVBoxLayout *layout = new QVBoxLayout( this ); 164 QVBoxLayout *layout = new QVBoxLayout( this );
166 layout->setSpacing( 8 ); 165 layout->setSpacing( 8 );
167 layout->setMargin( 11 ); 166 layout->setMargin( 11 );
168 167
169 /* 168 /*
170 * creates a label 169 * creates a label
171 * The first parameter is this widget so the Label is a child 170 * The first parameter is this widget so the Label is a child
172 * of us and will be deleted when we're deleted. 171 * of us and will be deleted when we're deleted.
173 */ 172 */
174 QLabel *lbl = new QLabel( this, "a name for the label" ); 173 QLabel *lbl = new QLabel( this, "a name for the label" );
175 /* 174 /*
176 * Resource will search hard for a Pixmap in $OPIEDIR/pics 175 * OResource will search hard for a Pixmap in $OPIEDIR/pics
177 * to find 'logo/opielogo' You need to pass the subdir 176 * to find 'logo/opielogo' You need to pass the subdir
178 * but not the ending 177 * but not the ending
179 */ 178 */
180 lbl->setPixmap( Resource::loadPixmap("logo/opielogo") ); 179 lbl->setPixmap( Opie::Core::OResource::loadPixmap("logo/opielogo", Opie::Core::OResource::SmallIcon) );
181 layout->addWidget( lbl ); 180 layout->addWidget( lbl );
182 181
183 182
184 /* creates a button as child of this widget */ 183 /* creates a button as child of this widget */
185 m_button = new QPushButton(this); 184 m_button = new QPushButton(this);
186 /* 185 /*
187 * another way to call tr. The first parameter is the string 186 * another way to call tr. The first parameter is the string
188 * to translate and the second a hint to the translator 187 * to translate and the second a hint to the translator
189 */ 188 */
190 m_button->setText( tr("Fire", "translatable fire string" ) ); 189 m_button->setText( tr("Fire", "translatable fire string" ) );
191 layout->addWidget( m_button ); 190 layout->addWidget( m_button );
192 191
193 192
194 connect( m_button, SIGNAL(clicked() ), 193 connect( m_button, SIGNAL(clicked() ),
195 this, SLOT( slotQuit() ) ); 194 this, SLOT( slotQuit() ) );
196} 195}
197 196
198 197
199Simple2::~Simple2() { 198Simple2::~Simple2() {
200 199
201} 200}
202 201
203void Simple2::slotFire() { 202void Simple2::slotFire() {
204 /* 203 /*
205 * We will fire up a sound 204 * We will fire up a sound
206 * Note that Sound will use Resource as well 205 * Note that Sound will use Resource as well
207 * and we do not need to supply an ending 206 * and we do not need to supply an ending
208 * sounds are found in $OPIEDIR/sounds 207 * sounds are found in $OPIEDIR/sounds
209 */ 208 */
210 Sound snd("hit_target01"); 209 Sound snd("hit_target01");
211 snd.play(); 210 snd.play();
212 211
213} 212}
diff --git a/examples/menuapplet/config.in b/examples/menuapplet/config.in
index 3167478..9425d9f 100644
--- a/examples/menuapplet/config.in
+++ b/examples/menuapplet/config.in
@@ -1,4 +1,4 @@
1 config EXAMPLE_MENU 1 config EXAMPLE_MENU
2 boolean "O-Menu Applet" 2 boolean "O-Menu Applet"
3 default "y" 3 default "y"
4 depends ( LIBQPE || LIBQPE-X11 ) && EXAMPLES 4 depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && EXAMPLES
diff --git a/examples/menuapplet/example.cpp b/examples/menuapplet/example.cpp
index 8ae77da..079030f 100644
--- a/examples/menuapplet/example.cpp
+++ b/examples/menuapplet/example.cpp
@@ -1,78 +1,73 @@
1#include "example.h" 1#include "example.h"
2 2
3#include <qpe/applnk.h> 3#include <opie2/oresource.h>
4#include <qpe/resource.h>
5 4
6/* QT */ 5/* QT */
7#include <qiconset.h> 6#include <qiconset.h>
8#include <qpopupmenu.h> 7#include <qpopupmenu.h>
9#include <qmessagebox.h> 8#include <qmessagebox.h>
10 9
11 10
12MenuAppletExample::MenuAppletExample() 11MenuAppletExample::MenuAppletExample()
13 :QObject( 0, "MenuAppletExample" ) 12 :QObject( 0, "MenuAppletExample" )
14{ 13{
15} 14}
16 15
17MenuAppletExample::~MenuAppletExample ( ) 16MenuAppletExample::~MenuAppletExample ( )
18{} 17{}
19 18
20int MenuAppletExample::position() const 19int MenuAppletExample::position() const
21{ 20{
22 return 3; 21 return 3;
23} 22}
24 23
25QString MenuAppletExample::name() const 24QString MenuAppletExample::name() const
26{ 25{
27 return tr( "MenuApplet Example Name" ); 26 return tr( "MenuApplet Example Name" );
28} 27}
29 28
30QString MenuAppletExample::text() const 29QString MenuAppletExample::text() const
31{ 30{
32 return tr( "Click the white rabbit" ); 31 return tr( "Click the white rabbit" );
33} 32}
34 33
35 34
36QIconSet MenuAppletExample::icon() const 35QIconSet MenuAppletExample::icon() const
37{ 36{
38 QPixmap pix; 37 return Opie::Core::OResource::loadPixmap( "Tux", Opie::Core::OResource::SmallIcon );
39 QImage img = Resource::loadImage( "Tux" );
40 if ( !img.isNull() )
41 pix.convertFromImage( img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) );
42 return pix;
43} 38}
44 39
45QPopupMenu* MenuAppletExample::popup(QWidget*) const 40QPopupMenu* MenuAppletExample::popup(QWidget*) const
46{ 41{
47 /* no subdir */ 42 /* no subdir */
48 return 0; 43 return 0;
49} 44}
50 45
51void MenuAppletExample::activated() 46void MenuAppletExample::activated()
52{ 47{
53 QMessageBox::information(0,tr("No white rabbit found"), 48 QMessageBox::information(0,tr("No white rabbit found"),
54 tr("<qt>No white rabbit was seen near Opie." 49 tr("<qt>No white rabbit was seen near Opie."
55 "Only the beautiful OpieZilla is available" 50 "Only the beautiful OpieZilla is available"
56 "for your pleassure</qt>")); 51 "for your pleassure</qt>"));
57} 52}
58 53
59 54
60QRESULT MenuAppletExample::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) 55QRESULT MenuAppletExample::queryInterface( const QUuid &uuid, QUnknownInterface **iface )
61{ 56{
62 *iface = 0; 57 *iface = 0;
63 if ( uuid == IID_QUnknown ) 58 if ( uuid == IID_QUnknown )
64 *iface = this; 59 *iface = this;
65 else if ( uuid == IID_MenuApplet ) 60 else if ( uuid == IID_MenuApplet )
66 *iface = this; 61 *iface = this;
67 else 62 else
68 return QS_FALSE; 63 return QS_FALSE;
69 64
70 if ( *iface ) 65 if ( *iface )
71 (*iface)->addRef(); 66 (*iface)->addRef();
72 return QS_OK; 67 return QS_OK;
73} 68}
74 69
75Q_EXPORT_INTERFACE() 70Q_EXPORT_INTERFACE()
76{ 71{
77 Q_CREATE_INSTANCE( MenuAppletExample ) 72 Q_CREATE_INSTANCE( MenuAppletExample )
78} 73}
diff --git a/examples/menuapplet/menuapplet.pro b/examples/menuapplet/menuapplet.pro
index 1e20e78..e8858ec 100644
--- a/examples/menuapplet/menuapplet.pro
+++ b/examples/menuapplet/menuapplet.pro
@@ -1,12 +1,12 @@
1TEMPLATE = lib 1TEMPLATE = lib
2CONFIG += qt plugn warn_on 2CONFIG += qt plugn warn_on
3HEADERS = example.h 3HEADERS = example.h
4SOURCES = example.cpp 4SOURCES = example.cpp
5TARGET = example_applet 5TARGET = example_applet
6DESTDIR = $(OPIEDIR)/plugins/applets 6DESTDIR = $(OPIEDIR)/plugins/applets
7INCLUDEPATH += $(OPIEDIR)/include 7INCLUDEPATH += $(OPIEDIR)/include
8DEPENDPATH += $(OPIEDIR)/include 8DEPENDPATH += $(OPIEDIR)/include
9LIBS += -lqpe 9LIBS += -lqpe -lopiecore2
10VERSION = 1.0.0 10VERSION = 1.0.0
11 11
12include( $(OPIEDIR)/include.pro ) 12include( $(OPIEDIR)/include.pro )
diff --git a/examples/opieui/config.in b/examples/opieui/config.in
index f538430..cf5fd01 100644
--- a/examples/opieui/config.in
+++ b/examples/opieui/config.in
@@ -1,4 +1,4 @@
1 config EXAMPLE_LIBOPIE2UI 1 config EXAMPLE_LIBOPIE2UI
2 boolean "libopieui2 examples" 2 boolean "libopieui2 examples"
3 depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2UI 3 depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && LIBOPIE2UI && EXAMPLES
4 4
diff --git a/examples/opieui/owidgetstack_example/owidgetstack_example.cpp b/examples/opieui/owidgetstack_example/owidgetstack_example.cpp
index 272e42b..ded3b0c 100644
--- a/examples/opieui/owidgetstack_example/owidgetstack_example.cpp
+++ b/examples/opieui/owidgetstack_example/owidgetstack_example.cpp
@@ -1,133 +1,133 @@
1/* 1/*
2 * You may use, modify and distribute this example without any limitation 2 * You may use, modify and distribute this example without any limitation
3 */ 3 */
4 4
5#include "owidgetstack_example.h" 5#include "owidgetstack_example.h"
6 6
7/* OPIE */ 7/* OPIE */
8#include <opie2/oapplicationfactory.h> 8#include <opie2/oapplicationfactory.h>
9#include <opie2/owidgetstack.h> 9#include <opie2/owidgetstack.h>
10#include <qpe/resource.h> 10#include <opie2/oresource.h>
11 11
12/* QT */ 12/* QT */
13#include <qaction.h> 13#include <qaction.h>
14#include <qtoolbar.h> 14#include <qtoolbar.h>
15#include <qpopupmenu.h> 15#include <qpopupmenu.h>
16#include <qmenubar.h> 16#include <qmenubar.h>
17#include <qlayout.h> 17#include <qlayout.h>
18#include <qlabel.h> 18#include <qlabel.h>
19#include <qpushbutton.h> 19#include <qpushbutton.h>
20#include <qsignalmapper.h> 20#include <qsignalmapper.h>
21 21
22using namespace Opie::Core; 22using namespace Opie::Core;
23using namespace Opie::Ui; 23using namespace Opie::Ui;
24 24
25OPIE_EXPORT_APP( OApplicationFactory<StackExample> ) 25OPIE_EXPORT_APP( OApplicationFactory<StackExample> )
26 26
27StackExample::StackExample( QWidget* parent, const char* name, WFlags fl ) 27StackExample::StackExample( QWidget* parent, const char* name, WFlags fl )
28 : QMainWindow( parent, name, fl ) 28 : QMainWindow( parent, name, fl )
29{ 29{
30 m_stack = new OWidgetStack( this ); 30 m_stack = new OWidgetStack( this );
31 setCentralWidget( m_stack ); 31 setCentralWidget( m_stack );
32 32
33 /* nice Signal Mapper ;) */ 33 /* nice Signal Mapper ;) */
34 QSignalMapper *sm = new QSignalMapper(this); 34 QSignalMapper *sm = new QSignalMapper(this);
35 connect(sm, SIGNAL(mapped(int) ), m_stack, SLOT(raiseWidget(int)) ); 35 connect(sm, SIGNAL(mapped(int) ), m_stack, SLOT(raiseWidget(int)) );
36 36
37 /* toolbar first but this should be known from the other examples */ 37 /* toolbar first but this should be known from the other examples */
38 setToolBarsMovable( false ); 38 setToolBarsMovable( false );
39 39
40 /* only a menubar here */ 40 /* only a menubar here */
41 QToolBar* holder = new QToolBar( this ); 41 QToolBar* holder = new QToolBar( this );
42 holder->setHorizontalStretchable( true ); 42 holder->setHorizontalStretchable( true );
43 43
44 QMenuBar *bar = new QMenuBar( holder ); 44 QMenuBar *bar = new QMenuBar( holder );
45 QPopupMenu *menu = new QPopupMenu( this ); 45 QPopupMenu *menu = new QPopupMenu( this );
46 46
47 QAction* a = new QAction( tr("Show MainWidget"), Resource::loadPixmap("zoom"), 47 QAction* a = new QAction( tr("Show MainWidget"), Opie::Core::OResource::loadPixmap("zoom", Opie::Core::OResource::SmallIcon),
48 QString::null, 0, this, 0 ); 48 QString::null, 0, this, 0 );
49 sm->setMapping(a, 1 ); 49 sm->setMapping(a, 1 );
50 connect(a, SIGNAL(activated() ), 50 connect(a, SIGNAL(activated() ),
51 sm, SLOT(map() ) ); 51 sm, SLOT(map() ) );
52 a->addTo( menu ); 52 a->addTo( menu );
53 53
54 a = new QAction( tr("Show Details Small"), Resource::loadPixmap("zoom"), 54 a = new QAction( tr("Show Details Small"), Opie::Core::OResource::loadPixmap("zoom", Opie::Core::OResource::SmallIcon),
55 QString::null, 0, this, 0 ); 55 QString::null, 0, this, 0 );
56 sm->setMapping(a, 2 ); 56 sm->setMapping(a, 2 );
57 connect(a, SIGNAL(activated() ), 57 connect(a, SIGNAL(activated() ),
58 sm, SLOT(map() ) ); 58 sm, SLOT(map() ) );
59 a->addTo( menu ); 59 a->addTo( menu );
60 60
61 a = new QAction( tr("Show Details More"), Resource::loadPixmap("zoom"), 61 a = new QAction( tr("Show Details More"), Opie::Core::OResource::loadPixmap("zoom", Opie::Core::OResource::SmallIcon),
62 QString::null, 0, this, 0 ); 62 QString::null, 0, this, 0 );
63 sm->setMapping(a, 3 ); 63 sm->setMapping(a, 3 );
64 connect(a, SIGNAL(activated() ), 64 connect(a, SIGNAL(activated() ),
65 sm, SLOT(map() ) ); 65 sm, SLOT(map() ) );
66 a->addTo( menu ); 66 a->addTo( menu );
67 67
68 a = new QAction( tr("Show Details All"), Resource::loadPixmap("zoom"), 68 a = new QAction( tr("Show Details All"), Opie::Core::OResource::loadPixmap("zoom", Opie::Core::OResource::SmallIcon),
69 QString::null, 0, this, 0 ); 69 QString::null, 0, this, 0 );
70 sm->setMapping(a, 4 ); 70 sm->setMapping(a, 4 );
71 connect(a, SIGNAL(activated() ), 71 connect(a, SIGNAL(activated() ),
72 sm, SLOT(map() ) ); 72 sm, SLOT(map() ) );
73 73
74 bar->insertItem( tr("Actions"), menu ); 74 bar->insertItem( tr("Actions"), menu );
75 75
76 /* now the gui */ 76 /* now the gui */
77 77
78 /* first widget, main widget */ 78 /* first widget, main widget */
79 QWidget * wid = new QWidget( m_stack ); 79 QWidget * wid = new QWidget( m_stack );
80 QGridLayout *grid = new QGridLayout(wid, 2, 2 ); 80 QGridLayout *grid = new QGridLayout(wid, 2, 2 );
81 81
82 QPushButton *btn = new QPushButton( tr("Show Details Small"), wid, "details1" ); 82 QPushButton *btn = new QPushButton( tr("Show Details Small"), wid, "details1" );
83 sm->setMapping(btn, 2 ); 83 sm->setMapping(btn, 2 );
84 connect(btn, SIGNAL(clicked()), sm, SLOT(map() ) ); 84 connect(btn, SIGNAL(clicked()), sm, SLOT(map() ) );
85 grid->addWidget( btn, 0, 0 ); 85 grid->addWidget( btn, 0, 0 );
86 86
87 btn = new QPushButton( tr("Show Details Medium"), wid, "details2"); 87 btn = new QPushButton( tr("Show Details Medium"), wid, "details2");
88 sm->setMapping(btn, 3 ); 88 sm->setMapping(btn, 3 );
89 connect(btn, SIGNAL(clicked()), sm, SLOT(map() ) ); 89 connect(btn, SIGNAL(clicked()), sm, SLOT(map() ) );
90 grid->addWidget( btn, 0, 1 ); 90 grid->addWidget( btn, 0, 1 );
91 91
92 btn = new QPushButton( tr("Show Details All"), wid, "details3"); 92 btn = new QPushButton( tr("Show Details All"), wid, "details3");
93 sm->setMapping(btn, 4 ); 93 sm->setMapping(btn, 4 );
94 connect(btn, SIGNAL(clicked()), sm, SLOT(map() ) ); 94 connect(btn, SIGNAL(clicked()), sm, SLOT(map() ) );
95 grid->addWidget( btn, 1, 1 ); 95 grid->addWidget( btn, 1, 1 );
96 96
97 m_stack->addWidget( wid, 1 ); 97 m_stack->addWidget( wid, 1 );
98 m_main = wid; 98 m_main = wid;
99 99
100 QLabel *lbl = new QLabel(m_stack ); 100 QLabel *lbl = new QLabel(m_stack );
101 lbl->setText(tr("Only small Details are shown here. Määh") ); 101 lbl->setText(tr("Only small Details are shown here. M�h") );
102 m_stack->addWidget( lbl, 2 ); 102 m_stack->addWidget( lbl, 2 );
103 103
104 lbl = new QLabel( m_stack ); 104 lbl = new QLabel( m_stack );
105 lbl->setText( tr("Some more details....Wo ist das Schaf?") ); 105 lbl->setText( tr("Some more details....Wo ist das Schaf?") );
106 m_stack->addWidget( lbl, 3 ); 106 m_stack->addWidget( lbl, 3 );
107 107
108 lbl = new QLabel( m_stack ); 108 lbl = new QLabel( m_stack );
109 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") ); 109 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 Sd,weiss du, verstehst du? ;)<br>Susi ist dOOf, es lebe die Ofenecke...", "hard to translate that") );
110 m_stack->addWidget( lbl, 4 ); 110 m_stack->addWidget( lbl, 4 );
111 111
112 112
113 /* THE signal mapper does all the magic */ 113 /* THE signal mapper does all the magic */
114 m_stack->raiseWidget( m_main ); 114 m_stack->raiseWidget( m_main );
115} 115}
116 116
117 117
118StackExample::~StackExample() { 118StackExample::~StackExample() {
119 119
120} 120}
121 121
122 122
123 123
124void StackExample::closeEvent( QCloseEvent* ev) { 124void StackExample::closeEvent( QCloseEvent* ev) {
125 /* if the close even came when we displayed a details */ 125 /* if the close even came when we displayed a details */
126 if (m_stack->visibleWidget() != m_main ) { 126 if (m_stack->visibleWidget() != m_main ) {
127 m_stack->raiseWidget( m_main ); 127 m_stack->raiseWidget( m_main );
128 ev->ignore(); 128 ev->ignore();
129 return; 129 return;
130 } 130 }
131 131
132 ev->accept(); 132 ev->accept();
133} 133}
diff --git a/examples/opieui/owidgetstack_example/owidgetstack_example.pro b/examples/opieui/owidgetstack_example/owidgetstack_example.pro
index 4cfce9c..8960f03 100644
--- a/examples/opieui/owidgetstack_example/owidgetstack_example.pro
+++ b/examples/opieui/owidgetstack_example/owidgetstack_example.pro
@@ -1,13 +1,13 @@
1CONFIG += qt warn_on 1CONFIG += qt warn_on
2TEMPLATE = app 2TEMPLATE = app
3TARGET = owidgetstack-example 3TARGET = owidgetstack-example
4 4
5SOURCES = owidgetstack_example.cpp 5SOURCES = owidgetstack_example.cpp
6HEADERS = owidgetstack_example.h 6HEADERS = owidgetstack_example.h
7 7
8INCLUDEPATH += $(OPIEDIR)/include 8INCLUDEPATH += $(OPIEDIR)/include
9DEPENDSPATH += $(OPIEDIR)/include 9DEPENDSPATH += $(OPIEDIR)/include
10 10
11LIBS += -lqpe -lopieui2 11LIBS += -lqpe -lopiecore2 -lopieui2
12 12
13include( $(OPIEDIR)/include.pro ) 13include( $(OPIEDIR)/include.pro )
diff --git a/examples/simple-icon/config.in b/examples/simple-icon/config.in
index ec5e1ee..f0f9181 100644
--- a/examples/simple-icon/config.in
+++ b/examples/simple-icon/config.in
@@ -1,4 +1,4 @@
1 config SIMPLE_ICON 1 config SIMPLE_ICON
2 boolean "Simples Widget which loads Pixmaps and plays sound" 2 boolean "Simples Widget which loads Pixmaps and plays sound"
3 default "y" 3 default "y"
4 depends ( LIBQPE || LIBQPE-X11 ) && EXAMPLES 4 depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && EXAMPLES
diff --git a/examples/simple-icon/opie-simple.control b/examples/simple-icon/opie-simple.control
index 5adcf01..5e326ab 100644
--- a/examples/simple-icon/opie-simple.control
+++ b/examples/simple-icon/opie-simple.control
@@ -1,9 +1,9 @@
1Package: opie-simple-icon-example 1Package: opie-simple-icon-example
2Files: bin/simple-icon apps/Examples/simple-icon.desktop 2Files: bin/simple-icon apps/Examples/simple-icon.desktop
3Priority: optional 3Priority: optional
4Section: opie/examples 4Section: opie/examples
5Maintainer: Holger 'zecke' Freyther <zecke@handhelds.org> 5Maintainer: Holger 'zecke' Freyther <zecke@handhelds.org>
6Architecture: arm 6Architecture: arm
7Depends: task-opie-minimal, opie-pics 7Depends: task-opie-minimal, libopiecore2, opie-pics
8Description: A simple icon example 8Description: A simple icon example
9Version: $QPE_VERSION$EXTRAVERSION 9Version: $QPE_VERSION$EXTRAVERSION
diff --git a/examples/simple-icon/simple.cpp b/examples/simple-icon/simple.cpp
index fec1823..2c98ec0 100644
--- a/examples/simple-icon/simple.cpp
+++ b/examples/simple-icon/simple.cpp
@@ -1,100 +1,99 @@
1#include <qlabel.h> // a label 1#include <qlabel.h> // a label
2#include <qpushbutton.h> // the header file for the QPushButton 2#include <qpushbutton.h> // the header file for the QPushButton
3#include <qlayout.h> 3#include <qlayout.h>
4 4
5#include <qpe/qpeapplication.h> // the QPEApplication 5#include <qpe/qpeapplication.h> // the QPEApplication
6#include <qpe/resource.h> // for loading icon
7#include <qpe/sound.h> // for playing a sound 6#include <qpe/sound.h> // for playing a sound
8 7
9#include <opie2/oapplicationfactory.h> // a template + macro to save the main method and allow quick launching 8#include <opie2/oapplicationfactory.h> // a template + macro to save the main method and allow quick launching
10 9#include <opie2/oresource.h> // for loading icon
11#include "simple.h" 10#include "simple.h"
12 11
13/* 12/*
14 * implementation of simple 13 * implementation of simple
15 */ 14 */
16 15
17/* 16/*
18 * The factory is used for quicklaunching 17 * The factory is used for quicklaunching
19 * 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 18 * 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
20 * 19 *
21 * Depending on the global quick launch setting this will create 20 * Depending on the global quick launch setting this will create
22 * either a main method or one for our component plugin system 21 * either a main method or one for our component plugin system
23 */ 22 */
24using namespace Opie::Core; 23using namespace Opie::Core;
25OPIE_EXPORT_APP( OApplicationFactory<Simple> ) 24OPIE_EXPORT_APP( OApplicationFactory<Simple> )
26 25
27Simple::Simple( QWidget* parent, const char* name, WFlags fl ) 26Simple::Simple( QWidget* parent, const char* name, WFlags fl )
28 : QWidget( parent, name, fl ) { 27 : QWidget( parent, name, fl ) {
29 28
30 /* 29 /*
31 * sets the caption of this toplevel widget 30 * sets the caption of this toplevel widget
32 * put all translatable string into tr() 31 * put all translatable string into tr()
33 */ 32 */
34 setCaption(tr("My Simple Application") ); 33 setCaption(tr("My Simple Application") );
35 34
36 /* 35 /*
37 * A simple vertical layout 36 * A simple vertical layout
38 * either call layout->setAutoAdd( true ) 37 * either call layout->setAutoAdd( true )
39 * or use layout->addWidget( wid ) to add widgets 38 * or use layout->addWidget( wid ) to add widgets
40 */ 39 */
41 QVBoxLayout *layout = new QVBoxLayout( this ); 40 QVBoxLayout *layout = new QVBoxLayout( this );
42 layout->setSpacing( 8 ); 41 layout->setSpacing( 8 );
43 layout->setMargin( 11 ); 42 layout->setMargin( 11 );
44 43
45 /* 44 /*
46 * creates a label 45 * creates a label
47 * The first parameter is this widget so the Label is a child 46 * The first parameter is this widget so the Label is a child
48 * of us and will be deleted when we're deleted. 47 * of us and will be deleted when we're deleted.
49 */ 48 */
50 QLabel *lbl = new QLabel( this, "a name for the label" ); 49 QLabel *lbl = new QLabel( this, "a name for the label" );
51 /* 50 /*
52 * Resource will search hard for a Pixmap in $OPIEDIR/pics 51 * Resource will search hard for a Pixmap in $OPIEDIR/pics
53 * to find 'logo/opielogo' You need to pass the subdir 52 * to find 'logo/opielogo' You need to pass the subdir
54 * but not the ending 53 * but not the ending
55 */ 54 */
56 lbl->setPixmap( Resource::loadPixmap("logo/opielogo") ); 55 lbl->setPixmap( Opie::Core::OResource::loadPixmap("logo/opielogo", Opie::Core::OResource::SmallIcon) );
57 layout->addWidget( lbl ); 56 layout->addWidget( lbl );
58 57
59 58
60 /* creates a button as child of this widget */ 59 /* creates a button as child of this widget */
61 m_button = new QPushButton(this); 60 m_button = new QPushButton(this);
62 /* 61 /*
63 * another way to call tr. The first parameter is the string 62 * another way to call tr. The first parameter is the string
64 * to translate and the second a hint to the translator 63 * to translate and the second a hint to the translator
65 */ 64 */
66 m_button->setText( tr("Fire", "translatable fire string" ) ); 65 m_button->setText( tr("Fire", "translatable fire string" ) );
67 layout->addWidget( m_button ); 66 layout->addWidget( m_button );
68 67
69 /* 68 /*
70 * Now we bring the action into it. The power of qt is the dynamic 69 * Now we bring the action into it. The power of qt is the dynamic
71 * signal and slots model 70 * signal and slots model
72 * Usage is simple connect m_buttons clicked signal to our 71 * Usage is simple connect m_buttons clicked signal to our
73 * slotQuit slot. 72 * slotQuit slot.
74 * We could also have connected a SIGNAL to a SIGNAL or the clicked 73 * We could also have connected a SIGNAL to a SIGNAL or the clicked
75 * signal directly to qApp and SLOT(quit() ) 74 * signal directly to qApp and SLOT(quit() )
76 */ 75 */
77 connect( m_button, SIGNAL(clicked() ), 76 connect( m_button, SIGNAL(clicked() ),
78 this, SLOT( slotQuit() ) ); 77 this, SLOT( slotQuit() ) );
79} 78}
80 79
81/* 80/*
82 * Our destructor is empty because all child 81 * Our destructor is empty because all child
83 * widgets and layouts will be deleted by Qt. 82 * widgets and layouts will be deleted by Qt.
84 * Same applies to QObjects 83 * Same applies to QObjects
85 */ 84 */
86Simple::~Simple() { 85Simple::~Simple() {
87 86
88} 87}
89 88
90void Simple::slotQuit() { 89void Simple::slotQuit() {
91 /* 90 /*
92 * We will fire up a sound 91 * We will fire up a sound
93 * Note that Sound will use Resource as well 92 * Note that Sound will use Resource as well
94 * and we do not need to supply an ending 93 * and we do not need to supply an ending
95 * sounds are found in $OPIEDIR/sounds 94 * sounds are found in $OPIEDIR/sounds
96 */ 95 */
97 Sound snd("hit_target01"); 96 Sound snd("hit_target01");
98 snd.play(); 97 snd.play();
99 98
100} 99}
diff --git a/examples/simple-main/config.in b/examples/simple-main/config.in
index 57cf603..bc509ea 100644
--- a/examples/simple-main/config.in
+++ b/examples/simple-main/config.in
@@ -1,4 +1,4 @@
1 config SIMPLE_MAIN 1 config SIMPLE_MAIN
2 boolean "Simple Mainwindow with Actions buttons and iconsets" 2 boolean "Simple Mainwindow with Actions buttons and iconsets"
3 default "y" 3 default "y"
4 depends ( LIBQPE || LIBQPE-X11 ) && EXAMPLES 4 depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && EXAMPLES
diff --git a/examples/simple-main/opie-simple.control b/examples/simple-main/opie-simple.control
index 331b2f4..3cde394 100644
--- a/examples/simple-main/opie-simple.control
+++ b/examples/simple-main/opie-simple.control
@@ -1,9 +1,9 @@
1Package: opie-simple-main-example 1Package: opie-simple-main-example
2Files: bin/simple-main apps/Examples/simple-main.desktop 2Files: bin/simple-main apps/Examples/simple-main.desktop
3Priority: optional 3Priority: optional
4Section: opie/examples 4Section: opie/examples
5Maintainer: Holger 'zecke' Freyther <zecke@handhelds.org> 5Maintainer: Holger 'zecke' Freyther <zecke@handhelds.org>
6Architecture: arm 6Architecture: arm
7Depends: task-opie-minimal, opie-pics 7Depends: task-opie-minimal, libopiecore2, opie-pics
8Description: A simple example 8Description: A simple example
9Version: $QPE_VERSION$EXTRAVERSION 9Version: $QPE_VERSION$EXTRAVERSION
diff --git a/examples/simple-main/simple.cpp b/examples/simple-main/simple.cpp
index cf00cc6..b227a1f 100644
--- a/examples/simple-main/simple.cpp
+++ b/examples/simple-main/simple.cpp
@@ -1,219 +1,219 @@
1#include <qaction.h> // action 1#include <qaction.h> // action
2#include <qmenubar.h> // menubar 2#include <qmenubar.h> // menubar
3#include <qtoolbar.h> // toolbar 3#include <qtoolbar.h> // toolbar
4#include <qlabel.h> // a label 4#include <qlabel.h> // a label
5#include <qpushbutton.h> // the header file for the QPushButton 5#include <qpushbutton.h> // the header file for the QPushButton
6#include <qlayout.h> 6#include <qlayout.h>
7 7
8#include <qpe/qpeapplication.h> // the QPEApplication 8#include <qpe/qpeapplication.h> // the QPEApplication
9#include <qpe/resource.h>
10 9
11#include <opie2/oapplicationfactory.h> // a template + macro to save the main method and allow quick launching 10#include <opie2/oapplicationfactory.h> // a template + macro to save the main method and allow quick launching
11#include <opie2/oresource.h>
12 12
13#include "simple.h" 13#include "simple.h"
14 14
15/* 15/*
16 * implementation of simple 16 * implementation of simple
17 */ 17 */
18 18
19/* 19/*
20 * The factory is used for quicklaunching 20 * The factory is used for quicklaunching
21 * 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 21 * 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
22 * 22 *
23 * Depending on the global quick launch setting this will create 23 * Depending on the global quick launch setting this will create
24 * either a main method or one for our component plugin system 24 * either a main method or one for our component plugin system
25 */ 25 */
26 26
27using namespace Opie::Core; 27using namespace Opie::Core;
28OPIE_EXPORT_APP( OApplicationFactory<MainWindow> ) 28OPIE_EXPORT_APP( OApplicationFactory<MainWindow> )
29 29
30MainWindow::MainWindow(QWidget *parent, const char* name, WFlags fl ) 30MainWindow::MainWindow(QWidget *parent, const char* name, WFlags fl )
31 : QMainWindow( parent, name, fl ) { 31 : QMainWindow( parent, name, fl ) {
32 setCaption(tr("My MainWindow") ); 32 setCaption(tr("My MainWindow") );
33 setIcon( Resource::loadPixmap("new") ); 33 setIcon( Opie::Core::OResource::loadPixmap("new", Opie::Core::OResource::SmallIcon) );
34 /* 34 /*
35 * out mainwindow should have a menubar 35 * out mainwindow should have a menubar
36 * a toolbar, a mainwidget and use Resource 36 * a toolbar, a mainwidget and use Resource
37 * to get the IconSets 37 * to get the IconSets
38 */ 38 */
39 /* 39 /*
40 * we initialize the GUI in a different methid 40 * we initialize the GUI in a different methid
41 */ 41 */
42 initUI(); 42 initUI();
43 43
44 Simple *simple = new Simple( this ); 44 Simple *simple = new Simple( this );
45 setCentralWidget( simple ); 45 setCentralWidget( simple );
46 46
47 /* 47 /*
48 * If you use signal and slots do not include the parameter 48 * If you use signal and slots do not include the parameter
49 * names inside 49 * names inside
50 * so SIGNAL(fooBar(int) ) and NOT SIGNAL(fooBar(int foo) ) 50 * so SIGNAL(fooBar(int) ) and NOT SIGNAL(fooBar(int foo) )
51 */ 51 */
52 /* 52 /*
53 * We connect the activation of our QAction 53 * We connect the activation of our QAction
54 * to the slot connected to the firebutton 54 * to the slot connected to the firebutton
55 * We could also connect the signal to the clicked 55 * We could also connect the signal to the clicked
56 * signal of the button 56 * signal of the button
57 */ 57 */
58 connect(m_fire, SIGNAL(activated() ), 58 connect(m_fire, SIGNAL(activated() ),
59 simple, SLOT(slotFire() ) ); 59 simple, SLOT(slotFire() ) );
60} 60}
61 61
62MainWindow::~MainWindow() { 62MainWindow::~MainWindow() {
63 // again nothing to delete because Qt takes care 63 // again nothing to delete because Qt takes care
64} 64}
65 65
66/* 66/*
67 * set Document is a special function used by Document 67 * set Document is a special function used by Document
68 * centric applications. 68 * centric applications.
69 * In example if Opie receives a Todo via IrDa it uses 69 * In example if Opie receives a Todo via IrDa it uses
70 * setDocument via QCOP the IPC system to load the card 70 * setDocument via QCOP the IPC system to load the card
71 * Or If you decide to open a file in filemanager with textedit 71 * Or If you decide to open a file in filemanager with textedit
72 * setDocument is called via IPC in textedit. 72 * setDocument is called via IPC in textedit.
73 * Also any call to QPE/Application/xyz and xyz is currently not running 73 * Also any call to QPE/Application/xyz and xyz is currently not running
74 * leads to the start of xyz and delivering of the QCOP call 74 * leads to the start of xyz and delivering of the QCOP call
75 * But more on QCOP in the next application 75 * But more on QCOP in the next application
76 */ 76 */
77void MainWindow::setDocument( const QString& /*str*/ ) { 77void MainWindow::setDocument( const QString& /*str*/ ) {
78 // in our case empty but you should see if it is a direct 78 // in our case empty but you should see if it is a direct
79 // file request or if it is a DocLnk. 79 // file request or if it is a DocLnk.
80 // A DocLnk is Link to an Document so you would end up 80 // A DocLnk is Link to an Document so you would end up
81 // opening the document behind the file you got 81 // opening the document behind the file you got
82} 82}
83 83
84/* 84/*
85 * Two new concepts with this Method 85 * Two new concepts with this Method
86 * 1. QAction. An action can be grouped and emits 86 * 1. QAction. An action can be grouped and emits
87 * an activated signal. Action a universal useable 87 * an activated signal. Action a universal useable
88 * you can just plug/addTo in most Qt widgets. For example 88 * you can just plug/addTo in most Qt widgets. For example
89 * the same action can be plugged into a ToolBar, MenuBar, 89 * the same action can be plugged into a ToolBar, MenuBar,
90 * QPopupMenu and other widgets but you do not need to worry 90 * QPopupMenu and other widgets but you do not need to worry
91 * about it 91 * about it
92 * 92 *
93 * 2. an IconSet contains pixmaps and provides them scaled down, scaled up 93 * 2. an IconSet contains pixmaps and provides them scaled down, scaled up
94 * enabled and disabled. SO if you use QIConSet and the toolbar 94 * enabled and disabled. SO if you use QIConSet and the toolbar
95 * size changes to use big pixmaps you will not use upscaled icons 95 * size changes to use big pixmaps you will not use upscaled icons
96 * but the right ones thanks to QIconSet and Resource 96 * but the right ones thanks to QIconSet and Resource
97 */ 97 */
98 98
99void MainWindow::initUI() { 99void MainWindow::initUI() {
100/* 100/*
101 * We want to provde a File Menu with Quit as option 101 * We want to provde a File Menu with Quit as option
102 * and a Fire Toolbutton ( QAction ) 102 * and a Fire Toolbutton ( QAction )
103 * So we need two actions 103 * So we need two actions
104 * A toolbar and a popupMenu 104 * A toolbar and a popupMenu
105 */ 105 */
106 setToolBarsMovable( false ); 106 setToolBarsMovable( false );
107 /* 107 /*
108 *We don't want the static toolbar but share it with the 108 *We don't want the static toolbar but share it with the
109 * toolbar on small screens 109 * toolbar on small screens
110 */ 110 */
111 QToolBar *menuBarHolder = new QToolBar( this ); 111 QToolBar *menuBarHolder = new QToolBar( this );
112 /* we allow the menubarholder to become bigger than 112 /* we allow the menubarholder to become bigger than
113 * the screen width and to offer a > for the additional items 113 * the screen width and to offer a > for the additional items
114 */ 114 */
115 menuBarHolder->setHorizontalStretchable( true ); 115 menuBarHolder->setHorizontalStretchable( true );
116 QMenuBar *mb = new QMenuBar( menuBarHolder ); 116 QMenuBar *mb = new QMenuBar( menuBarHolder );
117 QToolBar *tb = new QToolBar( this ); 117 QToolBar *tb = new QToolBar( this );
118 118
119 QPopupMenu *fileMenu = new QPopupMenu( this ); 119 QPopupMenu *fileMenu = new QPopupMenu( this );
120 120
121 /* 121 /*
122 * we create our first action with the Text Quit 122 * we create our first action with the Text Quit
123 * a IconSet, no menu name, no acceleration ( keyboard shortcut ), 123 * a IconSet, no menu name, no acceleration ( keyboard shortcut ),
124 * with parent this, and name "quit_action" 124 * with parent this, and name "quit_action"
125 */ 125 */
126 /* 126 /*
127 * Note if you want a picture out of the inline directory 127 * Note if you want a picture out of the inline directory
128 * you musn't prefix inline/ inline means these pics are built in 128 * you musn't prefix inline/ inline means these pics are built in
129 * into libqpe so the name without ending and directory is enough 129 * into libqpe so the name without ending and directory is enough
130 */ 130 */
131 QAction *a = new QAction( tr("Quit"), Resource::loadIconSet("quit_icon"), 131 QAction *a = new QAction( tr("Quit"), Opie::Core::OResource::loadPixmap("quit_icon", Opie::Core::OResource::SmallIcon),
132 QString::null, 0, this, "quit_action" ); 132 QString::null, 0, this, "quit_action" );
133 /* 133 /*
134 * Connect quit to the QApplication quit slot 134 * Connect quit to the QApplication quit slot
135 */ 135 */
136 connect(a, SIGNAL(activated() ), 136 connect(a, SIGNAL(activated() ),
137 qApp, SLOT(quit() ) ); 137 qApp, SLOT(quit() ) );
138 a->addTo( fileMenu ); 138 a->addTo( fileMenu );
139 139
140 a = new QAction(tr("Fire"), 140 a = new QAction(tr("Fire"),
141 Resource::loadIconSet("new"), 141 Opie::Core::OResource::loadPixmap("new", Opie::Core::OResource::SmallIcon),
142 QString::null, 0, this, "fire_button"); 142 QString::null, 0, this, "fire_button");
143 143
144 /* see the power? */ 144 /* see the power? */
145 a->addTo( fileMenu ); 145 a->addTo( fileMenu );
146 a->addTo( tb ); 146 a->addTo( tb );
147 m_fire = a; 147 m_fire = a;
148 148
149 149
150 mb->insertItem(tr("File"), fileMenu ); 150 mb->insertItem(tr("File"), fileMenu );
151 151
152} 152}
153 153
154Simple::Simple( QWidget* parent, const char* name, WFlags fl ) 154Simple::Simple( QWidget* parent, const char* name, WFlags fl )
155 : QWidget( parent, name, fl ) { 155 : QWidget( parent, name, fl ) {
156 156
157 /* 157 /*
158 * sets the caption of this toplevel widget 158 * sets the caption of this toplevel widget
159 * put all translatable string into tr() 159 * put all translatable string into tr()
160 */ 160 */
161 setCaption(tr("My Simple Application") ); 161 setCaption(tr("My Simple Application") );
162 162
163 /* 163 /*
164 * A simple vertical layout 164 * A simple vertical layout
165 * either call layout->setAutoAdd( true ) 165 * either call layout->setAutoAdd( true )
166 * or use layout->addWidget( wid ) to add widgets 166 * or use layout->addWidget( wid ) to add widgets
167 */ 167 */
168 QVBoxLayout *layout = new QVBoxLayout( this ); 168 QVBoxLayout *layout = new QVBoxLayout( this );
169 layout->setSpacing( 8 ); 169 layout->setSpacing( 8 );
170 layout->setMargin( 11 ); 170 layout->setMargin( 11 );
171 171
172 /* 172 /*
173 * creates a label 173 * creates a label
174 * The first parameter is this widget so the Label is a child 174 * The first parameter is this widget so the Label is a child
175 * of us and will be deleted when we're deleted. 175 * of us and will be deleted when we're deleted.
176 */ 176 */
177 QLabel *lbl = new QLabel( this, "a name for the label" ); 177 QLabel *lbl = new QLabel( this, "a name for the label" );
178 lbl->setText( tr("Click on the button or follow the white rabbit") ); 178 lbl->setText( tr("Click on the button or follow the white rabbit") );
179 layout->addWidget( lbl ); 179 layout->addWidget( lbl );
180 180
181 181
182 /* creates a button as child of this widget */ 182 /* creates a button as child of this widget */
183 m_button = new QPushButton(this); 183 m_button = new QPushButton(this);
184 /* 184 /*
185 * another way to call tr. The first parameter is the string 185 * another way to call tr. The first parameter is the string
186 * to translate and the second a hint to the translator 186 * to translate and the second a hint to the translator
187 */ 187 */
188 m_button->setText( tr("Fire", "translatable quit string" ) ); 188 m_button->setText( tr("Fire", "translatable quit string" ) );
189 layout->addWidget( m_button ); 189 layout->addWidget( m_button );
190 190
191 /* 191 /*
192 * Now we bring the action into it. The power of qt is the dynamic 192 * Now we bring the action into it. The power of qt is the dynamic
193 * signal and slots model 193 * signal and slots model
194 * Usage is simple connect m_buttons clicked signal to our 194 * Usage is simple connect m_buttons clicked signal to our
195 * slotQuit slot. 195 * slotQuit slot.
196 * We could also have connected a SIGNAL to a SIGNAL or the clicked 196 * We could also have connected a SIGNAL to a SIGNAL or the clicked
197 * signal directly to qApp and SLOT(quit() ) 197 * signal directly to qApp and SLOT(quit() )
198 */ 198 */
199 connect( m_button, SIGNAL(clicked() ), 199 connect( m_button, SIGNAL(clicked() ),
200 this, SLOT( slotFire() ) ); 200 this, SLOT( slotFire() ) );
201} 201}
202 202
203/* 203/*
204 * Our destructor is empty because all child 204 * Our destructor is empty because all child
205 * widgets and layouts will be deleted by Qt. 205 * widgets and layouts will be deleted by Qt.
206 * Same applies to QObjects 206 * Same applies to QObjects
207 */ 207 */
208Simple::~Simple() { 208Simple::~Simple() {
209 209
210} 210}
211 211
212void Simple::slotFire() { 212void Simple::slotFire() {
213 /* 213 /*
214 * NOTE: Simple is now a child window of MainWindow 214 * NOTE: Simple is now a child window of MainWindow
215 * close will hide() Simple and not delete it. But as 215 * close will hide() Simple and not delete it. But as
216 * the mainwindow is shown all children will be shown as well 216 * the mainwindow is shown all children will be shown as well
217 */ 217 */
218 close(); 218 close();
219} 219}
diff --git a/examples/simple-pim/opie-simple.control b/examples/simple-pim/opie-simple.control
index 1b54f91..80ad85b 100644
--- a/examples/simple-pim/opie-simple.control
+++ b/examples/simple-pim/opie-simple.control
@@ -1,9 +1,9 @@
1Package: opie-simple-pim-example 1Package: opie-simple-pim-example
2Files: bin/main-tab apps/Examples/main-tab.desktop 2Files: bin/main-tab apps/Examples/main-tab.desktop
3Priority: optional 3Priority: optional
4Section: opie/examples 4Section: opie/examples
5Maintainer: Holger 'zecke' Freyther <zecke@handhelds.org> 5Maintainer: Holger 'zecke' Freyther <zecke@handhelds.org>
6Architecture: arm 6Architecture: arm
7Depends: task-opie-minimal, opie-pics 7Depends: task-opie-minimal, libopiecore2, libopieui2, libopiepim2, opie-pics
8Description: A simple example 8Description: A simple example
9Version: $QPE_VERSION$EXTRAVERSION 9Version: $QPE_VERSION$EXTRAVERSION
diff --git a/examples/simple-pim/simple.cpp b/examples/simple-pim/simple.cpp
index 00c5600..6019d04 100644
--- a/examples/simple-pim/simple.cpp
+++ b/examples/simple-pim/simple.cpp
@@ -1,461 +1,461 @@
1/* We use a sane order of include files, from the most special to the least special 1/* We use a sane order of include files, from the most special to the least special
2 That helps to reduce the number of implicit includes hence increases the reuse */ 2 That helps to reduce the number of implicit includes hence increases the reuse */
3 3
4/* First the local include files */ 4/* First the local include files */
5#include "simple.h" 5#include "simple.h"
6 6
7/* Then the Ope include files. 7/* Then the Ope include files.
8This includes qpe stuff which will eventually be merged with libopie2 */ 8This includes qpe stuff which will eventually be merged with libopie2 */
9#include <opie2/odebug.h> // for odebug streams 9#include <opie2/odebug.h> // for odebug streams
10#include <opie2/oapplicationfactory.h> // a template + macro to save the main method and allow quick launching 10#include <opie2/oapplicationfactory.h> // a template + macro to save the main method and allow quick launching
11#include <opie2/oresource.h>
11#include <opie2/otabwidget.h> 12#include <opie2/otabwidget.h>
12#include <opie2/owait.h> 13#include <opie2/owait.h>
13#include <qpe/qpeapplication.h> // the QPEApplication 14#include <qpe/qpeapplication.h> // the QPEApplication
14#include <qpe/resource.h>
15#include <qpe/sound.h> 15#include <qpe/sound.h>
16#include <qpe/qcopenvelope_qws.h> 16#include <qpe/qcopenvelope_qws.h>
17#include <qpe/datebookmonth.h> 17#include <qpe/datebookmonth.h>
18#include <qpe/timestring.h> 18#include <qpe/timestring.h>
19using namespace Opie::Core; 19using namespace Opie::Core;
20 20
21/* Now the Qt includes */ 21/* Now the Qt includes */
22#include <qaction.h> // action 22#include <qaction.h> // action
23#include <qmenubar.h> // menubar 23#include <qmenubar.h> // menubar
24#include <qtoolbar.h> // toolbar 24#include <qtoolbar.h> // toolbar
25#include <qlabel.h> // a label 25#include <qlabel.h> // a label
26#include <qpushbutton.h> // the header file for the QPushButton 26#include <qpushbutton.h> // the header file for the QPushButton
27#include <qlayout.h> 27#include <qlayout.h>
28#include <qtimer.h> // we use it for the singleShot 28#include <qtimer.h> // we use it for the singleShot
29#include <qdatetime.h> // for QDate 29#include <qdatetime.h> // for QDate
30#include <qtextview.h> // a rich text widget 30#include <qtextview.h> // a rich text widget
31#include <qdialog.h> 31#include <qdialog.h>
32#include <qwhatsthis.h> // for whats this 32#include <qwhatsthis.h> // for whats this
33 33
34/* Add standard includes here if you need some 34/* Add standard includes here if you need some
35 Examples are: stdlib.h, socket.h, etc. */ 35 Examples are: stdlib.h, socket.h, etc. */
36 36
37/* 37/*
38 * implementation of simple 38 * implementation of simple
39 */ 39 */
40 40
41/* 41/*
42 * The factory is used for quicklaunching 42 * The factory is used for quicklaunching
43 * 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 43 * 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
44 * 44 *
45 * Depending on the global quick launch setting this will create 45 * Depending on the global quick launch setting this will create
46 * either a main method or one for our component plugin system 46 * either a main method or one for our component plugin system
47 */ 47 */
48 48
49OPIE_EXPORT_APP( OApplicationFactory<MainWindow> ) 49OPIE_EXPORT_APP( OApplicationFactory<MainWindow> )
50 50
51MainWindow::MainWindow(QWidget *parent, const char* name, WFlags fl ) 51MainWindow::MainWindow(QWidget *parent, const char* name, WFlags fl )
52 : QMainWindow( parent, name, fl ) { 52 : QMainWindow( parent, name, fl ) {
53 setCaption(tr("My MainWindow") ); 53 setCaption(tr("My MainWindow") );
54 54
55 m_desktopChannel = 0; 55 m_desktopChannel = 0;
56 m_loading = 0; 56 m_loading = 0;
57 57
58 initUI(); 58 initUI();
59 59
60 60
61 /* 61 /*
62 * Tab widget as central 62 * Tab widget as central
63 */ 63 */
64 m_tab = new Opie::Ui::OTabWidget(this); 64 m_tab = new Opie::Ui::OTabWidget(this);
65 65
66 setCentralWidget( m_tab ); 66 setCentralWidget( m_tab );
67 67
68 m_todoView = new PIMListView(m_tab, "Todo view" ); 68 m_todoView = new PIMListView(m_tab, "Todo view" );
69 m_tab->addTab( m_todoView,"todo/TodoList", tr("Todos") ); 69 m_tab->addTab( m_todoView,"todo/TodoList", tr("Todos") );
70 70
71 m_dateView = new PIMListView(m_tab, "Datebook view" ); 71 m_dateView = new PIMListView(m_tab, "Datebook view" );
72 m_tab->addTab( m_dateView, "datebook/DateBook", tr("Events") ); 72 m_tab->addTab( m_dateView, "datebook/DateBook", tr("Events") );
73 73
74 /* now connect the actions */ 74 /* now connect the actions */
75 /* 75 /*
76 * we connect the activated to our show 76 * we connect the activated to our show
77 * and on activation we will show a detailed 77 * and on activation we will show a detailed
78 * summary of the record 78 * summary of the record
79 */ 79 */
80 connect(m_fire, SIGNAL(activated() ), 80 connect(m_fire, SIGNAL(activated() ),
81 this, SLOT(slotShow() ) ); 81 this, SLOT(slotShow() ) );
82 82
83 /* 83 /*
84 * We will change the date 84 * We will change the date
85 */ 85 */
86 connect(m_dateAction, SIGNAL(activated() ), 86 connect(m_dateAction, SIGNAL(activated() ),
87 this, SLOT(slotDate() ) ); 87 this, SLOT(slotDate() ) );
88 88
89 /* 89 /*
90 * connect the show signal of the PIMListView 90 * connect the show signal of the PIMListView
91 * to a slot to show a dialog 91 * to a slot to show a dialog
92 */ 92 */
93 connect(m_todoView, SIGNAL(showRecord(const Opie::OPimRecord&) ), 93 connect(m_todoView, SIGNAL(showRecord(const Opie::OPimRecord&) ),
94 this, SLOT(slotShowRecord(const Opie::OPimRecord&) ) ); 94 this, SLOT(slotShowRecord(const Opie::OPimRecord&) ) );
95 connect(m_dateView, SIGNAL(showRecord(const Opie::OPimRecord&) ), 95 connect(m_dateView, SIGNAL(showRecord(const Opie::OPimRecord&) ),
96 this, SLOT(slotShowRecord(const Opie::OPimRecord&) ) ); 96 this, SLOT(slotShowRecord(const Opie::OPimRecord&) ) );
97 97
98 /* 98 /*
99 * Now comes the important lines of code for this example 99 * Now comes the important lines of code for this example
100 * We do not directly call load but delay loading until 100 * We do not directly call load but delay loading until
101 * all Events are dispatches and handled. 101 * all Events are dispatches and handled.
102 * SO we will load once our window is mapped to screen 102 * SO we will load once our window is mapped to screen
103 * to achieve that we use a QTimer::singleShot 103 * to achieve that we use a QTimer::singleShot
104 * After 10 milli seconds the timer fires and on TimerEvent 104 * After 10 milli seconds the timer fires and on TimerEvent
105 * out slot slotLoad will be called 105 * out slot slotLoad will be called
106 * Remember this a Constructor to construct your object and not 106 * Remember this a Constructor to construct your object and not
107 * to load 107 * to load
108 */ 108 */
109 QTimer::singleShot( 10, this, SLOT(slotLoad() ) ); 109 QTimer::singleShot( 10, this, SLOT(slotLoad() ) );
110} 110}
111 111
112MainWindow::~MainWindow() { 112MainWindow::~MainWindow() {
113 // again nothing to delete because Qt takes care 113 // again nothing to delete because Qt takes care
114} 114}
115 115
116 116
117void MainWindow::setDocument( const QString& /*str*/ ) { 117void MainWindow::setDocument( const QString& /*str*/ ) {
118} 118}
119 119
120 120
121void MainWindow::initUI() { 121void MainWindow::initUI() {
122 122
123 setToolBarsMovable( false ); 123 setToolBarsMovable( false );
124 124
125 QToolBar *menuBarHolder = new QToolBar( this ); 125 QToolBar *menuBarHolder = new QToolBar( this );
126 126
127 menuBarHolder->setHorizontalStretchable( true ); 127 menuBarHolder->setHorizontalStretchable( true );
128 QMenuBar *mb = new QMenuBar( menuBarHolder ); 128 QMenuBar *mb = new QMenuBar( menuBarHolder );
129 QToolBar *tb = new QToolBar( this ); 129 QToolBar *tb = new QToolBar( this );
130 130
131 QPopupMenu *fileMenu = new QPopupMenu( this ); 131 QPopupMenu *fileMenu = new QPopupMenu( this );
132 132
133 133
134 QAction *a = new QAction( tr("Quit"), Resource::loadIconSet("quit_icon"), 134 QAction *a = new QAction( tr("Quit"), Opie::Core::OResource::loadPixmap("quit_icon", Opie::Core::OResource::SmallIcon),
135 QString::null, 0, this, "quit_action" ); 135 QString::null, 0, this, "quit_action" );
136 /* 136 /*
137 * Connect quit to the QApplication quit slot 137 * Connect quit to the QApplication quit slot
138 */ 138 */
139 connect(a, SIGNAL(activated() ), 139 connect(a, SIGNAL(activated() ),
140 qApp, SLOT(quit() ) ); 140 qApp, SLOT(quit() ) );
141 a->addTo( fileMenu ); 141 a->addTo( fileMenu );
142 142
143 a = new QAction(tr("View Current"), 143 a = new QAction(tr("View Current"),
144 Resource::loadIconSet("zoom"), 144 Opie::Core::OResource::loadPixmap("zoom", Opie::Core::OResource::SmallIcon),
145 QString::null, 0, this, "view current"); 145 QString::null, 0, this, "view current");
146 /* a simple whats this online explanation of out button */ 146 /* a simple whats this online explanation of out button */
147 a->setWhatsThis(tr("Views the current record") ); 147 a->setWhatsThis(tr("Views the current record") );
148 /* or QWhatsThis::add(widget, "description" ); */ 148 /* or QWhatsThis::add(widget, "description" ); */
149 149
150 /* see the power? */ 150 /* see the power? */
151 a->addTo( fileMenu ); 151 a->addTo( fileMenu );
152 a->addTo( tb ); 152 a->addTo( tb );
153 m_fire = a; 153 m_fire = a;
154 154
155 a = new QAction(tr("Choose Date"), 155 a = new QAction(tr("Choose Date"),
156 Resource::loadIconSet("day"), 156 Opie::Core::OResource::loadPixmap("day", Opie::Core::OResource::SmallIcon),
157 QString::null, 0, this, "choose date" ); 157 QString::null, 0, this, "choose date" );
158 a->addTo( fileMenu ); 158 a->addTo( fileMenu );
159 a->addTo( tb ); 159 a->addTo( tb );
160 m_dateAction = a; 160 m_dateAction = a;
161 161
162 mb->insertItem(tr("File"), fileMenu ); 162 mb->insertItem(tr("File"), fileMenu );
163 163
164} 164}
165 165
166void MainWindow::slotLoad() { 166void MainWindow::slotLoad() {
167 /* 167 /*
168 * There is no real shared access in the PIM API 168 * There is no real shared access in the PIM API
169 * It wasn't finish cause of health problems of one 169 * It wasn't finish cause of health problems of one
170 * of the authors so we do something fancy and use QCOP 170 * of the authors so we do something fancy and use QCOP
171 * the IPC system to get a current copy 171 * the IPC system to get a current copy
172 */ 172 */
173 /* NOTES to QCOP: QCOP operates over channels and use QDataStream 173 /* NOTES to QCOP: QCOP operates over channels and use QDataStream
174 * to send data. You can check if a channel isRegistered or hook 174 * to send data. You can check if a channel isRegistered or hook
175 * yourself to that channel. A Channel is QCString and normally 175 * yourself to that channel. A Channel is QCString and normally
176 * prefix with QPE/ and then the system in example QPE/System, 176 * prefix with QPE/ and then the system in example QPE/System,
177 * QPE/Desktop a special channel is the application channel 177 * QPE/Desktop a special channel is the application channel
178 * it QPE/Application/appname this channel gets created on app 178 * it QPE/Application/appname this channel gets created on app
179 * startup by QPEApplication. QCOP is asynchronous 179 * startup by QPEApplication. QCOP is asynchronous
180 * 180 *
181 * To send you'll use QCopEnevelope 181 * To send you'll use QCopEnevelope
182 * 182 *
183 */ 183 */
184 /* 184 /*
185 * What we will do is first is get to know if either 185 * What we will do is first is get to know if either
186 * datebook or todolist are running if so we will kindly 186 * datebook or todolist are running if so we will kindly
187 * asked to save the data for us. 187 * asked to save the data for us.
188 * If neither are running we can load directly 188 * If neither are running we can load directly
189 */ 189 */
190 if (!QCopChannel::isRegistered("QPE/Application/todolist") && 190 if (!QCopChannel::isRegistered("QPE/Application/todolist") &&
191 !QCopChannel::isRegistered("QPE/Application/datebook") ) { 191 !QCopChannel::isRegistered("QPE/Application/datebook") ) {
192 m_db.load(); 192 m_db.load();
193 m_tb.load(); 193 m_tb.load();
194 return slotLoadForDay( QDate::currentDate() ); 194 return slotLoadForDay( QDate::currentDate() );
195 } 195 }
196 196
197 /* 197 /*
198 * prepare our answer machine the QCopChannel 198 * prepare our answer machine the QCopChannel
199 * QPE/Desktop will send "flushDone(QString)" when 199 * QPE/Desktop will send "flushDone(QString)" when
200 * the flush is done it emits a signal on receive 200 * the flush is done it emits a signal on receive
201 */ 201 */
202 m_desktopChannel = new QCopChannel("QPE/Desktop"); 202 m_desktopChannel = new QCopChannel("QPE/Desktop");
203 connect(m_desktopChannel, SIGNAL(received(const QCString&,const QByteArray&) ), 203 connect(m_desktopChannel, SIGNAL(received(const QCString&,const QByteArray&) ),
204 this, SLOT(slotDesktopReceive(const QCString&,const QByteArray&) ) ); 204 this, SLOT(slotDesktopReceive(const QCString&,const QByteArray&) ) );
205 /* the numberof synced channels will be set to zero */ 205 /* the numberof synced channels will be set to zero */
206 m_synced = 0; 206 m_synced = 0;
207 207
208 /* 208 /*
209 * We use {} around the QCopEnvelope because it sends its 209 * We use {} around the QCopEnvelope because it sends its
210 * data on destruction of QCopEnvelope with 210 * data on destruction of QCopEnvelope with
211 */ 211 */
212 /* check again if not present increment synced*/ 212 /* check again if not present increment synced*/
213 if ( QCopChannel::isRegistered("QPE/Application/todolist") ) { 213 if ( QCopChannel::isRegistered("QPE/Application/todolist") ) {
214 QCopEnvelope env("QPE/Application/todolist", "flush()" ); 214 QCopEnvelope env("QPE/Application/todolist", "flush()" );
215 // env << data; but we do not have any parameters here 215 // env << data; but we do not have any parameters here
216 }else 216 }else
217 m_synced++; 217 m_synced++;
218 218
219 if ( QCopChannel::isRegistered("QPE/Application/datebook") ) { 219 if ( QCopChannel::isRegistered("QPE/Application/datebook") ) {
220 QCopEnvelope env("QPE/Application/datebook", "flush()" ); 220 QCopEnvelope env("QPE/Application/datebook", "flush()" );
221 }else 221 }else
222 m_synced++; 222 m_synced++;
223 223
224 /* we will provide a wait scrren */ 224 /* we will provide a wait scrren */
225 m_loading = new Opie::Ui::OWait(this, "wait screen" ); 225 m_loading = new Opie::Ui::OWait(this, "wait screen" );
226} 226}
227 227
228void MainWindow::slotDesktopReceive(const QCString& cmd, const QByteArray& data ) { 228void MainWindow::slotDesktopReceive(const QCString& cmd, const QByteArray& data ) {
229 /* the bytearray was filled with the QDataStream now 229 /* the bytearray was filled with the QDataStream now
230 * we open it read only to get the value(s) 230 * we open it read only to get the value(s)
231 */ 231 */
232 QDataStream stream(data, IO_ReadOnly ); 232 QDataStream stream(data, IO_ReadOnly );
233 /* 233 /*
234 * we're only interested in the flushDone 234 * we're only interested in the flushDone
235 */ 235 */
236 if ( cmd == "flushDone(QString)" ) { 236 if ( cmd == "flushDone(QString)" ) {
237 QString appname; 237 QString appname;
238 stream >> appname; // get the first argument out of stream 238 stream >> appname; // get the first argument out of stream
239 if (appname == QString::fromLatin1("datebook") || 239 if (appname == QString::fromLatin1("datebook") ||
240 appname == QString::fromLatin1("todolist") ) 240 appname == QString::fromLatin1("todolist") )
241 m_synced++; 241 m_synced++;
242 } 242 }
243 243
244 /* 244 /*
245 * If we synced both we can go ahead 245 * If we synced both we can go ahead
246 * In future this is not needed anymore when we finally 246 * In future this is not needed anymore when we finally
247 * implemented X-Ref and other PIM features 247 * implemented X-Ref and other PIM features
248 */ 248 */
249 if (m_synced >= 2 ) { 249 if (m_synced >= 2 ) {
250 delete m_loading; 250 delete m_loading;
251 delete m_desktopChannel; 251 delete m_desktopChannel;
252 /* now we finally can start doing the actual loading */ 252 /* now we finally can start doing the actual loading */
253 m_tb.load(); 253 m_tb.load();
254 m_db.load(); 254 m_db.load();
255 { 255 {
256 /* tell the applications to reload */ 256 /* tell the applications to reload */
257 QCopEnvelope("QPE/Application/todolist", "reload()"); 257 QCopEnvelope("QPE/Application/todolist", "reload()");
258 QCopEnvelope("QPE/Application/datebook", "reload()"); 258 QCopEnvelope("QPE/Application/datebook", "reload()");
259 } 259 }
260 slotLoadForDay( QDate::currentDate() ); 260 slotLoadForDay( QDate::currentDate() );
261 } 261 }
262 262
263} 263}
264 264
265/* overloaded member for shortcoming of libqpe */ 265/* overloaded member for shortcoming of libqpe */
266void MainWindow::slotLoadForDay(int y, int m, int d) { 266void MainWindow::slotLoadForDay(int y, int m, int d) {
267 /* year,month, day */ 267 /* year,month, day */
268 slotLoadForDay( QDate(y, m, d ) ); 268 slotLoadForDay( QDate(y, m, d ) );
269} 269}
270 270
271void MainWindow::slotLoadForDay(const QDate& date) { 271void MainWindow::slotLoadForDay(const QDate& date) {
272 272
273 273
274 /* all todos for today including the ones without dueDate */ 274 /* all todos for today including the ones without dueDate */
275 m_todoView->set( m_tb.effectiveToDos(date, date ) ); 275 m_todoView->set( m_tb.effectiveToDos(date, date ) );
276 m_dateView->set( m_db.occurrences( date, date ) ); 276 m_dateView->set( m_db.occurrences( date, date ) );
277} 277}
278 278
279/* we want to show the current record */ 279/* we want to show the current record */
280void MainWindow::slotShow() { 280void MainWindow::slotShow() {
281 /* we only added PIMListViews so we can safely cast */ 281 /* we only added PIMListViews so we can safely cast */
282 PIMListView *view = static_cast<PIMListView*>(m_tab->currentWidget() ); 282 PIMListView *view = static_cast<PIMListView*>(m_tab->currentWidget() );
283 283
284 /* ask the view to send a signal */ 284 /* ask the view to send a signal */
285 view->showCurrentRecord(); 285 view->showCurrentRecord();
286 286
287} 287}
288 288
289/* as answer this slot will be called */ 289/* as answer this slot will be called */
290void MainWindow::slotShowRecord( const Opie::OPimRecord& rec) { 290void MainWindow::slotShowRecord( const Opie::OPimRecord& rec) {
291 /* got a parent but still is a toplevel MODAL dialog */ 291 /* got a parent but still is a toplevel MODAL dialog */
292 QDialog* dia = new QDialog(this,"dialog",TRUE ); 292 QDialog* dia = new QDialog(this,"dialog",TRUE );
293 QVBoxLayout *box = new QVBoxLayout( dia ); 293 QVBoxLayout *box = new QVBoxLayout( dia );
294 dia->setCaption( tr("View Record") ); 294 dia->setCaption( tr("View Record") );
295 295
296 296
297 QTextView *view = new QTextView(dia ); 297 QTextView *view = new QTextView(dia );
298 view->setText( rec.toRichText() ); 298 view->setText( rec.toRichText() );
299 box->addWidget( view ); 299 box->addWidget( view );
300 /* 300 /*
301 * execute via QPEApplication 301 * execute via QPEApplication
302 * this allows QPEApplication to make a sane decision 302 * this allows QPEApplication to make a sane decision
303 * on the size 303 * on the size
304 */ 304 */
305 dia->showMaximized(); 305 dia->showMaximized();
306 QPEApplication::execDialog( dia ); 306 QPEApplication::execDialog( dia );
307 delete dia; 307 delete dia;
308} 308}
309 309
310 310
311void MainWindow::slotDate() { 311void MainWindow::slotDate() {
312 /* 312 /*
313 * called by the action we will show a Popup 313 * called by the action we will show a Popup
314 * at the current mouse position with a DateChooser 314 * at the current mouse position with a DateChooser
315 * to select the day 315 * to select the day
316 */ 316 */
317 odebug << "slot Date" << oendl; 317 odebug << "slot Date" << oendl;
318 QPopupMenu *menu = new QPopupMenu(); 318 QPopupMenu *menu = new QPopupMenu();
319 /* A Month to select a date from TRUE for auto close */ 319 /* A Month to select a date from TRUE for auto close */
320 DateBookMonth *month = new DateBookMonth(menu, 0, true ); 320 DateBookMonth *month = new DateBookMonth(menu, 0, true );
321 connect(month, SIGNAL(dateClicked(int,int,int) ), 321 connect(month, SIGNAL(dateClicked(int,int,int) ),
322 this, SLOT(slotLoadForDay(int,int,int) ) ); 322 this, SLOT(slotLoadForDay(int,int,int) ) );
323 323
324 menu->insertItem( month ); 324 menu->insertItem( month );
325 325
326 menu->exec( QCursor::pos() ); 326 menu->exec( QCursor::pos() );
327 327
328 /* 328 /*
329 * we do not need to delete month because 329 * we do not need to delete month because
330 * we delete its parent menu 330 * we delete its parent menu
331 */ 331 */
332 332
333 delete menu; 333 delete menu;
334} 334}
335 335
336/* 336/*
337 * An anonymous namespace this symbol is only available here 337 * An anonymous namespace this symbol is only available here
338 * so truely private 338 * so truely private
339 */ 339 */
340namespace { 340namespace {
341 /* not static cause namespace does that what static would do */ 341 /* not static cause namespace does that what static would do */
342 const int RTTI = 5050; 342 const int RTTI = 5050;
343 /* 343 /*
344 * every ListView got Items. we've special pim items 344 * every ListView got Items. we've special pim items
345 * holding ownership and the pointer to a pim record 345 * holding ownership and the pointer to a pim record
346 * it can't hold a pimrecord directly because this 346 * it can't hold a pimrecord directly because this
347 * would introduce slicing... any break 347 * would introduce slicing... any break
348 */ 348 */
349 /* 349 /*
350 * A struct is a special class. Everything is public by 350 * A struct is a special class. Everything is public by
351 * default. 351 * default.
352 */ 352 */
353 struct PIMListViewItem : public QListViewItem { 353 struct PIMListViewItem : public QListViewItem {
354 /* 354 /*
355 *currently no hierachies are planed for the example 355 *currently no hierachies are planed for the example
356 * so only one constructor with a QListView as parent 356 * so only one constructor with a QListView as parent
357 */ 357 */
358 PIMListViewItem( QListView*, Opie::OPimRecord* record ); 358 PIMListViewItem( QListView*, Opie::OPimRecord* record );
359 ~PIMListViewItem(); 359 ~PIMListViewItem();
360 360
361 /* used by the QListViewItem to easily allow identifiying of different 361 /* used by the QListViewItem to easily allow identifiying of different
362 * items. Values greater than 1000 should be used */ 362 * items. Values greater than 1000 should be used */
363 int rtti()const; 363 int rtti()const;
364 Opie::OPimRecord* record()const; 364 Opie::OPimRecord* record()const;
365 365
366 private: 366 private:
367 Opie::OPimRecord* m_record; 367 Opie::OPimRecord* m_record;
368 }; 368 };
369 369
370 PIMListViewItem::PIMListViewItem( QListView *p, Opie::OPimRecord* rec ) 370 PIMListViewItem::PIMListViewItem( QListView *p, Opie::OPimRecord* rec )
371 : QListViewItem(p), m_record( rec ) { 371 : QListViewItem(p), m_record( rec ) {
372 } 372 }
373 373
374 PIMListViewItem::~PIMListViewItem() { 374 PIMListViewItem::~PIMListViewItem() {
375 /* we've the onwership so we need to delete it */ 375 /* we've the onwership so we need to delete it */
376 delete m_record; 376 delete m_record;
377 } 377 }
378 378
379 Opie::OPimRecord* PIMListViewItem::record()const { 379 Opie::OPimRecord* PIMListViewItem::record()const {
380 return m_record; 380 return m_record;
381 } 381 }
382 382
383} 383}
384 384
385 385
386PIMListView::PIMListView( QWidget* widget, const char* name, WFlags fl ) 386PIMListView::PIMListView( QWidget* widget, const char* name, WFlags fl )
387 : QListView(widget, name, fl ) 387 : QListView(widget, name, fl )
388{ 388{
389 addColumn("Summary"); 389 addColumn("Summary");
390} 390}
391 391
392PIMListView::~PIMListView() { 392PIMListView::~PIMListView() {
393 393
394} 394}
395 395
396void PIMListView::set( Opie::OPimTodoAccess::List list ) { 396void PIMListView::set( Opie::OPimTodoAccess::List list ) {
397 /* clear first and then add new items */ 397 /* clear first and then add new items */
398 clear(); 398 clear();
399 399
400 Opie::OPimTodoAccess::List::Iterator it; 400 Opie::OPimTodoAccess::List::Iterator it;
401 for (it = list.begin(); it != list.end(); ++it ) { 401 for (it = list.begin(); it != list.end(); ++it ) {
402 /* 402 /*
403 * make a new item which automatically gets added to the listview 403 * make a new item which automatically gets added to the listview
404 * and call the copy c'tor to create a new OPimTodo 404 * and call the copy c'tor to create a new OPimTodo
405 */ 405 */
406 PIMListViewItem *i = new PIMListViewItem(this, new Opie::OPimTodo( *it ) ); 406 PIMListViewItem *i = new PIMListViewItem(this, new Opie::OPimTodo( *it ) );
407 i->setText(0, (*it).summary() ); 407 i->setText(0, (*it).summary() );
408 } 408 }
409} 409}
410 410
411void PIMListView::set( const Opie::OPimOccurrence::List& lst ) { 411void PIMListView::set( const Opie::OPimOccurrence::List& lst ) {
412 /* clear first and then add items */ 412 /* clear first and then add items */
413 clear(); 413 clear();
414 414
415 Opie::OPimOccurrence::List::ConstIterator it; 415 Opie::OPimOccurrence::List::ConstIterator it;
416 for ( it = lst.begin(); it != lst.end(); ++it ) { 416 for ( it = lst.begin(); it != lst.end(); ++it ) {
417 PIMListViewItem *i = new PIMListViewItem(this, new Opie::OPimEvent( (*it).toEvent() ) ); 417 PIMListViewItem *i = new PIMListViewItem(this, new Opie::OPimEvent( (*it).toEvent() ) );
418 i->setText( 0, PIMListView::makeString( (*it) ) ); 418 i->setText( 0, PIMListView::makeString( (*it) ) );
419 } 419 }
420 420
421} 421}
422 422
423void PIMListView::showCurrentRecord() { 423void PIMListView::showCurrentRecord() {
424 /* it could be possible that their is no currentItem */ 424 /* it could be possible that their is no currentItem */
425 if (!currentItem() ) 425 if (!currentItem() )
426 return; 426 return;
427 427
428 /* 428 /*
429 * we only add PIMListViewItems so it is save 429 * we only add PIMListViewItems so it is save
430 * to do this case. If this would not be the case 430 * to do this case. If this would not be the case
431 * use rtti() to check in a switch() case 431 * use rtti() to check in a switch() case
432 */ 432 */
433 PIMListViewItem *item = static_cast<PIMListViewItem*>( currentItem() ); 433 PIMListViewItem *item = static_cast<PIMListViewItem*>( currentItem() );
434 434
435 /* finally you see how to emit a signal */ 435 /* finally you see how to emit a signal */
436 emit showRecord( (*item->record() ) ); 436 emit showRecord( (*item->record() ) );
437} 437}
438 438
439QString PIMListView::makeString( const Opie::OPimOccurrence& _ev ) { 439QString PIMListView::makeString( const Opie::OPimOccurrence& _ev ) {
440 QString str; 440 QString str;
441 str += _ev.summary(); 441 str += _ev.summary();
442 442
443 Opie::OPimEvent ev = _ev.toEvent(); 443 Opie::OPimEvent ev = _ev.toEvent();
444 if ( !ev.isAllDay() ) { 444 if ( !ev.isAllDay() ) {
445#if 0 445#if 0
446 if ( ev.startDate() != ev.endDate() ) { 446 if ( ev.startDate() != ev.endDate() ) {
447 str += tr("Start ") + TimeString::timeString( ev.startDateTime().time() ); 447 str += tr("Start ") + TimeString::timeString( ev.startDateTime().time() );
448 str += " - " + TimeString::longDateString( ev.startDateTime().date() ); 448 str += " - " + TimeString::longDateString( ev.startDateTime().date() );
449 str += tr("End ") + TimeString::timeString( ev.endDateTime().time() ); 449 str += tr("End ") + TimeString::timeString( ev.endDateTime().time() );
450 str += " - " + TimeString::longDateString( ev.endDateTime().date() ); 450 str += " - " + TimeString::longDateString( ev.endDateTime().date() );
451 }else 451 }else
452 #endif 452 #endif
453 { 453 {
454 str += tr("Time ") + TimeString::timeString( _ev.startTime() ); 454 str += tr("Time ") + TimeString::timeString( _ev.startTime() );
455 str += " - " + TimeString::timeString( _ev.endTime() ); 455 str += " - " + TimeString::timeString( _ev.endTime() );
456 } 456 }
457 }else 457 }else
458 str += tr(" This is an All-Day Event"); 458 str += tr(" This is an All-Day Event");
459 459
460 return str; 460 return str;
461} 461}