-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 |
4 files changed, 16 insertions, 107 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 | |||
@@ -3,2 +3,2 @@ | |||
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 | |||
@@ -12,3 +12,3 @@ DEPENDSPATH += $(OPIEDIR)/include | |||
12 | 12 | ||
13 | LIBS += -lqpe | 13 | LIBS += -lqpe -lopieui2 |
14 | 14 | ||
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 | */ |
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; |
@@ -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 | */ | ||
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 | |||
@@ -19,2 +19,3 @@ | |||
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 | */ |
@@ -47,2 +48,3 @@ public: | |||
47 | ~SimpleApplet(); | 48 | ~SimpleApplet(); |
49 | static int position(); | ||
48 | private: | 50 | private: |
@@ -53,23 +55,2 @@ private: | |||
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 | ||