summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/core/opimaccesstemplate.h
Side-by-side diff
Diffstat (limited to 'libopie2/opiepim/core/opimaccesstemplate.h') (more/less context) (show whitespace changes)
-rw-r--r--libopie2/opiepim/core/opimaccesstemplate.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/libopie2/opiepim/core/opimaccesstemplate.h b/libopie2/opiepim/core/opimaccesstemplate.h
index 6de68b1..8cf81c8 100644
--- a/libopie2/opiepim/core/opimaccesstemplate.h
+++ b/libopie2/opiepim/core/opimaccesstemplate.h
@@ -84,24 +84,25 @@ public:
/* invalidate cache here */
/**
* clears the backend and invalidates the backend
*/
virtual void clear() ;
/**
* add T to the backend
* @param t The item to add.
* @return <i>true</i> if added successfully.
*/
virtual bool add( const T& t ) ;
+ bool add( const OPimRecord& );
/* only the uid matters */
/**
* remove T from the backend
* @param t The item to remove
* @return <i>true</i> if successful.
*/
virtual bool remove( const T& t );
/**
* remove the OPimRecord with uid
* @param uid The ID of the item to remove
@@ -203,24 +204,33 @@ T OPimAccessTemplate<T>::find( int uid, const QArray<int>& ar,
}
template <class T>
void OPimAccessTemplate<T>::clear() {
invalidateCache();
m_backEnd->clear();
}
template <class T>
bool OPimAccessTemplate<T>::add( const T& t ) {
cache( t );
return m_backEnd->add( t );
}
template <class T>
+bool OPimAccessTemplate<T>::add( const OPimRecord& rec) {
+ /* same type */
+ if ( rec.rtti() == T::rtti() ) {
+ const T &t = static_cast<const T&>(rec);
+ return add(t);
+ }
+ return false;
+}
+template <class T>
bool OPimAccessTemplate<T>::remove( const T& t ) {
return remove( t.uid() );
}
template <class T>
bool OPimAccessTemplate<T>::remove( int uid ) {
m_cache.remove( uid );
return m_backEnd->remove( uid );
}
template <class T>
bool OPimAccessTemplate<T>::replace( const T& t ) {
m_cache.replace( t );
return m_backEnd->replace( t );