Diffstat (limited to 'core/pim/datebook2/managertemplate.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/pim/datebook2/managertemplate.h | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/core/pim/datebook2/managertemplate.h b/core/pim/datebook2/managertemplate.h index 668fda7..cdf121d 100644 --- a/core/pim/datebook2/managertemplate.h +++ b/core/pim/datebook2/managertemplate.h | |||
@@ -2,6 +2,7 @@ | |||
2 | #define OPIE_DATE_BOOK_MANAGER_TEMPLATE_H | 2 | #define OPIE_DATE_BOOK_MANAGER_TEMPLATE_H |
3 | 3 | ||
4 | #include <qdialog.h> | 4 | #include <qdialog.h> |
5 | #include <qmap.h> | ||
5 | #include <qstring.h> | 6 | #include <qstring.h> |
6 | 7 | ||
7 | namespace Datebook { | 8 | namespace Datebook { |
@@ -11,9 +12,10 @@ namespace Datebook { | |||
11 | */ | 12 | */ |
12 | template<class T> | 13 | template<class T> |
13 | class ManagerTemplate { | 14 | class ManagerTemplate { |
15 | typedef typename QMap<QString, T>::Iterator Iterator; | ||
14 | public: | 16 | public: |
15 | ManagerTemplate(); | 17 | ManagerTemplate(); |
16 | ~ManagerTemplate(); | 18 | virtual ~ManagerTemplate(); |
17 | 19 | ||
18 | virtual void add( const QString&, const T& t ); | 20 | virtual void add( const QString&, const T& t ); |
19 | void remove( const QString& ); | 21 | void remove( const QString& ); |
@@ -31,6 +33,41 @@ namespace Datebook { | |||
31 | virtual bool doLoad() = 0; | 33 | virtual bool doLoad() = 0; |
32 | 34 | ||
33 | }; | 35 | }; |
36 | template<class T> | ||
37 | ManagerTemplate<T>::ManagerTemplate() { | ||
38 | } | ||
39 | template<class T> | ||
40 | ManagerTemplate<T>::~ManagerTemplate() { | ||
41 | } | ||
42 | template<class T> | ||
43 | void ManagerTemplate<T>::add( const QString& str, const T& t ) { | ||
44 | m_map.insert( str, t ); | ||
45 | } | ||
46 | template<class T> | ||
47 | void ManagerTemplate<T>::remove( const QString& str ) { | ||
48 | m_map.remove( str ); | ||
49 | } | ||
50 | template<class T> | ||
51 | bool ManagerTemplate<T>::load() { | ||
52 | return doLoad(); | ||
53 | } | ||
54 | template<class T> | ||
55 | bool ManagerTemplate<T>::save() { | ||
56 | return doSave(); | ||
57 | } | ||
58 | template<class T> | ||
59 | QStringList ManagerTemplate<T>::names() { | ||
60 | QStringList lst; | ||
61 | Iterator it; | ||
62 | for ( it = m_map.begin(); it != m_map.end(); ++it ) { | ||
63 | lst << it.key(); | ||
64 | } | ||
65 | return lst; | ||
66 | } | ||
67 | template<class T> | ||
68 | T ManagerTemplate<T>::value( const QString& str)const { | ||
69 | return m_map[str]; | ||
70 | } | ||
34 | } | 71 | } |
35 | 72 | ||
36 | #endif | 73 | #endif |