summaryrefslogtreecommitdiff
path: root/examples/applet/simpleimpl.cpp
Unidiff
Diffstat (limited to 'examples/applet/simpleimpl.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--examples/applet/simpleimpl.cpp96
1 files changed, 12 insertions, 84 deletions
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 +1,9 @@
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>
@@ -4,6 +12,3 @@
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
@@ -73,35 +78,5 @@ void SimpleApplet::paintEvent( QPaintEvent* ) {
73/* 78/*
74 * Here comes the implementation of the interface 79 * We need to add this symbol for the plugin exporter!
75 */ 80 */
76SimpleAppletImpl::SimpleAppletImpl() { 81int SimpleApplet::position(){
77}
78/* needed cause until it is only pure virtual */
79SimpleAppletImpl::~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 */
92QWidget* 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 */
106int SimpleAppletImpl::position()const {
107 return 1; 82 return 1;
@@ -110,53 +85,6 @@ int SimpleAppletImpl::position()const {
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 */
117QRESULT 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 */
159Q_EXPORT_INTERFACE() { 90EXPORT_OPIE_APPLET_v1( SimpleApplet ) \ No newline at end of file
160 Q_CREATE_INSTANCE( SimpleAppletImpl )
161}
162