author | mickeyl <mickeyl> | 2004-03-01 21:10:13 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-03-01 21:10:13 (UTC) |
commit | 77af6f58d59011e123309c82b684695508a46787 (patch) (unidiff) | |
tree | 1eeb3b323bc14581af7da9fe5b58c4c611b00575 /noncore/applets/memoryapplet | |
parent | 7b0bdb05e4ae29b2643d73e3b8f20a86a86dcccc (diff) | |
download | opie-77af6f58d59011e123309c82b684695508a46787.zip opie-77af6f58d59011e123309c82b684695508a46787.tar.gz opie-77af6f58d59011e123309c82b684695508a46787.tar.bz2 |
remove boiler plate code in favour of a template
Diffstat (limited to 'noncore/applets/memoryapplet') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/applets/memoryapplet/memoryapplet.pro | 4 | ||||
-rw-r--r-- | noncore/applets/memoryapplet/memoryappletimpl.cpp | 65 | ||||
-rw-r--r-- | noncore/applets/memoryapplet/memoryappletimpl.h | 43 | ||||
-rw-r--r-- | noncore/applets/memoryapplet/memorymeter.cpp | 14 | ||||
-rw-r--r-- | noncore/applets/memoryapplet/memorymeter.h | 1 |
5 files changed, 13 insertions, 114 deletions
diff --git a/noncore/applets/memoryapplet/memoryapplet.pro b/noncore/applets/memoryapplet/memoryapplet.pro index 6031386..3cd7839 100644 --- a/noncore/applets/memoryapplet/memoryapplet.pro +++ b/noncore/applets/memoryapplet/memoryapplet.pro | |||
@@ -3,14 +3,12 @@ CONFIG += qt plugin warn_on release | |||
3 | HEADERS = ../../settings/sysinfo/graph.h \ | 3 | HEADERS = ../../settings/sysinfo/graph.h \ |
4 | ../../settings/sysinfo/load.h \ | 4 | ../../settings/sysinfo/load.h \ |
5 | ../../settings/sysinfo/memory.h \ | 5 | ../../settings/sysinfo/memory.h \ |
6 | memoryappletimpl.h \ | ||
7 | memorymeter.h \ | 6 | memorymeter.h \ |
8 | memorystatus.h \ | 7 | memorystatus.h \ |
9 | swapfile.h | 8 | swapfile.h |
10 | SOURCES = ../../settings/sysinfo/graph.cpp \ | 9 | SOURCES = ../../settings/sysinfo/graph.cpp \ |
11 | ../../settings/sysinfo/load.cpp \ | 10 | ../../settings/sysinfo/load.cpp \ |
12 | ../../settings/sysinfo/memory.cpp \ | 11 | ../../settings/sysinfo/memory.cpp \ |
13 | memoryappletimpl.cpp \ | ||
14 | memorymeter.cpp \ | 12 | memorymeter.cpp \ |
15 | memorystatus.cpp \ | 13 | memorystatus.cpp \ |
16 | swapfile.cpp | 14 | swapfile.cpp |
@@ -19,6 +17,6 @@ DESTDIR = $(OPIEDIR)/plugins/applets | |||
19 | INCLUDEPATH += $(OPIEDIR)/include | 17 | INCLUDEPATH += $(OPIEDIR)/include |
20 | DEPENDPATH += ../$(OPIEDIR)/include | 18 | DEPENDPATH += ../$(OPIEDIR)/include |
21 | VERSION = 1.0.0 | 19 | VERSION = 1.0.0 |
22 | LIBS += -lqpe -lopieui2 | 20 | LIBS += -lqpe -lopiecore2 -lopieui2 |
23 | 21 | ||
24 | include ( $(OPIEDIR)/include.pro ) | 22 | include ( $(OPIEDIR)/include.pro ) |
diff --git a/noncore/applets/memoryapplet/memoryappletimpl.cpp b/noncore/applets/memoryapplet/memoryappletimpl.cpp deleted file mode 100644 index a117e7f..0000000 --- a/noncore/applets/memoryapplet/memoryappletimpl.cpp +++ b/dev/null | |||
@@ -1,65 +0,0 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of the Qtopia Environment. | ||
5 | ** | ||
6 | ** This file may be distributed and/or modified under the terms of the | ||
7 | ** GNU General Public License version 2 as published by the Free Software | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
13 | ** | ||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
15 | ** | ||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
17 | ** not clear to you. | ||
18 | ** | ||
19 | **********************************************************************/ | ||
20 | #include "memorymeter.h" | ||
21 | #include "memoryappletimpl.h" | ||
22 | |||
23 | MemoryAppletImpl::MemoryAppletImpl() | ||
24 | : memory(0) | ||
25 | { | ||
26 | } | ||
27 | |||
28 | MemoryAppletImpl::~MemoryAppletImpl() | ||
29 | { | ||
30 | delete memory; | ||
31 | } | ||
32 | |||
33 | QWidget *MemoryAppletImpl::applet( QWidget *parent ) | ||
34 | { | ||
35 | if ( !memory ) | ||
36 | memory = new MemoryMeter( parent ); | ||
37 | |||
38 | return memory; | ||
39 | } | ||
40 | |||
41 | int MemoryAppletImpl::position() const | ||
42 | { | ||
43 | return 8; | ||
44 | } | ||
45 | |||
46 | QRESULT MemoryAppletImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) | ||
47 | { | ||
48 | *iface = 0; | ||
49 | if ( uuid == IID_QUnknown ) | ||
50 | *iface = this; | ||
51 | else if ( uuid == IID_TaskbarApplet ) | ||
52 | *iface = this; | ||
53 | else | ||
54 | return QS_FALSE; | ||
55 | |||
56 | (*iface)->addRef(); | ||
57 | |||
58 | return QS_OK; | ||
59 | } | ||
60 | |||
61 | Q_EXPORT_INTERFACE() | ||
62 | { | ||
63 | Q_CREATE_INSTANCE( MemoryAppletImpl ) | ||
64 | } | ||
65 | |||
diff --git a/noncore/applets/memoryapplet/memoryappletimpl.h b/noncore/applets/memoryapplet/memoryappletimpl.h deleted file mode 100644 index 2db7dbe..0000000 --- a/noncore/applets/memoryapplet/memoryappletimpl.h +++ b/dev/null | |||
@@ -1,43 +0,0 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of the Qtopia Environment. | ||
5 | ** | ||
6 | ** This file may be distributed and/or modified under the terms of the | ||
7 | ** GNU General Public License version 2 as published by the Free Software | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
13 | ** | ||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
15 | ** | ||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
17 | ** not clear to you. | ||
18 | ** | ||
19 | **********************************************************************/ | ||
20 | #ifndef MEMORYAPPLETIMPL_H | ||
21 | #define MEMORYAPPLETIMPL_H | ||
22 | |||
23 | #include <qtopia/taskbarappletinterface.h> | ||
24 | |||
25 | class MemoryMeter; | ||
26 | |||
27 | class /*QTOPIA_PLUGIN_EXPORT*/ MemoryAppletImpl : public TaskbarAppletInterface | ||
28 | { | ||
29 | public: | ||
30 | MemoryAppletImpl(); | ||
31 | virtual ~MemoryAppletImpl(); | ||
32 | |||
33 | QRESULT queryInterface( const QUuid&, QUnknownInterface** ); | ||
34 | Q_REFCOUNT | ||
35 | |||
36 | virtual QWidget *applet( QWidget *parent ); | ||
37 | virtual int position() const; | ||
38 | |||
39 | private: | ||
40 | MemoryMeter *memory; | ||
41 | }; | ||
42 | |||
43 | #endif | ||
diff --git a/noncore/applets/memoryapplet/memorymeter.cpp b/noncore/applets/memoryapplet/memorymeter.cpp index 54b5c52..9299f49 100644 --- a/noncore/applets/memoryapplet/memorymeter.cpp +++ b/noncore/applets/memoryapplet/memorymeter.cpp | |||
@@ -20,12 +20,10 @@ | |||
20 | #include "memorymeter.h" | 20 | #include "memorymeter.h" |
21 | #include "memorystatus.h" | 21 | #include "memorystatus.h" |
22 | 22 | ||
23 | #include <opie2/otaskbarapplet.h> | ||
23 | #include <qtopia/power.h> | 24 | #include <qtopia/power.h> |
24 | #include <qtopia/config.h> | 25 | #include <qtopia/config.h> |
25 | |||
26 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | ||
27 | #include <qtopia/qcopenvelope_qws.h> | 26 | #include <qtopia/qcopenvelope_qws.h> |
28 | #endif | ||
29 | 27 | ||
30 | #include <qpainter.h> | 28 | #include <qpainter.h> |
31 | #include <qtimer.h> | 29 | #include <qtimer.h> |
@@ -66,6 +64,11 @@ MemoryMeter::~MemoryMeter() | |||
66 | delete (QWidget *) memoryView; | 64 | delete (QWidget *) memoryView; |
67 | } | 65 | } |
68 | 66 | ||
67 | int MemoryMeter::position() | ||
68 | { | ||
69 | return 7; | ||
70 | } | ||
71 | |||
69 | QSize MemoryMeter::sizeHint() const | 72 | QSize MemoryMeter::sizeHint() const |
70 | { | 73 | { |
71 | return QSize(10, AppLnk::smallIconSize()); | 74 | return QSize(10, AppLnk::smallIconSize()); |
@@ -237,3 +240,8 @@ void MemoryMeter::paintEvent( QPaintEvent* ) | |||
237 | } | 240 | } |
238 | } | 241 | } |
239 | 242 | ||
243 | Q_EXPORT_INTERFACE() | ||
244 | { | ||
245 | Q_CREATE_INSTANCE( OTaskbarAppletWrapper<MemoryMeter> ); | ||
246 | } | ||
247 | |||
diff --git a/noncore/applets/memoryapplet/memorymeter.h b/noncore/applets/memoryapplet/memorymeter.h index 0f3cb0b..ed541f0 100644 --- a/noncore/applets/memoryapplet/memorymeter.h +++ b/noncore/applets/memoryapplet/memorymeter.h | |||
@@ -31,6 +31,7 @@ class MemoryMeter : public QWidget | |||
31 | public: | 31 | public: |
32 | MemoryMeter( QWidget *parent = 0 ); | 32 | MemoryMeter( QWidget *parent = 0 ); |
33 | ~MemoryMeter(); | 33 | ~MemoryMeter(); |
34 | static int position(); | ||
34 | 35 | ||
35 | QSize sizeHint() const; | 36 | QSize sizeHint() const; |
36 | MemoryStatus* memoryView; | 37 | MemoryStatus* memoryView; |