summaryrefslogtreecommitdiff
path: root/libopie/pim/otodoaccesssql.cpp
authorzecke <zecke>2002-10-13 02:22:58 (UTC)
committer zecke <zecke>2002-10-13 02:22:58 (UTC)
commitd96ce086c617b5b2efc5081cd10a43257a78f488 (patch) (side-by-side diff)
tree4f6b80b7295127bd82cc5fb8ffd1d532c42a396b /libopie/pim/otodoaccesssql.cpp
parent2ce86d9be1bbf99092348adf815578b110fe7289 (diff)
downloadopie-d96ce086c617b5b2efc5081cd10a43257a78f488.zip
opie-d96ce086c617b5b2efc5081cd10a43257a78f488.tar.gz
opie-d96ce086c617b5b2efc5081cd10a43257a78f488.tar.bz2
OPimAccessBackend nothing tried a isDirty()const ... but removed it
ORecordList uidAt(uint index ) added Speed Improvements at the SQL backend do not load the list of uids until it's really needed do not reload the uid list until it's really needed we got a bitfield m_dirty there...
Diffstat (limited to 'libopie/pim/otodoaccesssql.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/pim/otodoaccesssql.cpp31
1 files changed, 22 insertions, 9 deletions
diff --git a/libopie/pim/otodoaccesssql.cpp b/libopie/pim/otodoaccesssql.cpp
index a059dab..ea8b3c9 100644
--- a/libopie/pim/otodoaccesssql.cpp
+++ b/libopie/pim/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 );
}