author | zecke <zecke> | 2004-03-14 20:08:59 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-03-14 20:08:59 (UTC) |
commit | 0d79c003839718ae70b3b997162044abd5c26bf6 (patch) (unidiff) | |
tree | 19708b041da3a09df8f3b571cd634a846f4ad6d7 | |
parent | 05c8d999941989a97a581fb5822437034ec10fd7 (diff) | |
download | opie-0d79c003839718ae70b3b997162044abd5c26bf6.zip opie-0d79c003839718ae70b3b997162044abd5c26bf6.tar.gz opie-0d79c003839718ae70b3b997162044abd5c26bf6.tar.bz2 |
Update the Examples
-rw-r--r-- | examples/applet/config.in | 2 | ||||
-rw-r--r-- | examples/applet/example.pro | 2 | ||||
-rw-r--r-- | examples/applet/simpleimpl.cpp | 96 | ||||
-rw-r--r-- | examples/applet/simpleimpl.h | 23 | ||||
-rw-r--r-- | examples/main-tab/config.in | 2 | ||||
-rw-r--r-- | examples/main-tab/example.pro | 2 | ||||
-rw-r--r-- | examples/main-tab/simple.cpp | 8 | ||||
-rw-r--r-- | examples/simple-icon/simple.cpp | 4 | ||||
-rw-r--r-- | examples/simple-main/simple.cpp | 3 | ||||
-rw-r--r-- | examples/simple-pim/config.in | 2 | ||||
-rw-r--r-- | examples/simple-pim/example.pro | 2 | ||||
-rw-r--r-- | examples/simple-pim/simple.cpp | 39 | ||||
-rw-r--r-- | examples/simple-pim/simple.h | 26 | ||||
-rw-r--r-- | examples/simple/simple.cpp | 4 | ||||
-rw-r--r-- | examples/todayplugin/config.in | 2 | ||||
-rw-r--r-- | examples/todayplugin/example.pro | 2 | ||||
-rw-r--r-- | examples/todayplugin/exampleplugin.h | 4 | ||||
-rw-r--r-- | examples/todayplugin/examplepluginimpl.h | 2 | ||||
-rw-r--r-- | examples/todayplugin/examplepluginwidget.cpp | 3 | ||||
-rw-r--r-- | examples/todayplugin/examplepluginwidget.h | 4 |
20 files changed, 76 insertions, 156 deletions
diff --git a/examples/applet/config.in b/examples/applet/config.in index 177de27..c3fb6dd 100644 --- a/examples/applet/config.in +++ b/examples/applet/config.in | |||
@@ -1,4 +1,4 @@ | |||
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 ) && EXAMPLES | 4 | depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIEUI2 &&EXAMPLES |
diff --git a/examples/applet/example.pro b/examples/applet/example.pro index 3efd31e..5ae540b 100644 --- a/examples/applet/example.pro +++ b/examples/applet/example.pro | |||
@@ -1,16 +1,16 @@ | |||
1 | CONFIG += warn_on qt | 1 | CONFIG += warn_on qt |
2 | 2 | ||
3 | TEMPLATE = lib | 3 | TEMPLATE = lib |
4 | DESTDIR = $(OPIEDIR)/plugins/applets | 4 | DESTDIR = $(OPIEDIR)/plugins/applets |
5 | TARGET = example | 5 | TARGET = example |
6 | 6 | ||
7 | SOURCES = simpleimpl.cpp | 7 | SOURCES = simpleimpl.cpp |
8 | HEADERS = simpleimpl.h | 8 | HEADERS = simpleimpl.h |
9 | 9 | ||
10 | INCLUDEPATH += $(OPIEDIR)/include | 10 | INCLUDEPATH += $(OPIEDIR)/include |
11 | DEPENDSPATH += $(OPIEDIR)/include | 11 | DEPENDSPATH += $(OPIEDIR)/include |
12 | 12 | ||
13 | LIBS += -lqpe | 13 | LIBS += -lqpe -lopieui2 |
14 | 14 | ||
15 | 15 | ||
16 | include ( $(OPIEDIR)/include.pro ) | 16 | include ( $(OPIEDIR)/include.pro ) |
diff --git a/examples/applet/simpleimpl.cpp b/examples/applet/simpleimpl.cpp index 82fc6e5..62d9bf7 100644 --- a/examples/applet/simpleimpl.cpp +++ b/examples/applet/simpleimpl.cpp | |||
@@ -1,162 +1,90 @@ | |||
1 | |||
2 | #include "simpleimpl.h" | ||
3 | |||
4 | #include <opie2/otaskbarapplet.h> | ||
5 | |||
6 | #include <qpe/applnk.h> // for AppLnk | ||
7 | #include <qpe/resource.h> // for Resource loading | ||
8 | |||
1 | #include <qlabel.h> | 9 | #include <qlabel.h> |
2 | #include <qpainter.h> | 10 | #include <qpainter.h> |
3 | #include <qmessagebox.h> | 11 | #include <qmessagebox.h> |
4 | 12 | ||
5 | #include <qpe/applnk.h> // for AppLnk | ||
6 | #include <qpe/resource.h> // for Resource loading | ||
7 | 13 | ||
8 | #include "simpleimpl.h" | ||
9 | 14 | ||
10 | 15 | ||
11 | SimpleApplet::SimpleApplet(QWidget *parent) | 16 | SimpleApplet::SimpleApplet(QWidget *parent) |
12 | : QWidget( parent, "Simple Applet" ) { | 17 | : QWidget( parent, "Simple Applet" ) { |
13 | /* | 18 | /* |
14 | * we will load an Image, scale it for the right usage | 19 | * we will load an Image, scale it for the right usage |
15 | * remember your applet might be used by different | 20 | * remember your applet might be used by different |
16 | * resolutions. | 21 | * resolutions. |
17 | * Then we will convert the image back to an Pixmap | 22 | * Then we will convert the image back to an Pixmap |
18 | * and draw this Pimxap. We need to use Image because its | 23 | * and draw this Pimxap. We need to use Image because its |
19 | * the only class that allows scaling. | 24 | * the only class that allows scaling. |
20 | */ | 25 | */ |
21 | 26 | ||
22 | QImage image = Resource::loadImage("Tux"); | 27 | QImage image = Resource::loadImage("Tux"); |
23 | /* | 28 | /* |
24 | * smooth scale to AppLnk smallIconSize for applest | 29 | * smooth scale to AppLnk smallIconSize for applest |
25 | * smallIconSize gets adjusted to the resolution | 30 | * smallIconSize gets adjusted to the resolution |
26 | * so on some displays like SIMpad and a C-750 the smallIconSize | 31 | * so on some displays like SIMpad and a C-750 the smallIconSize |
27 | * is greater than on a iPAQ h3870 | 32 | * is greater than on a iPAQ h3870 |
28 | */ | 33 | */ |
29 | image = image.smoothScale(AppLnk::smallIconSize(), AppLnk::smallIconSize() ); | 34 | image = image.smoothScale(AppLnk::smallIconSize(), AppLnk::smallIconSize() ); |
30 | 35 | ||
31 | /* | 36 | /* |
32 | * now we need to convert the Image to a Pixmap cause these | 37 | * now we need to convert the Image to a Pixmap cause these |
33 | * can be drawn more easily | 38 | * can be drawn more easily |
34 | */ | 39 | */ |
35 | m_pix = new QPixmap(); | 40 | m_pix = new QPixmap(); |
36 | m_pix->convertFromImage( image ); | 41 | m_pix->convertFromImage( image ); |
37 | 42 | ||
38 | /* | 43 | /* |
39 | * Now we will say that we don't want to be bigger than our | 44 | * Now we will say that we don't want to be bigger than our |
40 | * Pixmap | 45 | * Pixmap |
41 | */ | 46 | */ |
42 | setFixedHeight(AppLnk::smallIconSize() ); | 47 | setFixedHeight(AppLnk::smallIconSize() ); |
43 | setFixedWidth( AppLnk::smallIconSize() ); | 48 | setFixedWidth( AppLnk::smallIconSize() ); |
44 | 49 | ||
45 | } | 50 | } |
46 | 51 | ||
47 | SimpleApplet::~SimpleApplet() { | 52 | SimpleApplet::~SimpleApplet() { |
48 | delete m_pix; | 53 | delete m_pix; |
49 | } | 54 | } |
50 | 55 | ||
51 | 56 | ||
52 | /* | 57 | /* |
53 | * here you would normal show or do something | 58 | * here you would normal show or do something |
54 | * useful. If you want to show a widget at the top left | 59 | * useful. If you want to show a widget at the top left |
55 | * of your icon you need to map your rect().topLeft() to | 60 | * of your icon you need to map your rect().topLeft() to |
56 | * global with mapToGlobal(). Then you might also need to | 61 | * global with mapToGlobal(). Then you might also need to |
57 | * move the widgets so it is visible | 62 | * move the widgets so it is visible |
58 | */ | 63 | */ |
59 | void SimpleApplet::mousePressEvent(QMouseEvent* ) { | 64 | void SimpleApplet::mousePressEvent(QMouseEvent* ) { |
60 | QMessageBox::information(this, tr("No action taken"), | 65 | QMessageBox::information(this, tr("No action taken"), |
61 | tr("<qt>This Plugin does not yet support anything usefule aye.</qt>"), | 66 | tr("<qt>This Plugin does not yet support anything usefule aye.</qt>"), |
62 | QMessageBox::Ok ); | 67 | QMessageBox::Ok ); |
63 | 68 | ||
64 | } | 69 | } |
65 | 70 | ||
66 | void SimpleApplet::paintEvent( QPaintEvent* ) { | 71 | void SimpleApplet::paintEvent( QPaintEvent* ) { |
67 | QPainter p(this); | 72 | QPainter p(this); |
68 | 73 | ||
69 | /* simpy draw the pixmap from the start of this widget */ | 74 | /* simpy draw the pixmap from the start of this widget */ |
70 | p.drawPixmap(0, 0, *m_pix ); | 75 | p.drawPixmap(0, 0, *m_pix ); |
71 | } | 76 | } |
72 | 77 | ||
73 | /* | 78 | /* |
74 | * Here comes the implementation of the interface | 79 | * We need to add this symbol for the plugin exporter! |
75 | */ | 80 | */ |
76 | SimpleAppletImpl::SimpleAppletImpl() { | 81 | int SimpleApplet::position(){ |
77 | } | ||
78 | /* needed cause until it is only pure virtual */ | ||
79 | SimpleAppletImpl::~SimpleAppletImpl() { | ||
80 | /* | ||
81 | * we will delete our applets as well | ||
82 | * setAUtoDelete makes the QList free | ||
83 | * the objects behind the pointers | ||
84 | */ | ||
85 | m_applets.setAutoDelete( true ); | ||
86 | m_applets.clear(); | ||
87 | } | ||
88 | |||
89 | /* | ||
90 | * For the taskbar interface return a Widget | ||
91 | */ | ||
92 | QWidget* SimpleAppletImpl::applet( QWidget* parent ) { | ||
93 | /* | ||
94 | * There are problems with ownership. So we add | ||
95 | * our ownlist and clear this; | ||
96 | */ | ||
97 | SimpleApplet* ap = new SimpleApplet( parent ); | ||
98 | m_applets.append( ap ); | ||
99 | |||
100 | return ap; | ||
101 | } | ||
102 | |||
103 | /* | ||
104 | * A small hint where the Applet Should be displayed | ||
105 | */ | ||
106 | int SimpleAppletImpl::position()const { | ||
107 | return 1; | 82 | return 1; |
108 | } | 83 | } |
109 | 84 | ||
110 | 85 | ||
111 | /* | ||
112 | * Now the important QUnkownInterface method without | ||
113 | * this one your applet won't load | ||
114 | * @param uuid The uuid of the interface | ||
115 | * @param iface The pointer to the interface ptr | ||
116 | */ | ||
117 | QRESULT SimpleAppletImpl::queryInterface( const QUuid& uuid, QUnknownInterface** iface) { | ||
118 | /* set the pointer to the interface to 0 */ | ||
119 | *iface = 0; | ||
120 | |||
121 | /* | ||
122 | * we check if we support the requested interface | ||
123 | * and then assign to the pointer. | ||
124 | * You may alos create another interface here so | ||
125 | * *iface = this is only in this simple case true you | ||
126 | * could also support more interfaces. | ||
127 | * But this example below is the most common use. | ||
128 | * Now the caller knows that the Interface Pointer | ||
129 | * is valid and the interface supported | ||
130 | */ | ||
131 | if ( uuid == IID_QUnknown ) | ||
132 | *iface = this; | ||
133 | else if ( uuid == IID_TaskbarApplet ) | ||
134 | *iface = this; | ||
135 | else | ||
136 | return QS_FALSE; | ||
137 | |||
138 | if ( *iface ) | ||
139 | (*iface)->addRef(); | ||
140 | |||
141 | return QS_OK; | ||
142 | } | ||
143 | |||
144 | 86 | ||
145 | /* | 87 | /* |
146 | * Finally we need to export the Interface. | 88 | * Here comes the implementation of the interface |
147 | * CREATE_INSTANCE creates a interface and calls | ||
148 | * queryInterface for the QUnknownInterface once | ||
149 | * With out this function the applet can't be loaded. | ||
150 | * | ||
151 | * NOTE: If your applet does not load it's likely you've an | ||
152 | * unresolved symbol. Change the .pro TEMPLATE = lib to TEMPLATE= app | ||
153 | * and recompile. If the linker only complains about a missing | ||
154 | * main method the problem is more complex. In most cases it'll say | ||
155 | * you which symbols are missing and you can implement them. | ||
156 | * The main(int argc, char* argv[] ) does not need to be | ||
157 | * included in a library so it's ok that the linker complains | ||
158 | */ | 89 | */ |
159 | Q_EXPORT_INTERFACE() { | 90 | EXPORT_OPIE_APPLET_v1( SimpleApplet ) \ No newline at end of file |
160 | Q_CREATE_INSTANCE( SimpleAppletImpl ) | ||
161 | } | ||
162 | |||
diff --git a/examples/applet/simpleimpl.h b/examples/applet/simpleimpl.h index f58e2af..90c632f 100644 --- a/examples/applet/simpleimpl.h +++ b/examples/applet/simpleimpl.h | |||
@@ -1,77 +1,58 @@ | |||
1 | /* | 1 | /* |
2 | * You may use, modify and distribute without any limitation | 2 | * You may use, modify and distribute without any limitation |
3 | */ | 3 | */ |
4 | 4 | ||
5 | /** | 5 | /** |
6 | * Opie and Qtopia uses a component system called QCOM | 6 | * Opie and Qtopia uses a component system called QCOM |
7 | * which was first part of the Qt 3.0 API but was made | 7 | * which was first part of the Qt 3.0 API but was made |
8 | * prviate during the betas. Opie and Qtopia still use it | 8 | * prviate during the betas. Opie and Qtopia still use it |
9 | * and we're happy with it. | 9 | * and we're happy with it. |
10 | * Every starts with the QUnknownInterface. It supports functions | 10 | * Every starts with the QUnknownInterface. It supports functions |
11 | * for reference counting and the most important one | 11 | * for reference counting and the most important one |
12 | * is for a query. Every QCOM interface got a global unique id ( GUID,UUID ) | 12 | * is for a query. Every QCOM interface got a global unique id ( GUID,UUID ) |
13 | * query is used to see if a interface is supported by | 13 | * query is used to see if a interface is supported by |
14 | * a dynamic shared object ( dso / plugin ) | 14 | * a dynamic shared object ( dso / plugin ) |
15 | * For tasks like loading Applications, InputMethods, Today, MenuButton, | 15 | * For tasks like loading Applications, InputMethods, Today, MenuButton, |
16 | * Taskbar, Style, Email Client there are specefic Interfaces you | 16 | * Taskbar, Style, Email Client there are specefic Interfaces you |
17 | * need to implement. The interfaces inherits from QUnknownInterface and | 17 | * need to implement. The interfaces inherits from QUnknownInterface and |
18 | * you'll need inherit from the interface. | 18 | * you'll need inherit from the interface. |
19 | * As example we will use the Taskbar interface | 19 | * As example we will use the Taskbar interface |
20 | * the OTaskBarAppletWrapper implements the factory for us | ||
20 | */ | 21 | */ |
21 | 22 | ||
22 | #ifndef SIMPLE_OPIE_EXAMPLE_APPLET_H | 23 | #ifndef SIMPLE_OPIE_EXAMPLE_APPLET_H |
23 | #define SIMPLE_OPIE_EXAMPLE_APPLET_H | 24 | #define SIMPLE_OPIE_EXAMPLE_APPLET_H |
24 | 25 | ||
25 | /* | 26 | /* |
26 | * The taskbar applet interfaces wants us to implement position() and applet() | 27 | * The taskbar applet interfaces wants us to implement position() and applet() |
27 | * additionally we need to implement add(), release() and queryInterface for QUnknownInterface | 28 | * additionally we need to implement add(), release() and queryInterface for QUnknownInterface |
28 | * luckiy there is a macro for the reference counting | 29 | * luckiy there is a macro for the reference counting |
29 | * We provide an Implementation of the interface. | 30 | * We provide an Implementation of the interface. |
30 | */ | 31 | */ |
31 | #include <qwidget.h> | 32 | #include <qwidget.h> |
32 | #include <qlist.h> | 33 | #include <qlist.h> |
33 | 34 | ||
34 | #include <qpe/taskbarappletinterface.h> | 35 | #include <qpe/taskbarappletinterface.h> |
35 | 36 | ||
36 | 37 | ||
37 | /* | 38 | /* |
38 | * Because we only draw an Icon in a fixed width and height | 39 | * Because we only draw an Icon in a fixed width and height |
39 | * we declare and define SimpleApplet here and you could use QLabel | 40 | * we declare and define SimpleApplet here and you could use QLabel |
40 | * setPixmap or use QWidget and draw yourself. | 41 | * setPixmap or use QWidget and draw yourself. |
41 | * You might also want to reimplement mouse*Event to use some simple actions | 42 | * You might also want to reimplement mouse*Event to use some simple actions |
42 | */ | 43 | */ |
43 | class SimpleApplet : public QWidget { | 44 | class SimpleApplet : public QWidget { |
44 | Q_OBJECT | 45 | Q_OBJECT |
45 | public: | 46 | public: |
46 | SimpleApplet(QWidget *parent); | 47 | SimpleApplet(QWidget *parent); |
47 | ~SimpleApplet(); | 48 | ~SimpleApplet(); |
49 | static int position(); | ||
48 | private: | 50 | private: |
49 | void mousePressEvent( QMouseEvent* ); | 51 | void mousePressEvent( QMouseEvent* ); |
50 | void paintEvent( QPaintEvent* ); | 52 | void paintEvent( QPaintEvent* ); |
51 | QPixmap *m_pix; | 53 | QPixmap *m_pix; |
52 | }; | 54 | }; |
53 | 55 | ||
54 | class SimpleAppletImpl : public TaskbarAppletInterface { | ||
55 | public: | ||
56 | |||
57 | SimpleAppletImpl(); | ||
58 | virtual ~SimpleAppletImpl(); | ||
59 | |||
60 | QRESULT queryInterface( const QUuid&, QUnknownInterface** ); | ||
61 | |||
62 | QWidget *applet( QWidget* parent ); | ||
63 | int position()const; | ||
64 | |||
65 | /* | ||
66 | * macro for reference countint | ||
67 | * if reference drops to zero | ||
68 | * delete this is called | ||
69 | */ | ||
70 | Q_REFCOUNT | ||
71 | |||
72 | private: | ||
73 | QList<SimpleApplet> m_applets; | ||
74 | }; | ||
75 | 56 | ||
76 | 57 | ||
77 | #endif | 58 | #endif |
diff --git a/examples/main-tab/config.in b/examples/main-tab/config.in index e021d59..3a67bcb 100644 --- a/examples/main-tab/config.in +++ b/examples/main-tab/config.in | |||
@@ -1,4 +1,4 @@ | |||
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 && LIBOPIE | 4 | depends ( LIBQPE || LIBQPE-X11 ) && EXAMPLES && LIBOPIEUI2 |
diff --git a/examples/main-tab/example.pro b/examples/main-tab/example.pro index 3cafc20..87abf22 100644 --- a/examples/main-tab/example.pro +++ b/examples/main-tab/example.pro | |||
@@ -1,17 +1,17 @@ | |||
1 | CONFIG += qt warn_on quick-app | 1 | CONFIG += qt warn_on quick-app |
2 | 2 | ||
3 | 3 | ||
4 | TARGET = main-tab | 4 | TARGET = main-tab |
5 | 5 | ||
6 | HEADERS = simple.h | 6 | HEADERS = simple.h |
7 | SOURCES = simple.cpp | 7 | SOURCES = simple.cpp |
8 | 8 | ||
9 | 9 | ||
10 | INCLUDEPATH += $(OPIEDIR)/include | 10 | INCLUDEPATH += $(OPIEDIR)/include |
11 | DEPENDPATH += $(OPIEDIR)/include | 11 | DEPENDPATH += $(OPIEDIR)/include |
12 | 12 | ||
13 | 13 | ||
14 | # we now also include opie | 14 | # we now also include opie |
15 | LIBS += -lqpe -lopie | 15 | LIBS += -lqpe -lopieui2 |
16 | 16 | ||
17 | include ( $(OPIEDIR)/include.pro ) | 17 | include ( $(OPIEDIR)/include.pro ) |
diff --git a/examples/main-tab/simple.cpp b/examples/main-tab/simple.cpp index c5a6d5a..7edb557 100644 --- a/examples/main-tab/simple.cpp +++ b/examples/main-tab/simple.cpp | |||
@@ -1,211 +1,213 @@ | |||
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> | 9 | #include <qpe/resource.h> |
10 | #include <qpe/sound.h> | 10 | #include <qpe/sound.h> |
11 | 11 | ||
12 | #include <opie/oapplicationfactory.h> // a template + macro to save the main method and allow quick launching | 12 | #include <opie2/oapplicationfactory.h> // a template + macro to save the main method and allow quick launching |
13 | #include <opie/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 */ | ||
30 | using namespace Opie::Core; | ||
29 | OPIE_EXPORT_APP( OApplicationFactory<MainWindow> ) | 31 | OPIE_EXPORT_APP( OApplicationFactory<MainWindow> ) |
30 | 32 | ||
31 | MainWindow::MainWindow(QWidget *parent, const char* name, WFlags fl ) | 33 | MainWindow::MainWindow(QWidget *parent, const char* name, WFlags fl ) |
32 | : QMainWindow( parent, name, fl ) { | 34 | : QMainWindow( parent, name, fl ) { |
33 | setCaption(tr("My MainWindow") ); | 35 | setCaption(tr("My MainWindow") ); |
34 | 36 | ||
35 | initUI(); | 37 | initUI(); |
36 | 38 | ||
37 | 39 | ||
38 | /* | 40 | /* |
39 | * Tab widget as central | 41 | * Tab widget as central |
40 | */ | 42 | */ |
41 | OTabWidget *tab = new OTabWidget(this); | 43 | Opie::Ui::OTabWidget *tab = new Opie::Ui::OTabWidget(this); |
42 | connect(tab, SIGNAL(currentChanged(QWidget*) ), | 44 | connect(tab, SIGNAL(currentChanged(QWidget*) ), |
43 | this, SLOT( slotCurrentChanged(QWidget*) ) ); | 45 | this, SLOT( slotCurrentChanged(QWidget*) ) ); |
44 | setCentralWidget( tab ); | 46 | setCentralWidget( tab ); |
45 | 47 | ||
46 | Simple1 *simple1 = new Simple1( this ); | 48 | Simple1 *simple1 = new Simple1( this ); |
47 | tab->addTab( simple1, "new", tr("Simple1") ); | 49 | tab->addTab( simple1, "new", tr("Simple1") ); |
48 | tab->setCurrentTab( tr("Simple1") ); | 50 | tab->setCurrentTab( tr("Simple1") ); |
49 | 51 | ||
50 | Simple2 *simple2 = new Simple2( this ); | 52 | Simple2 *simple2 = new Simple2( this ); |
51 | tab->addTab( simple2, "trash", tr("Simple2") ); | 53 | tab->addTab( simple2, "trash", tr("Simple2") ); |
52 | 54 | ||
53 | m_oldCurrent = simple1; | 55 | m_oldCurrent = simple1; |
54 | 56 | ||
55 | connect(m_fire, SIGNAL(activated() ), | 57 | connect(m_fire, SIGNAL(activated() ), |
56 | simple1, SLOT(slotFire() ) ); | 58 | simple1, SLOT(slotFire() ) ); |
57 | } | 59 | } |
58 | 60 | ||
59 | MainWindow::~MainWindow() { | 61 | MainWindow::~MainWindow() { |
60 | // again nothing to delete because Qt takes care | 62 | // again nothing to delete because Qt takes care |
61 | } | 63 | } |
62 | 64 | ||
63 | 65 | ||
64 | void MainWindow::setDocument( const QString& /*str*/ ) { | 66 | void MainWindow::setDocument( const QString& /*str*/ ) { |
65 | } | 67 | } |
66 | void MainWindow::slotCurrentChanged( QWidget *wid) { | 68 | void MainWindow::slotCurrentChanged( QWidget *wid) { |
67 | disconnect(m_fire, SIGNAL(activated() ), | 69 | disconnect(m_fire, SIGNAL(activated() ), |
68 | m_oldCurrent, SLOT(slotFire() ) ); | 70 | m_oldCurrent, SLOT(slotFire() ) ); |
69 | connect(m_fire, SIGNAL(activated() ), | 71 | connect(m_fire, SIGNAL(activated() ), |
70 | wid, SLOT(slotFire() ) ); | 72 | wid, SLOT(slotFire() ) ); |
71 | 73 | ||
72 | m_oldCurrent = wid; | 74 | m_oldCurrent = wid; |
73 | } | 75 | } |
74 | 76 | ||
75 | void MainWindow::initUI() { | 77 | void MainWindow::initUI() { |
76 | 78 | ||
77 | setToolBarsMovable( false ); | 79 | setToolBarsMovable( false ); |
78 | 80 | ||
79 | QToolBar *menuBarHolder = new QToolBar( this ); | 81 | QToolBar *menuBarHolder = new QToolBar( this ); |
80 | 82 | ||
81 | menuBarHolder->setHorizontalStretchable( true ); | 83 | menuBarHolder->setHorizontalStretchable( true ); |
82 | QMenuBar *mb = new QMenuBar( menuBarHolder ); | 84 | QMenuBar *mb = new QMenuBar( menuBarHolder ); |
83 | QToolBar *tb = new QToolBar( this ); | 85 | QToolBar *tb = new QToolBar( this ); |
84 | 86 | ||
85 | QPopupMenu *fileMenu = new QPopupMenu( this ); | 87 | QPopupMenu *fileMenu = new QPopupMenu( this ); |
86 | 88 | ||
87 | 89 | ||
88 | QAction *a = new QAction( tr("Quit"), Resource::loadIconSet("quit_icon"), | 90 | QAction *a = new QAction( tr("Quit"), Resource::loadIconSet("quit_icon"), |
89 | QString::null, 0, this, "quit_action" ); | 91 | QString::null, 0, this, "quit_action" ); |
90 | /* | 92 | /* |
91 | * Connect quit to the QApplication quit slot | 93 | * Connect quit to the QApplication quit slot |
92 | */ | 94 | */ |
93 | connect(a, SIGNAL(activated() ), | 95 | connect(a, SIGNAL(activated() ), |
94 | qApp, SLOT(quit() ) ); | 96 | qApp, SLOT(quit() ) ); |
95 | a->addTo( fileMenu ); | 97 | a->addTo( fileMenu ); |
96 | 98 | ||
97 | a = new QAction(tr("Fire"), | 99 | a = new QAction(tr("Fire"), |
98 | Resource::loadIconSet("new"), | 100 | Resource::loadIconSet("new"), |
99 | QString::null, 0, this, "fire_button"); | 101 | QString::null, 0, this, "fire_button"); |
100 | 102 | ||
101 | /* see the power? */ | 103 | /* see the power? */ |
102 | a->addTo( fileMenu ); | 104 | a->addTo( fileMenu ); |
103 | a->addTo( tb ); | 105 | a->addTo( tb ); |
104 | m_fire = a; | 106 | m_fire = a; |
105 | 107 | ||
106 | 108 | ||
107 | mb->insertItem(tr("File"), fileMenu ); | 109 | mb->insertItem(tr("File"), fileMenu ); |
108 | 110 | ||
109 | } | 111 | } |
110 | 112 | ||
111 | Simple1::Simple1( QWidget* parent, const char* name, WFlags fl ) | 113 | Simple1::Simple1( QWidget* parent, const char* name, WFlags fl ) |
112 | : QWidget( parent, name, fl ) { | 114 | : QWidget( parent, name, fl ) { |
113 | 115 | ||
114 | QVBoxLayout *layout = new QVBoxLayout( this ); | 116 | QVBoxLayout *layout = new QVBoxLayout( this ); |
115 | layout->setSpacing( 8 ); | 117 | layout->setSpacing( 8 ); |
116 | layout->setMargin( 11 ); | 118 | layout->setMargin( 11 ); |
117 | 119 | ||
118 | 120 | ||
119 | QLabel *lbl = new QLabel( this, "a name for the label" ); | 121 | QLabel *lbl = new QLabel( this, "a name for the label" ); |
120 | lbl->setText( tr("Click on the button or follow the white rabbit") ); | 122 | lbl->setText( tr("Click on the button or follow the white rabbit") ); |
121 | layout->addWidget( lbl ); | 123 | layout->addWidget( lbl ); |
122 | 124 | ||
123 | 125 | ||
124 | m_button = new QPushButton(this); | 126 | m_button = new QPushButton(this); |
125 | 127 | ||
126 | 128 | ||
127 | m_button->setText( tr("Fire", "translatable quit string" ) ); | 129 | m_button->setText( tr("Fire", "translatable quit string" ) ); |
128 | layout->addWidget( m_button ); | 130 | layout->addWidget( m_button ); |
129 | 131 | ||
130 | 132 | ||
131 | connect( m_button, SIGNAL(clicked() ), | 133 | connect( m_button, SIGNAL(clicked() ), |
132 | this, SLOT( slotFire() ) ); | 134 | this, SLOT( slotFire() ) ); |
133 | } | 135 | } |
134 | 136 | ||
135 | Simple1::~Simple1() { | 137 | Simple1::~Simple1() { |
136 | 138 | ||
137 | } | 139 | } |
138 | 140 | ||
139 | void Simple1::slotFire() { | 141 | void Simple1::slotFire() { |
140 | /* | 142 | /* |
141 | * NOTE: Simple is now a child window of MainWindow | 143 | * NOTE: Simple is now a child window of MainWindow |
142 | * close will hide() Simple and not delete it. But as | 144 | * close will hide() Simple and not delete it. But as |
143 | * the mainwindow is shown all children will be shown as well | 145 | * the mainwindow is shown all children will be shown as well |
144 | */ | 146 | */ |
145 | close(); | 147 | close(); |
146 | } | 148 | } |
147 | 149 | ||
148 | 150 | ||
149 | Simple2::Simple2( QWidget* parent, const char* name, WFlags fl ) | 151 | Simple2::Simple2( QWidget* parent, const char* name, WFlags fl ) |
150 | : QWidget( parent, name, fl ) { | 152 | : QWidget( parent, name, fl ) { |
151 | 153 | ||
152 | /* | 154 | /* |
153 | * sets the caption of this toplevel widget | 155 | * sets the caption of this toplevel widget |
154 | * put all translatable string into tr() | 156 | * put all translatable string into tr() |
155 | */ | 157 | */ |
156 | setCaption(tr("My Simple Application") ); | 158 | setCaption(tr("My Simple Application") ); |
157 | 159 | ||
158 | /* | 160 | /* |
159 | * A simple vertical layout | 161 | * A simple vertical layout |
160 | * either call layout->setAutoAdd( true ) | 162 | * either call layout->setAutoAdd( true ) |
161 | * or use layout->addWidget( wid ) to add widgets | 163 | * or use layout->addWidget( wid ) to add widgets |
162 | */ | 164 | */ |
163 | QVBoxLayout *layout = new QVBoxLayout( this ); | 165 | QVBoxLayout *layout = new QVBoxLayout( this ); |
164 | layout->setSpacing( 8 ); | 166 | layout->setSpacing( 8 ); |
165 | layout->setMargin( 11 ); | 167 | layout->setMargin( 11 ); |
166 | 168 | ||
167 | /* | 169 | /* |
168 | * creates a label | 170 | * creates a label |
169 | * The first parameter is this widget so the Label is a child | 171 | * The first parameter is this widget so the Label is a child |
170 | * of us and will be deleted when we're deleted. | 172 | * of us and will be deleted when we're deleted. |
171 | */ | 173 | */ |
172 | QLabel *lbl = new QLabel( this, "a name for the label" ); | 174 | QLabel *lbl = new QLabel( this, "a name for the label" ); |
173 | /* | 175 | /* |
174 | * Resource will search hard for a Pixmap in $OPIEDIR/pics | 176 | * Resource will search hard for a Pixmap in $OPIEDIR/pics |
175 | * to find 'logo/opielogo' You need to pass the subdir | 177 | * to find 'logo/opielogo' You need to pass the subdir |
176 | * but not the ending | 178 | * but not the ending |
177 | */ | 179 | */ |
178 | lbl->setPixmap( Resource::loadPixmap("logo/opielogo") ); | 180 | lbl->setPixmap( Resource::loadPixmap("logo/opielogo") ); |
179 | layout->addWidget( lbl ); | 181 | layout->addWidget( lbl ); |
180 | 182 | ||
181 | 183 | ||
182 | /* creates a button as child of this widget */ | 184 | /* creates a button as child of this widget */ |
183 | m_button = new QPushButton(this); | 185 | m_button = new QPushButton(this); |
184 | /* | 186 | /* |
185 | * another way to call tr. The first parameter is the string | 187 | * another way to call tr. The first parameter is the string |
186 | * to translate and the second a hint to the translator | 188 | * to translate and the second a hint to the translator |
187 | */ | 189 | */ |
188 | m_button->setText( tr("Fire", "translatable fire string" ) ); | 190 | m_button->setText( tr("Fire", "translatable fire string" ) ); |
189 | layout->addWidget( m_button ); | 191 | layout->addWidget( m_button ); |
190 | 192 | ||
191 | 193 | ||
192 | connect( m_button, SIGNAL(clicked() ), | 194 | connect( m_button, SIGNAL(clicked() ), |
193 | this, SLOT( slotQuit() ) ); | 195 | this, SLOT( slotQuit() ) ); |
194 | } | 196 | } |
195 | 197 | ||
196 | 198 | ||
197 | Simple2::~Simple2() { | 199 | Simple2::~Simple2() { |
198 | 200 | ||
199 | } | 201 | } |
200 | 202 | ||
201 | void Simple2::slotFire() { | 203 | void Simple2::slotFire() { |
202 | /* | 204 | /* |
203 | * We will fire up a sound | 205 | * We will fire up a sound |
204 | * Note that Sound will use Resource as well | 206 | * Note that Sound will use Resource as well |
205 | * and we do not need to supply an ending | 207 | * and we do not need to supply an ending |
206 | * sounds are found in $OPIEDIR/sounds | 208 | * sounds are found in $OPIEDIR/sounds |
207 | */ | 209 | */ |
208 | Sound snd("hit_target01"); | 210 | Sound snd("hit_target01"); |
209 | snd.play(); | 211 | snd.play(); |
210 | 212 | ||
211 | } | 213 | } |
diff --git a/examples/simple-icon/simple.cpp b/examples/simple-icon/simple.cpp index 054ade8..fec1823 100644 --- a/examples/simple-icon/simple.cpp +++ b/examples/simple-icon/simple.cpp | |||
@@ -1,100 +1,100 @@ | |||
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 | 6 | #include <qpe/resource.h> // for loading icon |
7 | #include <qpe/sound.h> // for playing a sound | 7 | #include <qpe/sound.h> // for playing a sound |
8 | 8 | ||
9 | #include <opie/oapplicationfactory.h> // a template + macro to save the main method and allow quick launching | 9 | #include <opie2/oapplicationfactory.h> // a template + macro to save the main method and allow quick launching |
10 | 10 | ||
11 | #include "simple.h" | 11 | #include "simple.h" |
12 | 12 | ||
13 | /* | 13 | /* |
14 | * implementation of simple | 14 | * implementation of simple |
15 | */ | 15 | */ |
16 | 16 | ||
17 | /* | 17 | /* |
18 | * The factory is used for quicklaunching | 18 | * 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 | 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 |
20 | * | 20 | * |
21 | * Depending on the global quick launch setting this will create | 21 | * Depending on the global quick launch setting this will create |
22 | * either a main method or one for our component plugin system | 22 | * either a main method or one for our component plugin system |
23 | */ | 23 | */ |
24 | 24 | using namespace Opie::Core; | |
25 | OPIE_EXPORT_APP( OApplicationFactory<Simple> ) | 25 | OPIE_EXPORT_APP( OApplicationFactory<Simple> ) |
26 | 26 | ||
27 | Simple::Simple( QWidget* parent, const char* name, WFlags fl ) | 27 | Simple::Simple( QWidget* parent, const char* name, WFlags fl ) |
28 | : QWidget( parent, name, fl ) { | 28 | : QWidget( parent, name, fl ) { |
29 | 29 | ||
30 | /* | 30 | /* |
31 | * sets the caption of this toplevel widget | 31 | * sets the caption of this toplevel widget |
32 | * put all translatable string into tr() | 32 | * put all translatable string into tr() |
33 | */ | 33 | */ |
34 | setCaption(tr("My Simple Application") ); | 34 | setCaption(tr("My Simple Application") ); |
35 | 35 | ||
36 | /* | 36 | /* |
37 | * A simple vertical layout | 37 | * A simple vertical layout |
38 | * either call layout->setAutoAdd( true ) | 38 | * either call layout->setAutoAdd( true ) |
39 | * or use layout->addWidget( wid ) to add widgets | 39 | * or use layout->addWidget( wid ) to add widgets |
40 | */ | 40 | */ |
41 | QVBoxLayout *layout = new QVBoxLayout( this ); | 41 | QVBoxLayout *layout = new QVBoxLayout( this ); |
42 | layout->setSpacing( 8 ); | 42 | layout->setSpacing( 8 ); |
43 | layout->setMargin( 11 ); | 43 | layout->setMargin( 11 ); |
44 | 44 | ||
45 | /* | 45 | /* |
46 | * creates a label | 46 | * creates a label |
47 | * The first parameter is this widget so the Label is a child | 47 | * The first parameter is this widget so the Label is a child |
48 | * of us and will be deleted when we're deleted. | 48 | * of us and will be deleted when we're deleted. |
49 | */ | 49 | */ |
50 | QLabel *lbl = new QLabel( this, "a name for the label" ); | 50 | QLabel *lbl = new QLabel( this, "a name for the label" ); |
51 | /* | 51 | /* |
52 | * Resource will search hard for a Pixmap in $OPIEDIR/pics | 52 | * Resource will search hard for a Pixmap in $OPIEDIR/pics |
53 | * to find 'logo/opielogo' You need to pass the subdir | 53 | * to find 'logo/opielogo' You need to pass the subdir |
54 | * but not the ending | 54 | * but not the ending |
55 | */ | 55 | */ |
56 | lbl->setPixmap( Resource::loadPixmap("logo/opielogo") ); | 56 | lbl->setPixmap( Resource::loadPixmap("logo/opielogo") ); |
57 | layout->addWidget( lbl ); | 57 | layout->addWidget( lbl ); |
58 | 58 | ||
59 | 59 | ||
60 | /* creates a button as child of this widget */ | 60 | /* creates a button as child of this widget */ |
61 | m_button = new QPushButton(this); | 61 | m_button = new QPushButton(this); |
62 | /* | 62 | /* |
63 | * another way to call tr. The first parameter is the string | 63 | * another way to call tr. The first parameter is the string |
64 | * to translate and the second a hint to the translator | 64 | * to translate and the second a hint to the translator |
65 | */ | 65 | */ |
66 | m_button->setText( tr("Fire", "translatable fire string" ) ); | 66 | m_button->setText( tr("Fire", "translatable fire string" ) ); |
67 | layout->addWidget( m_button ); | 67 | layout->addWidget( m_button ); |
68 | 68 | ||
69 | /* | 69 | /* |
70 | * Now we bring the action into it. The power of qt is the dynamic | 70 | * Now we bring the action into it. The power of qt is the dynamic |
71 | * signal and slots model | 71 | * signal and slots model |
72 | * Usage is simple connect m_buttons clicked signal to our | 72 | * Usage is simple connect m_buttons clicked signal to our |
73 | * slotQuit slot. | 73 | * slotQuit slot. |
74 | * We could also have connected a SIGNAL to a SIGNAL or the clicked | 74 | * We could also have connected a SIGNAL to a SIGNAL or the clicked |
75 | * signal directly to qApp and SLOT(quit() ) | 75 | * signal directly to qApp and SLOT(quit() ) |
76 | */ | 76 | */ |
77 | connect( m_button, SIGNAL(clicked() ), | 77 | connect( m_button, SIGNAL(clicked() ), |
78 | this, SLOT( slotQuit() ) ); | 78 | this, SLOT( slotQuit() ) ); |
79 | } | 79 | } |
80 | 80 | ||
81 | /* | 81 | /* |
82 | * Our destructor is empty because all child | 82 | * Our destructor is empty because all child |
83 | * widgets and layouts will be deleted by Qt. | 83 | * widgets and layouts will be deleted by Qt. |
84 | * Same applies to QObjects | 84 | * Same applies to QObjects |
85 | */ | 85 | */ |
86 | Simple::~Simple() { | 86 | Simple::~Simple() { |
87 | 87 | ||
88 | } | 88 | } |
89 | 89 | ||
90 | void Simple::slotQuit() { | 90 | void Simple::slotQuit() { |
91 | /* | 91 | /* |
92 | * We will fire up a sound | 92 | * We will fire up a sound |
93 | * Note that Sound will use Resource as well | 93 | * Note that Sound will use Resource as well |
94 | * and we do not need to supply an ending | 94 | * and we do not need to supply an ending |
95 | * sounds are found in $OPIEDIR/sounds | 95 | * sounds are found in $OPIEDIR/sounds |
96 | */ | 96 | */ |
97 | Sound snd("hit_target01"); | 97 | Sound snd("hit_target01"); |
98 | snd.play(); | 98 | snd.play(); |
99 | 99 | ||
100 | } | 100 | } |
diff --git a/examples/simple-main/simple.cpp b/examples/simple-main/simple.cpp index 8de911f..cf00cc6 100644 --- a/examples/simple-main/simple.cpp +++ b/examples/simple-main/simple.cpp | |||
@@ -1,218 +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> | 9 | #include <qpe/resource.h> |
10 | 10 | ||
11 | #include <opie/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 | 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 | ||
27 | using namespace Opie::Core; | ||
27 | OPIE_EXPORT_APP( OApplicationFactory<MainWindow> ) | 28 | OPIE_EXPORT_APP( OApplicationFactory<MainWindow> ) |
28 | 29 | ||
29 | MainWindow::MainWindow(QWidget *parent, const char* name, WFlags fl ) | 30 | MainWindow::MainWindow(QWidget *parent, const char* name, WFlags fl ) |
30 | : QMainWindow( parent, name, fl ) { | 31 | : QMainWindow( parent, name, fl ) { |
31 | setCaption(tr("My MainWindow") ); | 32 | setCaption(tr("My MainWindow") ); |
32 | setIcon( Resource::loadPixmap("new") ); | 33 | setIcon( Resource::loadPixmap("new") ); |
33 | /* | 34 | /* |
34 | * out mainwindow should have a menubar | 35 | * out mainwindow should have a menubar |
35 | * a toolbar, a mainwidget and use Resource | 36 | * a toolbar, a mainwidget and use Resource |
36 | * to get the IconSets | 37 | * to get the IconSets |
37 | */ | 38 | */ |
38 | /* | 39 | /* |
39 | * we initialize the GUI in a different methid | 40 | * we initialize the GUI in a different methid |
40 | */ | 41 | */ |
41 | initUI(); | 42 | initUI(); |
42 | 43 | ||
43 | Simple *simple = new Simple( this ); | 44 | Simple *simple = new Simple( this ); |
44 | setCentralWidget( simple ); | 45 | setCentralWidget( simple ); |
45 | 46 | ||
46 | /* | 47 | /* |
47 | * If you use signal and slots do not include the parameter | 48 | * If you use signal and slots do not include the parameter |
48 | * names inside | 49 | * names inside |
49 | * so SIGNAL(fooBar(int) ) and NOT SIGNAL(fooBar(int foo) ) | 50 | * so SIGNAL(fooBar(int) ) and NOT SIGNAL(fooBar(int foo) ) |
50 | */ | 51 | */ |
51 | /* | 52 | /* |
52 | * We connect the activation of our QAction | 53 | * We connect the activation of our QAction |
53 | * to the slot connected to the firebutton | 54 | * to the slot connected to the firebutton |
54 | * We could also connect the signal to the clicked | 55 | * We could also connect the signal to the clicked |
55 | * signal of the button | 56 | * signal of the button |
56 | */ | 57 | */ |
57 | connect(m_fire, SIGNAL(activated() ), | 58 | connect(m_fire, SIGNAL(activated() ), |
58 | simple, SLOT(slotFire() ) ); | 59 | simple, SLOT(slotFire() ) ); |
59 | } | 60 | } |
60 | 61 | ||
61 | MainWindow::~MainWindow() { | 62 | MainWindow::~MainWindow() { |
62 | // again nothing to delete because Qt takes care | 63 | // again nothing to delete because Qt takes care |
63 | } | 64 | } |
64 | 65 | ||
65 | /* | 66 | /* |
66 | * set Document is a special function used by Document | 67 | * set Document is a special function used by Document |
67 | * centric applications. | 68 | * centric applications. |
68 | * In example if Opie receives a Todo via IrDa it uses | 69 | * In example if Opie receives a Todo via IrDa it uses |
69 | * setDocument via QCOP the IPC system to load the card | 70 | * setDocument via QCOP the IPC system to load the card |
70 | * 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 |
71 | * setDocument is called via IPC in textedit. | 72 | * setDocument is called via IPC in textedit. |
72 | * 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 |
73 | * 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 |
74 | * But more on QCOP in the next application | 75 | * But more on QCOP in the next application |
75 | */ | 76 | */ |
76 | void MainWindow::setDocument( const QString& /*str*/ ) { | 77 | void MainWindow::setDocument( const QString& /*str*/ ) { |
77 | // 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 |
78 | // file request or if it is a DocLnk. | 79 | // file request or if it is a DocLnk. |
79 | // 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 |
80 | // opening the document behind the file you got | 81 | // opening the document behind the file you got |
81 | } | 82 | } |
82 | 83 | ||
83 | /* | 84 | /* |
84 | * Two new concepts with this Method | 85 | * Two new concepts with this Method |
85 | * 1. QAction. An action can be grouped and emits | 86 | * 1. QAction. An action can be grouped and emits |
86 | * an activated signal. Action a universal useable | 87 | * an activated signal. Action a universal useable |
87 | * you can just plug/addTo in most Qt widgets. For example | 88 | * you can just plug/addTo in most Qt widgets. For example |
88 | * the same action can be plugged into a ToolBar, MenuBar, | 89 | * the same action can be plugged into a ToolBar, MenuBar, |
89 | * QPopupMenu and other widgets but you do not need to worry | 90 | * QPopupMenu and other widgets but you do not need to worry |
90 | * about it | 91 | * about it |
91 | * | 92 | * |
92 | * 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 |
93 | * enabled and disabled. SO if you use QIConSet and the toolbar | 94 | * enabled and disabled. SO if you use QIConSet and the toolbar |
94 | * 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 |
95 | * but the right ones thanks to QIconSet and Resource | 96 | * but the right ones thanks to QIconSet and Resource |
96 | */ | 97 | */ |
97 | 98 | ||
98 | void MainWindow::initUI() { | 99 | void MainWindow::initUI() { |
99 | /* | 100 | /* |
100 | * We want to provde a File Menu with Quit as option | 101 | * We want to provde a File Menu with Quit as option |
101 | * and a Fire Toolbutton ( QAction ) | 102 | * and a Fire Toolbutton ( QAction ) |
102 | * So we need two actions | 103 | * So we need two actions |
103 | * A toolbar and a popupMenu | 104 | * A toolbar and a popupMenu |
104 | */ | 105 | */ |
105 | setToolBarsMovable( false ); | 106 | setToolBarsMovable( false ); |
106 | /* | 107 | /* |
107 | *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 |
108 | * toolbar on small screens | 109 | * toolbar on small screens |
109 | */ | 110 | */ |
110 | QToolBar *menuBarHolder = new QToolBar( this ); | 111 | QToolBar *menuBarHolder = new QToolBar( this ); |
111 | /* we allow the menubarholder to become bigger than | 112 | /* we allow the menubarholder to become bigger than |
112 | * the screen width and to offer a > for the additional items | 113 | * the screen width and to offer a > for the additional items |
113 | */ | 114 | */ |
114 | menuBarHolder->setHorizontalStretchable( true ); | 115 | menuBarHolder->setHorizontalStretchable( true ); |
115 | QMenuBar *mb = new QMenuBar( menuBarHolder ); | 116 | QMenuBar *mb = new QMenuBar( menuBarHolder ); |
116 | QToolBar *tb = new QToolBar( this ); | 117 | QToolBar *tb = new QToolBar( this ); |
117 | 118 | ||
118 | QPopupMenu *fileMenu = new QPopupMenu( this ); | 119 | QPopupMenu *fileMenu = new QPopupMenu( this ); |
119 | 120 | ||
120 | /* | 121 | /* |
121 | * we create our first action with the Text Quit | 122 | * we create our first action with the Text Quit |
122 | * a IconSet, no menu name, no acceleration ( keyboard shortcut ), | 123 | * a IconSet, no menu name, no acceleration ( keyboard shortcut ), |
123 | * with parent this, and name "quit_action" | 124 | * with parent this, and name "quit_action" |
124 | */ | 125 | */ |
125 | /* | 126 | /* |
126 | * Note if you want a picture out of the inline directory | 127 | * Note if you want a picture out of the inline directory |
127 | * 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 |
128 | * into libqpe so the name without ending and directory is enough | 129 | * into libqpe so the name without ending and directory is enough |
129 | */ | 130 | */ |
130 | QAction *a = new QAction( tr("Quit"), Resource::loadIconSet("quit_icon"), | 131 | QAction *a = new QAction( tr("Quit"), Resource::loadIconSet("quit_icon"), |
131 | QString::null, 0, this, "quit_action" ); | 132 | QString::null, 0, this, "quit_action" ); |
132 | /* | 133 | /* |
133 | * Connect quit to the QApplication quit slot | 134 | * Connect quit to the QApplication quit slot |
134 | */ | 135 | */ |
135 | connect(a, SIGNAL(activated() ), | 136 | connect(a, SIGNAL(activated() ), |
136 | qApp, SLOT(quit() ) ); | 137 | qApp, SLOT(quit() ) ); |
137 | a->addTo( fileMenu ); | 138 | a->addTo( fileMenu ); |
138 | 139 | ||
139 | a = new QAction(tr("Fire"), | 140 | a = new QAction(tr("Fire"), |
140 | Resource::loadIconSet("new"), | 141 | Resource::loadIconSet("new"), |
141 | QString::null, 0, this, "fire_button"); | 142 | QString::null, 0, this, "fire_button"); |
142 | 143 | ||
143 | /* see the power? */ | 144 | /* see the power? */ |
144 | a->addTo( fileMenu ); | 145 | a->addTo( fileMenu ); |
145 | a->addTo( tb ); | 146 | a->addTo( tb ); |
146 | m_fire = a; | 147 | m_fire = a; |
147 | 148 | ||
148 | 149 | ||
149 | mb->insertItem(tr("File"), fileMenu ); | 150 | mb->insertItem(tr("File"), fileMenu ); |
150 | 151 | ||
151 | } | 152 | } |
152 | 153 | ||
153 | Simple::Simple( QWidget* parent, const char* name, WFlags fl ) | 154 | Simple::Simple( QWidget* parent, const char* name, WFlags fl ) |
154 | : QWidget( parent, name, fl ) { | 155 | : QWidget( parent, name, fl ) { |
155 | 156 | ||
156 | /* | 157 | /* |
157 | * sets the caption of this toplevel widget | 158 | * sets the caption of this toplevel widget |
158 | * put all translatable string into tr() | 159 | * put all translatable string into tr() |
159 | */ | 160 | */ |
160 | setCaption(tr("My Simple Application") ); | 161 | setCaption(tr("My Simple Application") ); |
161 | 162 | ||
162 | /* | 163 | /* |
163 | * A simple vertical layout | 164 | * A simple vertical layout |
164 | * either call layout->setAutoAdd( true ) | 165 | * either call layout->setAutoAdd( true ) |
165 | * or use layout->addWidget( wid ) to add widgets | 166 | * or use layout->addWidget( wid ) to add widgets |
166 | */ | 167 | */ |
167 | QVBoxLayout *layout = new QVBoxLayout( this ); | 168 | QVBoxLayout *layout = new QVBoxLayout( this ); |
168 | layout->setSpacing( 8 ); | 169 | layout->setSpacing( 8 ); |
169 | layout->setMargin( 11 ); | 170 | layout->setMargin( 11 ); |
170 | 171 | ||
171 | /* | 172 | /* |
172 | * creates a label | 173 | * creates a label |
173 | * 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 |
174 | * of us and will be deleted when we're deleted. | 175 | * of us and will be deleted when we're deleted. |
175 | */ | 176 | */ |
176 | QLabel *lbl = new QLabel( this, "a name for the label" ); | 177 | QLabel *lbl = new QLabel( this, "a name for the label" ); |
177 | 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") ); |
178 | layout->addWidget( lbl ); | 179 | layout->addWidget( lbl ); |
179 | 180 | ||
180 | 181 | ||
181 | /* creates a button as child of this widget */ | 182 | /* creates a button as child of this widget */ |
182 | m_button = new QPushButton(this); | 183 | m_button = new QPushButton(this); |
183 | /* | 184 | /* |
184 | * another way to call tr. The first parameter is the string | 185 | * another way to call tr. The first parameter is the string |
185 | * to translate and the second a hint to the translator | 186 | * to translate and the second a hint to the translator |
186 | */ | 187 | */ |
187 | m_button->setText( tr("Fire", "translatable quit string" ) ); | 188 | m_button->setText( tr("Fire", "translatable quit string" ) ); |
188 | layout->addWidget( m_button ); | 189 | layout->addWidget( m_button ); |
189 | 190 | ||
190 | /* | 191 | /* |
191 | * 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 |
192 | * signal and slots model | 193 | * signal and slots model |
193 | * Usage is simple connect m_buttons clicked signal to our | 194 | * Usage is simple connect m_buttons clicked signal to our |
194 | * slotQuit slot. | 195 | * slotQuit slot. |
195 | * 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 |
196 | * signal directly to qApp and SLOT(quit() ) | 197 | * signal directly to qApp and SLOT(quit() ) |
197 | */ | 198 | */ |
198 | connect( m_button, SIGNAL(clicked() ), | 199 | connect( m_button, SIGNAL(clicked() ), |
199 | this, SLOT( slotFire() ) ); | 200 | this, SLOT( slotFire() ) ); |
200 | } | 201 | } |
201 | 202 | ||
202 | /* | 203 | /* |
203 | * Our destructor is empty because all child | 204 | * Our destructor is empty because all child |
204 | * widgets and layouts will be deleted by Qt. | 205 | * widgets and layouts will be deleted by Qt. |
205 | * Same applies to QObjects | 206 | * Same applies to QObjects |
206 | */ | 207 | */ |
207 | Simple::~Simple() { | 208 | Simple::~Simple() { |
208 | 209 | ||
209 | } | 210 | } |
210 | 211 | ||
211 | void Simple::slotFire() { | 212 | void Simple::slotFire() { |
212 | /* | 213 | /* |
213 | * NOTE: Simple is now a child window of MainWindow | 214 | * NOTE: Simple is now a child window of MainWindow |
214 | * close will hide() Simple and not delete it. But as | 215 | * close will hide() Simple and not delete it. But as |
215 | * the mainwindow is shown all children will be shown as well | 216 | * the mainwindow is shown all children will be shown as well |
216 | */ | 217 | */ |
217 | close(); | 218 | close(); |
218 | } | 219 | } |
diff --git a/examples/simple-pim/config.in b/examples/simple-pim/config.in index 5d80f21..aa1a426 100644 --- a/examples/simple-pim/config.in +++ b/examples/simple-pim/config.in | |||
@@ -1,4 +1,4 @@ | |||
1 | config SIMPLE_PIM_EXAMPLE | 1 | config SIMPLE_PIM_EXAMPLE |
2 | boolean "Mainwindow with PIM and QCOP usage" | 2 | boolean "Mainwindow with PIM and QCOP usage" |
3 | default "y" | 3 | default "y" |
4 | depends ( LIBQPE || LIBQPE-X11 ) && EXAMPLES && LIBOPIE | 4 | depends ( LIBQPE || LIBQPE-X11 ) && EXAMPLES && LIBOPIEPIM2 |
diff --git a/examples/simple-pim/example.pro b/examples/simple-pim/example.pro index c3aab53..ebcdb2b 100644 --- a/examples/simple-pim/example.pro +++ b/examples/simple-pim/example.pro | |||
@@ -1,17 +1,17 @@ | |||
1 | CONFIG += qt warn_on quick-app | 1 | CONFIG += qt warn_on quick-app |
2 | 2 | ||
3 | 3 | ||
4 | TARGET = simple-pim | 4 | TARGET = simple-pim |
5 | 5 | ||
6 | HEADERS = simple.h | 6 | HEADERS = simple.h |
7 | SOURCES = simple.cpp | 7 | SOURCES = simple.cpp |
8 | 8 | ||
9 | 9 | ||
10 | INCLUDEPATH += $(OPIEDIR)/include | 10 | INCLUDEPATH += $(OPIEDIR)/include |
11 | DEPENDPATH += $(OPIEDIR)/include | 11 | DEPENDPATH += $(OPIEDIR)/include |
12 | 12 | ||
13 | 13 | ||
14 | # we now also include opie | 14 | # we now also include opie |
15 | LIBS += -lqpe -lopie | 15 | LIBS += -lqpe -lopiepim2 -lopieui2 |
16 | 16 | ||
17 | include ( $(OPIEDIR)/include.pro ) | 17 | include ( $(OPIEDIR)/include.pro ) |
diff --git a/examples/simple-pim/simple.cpp b/examples/simple-pim/simple.cpp index 029e71b..50905bf 100644 --- a/examples/simple-pim/simple.cpp +++ b/examples/simple-pim/simple.cpp | |||
@@ -1,445 +1,446 @@ | |||
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 | #include <qtimer.h> // we use it for the singleShot | 7 | #include <qtimer.h> // we use it for the singleShot |
8 | #include <qdatetime.h> // for QDate | 8 | #include <qdatetime.h> // for QDate |
9 | #include <qtextview.h> // a rich text widget | 9 | #include <qtextview.h> // a rich text widget |
10 | #include <qdialog.h> | 10 | #include <qdialog.h> |
11 | #include <qwhatsthis.h> // for whats this | 11 | #include <qwhatsthis.h> // for whats this |
12 | 12 | ||
13 | #include <qpe/qpeapplication.h> // the QPEApplication | 13 | #include <qpe/qpeapplication.h> // the QPEApplication |
14 | #include <qpe/resource.h> | 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> |
19 | 19 | ||
20 | #include <opie/oapplicationfactory.h> // a template + macro to save the main method and allow quick launching | 20 | #include <opie2/oapplicationfactory.h> // a template + macro to save the main method and allow quick launching |
21 | #include <opie/otabwidget.h> | 21 | #include <opie2/otabwidget.h> |
22 | #include <opie/owait.h> | 22 | #include <opie2/owait.h> |
23 | 23 | ||
24 | #include "simple.h" | 24 | #include "simple.h" |
25 | 25 | ||
26 | /* | 26 | /* |
27 | * implementation of simple | 27 | * implementation of simple |
28 | */ | 28 | */ |
29 | 29 | ||
30 | /* | 30 | /* |
31 | * The factory is used for quicklaunching | 31 | * The factory is used for quicklaunching |
32 | * 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 | 32 | * 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 |
33 | * | 33 | * |
34 | * Depending on the global quick launch setting this will create | 34 | * Depending on the global quick launch setting this will create |
35 | * either a main method or one for our component plugin system | 35 | * either a main method or one for our component plugin system |
36 | */ | 36 | */ |
37 | 37 | ||
38 | using namespace Opie::Core; | ||
38 | OPIE_EXPORT_APP( OApplicationFactory<MainWindow> ) | 39 | OPIE_EXPORT_APP( OApplicationFactory<MainWindow> ) |
39 | 40 | ||
40 | MainWindow::MainWindow(QWidget *parent, const char* name, WFlags fl ) | 41 | MainWindow::MainWindow(QWidget *parent, const char* name, WFlags fl ) |
41 | : QMainWindow( parent, name, fl ) { | 42 | : QMainWindow( parent, name, fl ) { |
42 | setCaption(tr("My MainWindow") ); | 43 | setCaption(tr("My MainWindow") ); |
43 | 44 | ||
44 | m_desktopChannel = 0; | 45 | m_desktopChannel = 0; |
45 | m_loading = 0; | 46 | m_loading = 0; |
46 | 47 | ||
47 | initUI(); | 48 | initUI(); |
48 | 49 | ||
49 | 50 | ||
50 | /* | 51 | /* |
51 | * Tab widget as central | 52 | * Tab widget as central |
52 | */ | 53 | */ |
53 | m_tab = new OTabWidget(this); | 54 | m_tab = new Opie::Ui::OTabWidget(this); |
54 | 55 | ||
55 | setCentralWidget( m_tab ); | 56 | setCentralWidget( m_tab ); |
56 | 57 | ||
57 | m_todoView = new PIMListView(m_tab, "Todo view" ); | 58 | m_todoView = new PIMListView(m_tab, "Todo view" ); |
58 | m_tab->addTab( m_todoView,"todo/TodoList", tr("Todos") ); | 59 | m_tab->addTab( m_todoView,"todo/TodoList", tr("Todos") ); |
59 | 60 | ||
60 | m_dateView = new PIMListView(m_tab, "Datebook view" ); | 61 | m_dateView = new PIMListView(m_tab, "Datebook view" ); |
61 | m_tab->addTab( m_dateView, "datebook/DateBook", tr("Events") ); | 62 | m_tab->addTab( m_dateView, "datebook/DateBook", tr("Events") ); |
62 | 63 | ||
63 | /* now connect the actions */ | 64 | /* now connect the actions */ |
64 | /* | 65 | /* |
65 | * we connect the activated to our show | 66 | * we connect the activated to our show |
66 | * and on activation we will show a detailed | 67 | * and on activation we will show a detailed |
67 | * summary of the record | 68 | * summary of the record |
68 | */ | 69 | */ |
69 | connect(m_fire, SIGNAL(activated() ), | 70 | connect(m_fire, SIGNAL(activated() ), |
70 | this, SLOT(slotShow() ) ); | 71 | this, SLOT(slotShow() ) ); |
71 | 72 | ||
72 | /* | 73 | /* |
73 | * We will change the date | 74 | * We will change the date |
74 | */ | 75 | */ |
75 | connect(m_dateAction, SIGNAL(activated() ), | 76 | connect(m_dateAction, SIGNAL(activated() ), |
76 | this, SLOT(slotDate() ) ); | 77 | this, SLOT(slotDate() ) ); |
77 | 78 | ||
78 | /* | 79 | /* |
79 | * connect the show signal of the PIMListView | 80 | * connect the show signal of the PIMListView |
80 | * to a slot to show a dialog | 81 | * to a slot to show a dialog |
81 | */ | 82 | */ |
82 | connect(m_todoView, SIGNAL(showRecord(const OPimRecord&) ), | 83 | connect(m_todoView, SIGNAL(showRecord(const OPimRecord&) ), |
83 | this, SLOT(slotShowRecord(const OPimRecord&) ) ); | 84 | this, SLOT(slotShowRecord(const OPimRecord&) ) ); |
84 | connect(m_dateView, SIGNAL(showRecord(const OPimRecord&) ), | 85 | connect(m_dateView, SIGNAL(showRecord(const OPimRecord&) ), |
85 | this, SLOT(slotShowRecord(const OPimRecord&) ) ); | 86 | this, SLOT(slotShowRecord(const OPimRecord&) ) ); |
86 | 87 | ||
87 | /* | 88 | /* |
88 | * Now comes the important lines of code for this example | 89 | * Now comes the important lines of code for this example |
89 | * We do not directly call load but delay loading until | 90 | * We do not directly call load but delay loading until |
90 | * all Events are dispatches and handled. | 91 | * all Events are dispatches and handled. |
91 | * SO we will load once our window is mapped to screen | 92 | * SO we will load once our window is mapped to screen |
92 | * to achieve that we use a QTimer::singleShot | 93 | * to achieve that we use a QTimer::singleShot |
93 | * After 10 milli seconds the timer fires and on TimerEvent | 94 | * After 10 milli seconds the timer fires and on TimerEvent |
94 | * out slot slotLoad will be called | 95 | * out slot slotLoad will be called |
95 | * Remember this a Constructor to construct your object and not | 96 | * Remember this a Constructor to construct your object and not |
96 | * to load | 97 | * to load |
97 | */ | 98 | */ |
98 | QTimer::singleShot( 10, this, SLOT(slotLoad() ) ); | 99 | QTimer::singleShot( 10, this, SLOT(slotLoad() ) ); |
99 | } | 100 | } |
100 | 101 | ||
101 | MainWindow::~MainWindow() { | 102 | MainWindow::~MainWindow() { |
102 | // again nothing to delete because Qt takes care | 103 | // again nothing to delete because Qt takes care |
103 | } | 104 | } |
104 | 105 | ||
105 | 106 | ||
106 | void MainWindow::setDocument( const QString& /*str*/ ) { | 107 | void MainWindow::setDocument( const QString& /*str*/ ) { |
107 | } | 108 | } |
108 | 109 | ||
109 | 110 | ||
110 | void MainWindow::initUI() { | 111 | void MainWindow::initUI() { |
111 | 112 | ||
112 | setToolBarsMovable( false ); | 113 | setToolBarsMovable( false ); |
113 | 114 | ||
114 | QToolBar *menuBarHolder = new QToolBar( this ); | 115 | QToolBar *menuBarHolder = new QToolBar( this ); |
115 | 116 | ||
116 | menuBarHolder->setHorizontalStretchable( true ); | 117 | menuBarHolder->setHorizontalStretchable( true ); |
117 | QMenuBar *mb = new QMenuBar( menuBarHolder ); | 118 | QMenuBar *mb = new QMenuBar( menuBarHolder ); |
118 | QToolBar *tb = new QToolBar( this ); | 119 | QToolBar *tb = new QToolBar( this ); |
119 | 120 | ||
120 | QPopupMenu *fileMenu = new QPopupMenu( this ); | 121 | QPopupMenu *fileMenu = new QPopupMenu( this ); |
121 | 122 | ||
122 | 123 | ||
123 | QAction *a = new QAction( tr("Quit"), Resource::loadIconSet("quit_icon"), | 124 | QAction *a = new QAction( tr("Quit"), Resource::loadIconSet("quit_icon"), |
124 | QString::null, 0, this, "quit_action" ); | 125 | QString::null, 0, this, "quit_action" ); |
125 | /* | 126 | /* |
126 | * Connect quit to the QApplication quit slot | 127 | * Connect quit to the QApplication quit slot |
127 | */ | 128 | */ |
128 | connect(a, SIGNAL(activated() ), | 129 | connect(a, SIGNAL(activated() ), |
129 | qApp, SLOT(quit() ) ); | 130 | qApp, SLOT(quit() ) ); |
130 | a->addTo( fileMenu ); | 131 | a->addTo( fileMenu ); |
131 | 132 | ||
132 | a = new QAction(tr("View Current"), | 133 | a = new QAction(tr("View Current"), |
133 | Resource::loadIconSet("zoom"), | 134 | Resource::loadIconSet("zoom"), |
134 | QString::null, 0, this, "view current"); | 135 | QString::null, 0, this, "view current"); |
135 | /* a simple whats this online explanation of out button */ | 136 | /* a simple whats this online explanation of out button */ |
136 | a->setWhatsThis(tr("Views the current record") ); | 137 | a->setWhatsThis(tr("Views the current record") ); |
137 | /* or QWhatsThis::add(widget, "description" ); */ | 138 | /* or QWhatsThis::add(widget, "description" ); */ |
138 | 139 | ||
139 | /* see the power? */ | 140 | /* see the power? */ |
140 | a->addTo( fileMenu ); | 141 | a->addTo( fileMenu ); |
141 | a->addTo( tb ); | 142 | a->addTo( tb ); |
142 | m_fire = a; | 143 | m_fire = a; |
143 | 144 | ||
144 | a = new QAction(tr("Choose Date"), | 145 | a = new QAction(tr("Choose Date"), |
145 | Resource::loadIconSet("day"), | 146 | Resource::loadIconSet("day"), |
146 | QString::null, 0, this, "choose date" ); | 147 | QString::null, 0, this, "choose date" ); |
147 | a->addTo( fileMenu ); | 148 | a->addTo( fileMenu ); |
148 | a->addTo( tb ); | 149 | a->addTo( tb ); |
149 | m_dateAction = a; | 150 | m_dateAction = a; |
150 | 151 | ||
151 | mb->insertItem(tr("File"), fileMenu ); | 152 | mb->insertItem(tr("File"), fileMenu ); |
152 | 153 | ||
153 | } | 154 | } |
154 | 155 | ||
155 | void MainWindow::slotLoad() { | 156 | void MainWindow::slotLoad() { |
156 | /* | 157 | /* |
157 | * There is no real shared access in the PIM API | 158 | * There is no real shared access in the PIM API |
158 | * It wasn't finish cause of health problems of one | 159 | * It wasn't finish cause of health problems of one |
159 | * of the authors so we do something fancy and use QCOP | 160 | * of the authors so we do something fancy and use QCOP |
160 | * the IPC system to get a current copy | 161 | * the IPC system to get a current copy |
161 | */ | 162 | */ |
162 | /* NOTES to QCOP: QCOP operates over channels and use QDataStream | 163 | /* NOTES to QCOP: QCOP operates over channels and use QDataStream |
163 | * to send data. You can check if a channel isRegistered or hook | 164 | * to send data. You can check if a channel isRegistered or hook |
164 | * yourself to that channel. A Channel is QCString and normally | 165 | * yourself to that channel. A Channel is QCString and normally |
165 | * prefix with QPE/ and then the system in example QPE/System, | 166 | * prefix with QPE/ and then the system in example QPE/System, |
166 | * QPE/Desktop a special channel is the application channel | 167 | * QPE/Desktop a special channel is the application channel |
167 | * it QPE/Application/appname this channel gets created on app | 168 | * it QPE/Application/appname this channel gets created on app |
168 | * startup by QPEApplication. QCOP is asynchronous | 169 | * startup by QPEApplication. QCOP is asynchronous |
169 | * | 170 | * |
170 | * To send you'll use QCopEnevelope | 171 | * To send you'll use QCopEnevelope |
171 | * | 172 | * |
172 | */ | 173 | */ |
173 | /* | 174 | /* |
174 | * What we will do is first is get to know if either | 175 | * What we will do is first is get to know if either |
175 | * datebook or todolist are running if so we will kindly | 176 | * datebook or todolist are running if so we will kindly |
176 | * asked to save the data for us. | 177 | * asked to save the data for us. |
177 | * If neither are running we can load directly | 178 | * If neither are running we can load directly |
178 | */ | 179 | */ |
179 | if (!QCopChannel::isRegistered("QPE/Application/todolist") && | 180 | if (!QCopChannel::isRegistered("QPE/Application/todolist") && |
180 | !QCopChannel::isRegistered("QPE/Application/datebook") ) { | 181 | !QCopChannel::isRegistered("QPE/Application/datebook") ) { |
181 | m_db.load(); | 182 | m_db.load(); |
182 | m_tb.load(); | 183 | m_tb.load(); |
183 | return slotLoadForDay( QDate::currentDate() ); | 184 | return slotLoadForDay( QDate::currentDate() ); |
184 | } | 185 | } |
185 | 186 | ||
186 | /* | 187 | /* |
187 | * prepare our answer machine the QCopChannel | 188 | * prepare our answer machine the QCopChannel |
188 | * QPE/Desktop will send "flushDone(QString)" when | 189 | * QPE/Desktop will send "flushDone(QString)" when |
189 | * the flush is done it emits a signal on receive | 190 | * the flush is done it emits a signal on receive |
190 | */ | 191 | */ |
191 | m_desktopChannel = new QCopChannel("QPE/Desktop"); | 192 | m_desktopChannel = new QCopChannel("QPE/Desktop"); |
192 | connect(m_desktopChannel, SIGNAL(received(const QCString&,const QByteArray&) ), | 193 | connect(m_desktopChannel, SIGNAL(received(const QCString&,const QByteArray&) ), |
193 | this, SLOT(slotDesktopReceive(const QCString&,const QByteArray&) ) ); | 194 | this, SLOT(slotDesktopReceive(const QCString&,const QByteArray&) ) ); |
194 | /* the numberof synced channels will be set to zero */ | 195 | /* the numberof synced channels will be set to zero */ |
195 | m_synced = 0; | 196 | m_synced = 0; |
196 | 197 | ||
197 | /* | 198 | /* |
198 | * We use {} around the QCopEnvelope because it sends its | 199 | * We use {} around the QCopEnvelope because it sends its |
199 | * data on destruction of QCopEnvelope with | 200 | * data on destruction of QCopEnvelope with |
200 | */ | 201 | */ |
201 | /* check again if not present increment synced*/ | 202 | /* check again if not present increment synced*/ |
202 | if ( QCopChannel::isRegistered("QPE/Application/todolist") ) { | 203 | if ( QCopChannel::isRegistered("QPE/Application/todolist") ) { |
203 | QCopEnvelope env("QPE/Application/todolist", "flush()" ); | 204 | QCopEnvelope env("QPE/Application/todolist", "flush()" ); |
204 | // env << data; but we do not have any parameters here | 205 | // env << data; but we do not have any parameters here |
205 | }else | 206 | }else |
206 | m_synced++; | 207 | m_synced++; |
207 | 208 | ||
208 | if ( QCopChannel::isRegistered("QPE/Application/datebook") ) { | 209 | if ( QCopChannel::isRegistered("QPE/Application/datebook") ) { |
209 | QCopEnvelope env("QPE/Application/datebook", "flush()" ); | 210 | QCopEnvelope env("QPE/Application/datebook", "flush()" ); |
210 | }else | 211 | }else |
211 | m_synced++; | 212 | m_synced++; |
212 | 213 | ||
213 | /* we will provide a wait scrren */ | 214 | /* we will provide a wait scrren */ |
214 | m_loading = new OWait(this, "wait screen" ); | 215 | m_loading = new Opie::Ui::OWait(this, "wait screen" ); |
215 | } | 216 | } |
216 | 217 | ||
217 | void MainWindow::slotDesktopReceive(const QCString& cmd, const QByteArray& data ) { | 218 | void MainWindow::slotDesktopReceive(const QCString& cmd, const QByteArray& data ) { |
218 | /* the bytearray was filled with the QDataStream now | 219 | /* the bytearray was filled with the QDataStream now |
219 | * we open it read only to get the value(s) | 220 | * we open it read only to get the value(s) |
220 | */ | 221 | */ |
221 | QDataStream stream(data, IO_ReadOnly ); | 222 | QDataStream stream(data, IO_ReadOnly ); |
222 | /* | 223 | /* |
223 | * we're only interested in the flushDone | 224 | * we're only interested in the flushDone |
224 | */ | 225 | */ |
225 | if ( cmd == "flushDone(QString)" ) { | 226 | if ( cmd == "flushDone(QString)" ) { |
226 | QString appname; | 227 | QString appname; |
227 | stream >> appname; // get the first argument out of stream | 228 | stream >> appname; // get the first argument out of stream |
228 | if (appname == QString::fromLatin1("datebook") || | 229 | if (appname == QString::fromLatin1("datebook") || |
229 | appname == QString::fromLatin1("todolist") ) | 230 | appname == QString::fromLatin1("todolist") ) |
230 | m_synced++; | 231 | m_synced++; |
231 | } | 232 | } |
232 | 233 | ||
233 | /* | 234 | /* |
234 | * If we synced both we can go ahead | 235 | * If we synced both we can go ahead |
235 | * In future this is not needed anymore when we finally | 236 | * In future this is not needed anymore when we finally |
236 | * implemented X-Ref and other PIM features | 237 | * implemented X-Ref and other PIM features |
237 | */ | 238 | */ |
238 | if (m_synced >= 2 ) { | 239 | if (m_synced >= 2 ) { |
239 | delete m_loading; | 240 | delete m_loading; |
240 | delete m_desktopChannel; | 241 | delete m_desktopChannel; |
241 | /* now we finally can start doing the actual loading */ | 242 | /* now we finally can start doing the actual loading */ |
242 | m_tb.load(); | 243 | m_tb.load(); |
243 | m_db.load(); | 244 | m_db.load(); |
244 | { | 245 | { |
245 | /* tell the applications to reload */ | 246 | /* tell the applications to reload */ |
246 | QCopEnvelope("QPE/Application/todolist", "reload()"); | 247 | QCopEnvelope("QPE/Application/todolist", "reload()"); |
247 | QCopEnvelope("QPE/Application/datebook", "reload()"); | 248 | QCopEnvelope("QPE/Application/datebook", "reload()"); |
248 | } | 249 | } |
249 | slotLoadForDay( QDate::currentDate() ); | 250 | slotLoadForDay( QDate::currentDate() ); |
250 | } | 251 | } |
251 | 252 | ||
252 | } | 253 | } |
253 | 254 | ||
254 | /* overloaded member for shortcoming of libqpe */ | 255 | /* overloaded member for shortcoming of libqpe */ |
255 | void MainWindow::slotLoadForDay(int y, int m, int d) { | 256 | void MainWindow::slotLoadForDay(int y, int m, int d) { |
256 | /* year,month, day */ | 257 | /* year,month, day */ |
257 | slotLoadForDay( QDate(y, m, d ) ); | 258 | slotLoadForDay( QDate(y, m, d ) ); |
258 | } | 259 | } |
259 | 260 | ||
260 | void MainWindow::slotLoadForDay(const QDate& date) { | 261 | void MainWindow::slotLoadForDay(const QDate& date) { |
261 | 262 | ||
262 | 263 | ||
263 | /* all todos for today including the ones without dueDate */ | 264 | /* all todos for today including the ones without dueDate */ |
264 | m_todoView->set( m_tb.effectiveToDos(date, date ) ); | 265 | m_todoView->set( m_tb.effectiveToDos(date, date ) ); |
265 | m_dateView->set( m_db.effectiveEvents( date, date ) ); | 266 | m_dateView->set( m_db.effectiveEvents( date, date ) ); |
266 | } | 267 | } |
267 | 268 | ||
268 | /* we want to show the current record */ | 269 | /* we want to show the current record */ |
269 | void MainWindow::slotShow() { | 270 | void MainWindow::slotShow() { |
270 | /* we only added PIMListViews so we can safely cast */ | 271 | /* we only added PIMListViews so we can safely cast */ |
271 | PIMListView *view = static_cast<PIMListView*>(m_tab->currentWidget() ); | 272 | PIMListView *view = static_cast<PIMListView*>(m_tab->currentWidget() ); |
272 | 273 | ||
273 | /* ask the view to send a signal */ | 274 | /* ask the view to send a signal */ |
274 | view->showCurrentRecord(); | 275 | view->showCurrentRecord(); |
275 | 276 | ||
276 | } | 277 | } |
277 | 278 | ||
278 | /* as answer this slot will be called */ | 279 | /* as answer this slot will be called */ |
279 | void MainWindow::slotShowRecord( const OPimRecord& rec) { | 280 | void MainWindow::slotShowRecord( const Opie::OPimRecord& rec) { |
280 | /* got a parent but still is a toplevel MODAL dialog */ | 281 | /* got a parent but still is a toplevel MODAL dialog */ |
281 | QDialog* dia = new QDialog(this,"dialog",TRUE ); | 282 | QDialog* dia = new QDialog(this,"dialog",TRUE ); |
282 | QVBoxLayout *box = new QVBoxLayout( dia ); | 283 | QVBoxLayout *box = new QVBoxLayout( dia ); |
283 | dia->setCaption( tr("View Record") ); | 284 | dia->setCaption( tr("View Record") ); |
284 | 285 | ||
285 | 286 | ||
286 | QTextView *view = new QTextView(dia ); | 287 | QTextView *view = new QTextView(dia ); |
287 | view->setText( rec.toRichText() ); | 288 | view->setText( rec.toRichText() ); |
288 | box->addWidget( view ); | 289 | box->addWidget( view ); |
289 | /* | 290 | /* |
290 | * execute via QPEApplication | 291 | * execute via QPEApplication |
291 | * this allows QPEApplication to make a sane decision | 292 | * this allows QPEApplication to make a sane decision |
292 | * on the size | 293 | * on the size |
293 | */ | 294 | */ |
294 | dia->showMaximized(); | 295 | dia->showMaximized(); |
295 | QPEApplication::execDialog( dia ); | 296 | QPEApplication::execDialog( dia ); |
296 | delete dia; | 297 | delete dia; |
297 | } | 298 | } |
298 | 299 | ||
299 | 300 | ||
300 | void MainWindow::slotDate() { | 301 | void MainWindow::slotDate() { |
301 | /* | 302 | /* |
302 | * called by the action we will show a Popup | 303 | * called by the action we will show a Popup |
303 | * at the current mouse position with a DateChooser | 304 | * at the current mouse position with a DateChooser |
304 | * to select the day | 305 | * to select the day |
305 | */ | 306 | */ |
306 | qWarning("slot Date"); | 307 | qWarning("slot Date"); |
307 | QPopupMenu *menu = new QPopupMenu(); | 308 | QPopupMenu *menu = new QPopupMenu(); |
308 | /* A Month to select a date from TRUE for auto close */ | 309 | /* A Month to select a date from TRUE for auto close */ |
309 | DateBookMonth *month = new DateBookMonth(menu, 0, true ); | 310 | DateBookMonth *month = new DateBookMonth(menu, 0, true ); |
310 | connect(month, SIGNAL(dateClicked(int,int,int) ), | 311 | connect(month, SIGNAL(dateClicked(int,int,int) ), |
311 | this, SLOT(slotLoadForDay(int,int,int) ) ); | 312 | this, SLOT(slotLoadForDay(int,int,int) ) ); |
312 | 313 | ||
313 | menu->insertItem( month ); | 314 | menu->insertItem( month ); |
314 | 315 | ||
315 | menu->exec( QCursor::pos() ); | 316 | menu->exec( QCursor::pos() ); |
316 | 317 | ||
317 | /* | 318 | /* |
318 | * we do not need to delete month because | 319 | * we do not need to delete month because |
319 | * we delete its parent menu | 320 | * we delete its parent menu |
320 | */ | 321 | */ |
321 | 322 | ||
322 | delete menu; | 323 | delete menu; |
323 | } | 324 | } |
324 | 325 | ||
325 | /* | 326 | /* |
326 | * An anonymous namespace this symbol is only available here | 327 | * An anonymous namespace this symbol is only available here |
327 | * so truely private | 328 | * so truely private |
328 | */ | 329 | */ |
329 | namespace { | 330 | namespace { |
330 | /* not static cause namespace does that what static would do */ | 331 | /* not static cause namespace does that what static would do */ |
331 | const int RTTI = 5050; | 332 | const int RTTI = 5050; |
332 | /* | 333 | /* |
333 | * every ListView got Items. we've special pim items | 334 | * every ListView got Items. we've special pim items |
334 | * holding ownership and the pointer to a pim record | 335 | * holding ownership and the pointer to a pim record |
335 | * it can't hold a pimrecord directly because this | 336 | * it can't hold a pimrecord directly because this |
336 | * would introduce slicing... any break | 337 | * would introduce slicing... any break |
337 | */ | 338 | */ |
338 | /* | 339 | /* |
339 | * A struct is a special class. Everything is public by | 340 | * A struct is a special class. Everything is public by |
340 | * default. | 341 | * default. |
341 | */ | 342 | */ |
342 | struct PIMListViewItem : public QListViewItem { | 343 | struct PIMListViewItem : public QListViewItem { |
343 | /* | 344 | /* |
344 | *currently no hierachies are planed for the example | 345 | *currently no hierachies are planed for the example |
345 | * so only one constructor with a QListView as parent | 346 | * so only one constructor with a QListView as parent |
346 | */ | 347 | */ |
347 | PIMListViewItem( QListView*, OPimRecord* record ); | 348 | PIMListViewItem( QListView*, Opie::OPimRecord* record ); |
348 | ~PIMListViewItem(); | 349 | ~PIMListViewItem(); |
349 | 350 | ||
350 | /* used by the QListViewItem to easily allow identifiying of different | 351 | /* used by the QListViewItem to easily allow identifiying of different |
351 | * items. Values greater than 1000 should be used */ | 352 | * items. Values greater than 1000 should be used */ |
352 | int rtti()const; | 353 | int rtti()const; |
353 | OPimRecord* record()const; | 354 | Opie::OPimRecord* record()const; |
354 | 355 | ||
355 | private: | 356 | private: |
356 | OPimRecord* m_record; | 357 | Opie::OPimRecord* m_record; |
357 | }; | 358 | }; |
358 | 359 | ||
359 | PIMListViewItem::PIMListViewItem( QListView *p, OPimRecord* rec ) | 360 | PIMListViewItem::PIMListViewItem( QListView *p, Opie::OPimRecord* rec ) |
360 | : QListViewItem(p), m_record( rec ) { | 361 | : QListViewItem(p), m_record( rec ) { |
361 | } | 362 | } |
362 | 363 | ||
363 | PIMListViewItem::~PIMListViewItem() { | 364 | PIMListViewItem::~PIMListViewItem() { |
364 | /* we've the onwership so we need to delete it */ | 365 | /* we've the onwership so we need to delete it */ |
365 | delete m_record; | 366 | delete m_record; |
366 | } | 367 | } |
367 | 368 | ||
368 | OPimRecord* PIMListViewItem::record()const { | 369 | Opie::OPimRecord* PIMListViewItem::record()const { |
369 | return m_record; | 370 | return m_record; |
370 | } | 371 | } |
371 | 372 | ||
372 | } | 373 | } |
373 | 374 | ||
374 | 375 | ||
375 | PIMListView::PIMListView( QWidget* widget, const char* name, WFlags fl ) | 376 | PIMListView::PIMListView( QWidget* widget, const char* name, WFlags fl ) |
376 | : QListView(widget, name, fl ) | 377 | : QListView(widget, name, fl ) |
377 | { | 378 | { |
378 | addColumn("Summary"); | 379 | addColumn("Summary"); |
379 | } | 380 | } |
380 | 381 | ||
381 | PIMListView::~PIMListView() { | 382 | PIMListView::~PIMListView() { |
382 | 383 | ||
383 | } | 384 | } |
384 | 385 | ||
385 | void PIMListView::set( OTodoAccess::List list ) { | 386 | void PIMListView::set( Opie::OPimTodoAccess::List list ) { |
386 | /* clear first and then add new items */ | 387 | /* clear first and then add new items */ |
387 | clear(); | 388 | clear(); |
388 | 389 | ||
389 | OTodoAccess::List::Iterator it; | 390 | Opie::OPimTodoAccess::List::Iterator it; |
390 | for (it = list.begin(); it != list.end(); ++it ) { | 391 | for (it = list.begin(); it != list.end(); ++it ) { |
391 | /* | 392 | /* |
392 | * make a new item which automatically gets added to the listview | 393 | * make a new item which automatically gets added to the listview |
393 | * and call the copy c'tor to create a new OTodo | 394 | * and call the copy c'tor to create a new OPimTodo |
394 | */ | 395 | */ |
395 | PIMListViewItem *i = new PIMListViewItem(this, new OTodo( *it ) ); | 396 | PIMListViewItem *i = new PIMListViewItem(this, new Opie::OPimTodo( *it ) ); |
396 | i->setText(0, (*it).summary() ); | 397 | i->setText(0, (*it).summary() ); |
397 | } | 398 | } |
398 | } | 399 | } |
399 | 400 | ||
400 | void PIMListView::set( const OEffectiveEvent::ValueList& lst ) { | 401 | void PIMListView::set( const Opie::OEffectiveEvent::ValueList& lst ) { |
401 | /* clear first and then add items */ | 402 | /* clear first and then add items */ |
402 | clear(); | 403 | clear(); |
403 | 404 | ||
404 | OEffectiveEvent::ValueList::ConstIterator it; | 405 | Opie::OEffectiveEvent::ValueList::ConstIterator it; |
405 | for ( it = lst.begin(); it != lst.end(); ++it ) { | 406 | for ( it = lst.begin(); it != lst.end(); ++it ) { |
406 | PIMListViewItem *i = new PIMListViewItem(this, new OEvent( (*it).event() ) ); | 407 | PIMListViewItem *i = new PIMListViewItem(this, new Opie::OPimEvent( (*it).event() ) ); |
407 | i->setText( 0, PIMListView::makeString( (*it) ) ); | 408 | i->setText( 0, PIMListView::makeString( (*it) ) ); |
408 | } | 409 | } |
409 | 410 | ||
410 | } | 411 | } |
411 | 412 | ||
412 | void PIMListView::showCurrentRecord() { | 413 | void PIMListView::showCurrentRecord() { |
413 | /* it could be possible that their is no currentItem */ | 414 | /* it could be possible that their is no currentItem */ |
414 | if (!currentItem() ) | 415 | if (!currentItem() ) |
415 | return; | 416 | return; |
416 | 417 | ||
417 | /* | 418 | /* |
418 | * we only add PIMListViewItems so it is save | 419 | * we only add PIMListViewItems so it is save |
419 | * to do this case. If this would not be the case | 420 | * to do this case. If this would not be the case |
420 | * use rtti() to check in a switch() case | 421 | * use rtti() to check in a switch() case |
421 | */ | 422 | */ |
422 | PIMListViewItem *item = static_cast<PIMListViewItem*>( currentItem() ); | 423 | PIMListViewItem *item = static_cast<PIMListViewItem*>( currentItem() ); |
423 | 424 | ||
424 | /* finally you see how to emit a signal */ | 425 | /* finally you see how to emit a signal */ |
425 | emit showRecord( (*item->record() ) ); | 426 | emit showRecord( (*item->record() ) ); |
426 | } | 427 | } |
427 | 428 | ||
428 | QString PIMListView::makeString( const OEffectiveEvent& ev ) { | 429 | QString PIMListView::makeString( const Opie::OEffectiveEvent& ev ) { |
429 | QString str; | 430 | QString str; |
430 | str += ev.description(); | 431 | str += ev.description(); |
431 | if ( !ev.event().isAllDay() ) { | 432 | if ( !ev.event().isAllDay() ) { |
432 | if ( ev.startDate() != ev.endDate() ) { | 433 | if ( ev.startDate() != ev.endDate() ) { |
433 | str += tr("Start ") + TimeString::timeString( ev.event().startDateTime().time() ); | 434 | str += tr("Start ") + TimeString::timeString( ev.event().startDateTime().time() ); |
434 | str += " - " + TimeString::longDateString( ev.startDate() ); | 435 | str += " - " + TimeString::longDateString( ev.startDate() ); |
435 | str += tr("End ") + TimeString::timeString( ev.event().endDateTime().time() ); | 436 | str += tr("End ") + TimeString::timeString( ev.event().endDateTime().time() ); |
436 | str += " - " + TimeString::longDateString( ev.endDate() ); | 437 | str += " - " + TimeString::longDateString( ev.endDate() ); |
437 | }else{ | 438 | }else{ |
438 | str += tr("Time ") + TimeString::timeString( ev.startTime() ); | 439 | str += tr("Time ") + TimeString::timeString( ev.startTime() ); |
439 | str += " - " + TimeString::timeString( ev.endTime() ); | 440 | str += " - " + TimeString::timeString( ev.endTime() ); |
440 | } | 441 | } |
441 | }else | 442 | }else |
442 | str += tr(" This is an All-Day Event"); | 443 | str += tr(" This is an All-Day Event"); |
443 | 444 | ||
444 | return str; | 445 | return str; |
445 | } | 446 | } |
diff --git a/examples/simple-pim/simple.h b/examples/simple-pim/simple.h index bf9ede7..2a6e8ce 100644 --- a/examples/simple-pim/simple.h +++ b/examples/simple-pim/simple.h | |||
@@ -1,95 +1,99 @@ | |||
1 | 1 | ||
2 | /* | 2 | /* |
3 | * A Simple widget with a button to quit | 3 | * A Simple widget with a button to quit |
4 | * | 4 | * |
5 | */ | 5 | */ |
6 | 6 | ||
7 | /* | 7 | /* |
8 | * The below sequence is called a guard and guards | 8 | * The below sequence is called a guard and guards |
9 | * against multiple inclusion of header files | 9 | * against multiple inclusion of header files |
10 | * NOTE: you need to use unique names among the header files | 10 | * NOTE: you need to use unique names among the header files |
11 | */ | 11 | */ |
12 | #ifndef QUIET_SIMPLE_DEMO_H | 12 | #ifndef QUIET_SIMPLE_DEMO_H |
13 | #define QUIET_SIMPLE_DEMO_H | 13 | #define QUIET_SIMPLE_DEMO_H |
14 | 14 | ||
15 | 15 | ||
16 | 16 | ||
17 | 17 | ||
18 | #include <qmainwindow.h> // from this class we will inherit | 18 | #include <qmainwindow.h> // from this class we will inherit |
19 | #include <qlistview.h> // A ListView for our PIM records | 19 | #include <qlistview.h> // A ListView for our PIM records |
20 | 20 | ||
21 | #include <opie/otodoaccess.h> | 21 | #include <opie2/otodoaccess.h> |
22 | #include <opie/odatebookaccess.h> | 22 | #include <opie2/odatebookaccess.h> |
23 | 23 | ||
24 | class QPushButton; // forward declaration to not include the header. This can save time when compiling | 24 | class QPushButton; // forward declaration to not include the header. This can save time when compiling |
25 | class QAction; | 25 | class QAction; |
26 | class PIMListView; | 26 | class PIMListView; |
27 | class QDate; | 27 | class QDate; |
28 | class QCopChannel; | 28 | class QCopChannel; |
29 | namespace Opie{ | ||
30 | namespace Ui { | ||
29 | class OWait; | 31 | class OWait; |
30 | class OTabWidget; | 32 | class OTabWidget; |
33 | } | ||
34 | } | ||
31 | 35 | ||
32 | /* | 36 | /* |
33 | * A mainwindow is a special QWidget it helps layouting | 37 | * A mainwindow is a special QWidget it helps layouting |
34 | * toolbar, statusbar, menubar. Got dockable areas | 38 | * toolbar, statusbar, menubar. Got dockable areas |
35 | * So in one sentence it is a MainWindow :) | 39 | * So in one sentence it is a MainWindow :) |
36 | */ | 40 | */ |
37 | class MainWindow : public QMainWindow { | 41 | class MainWindow : public QMainWindow { |
38 | Q_OBJECT | 42 | Q_OBJECT |
39 | public: | 43 | public: |
40 | static QString appName() { return QString::fromLatin1("simple-pim"); } | 44 | static QString appName() { return QString::fromLatin1("simple-pim"); } |
41 | MainWindow( QWidget* parent, const char* name, WFlags fl ); | 45 | MainWindow( QWidget* parent, const char* name, WFlags fl ); |
42 | ~MainWindow(); | 46 | ~MainWindow(); |
43 | 47 | ||
44 | public slots: | 48 | public slots: |
45 | void setDocument( const QString& ); | 49 | void setDocument( const QString& ); |
46 | private slots: | 50 | private slots: |
47 | void slotDesktopReceive( const QCString&, const QByteArray& ); | 51 | void slotDesktopReceive( const QCString&, const QByteArray& ); |
48 | void slotLoad(); | 52 | void slotLoad(); |
49 | void slotLoadForDay(int, int, int ); | 53 | void slotLoadForDay(int, int, int ); |
50 | void slotLoadForDay(const QDate&); | 54 | void slotLoadForDay(const QDate&); |
51 | void slotShow(); | 55 | void slotShow(); |
52 | void slotDate(); | 56 | void slotDate(); |
53 | void slotShowRecord( const OPimRecord& ); | 57 | void slotShowRecord( const Opie::OPimRecord& ); |
54 | 58 | ||
55 | private: | 59 | private: |
56 | void initUI(); | 60 | void initUI(); |
57 | QAction *m_fire; | 61 | QAction *m_fire; |
58 | QAction *m_dateAction; | 62 | QAction *m_dateAction; |
59 | OTabWidget* m_tab; | 63 | Opie::Ui::OTabWidget* m_tab; |
60 | 64 | ||
61 | OTodoAccess m_tb; | 65 | Opie::OPimTodoAccess m_tb; |
62 | ODateBookAccess m_db; | 66 | Opie::ODateBookAccess m_db; |
63 | PIMListView *m_todoView; | 67 | PIMListView *m_todoView; |
64 | PIMListView *m_dateView; | 68 | PIMListView *m_dateView; |
65 | 69 | ||
66 | int m_synced; // a counter for synced objects.. | 70 | int m_synced; // a counter for synced objects.. |
67 | QCopChannel *m_desktopChannel; | 71 | QCopChannel *m_desktopChannel; |
68 | OWait *m_loading; | 72 | Opie::Ui::OWait *m_loading; |
69 | }; | 73 | }; |
70 | 74 | ||
71 | /* | 75 | /* |
72 | * Instead of the simple QWidgets we will design | 76 | * Instead of the simple QWidgets we will design |
73 | * a new widget based on a QListView | 77 | * a new widget based on a QListView |
74 | * it should show either Todos or EffectiveEvents | 78 | * it should show either Todos or EffectiveEvents |
75 | */ | 79 | */ |
76 | class PIMListView : public QListView { | 80 | class PIMListView : public QListView { |
77 | Q_OBJECT | 81 | Q_OBJECT |
78 | public: | 82 | public: |
79 | PIMListView( QWidget* parent, const char* name, WFlags fl= 0 ); | 83 | PIMListView( QWidget* parent, const char* name, WFlags fl= 0 ); |
80 | ~PIMListView(); | 84 | ~PIMListView(); |
81 | 85 | ||
82 | 86 | ||
83 | void set( OTodoAccess::List ); | 87 | void set( Opie::OPimTodoAccess::List ); |
84 | void set( const OEffectiveEvent::ValueList& ); | 88 | void set( const Opie::OEffectiveEvent::ValueList& ); |
85 | void showCurrentRecord(); | 89 | void showCurrentRecord(); |
86 | 90 | ||
87 | signals: | 91 | signals: |
88 | void showRecord( const OPimRecord& ); | 92 | void showRecord( const Opie::OPimRecord& ); |
89 | 93 | ||
90 | private: | 94 | private: |
91 | static QString makeString( const OEffectiveEvent& ev ); | 95 | static QString makeString( const Opie::OEffectiveEvent& ev ); |
92 | 96 | ||
93 | }; | 97 | }; |
94 | 98 | ||
95 | #endif | 99 | #endif |
diff --git a/examples/simple/simple.cpp b/examples/simple/simple.cpp index a0bc308..faf13c9 100644 --- a/examples/simple/simple.cpp +++ b/examples/simple/simple.cpp | |||
@@ -1,89 +1,91 @@ | |||
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 | 6 | ||
7 | #include <opie/oapplicationfactory.h> // a template + macro to save the main method and allow quick launching | 7 | #include <opie2/oapplicationfactory.h> // a template + macro to save the main method and allow quick launching |
8 | 8 | ||
9 | #include "simple.h" | 9 | #include "simple.h" |
10 | 10 | ||
11 | /* | 11 | /* |
12 | * implementation of simple | 12 | * implementation of simple |
13 | */ | 13 | */ |
14 | 14 | ||
15 | /* | 15 | /* |
16 | * The factory is used for quicklaunching | 16 | * The factory is used for quicklaunching |
17 | * 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 | 17 | * 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 | * | 18 | * |
19 | * Depending on the global quick launch setting this will create | 19 | * Depending on the global quick launch setting this will create |
20 | * either a main method or one for our component plugin system | 20 | * either a main method or one for our component plugin system |
21 | */ | 21 | */ |
22 | 22 | ||
23 | /* The OApplicationFactory is in Opie::Core */ | ||
24 | using namespace Opie::Core; | ||
23 | OPIE_EXPORT_APP( OApplicationFactory<Simple> ) | 25 | OPIE_EXPORT_APP( OApplicationFactory<Simple> ) |
24 | 26 | ||
25 | Simple::Simple( QWidget* parent, const char* name, WFlags fl ) | 27 | Simple::Simple( QWidget* parent, const char* name, WFlags fl ) |
26 | : QWidget( parent, name, fl ) { | 28 | : QWidget( parent, name, fl ) { |
27 | 29 | ||
28 | /* | 30 | /* |
29 | * sets the caption of this toplevel widget | 31 | * sets the caption of this toplevel widget |
30 | * put all translatable string into tr() | 32 | * put all translatable string into tr() |
31 | */ | 33 | */ |
32 | setCaption(tr("My Simple Application") ); | 34 | setCaption(tr("My Simple Application") ); |
33 | 35 | ||
34 | /* | 36 | /* |
35 | * A simple vertical layout | 37 | * A simple vertical layout |
36 | * either call layout->setAutoAdd( true ) | 38 | * either call layout->setAutoAdd( true ) |
37 | * or use layout->addWidget( wid ) to add widgets | 39 | * or use layout->addWidget( wid ) to add widgets |
38 | */ | 40 | */ |
39 | QVBoxLayout *layout = new QVBoxLayout( this ); | 41 | QVBoxLayout *layout = new QVBoxLayout( this ); |
40 | layout->setSpacing( 8 ); | 42 | layout->setSpacing( 8 ); |
41 | layout->setMargin( 11 ); | 43 | layout->setMargin( 11 ); |
42 | 44 | ||
43 | /* | 45 | /* |
44 | * creates a label | 46 | * creates a label |
45 | * The first parameter is this widget so the Label is a child | 47 | * The first parameter is this widget so the Label is a child |
46 | * of us and will be deleted when we're deleted. | 48 | * of us and will be deleted when we're deleted. |
47 | */ | 49 | */ |
48 | QLabel *lbl = new QLabel( this, "a name for the label" ); | 50 | QLabel *lbl = new QLabel( this, "a name for the label" ); |
49 | lbl->setText( tr("Click on the button or follow the white rabbit") ); | 51 | lbl->setText( tr("Click on the button or follow the white rabbit") ); |
50 | layout->addWidget( lbl ); | 52 | layout->addWidget( lbl ); |
51 | 53 | ||
52 | 54 | ||
53 | /* creates a button as child of this widget */ | 55 | /* creates a button as child of this widget */ |
54 | m_button = new QPushButton(this); | 56 | m_button = new QPushButton(this); |
55 | /* | 57 | /* |
56 | * another way to call tr. The first parameter is the string | 58 | * another way to call tr. The first parameter is the string |
57 | * to translate and the second a hint to the translator | 59 | * to translate and the second a hint to the translator |
58 | */ | 60 | */ |
59 | m_button->setText( tr("Quit", "translatable quit string" ) ); | 61 | m_button->setText( tr("Quit", "translatable quit string" ) ); |
60 | layout->addWidget( m_button ); | 62 | layout->addWidget( m_button ); |
61 | 63 | ||
62 | /* | 64 | /* |
63 | * Now we bring the action into it. The power of qt is the dynamic | 65 | * Now we bring the action into it. The power of qt is the dynamic |
64 | * signal and slots model | 66 | * signal and slots model |
65 | * Usage is simple connect m_buttons clicked signal to our | 67 | * Usage is simple connect m_buttons clicked signal to our |
66 | * slotQuit slot. | 68 | * slotQuit slot. |
67 | * We could also have connected a SIGNAL to a SIGNAL or the clicked | 69 | * We could also have connected a SIGNAL to a SIGNAL or the clicked |
68 | * signal directly to qApp and SLOT(quit() ) | 70 | * signal directly to qApp and SLOT(quit() ) |
69 | */ | 71 | */ |
70 | connect( m_button, SIGNAL(clicked() ), | 72 | connect( m_button, SIGNAL(clicked() ), |
71 | this, SLOT( slotQuit() ) ); | 73 | this, SLOT( slotQuit() ) ); |
72 | } | 74 | } |
73 | 75 | ||
74 | /* | 76 | /* |
75 | * Our destructor is empty because all child | 77 | * Our destructor is empty because all child |
76 | * widgets and layouts will be deleted by Qt. | 78 | * widgets and layouts will be deleted by Qt. |
77 | * Same applies to QObjects | 79 | * Same applies to QObjects |
78 | */ | 80 | */ |
79 | Simple::~Simple() { | 81 | Simple::~Simple() { |
80 | 82 | ||
81 | } | 83 | } |
82 | 84 | ||
83 | void Simple::slotQuit() { | 85 | void Simple::slotQuit() { |
84 | /* | 86 | /* |
85 | * we will close this window and Qt will recognize that | 87 | * we will close this window and Qt will recognize that |
86 | * the last window was closed and initiate a shutdown | 88 | * the last window was closed and initiate a shutdown |
87 | */ | 89 | */ |
88 | close(); | 90 | close(); |
89 | } | 91 | } |
diff --git a/examples/todayplugin/config.in b/examples/todayplugin/config.in index 53004cb..0a6a573 100644 --- a/examples/todayplugin/config.in +++ b/examples/todayplugin/config.in | |||
@@ -1,5 +1,5 @@ | |||
1 | config TODAY_EXAMPLE | 1 | config TODAY_EXAMPLE |
2 | boolean "Opie-Today Plugin Example" | 2 | boolean "Opie-Today Plugin Example" |
3 | default "n" | 3 | default "n" |
4 | depends ( LIBQPE || LIBQPE-X11 ) && EXAMPLES && LIBOPIE | 4 | depends ( LIBQPE || LIBQPE-X11 ) && EXAMPLES && LIBOPIEUI2 |
5 | 5 | ||
diff --git a/examples/todayplugin/example.pro b/examples/todayplugin/example.pro index 4c8c942..f4bca36 100644 --- a/examples/todayplugin/example.pro +++ b/examples/todayplugin/example.pro | |||
@@ -1,17 +1,17 @@ | |||
1 | TEMPLATE = lib | 1 | TEMPLATE = lib |
2 | CONFIG -= moc | 2 | CONFIG -= moc |
3 | CONFIG += qt release | 3 | CONFIG += qt release |
4 | 4 | ||
5 | # Input | 5 | # Input |
6 | HEADERS = exampleplugin.h examplepluginimpl.h examplepluginwidget.h | 6 | HEADERS = exampleplugin.h examplepluginimpl.h examplepluginwidget.h |
7 | SOURCES = exampleplugin.cpp examplepluginimpl.cpp examplepluginwidget.cpp | 7 | SOURCES = exampleplugin.cpp examplepluginimpl.cpp examplepluginwidget.cpp |
8 | 8 | ||
9 | INCLUDEPATH += $(OPIEDIR)/include | 9 | INCLUDEPATH += $(OPIEDIR)/include |
10 | DEPENDPATH += $(OPIEDIR)/include | 10 | DEPENDPATH += $(OPIEDIR)/include |
11 | 11 | ||
12 | LIBS+= -lqpe -lopie | 12 | LIBS+= -lqpe -lopieui2 |
13 | 13 | ||
14 | DESTDIR = $(OPIEDIR)/plugins/today | 14 | DESTDIR = $(OPIEDIR)/plugins/today |
15 | TARGET = todayexampleplugin | 15 | TARGET = todayexampleplugin |
16 | 16 | ||
17 | include ( $(OPIEDIR)/include.pro ) | 17 | include ( $(OPIEDIR)/include.pro ) |
diff --git a/examples/todayplugin/exampleplugin.h b/examples/todayplugin/exampleplugin.h index a1df923..94f5b37 100644 --- a/examples/todayplugin/exampleplugin.h +++ b/examples/todayplugin/exampleplugin.h | |||
@@ -1,42 +1,42 @@ | |||
1 | /* | 1 | /* |
2 | * exampleplugin.h | 2 | * exampleplugin.h |
3 | * | 3 | * |
4 | * email : harlekin@handhelds.org | 4 | * email : harlekin@handhelds.org |
5 | * | 5 | * |
6 | */ | 6 | */ |
7 | 7 | ||
8 | 8 | ||
9 | #ifndef EXAMPLE_PLUGIN_H | 9 | #ifndef EXAMPLE_PLUGIN_H |
10 | #define EXAMPLE_PLUGIN_H | 10 | #define EXAMPLE_PLUGIN_H |
11 | 11 | ||
12 | #include <qwidget.h> | 12 | #include <qwidget.h> |
13 | #include <qguardedptr.h> | 13 | #include <qguardedptr.h> |
14 | 14 | ||
15 | #include <opie/todayplugininterface.h> | 15 | #include <opie2/todayplugininterface.h> |
16 | #include <opie/todayconfigwidget.h> | 16 | #include <opie2/todayconfigwidget.h> |
17 | 17 | ||
18 | #include "examplepluginwidget.h" | 18 | #include "examplepluginwidget.h" |
19 | 19 | ||
20 | // implementation of the today plugin interface | 20 | // implementation of the today plugin interface |
21 | class ExamplePlugin : public TodayPluginObject { | 21 | class ExamplePlugin : public TodayPluginObject { |
22 | 22 | ||
23 | public: | 23 | public: |
24 | ExamplePlugin(); | 24 | ExamplePlugin(); |
25 | ~ExamplePlugin(); | 25 | ~ExamplePlugin(); |
26 | 26 | ||
27 | QString pluginName() const; | 27 | QString pluginName() const; |
28 | double versionNumber() const; | 28 | double versionNumber() const; |
29 | QString pixmapNameWidget() const; | 29 | QString pixmapNameWidget() const; |
30 | QWidget* widget(QWidget *); | 30 | QWidget* widget(QWidget *); |
31 | QString pixmapNameConfig() const; | 31 | QString pixmapNameConfig() const; |
32 | TodayConfigWidget* configWidget(QWidget *); | 32 | TodayConfigWidget* configWidget(QWidget *); |
33 | QString appName() const; | 33 | QString appName() const; |
34 | bool excludeFromRefresh() const; | 34 | bool excludeFromRefresh() const; |
35 | void refresh(); | 35 | void refresh(); |
36 | void reinitialize(); | 36 | void reinitialize(); |
37 | 37 | ||
38 | private: | 38 | private: |
39 | QGuardedPtr<ExamplePluginWidget> m_widget; | 39 | QGuardedPtr<ExamplePluginWidget> m_widget; |
40 | }; | 40 | }; |
41 | 41 | ||
42 | #endif | 42 | #endif |
diff --git a/examples/todayplugin/examplepluginimpl.h b/examples/todayplugin/examplepluginimpl.h index 77ec4f6..31f8907 100644 --- a/examples/todayplugin/examplepluginimpl.h +++ b/examples/todayplugin/examplepluginimpl.h | |||
@@ -1,30 +1,30 @@ | |||
1 | /* | 1 | /* |
2 | * examplepluginimpl.h | 2 | * examplepluginimpl.h |
3 | * | 3 | * |
4 | * email : harlekin@handhelds.org | 4 | * email : harlekin@handhelds.org |
5 | * | 5 | * |
6 | */ | 6 | */ |
7 | 7 | ||
8 | #ifndef EXAMPLE_PLUGIN_IMPL_H | 8 | #ifndef EXAMPLE_PLUGIN_IMPL_H |
9 | #define EXAMPLE_PLUGIN_IMPL_H | 9 | #define EXAMPLE_PLUGIN_IMPL_H |
10 | 10 | ||
11 | #include <opie/todayplugininterface.h> | 11 | #include <opie2/todayplugininterface.h> |
12 | 12 | ||
13 | class ExamplePlugin; | 13 | class ExamplePlugin; |
14 | 14 | ||
15 | class ExamplePluginImpl : public TodayPluginInterface{ | 15 | class ExamplePluginImpl : public TodayPluginInterface{ |
16 | 16 | ||
17 | public: | 17 | public: |
18 | ExamplePluginImpl(); | 18 | ExamplePluginImpl(); |
19 | virtual ~ExamplePluginImpl(); | 19 | virtual ~ExamplePluginImpl(); |
20 | 20 | ||
21 | QRESULT queryInterface( const QUuid &, QUnknownInterface** ); | 21 | QRESULT queryInterface( const QUuid &, QUnknownInterface** ); |
22 | Q_REFCOUNT | 22 | Q_REFCOUNT |
23 | 23 | ||
24 | virtual TodayPluginObject *guiPart(); | 24 | virtual TodayPluginObject *guiPart(); |
25 | 25 | ||
26 | private: | 26 | private: |
27 | ExamplePlugin *examplePlugin; | 27 | ExamplePlugin *examplePlugin; |
28 | }; | 28 | }; |
29 | 29 | ||
30 | #endif | 30 | #endif |
diff --git a/examples/todayplugin/examplepluginwidget.cpp b/examples/todayplugin/examplepluginwidget.cpp index d66a11a..10fd39a 100644 --- a/examples/todayplugin/examplepluginwidget.cpp +++ b/examples/todayplugin/examplepluginwidget.cpp | |||
@@ -1,62 +1,63 @@ | |||
1 | /* | 1 | /* |
2 | * examplepluginwidget.cpp | 2 | * examplepluginwidget.cpp |
3 | * | 3 | * |
4 | * email : harlekin@handhelds.org | 4 | * email : harlekin@handhelds.org |
5 | * | 5 | * |
6 | */ | 6 | */ |
7 | 7 | ||
8 | #include <qpe/config.h> | 8 | #include <qpe/config.h> |
9 | #include <qpe/qcopenvelope_qws.h> | 9 | #include <qpe/qcopenvelope_qws.h> |
10 | 10 | ||
11 | #include "examplepluginwidget.h" | 11 | #include "examplepluginwidget.h" |
12 | 12 | ||
13 | |||
13 | ExamplePluginWidget::ExamplePluginWidget( QWidget *parent, const char* name) | 14 | ExamplePluginWidget::ExamplePluginWidget( QWidget *parent, const char* name) |
14 | : QWidget(parent, name ) { | 15 | : QWidget(parent, name ) { |
15 | 16 | ||
16 | m_exampleLabel = 0l; | 17 | m_exampleLabel = 0l; |
17 | m_layout = 0l; | 18 | m_layout = 0l; |
18 | 19 | ||
19 | if ( m_exampleLabel ) { | 20 | if ( m_exampleLabel ) { |
20 | delete m_exampleLabel; | 21 | delete m_exampleLabel; |
21 | } | 22 | } |
22 | 23 | ||
23 | // since here a OClickableLabel is used, the plugin part will be clickable, and the actions | 24 | // since here a OClickableLabel is used, the plugin part will be clickable, and the actions |
24 | // that should be triggered when clicked are defined in slotClicked() | 25 | // that should be triggered when clicked are defined in slotClicked() |
25 | // of course also normal widgets can be used. | 26 | // of course also normal widgets can be used. |
26 | m_exampleLabel = new OClickableLabel( this ); | 27 | m_exampleLabel = new Opie::Ui::OClickableLabel( this ); |
27 | connect( m_exampleLabel, SIGNAL( clicked() ), this, SLOT( slotClicked() ) ); | 28 | connect( m_exampleLabel, SIGNAL( clicked() ), this, SLOT( slotClicked() ) ); |
28 | 29 | ||
29 | if ( m_layout ) { | 30 | if ( m_layout ) { |
30 | delete m_layout; | 31 | delete m_layout; |
31 | } | 32 | } |
32 | m_layout = new QHBoxLayout( this ); | 33 | m_layout = new QHBoxLayout( this ); |
33 | m_layout->setAutoAdd( true ); | 34 | m_layout->setAutoAdd( true ); |
34 | 35 | ||
35 | readConfig(); | 36 | readConfig(); |
36 | getInfo(); | 37 | getInfo(); |
37 | } | 38 | } |
38 | 39 | ||
39 | 40 | ||
40 | ExamplePluginWidget::~ExamplePluginWidget() { | 41 | ExamplePluginWidget::~ExamplePluginWidget() { |
41 | delete m_exampleLabel; | 42 | delete m_exampleLabel; |
42 | delete m_layout; | 43 | delete m_layout; |
43 | } | 44 | } |
44 | 45 | ||
45 | 46 | ||
46 | void ExamplePluginWidget::readConfig() { | 47 | void ExamplePluginWidget::readConfig() { |
47 | // we dont have any config entries in this plugin | 48 | // we dont have any config entries in this plugin |
48 | // normally this method is used after today config was used | 49 | // normally this method is used after today config was used |
49 | } | 50 | } |
50 | 51 | ||
51 | 52 | ||
52 | void ExamplePluginWidget::refresh() { | 53 | void ExamplePluginWidget::refresh() { |
53 | 54 | ||
54 | } | 55 | } |
55 | 56 | ||
56 | void ExamplePluginWidget::getInfo() { | 57 | void ExamplePluginWidget::getInfo() { |
57 | m_exampleLabel->setText( tr("Example text") ); | 58 | m_exampleLabel->setText( tr("Example text") ); |
58 | } | 59 | } |
59 | 60 | ||
60 | void ExamplePluginWidget::slotClicked() { | 61 | void ExamplePluginWidget::slotClicked() { |
61 | getInfo(); | 62 | getInfo(); |
62 | } | 63 | } |
diff --git a/examples/todayplugin/examplepluginwidget.h b/examples/todayplugin/examplepluginwidget.h index eb3c660..70e717e 100644 --- a/examples/todayplugin/examplepluginwidget.h +++ b/examples/todayplugin/examplepluginwidget.h | |||
@@ -1,35 +1,35 @@ | |||
1 | /* | 1 | /* |
2 | * examplepluginwidget.h | 2 | * examplepluginwidget.h |
3 | * | 3 | * |
4 | * email : harlekin@handhelds.org | 4 | * email : harlekin@handhelds.org |
5 | * | 5 | * |
6 | */ | 6 | */ |
7 | 7 | ||
8 | #ifndef EXAMPLE_PLUGIN_WIDGET_H | 8 | #ifndef EXAMPLE_PLUGIN_WIDGET_H |
9 | #define EXAMPLE_PLUGIN_WIDGET_H | 9 | #define EXAMPLE_PLUGIN_WIDGET_H |
10 | 10 | ||
11 | #include <qlayout.h> | 11 | #include <qlayout.h> |
12 | 12 | ||
13 | #include <opie/oclickablelabel.h> | 13 | #include <opie2/oclickablelabel.h> |
14 | 14 | ||
15 | class ExamplePluginWidget : public QWidget { | 15 | class ExamplePluginWidget : public QWidget { |
16 | 16 | ||
17 | Q_OBJECT | 17 | Q_OBJECT |
18 | 18 | ||
19 | public: | 19 | public: |
20 | ExamplePluginWidget( QWidget *parent, const char *name ); | 20 | ExamplePluginWidget( QWidget *parent, const char *name ); |
21 | ~ExamplePluginWidget(); | 21 | ~ExamplePluginWidget(); |
22 | 22 | ||
23 | void refresh(); | 23 | void refresh(); |
24 | 24 | ||
25 | private slots: | 25 | private slots: |
26 | void slotClicked(); | 26 | void slotClicked(); |
27 | 27 | ||
28 | private: | 28 | private: |
29 | OClickableLabel* m_exampleLabel; | 29 | Opie::Ui::OClickableLabel* m_exampleLabel; |
30 | QHBoxLayout* m_layout; | 30 | QHBoxLayout* m_layout; |
31 | void readConfig(); | 31 | void readConfig(); |
32 | void getInfo(); | 32 | void getInfo(); |
33 | }; | 33 | }; |
34 | 34 | ||
35 | #endif | 35 | #endif |