Diffstat (limited to 'libopie/pim/opimaccesstemplate.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie/pim/opimaccesstemplate.h | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/libopie/pim/opimaccesstemplate.h b/libopie/pim/opimaccesstemplate.h index 3e1f393..50cb1e4 100644 --- a/libopie/pim/opimaccesstemplate.h +++ b/libopie/pim/opimaccesstemplate.h | |||
@@ -28,86 +28,100 @@ public: | |||
28 | 28 | ||
29 | /** | 29 | /** |
30 | * c'tor BackEnd | 30 | * c'tor BackEnd |
31 | */ | 31 | */ |
32 | OPimAccessTemplate( BackEnd* end); | 32 | OPimAccessTemplate( BackEnd* end); |
33 | virtual ~OPimAccessTemplate(); | 33 | virtual ~OPimAccessTemplate(); |
34 | 34 | ||
35 | /** | 35 | /** |
36 | * load from the backend | 36 | * load from the backend |
37 | */ | 37 | */ |
38 | virtual bool load(); | 38 | virtual bool load(); |
39 | 39 | ||
40 | /** | 40 | /** Reload database. |
41 | * reload from the backend | 41 | * You should execute this function if the external database |
42 | * was changed. | ||
43 | * This function will load the external database and afterwards | ||
44 | * rejoin the local changes. Therefore the local database will be set consistent. | ||
42 | */ | 45 | */ |
43 | virtual bool reload(); | 46 | virtual bool reload(); |
44 | 47 | ||
45 | /** | 48 | /** Save contacts database. |
46 | * save to the backend | 49 | * Save is more a "commit". After calling this function, all changes are public available. |
50 | * @return true if successful | ||
47 | */ | 51 | */ |
48 | virtual bool save(); | 52 | virtual bool save(); |
49 | 53 | ||
50 | /** | 54 | /** |
51 | * if the resource was changed externally | 55 | * if the resource was changed externally |
56 | * You should use the signal handling instead of polling possible changes ! | ||
57 | * zecke: Do you implement a signal for otodoaccess ? | ||
52 | */ | 58 | */ |
53 | bool wasChangedExternally()const; | 59 | bool wasChangedExternally()const; |
54 | 60 | ||
55 | /** | 61 | /** |
56 | * return a List of records | 62 | * return a List of records |
57 | * you can iterate over them | 63 | * you can iterate over them |
58 | */ | 64 | */ |
59 | virtual List allRecords()const; | 65 | virtual List allRecords()const; |
60 | 66 | ||
61 | /** | 67 | /** |
62 | * queryByExample) | 68 | * queryByExample. |
63 | * @see otodoaccess, ocontactaccess | 69 | * @see otodoaccess, ocontactaccess |
64 | */ | 70 | */ |
65 | virtual List queryByExample( const T& t, int querySettings ); | 71 | virtual List queryByExample( const T& t, int querySettings ); |
66 | 72 | ||
67 | /** | 73 | /** |
68 | * find the OPimRecord uid | 74 | * find the OPimRecord uid |
69 | */ | 75 | */ |
70 | virtual T find( int uid )const; | 76 | virtual T find( int uid )const; |
71 | 77 | ||
72 | /** | 78 | /** |
73 | * read ahead cache find method ;) | 79 | * read ahead cache find method ;) |
74 | */ | 80 | */ |
75 | virtual T find( int uid, const QArray<int>&, | 81 | virtual T find( int uid, const QArray<int>&, |
76 | uint current, CacheDirection dir = Forward )const; | 82 | uint current, CacheDirection dir = Forward )const; |
77 | 83 | ||
78 | /* invalidate cache here */ | 84 | /* invalidate cache here */ |
79 | /** | 85 | /** |
80 | * clears the backend and invalidates the backend | 86 | * clears the backend and invalidates the backend |
81 | */ | 87 | */ |
82 | virtual void clear() ; | 88 | virtual void clear() ; |
83 | 89 | ||
84 | /** | 90 | /** |
85 | * add T to the backend | 91 | * add T to the backend |
92 | * @param t The item to add. | ||
93 | * @return <i>true</i> if added successfully. | ||
86 | */ | 94 | */ |
87 | virtual bool add( const T& t ) ; | 95 | virtual bool add( const T& t ) ; |
88 | 96 | ||
89 | /* only the uid matters */ | 97 | /* only the uid matters */ |
90 | /** | 98 | /** |
91 | * remove T from the backend | 99 | * remove T from the backend |
100 | * @param t The item to remove | ||
101 | * @return <i>true</i> if successful. | ||
92 | */ | 102 | */ |
93 | virtual bool remove( const T& t ); | 103 | virtual bool remove( const T& t ); |
94 | 104 | ||
95 | /** | 105 | /** |
96 | * remove the OPimRecord with uid | 106 | * remove the OPimRecord with uid |
107 | * @param uid The ID of the item to remove | ||
108 | * @return <i>true</i> if successful. | ||
97 | */ | 109 | */ |
98 | virtual bool remove( int uid ); | 110 | virtual bool remove( int uid ); |
99 | 111 | ||
100 | /** | 112 | /** |
101 | * replace T from backend | 113 | * replace T from backend |
114 | * @param t The item to replace | ||
115 | * @return <i>true</i> if successful. | ||
102 | */ | 116 | */ |
103 | virtual bool replace( const T& t) ; | 117 | virtual bool replace( const T& t) ; |
104 | 118 | ||
105 | /** | 119 | /** |
106 | * @internal | 120 | * @internal |
107 | */ | 121 | */ |
108 | void cache( const T& )const; | 122 | void cache( const T& )const; |
109 | void setSaneCacheSize( int ); | 123 | void setSaneCacheSize( int ); |
110 | protected: | 124 | protected: |
111 | /** | 125 | /** |
112 | * invalidate the cache | 126 | * invalidate the cache |
113 | */ | 127 | */ |
@@ -133,25 +147,26 @@ OPimAccessTemplate<T>::OPimAccessTemplate( BackEnd* end ) | |||
133 | template <class T> | 147 | template <class T> |
134 | OPimAccessTemplate<T>::~OPimAccessTemplate() { | 148 | OPimAccessTemplate<T>::~OPimAccessTemplate() { |
135 | qWarning("~OPimAccessTemplate<T>"); | 149 | qWarning("~OPimAccessTemplate<T>"); |
136 | delete m_backEnd; | 150 | delete m_backEnd; |
137 | } | 151 | } |
138 | template <class T> | 152 | template <class T> |
139 | bool OPimAccessTemplate<T>::load() { | 153 | bool OPimAccessTemplate<T>::load() { |
140 | invalidateCache(); | 154 | invalidateCache(); |
141 | return m_backEnd->load(); | 155 | return m_backEnd->load(); |
142 | } | 156 | } |
143 | template <class T> | 157 | template <class T> |
144 | bool OPimAccessTemplate<T>::reload() { | 158 | bool OPimAccessTemplate<T>::reload() { |
145 | return m_backEnd->reload(); | 159 | invalidateCache(); // zecke: I think this should be added (se) |
160 | return m_backEnd->reload(); | ||
146 | } | 161 | } |
147 | template <class T> | 162 | template <class T> |
148 | bool OPimAccessTemplate<T>::save() { | 163 | bool OPimAccessTemplate<T>::save() { |
149 | return m_backEnd->save(); | 164 | return m_backEnd->save(); |
150 | } | 165 | } |
151 | template <class T> | 166 | template <class T> |
152 | OPimAccessTemplate<T>::List OPimAccessTemplate<T>::allRecords()const { | 167 | OPimAccessTemplate<T>::List OPimAccessTemplate<T>::allRecords()const { |
153 | QArray<int> ints = m_backEnd->allRecords(); | 168 | QArray<int> ints = m_backEnd->allRecords(); |
154 | List lis(ints, this ); | 169 | List lis(ints, this ); |
155 | return lis; | 170 | return lis; |
156 | } | 171 | } |
157 | template <class T> | 172 | template <class T> |