summaryrefslogtreecommitdiff
path: root/libopie2
Side-by-side diff
Diffstat (limited to 'libopie2') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/backend/otodoaccesssql.cpp31
-rw-r--r--libopie2/opiepim/backend/otodoaccesssql.h3
-rw-r--r--libopie2/opiepim/core/opimaccesstemplate.h2
-rw-r--r--libopie2/opiepim/orecordlist.h5
4 files changed, 29 insertions, 12 deletions
diff --git a/libopie2/opiepim/backend/otodoaccesssql.cpp b/libopie2/opiepim/backend/otodoaccesssql.cpp
index a059dab..ea8b3c9 100644
--- a/libopie2/opiepim/backend/otodoaccesssql.cpp
+++ b/libopie2/opiepim/backend/otodoaccesssql.cpp
@@ -243,3 +243,3 @@ namespace {
OTodoAccessBackendSQL::OTodoAccessBackendSQL( const QString& file )
- : OTodoAccessBackend(), m_dict(15)
+ : OTodoAccessBackend(), m_dict(15), m_dirty(true)
{
@@ -263,4 +263,3 @@ bool OTodoAccessBackendSQL::load(){
- update();
- qWarning("loaded %d", m_uids.count() );
+ m_dirty = true;
return true;
@@ -275,2 +274,5 @@ bool OTodoAccessBackendSQL::save(){
QArray<int> OTodoAccessBackendSQL::allRecords()const {
+ if (m_dirty )
+ update();
+
return m_uids;
@@ -305,3 +307,3 @@ OTodo OTodoAccessBackendSQL::find( int uid, const QArray<int>& ints,
case 1:
- for (uint i = cur; i >= 0 && size < 8; i-- ) {
+ for (uint i = cur; i != 0 && size < 8; i-- ) {
search[size] = ints[i];
@@ -344,3 +346,3 @@ bool OTodoAccessBackendSQL::remove( int uid ) {
- update();
+ m_dirty = true;
return true;
@@ -354,3 +356,5 @@ bool OTodoAccessBackendSQL::replace( const OTodo& t) {
remove( t.uid() );
- return add(t);
+ bool b= add(t);
+ m_dirty = false; // we changed some stuff but the UID stayed the same
+ return b;
}
@@ -371,2 +375,3 @@ QArray<int> OTodoAccessBackendSQL::sorted( bool asc, int sortOrder,
int sortFilter, int cat ) {
+ qWarning("sorted %d, %d", asc, sortOrder );
QString query;
@@ -423,4 +428,7 @@ QArray<int> OTodoAccessBackendSQL::sorted( bool asc, int sortOrder,
}
- if ( !asc )
+
+ if ( !asc ) {
+ qWarning("not ascending!");
query += " DESC";
+ }
@@ -503,3 +511,8 @@ void OTodoAccessBackendSQL::fillDict() {
}
-void OTodoAccessBackendSQL::update() {
+/*
+ * need to be const so let's fool the
+ * compiler :(
+ */
+void OTodoAccessBackendSQL::update()const {
+ ((OTodoAccessBackendSQL*)this)->m_dirty = false;
LoadQuery lo;
@@ -509,3 +522,3 @@ void OTodoAccessBackendSQL::update() {
- m_uids = uids( res );
+ ((OTodoAccessBackendSQL*)this)->m_uids = uids( res );
}
diff --git a/libopie2/opiepim/backend/otodoaccesssql.h b/libopie2/opiepim/backend/otodoaccesssql.h
index c1aa2ed..0f6dd2c 100644
--- a/libopie2/opiepim/backend/otodoaccesssql.h
+++ b/libopie2/opiepim/backend/otodoaccesssql.h
@@ -34,3 +34,3 @@ public:
private:
- void update();
+ void update()const;
void fillDict();
@@ -45,2 +45,3 @@ private:
QArray<int> m_uids;
+ bool m_dirty : 1;
};
diff --git a/libopie2/opiepim/core/opimaccesstemplate.h b/libopie2/opiepim/core/opimaccesstemplate.h
index 92d7192..a0d8f63 100644
--- a/libopie2/opiepim/core/opimaccesstemplate.h
+++ b/libopie2/opiepim/core/opimaccesstemplate.h
@@ -186,3 +186,2 @@ T OPimAccessTemplate<T>::find( int uid, const QArray<int>& ar,
if (m_cache.contains( uid ) ) {
- qWarning("m cache contains %d", uid);
return m_cache.find( uid );
@@ -191,3 +190,2 @@ T OPimAccessTemplate<T>::find( int uid, const QArray<int>& ar,
T t = m_backEnd->find( uid, ar, current, dir );
- qWarning("found it and cache it now %d", uid);
cache( t );
diff --git a/libopie2/opiepim/orecordlist.h b/libopie2/opiepim/orecordlist.h
index 08f5c85..5404910 100644
--- a/libopie2/opiepim/orecordlist.h
+++ b/libopie2/opiepim/orecordlist.h
@@ -111,2 +111,3 @@ public:
T operator[]( uint i );
+ int uidAt(uint i );
// FIXME implemenent remove
@@ -264,2 +265,6 @@ T ORecordList<T>::operator[]( uint i ) {
}
+template <class T>
+int ORecordList<T>::uidAt( uint i ) {
+ return m_ids[i];
+}
#endif