summaryrefslogtreecommitdiff
path: root/libopie2/opiepim
Side-by-side diff
Diffstat (limited to 'libopie2/opiepim') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/backend/otodoaccessxml.cpp24
1 files changed, 19 insertions, 5 deletions
diff --git a/libopie2/opiepim/backend/otodoaccessxml.cpp b/libopie2/opiepim/backend/otodoaccessxml.cpp
index 3b4cab2..7a55c67 100644
--- a/libopie2/opiepim/backend/otodoaccessxml.cpp
+++ b/libopie2/opiepim/backend/otodoaccessxml.cpp
@@ -90,65 +90,65 @@ bool OTodoAccessXML::load() {
if ( ((unsigned char)dt[j]) > 0x7f )
haveUtf = TRUE;
if ( dt[j] == '&' )
haveEnt = TRUE;
++j;
}
if ( i == j ) {
// empty value
i = j + 1;
continue;
}
QCString value( dt+i, j-i+1 );
i = j + 1;
QString str = (haveUtf ? QString::fromUtf8( value )
: QString::fromLatin1( value ) );
if ( haveEnt )
str = Qtopia::plainString( str );
/*
* add key + value
*/
todo( &dict, ev, attr, str );
}
/*
* now add it
*/
m_events.insert(ev.uid(), ev );
}
- qWarning("counts %d", m_events.count() );
+ qWarning("counts %d records loaded!", m_events.count() );
return true;
}
bool OTodoAccessXML::reload() {
return load();
}
bool OTodoAccessXML::save() {
// qWarning("saving");
if (!m_opened || !m_changed ) {
// qWarning("not saving");
return true;
}
QString strNewFile = m_file + ".new";
QFile f( strNewFile );
if (!f.open( IO_WriteOnly|IO_Raw ) )
return false;
int written;
QString out;
out = "<!DOCTYPE Tasks>\n<Tasks>\n";
// for all todos
QMap<int, OTodo>::Iterator it;
for (it = m_events.begin(); it != m_events.end(); ++it ) {
out+= "<Task " + toString( (*it) ) + " />\n";
QCString cstr = out.utf8();
written = f.writeBlock( cstr.data(), cstr.length() );
/* less written then we wanted */
if ( written != (int)cstr.length() ) {
f.close();
QFile::remove( strNewFile );
return false;
@@ -489,61 +489,75 @@ public:
else if ( con1->todo.hasDueDate() )
ret = -1;
else if ( con2->todo.hasDueDate() )
ret = 0;
break;
}
default:
ret = 0;
break;
};
/* twist it we're not ascending*/
if (!m_asc)
ret = ret * -1;
return ret;
}
private:
bool m_asc;
int m_sort;
};
QArray<int> OTodoAccessXML::sorted( bool asc, int sortOrder,
int sortFilter, int cat ) {
qWarning("sorted! %d cat", cat);
OTodoXMLVector vector(m_events.count(), asc,sortOrder );
QMap<int, OTodo>::Iterator it;
int item = 0;
bool bCat = sortFilter & 1 ? true : false;
bool bOnly = sortFilter & 2 ? true : false;
+ bool comp = sortFilter & 4 ? true : false;
for ( it = m_events.begin(); it != m_events.end(); ++it ) {
/* show category */
if ( bCat && cat != 0)
- if (!(*it).categories().contains( cat ) )
+ if (!(*it).categories().contains( cat ) ) {
+ qWarning("category mis match");
continue;
- /* isOverdue but we should not show overdue */
- if ( (*it).isOverdue() && !bOnly )
+ }
+ /* isOverdue but we should not show overdue - why?*/
+/* if ( (*it).isOverdue() && !bOnly ) {
+ qWarning("item is overdue but !bOnly");
+ continue;
+ }
+*/
+ if ( !(*it).isOverdue() && bOnly ) {
+ qWarning("item is not overdue but bOnly checked");
continue;
- if ( !(*it).isOverdue() && bOnly )
+ }
+
+ if ((*it).isCompleted() && comp ) {
+ qWarning("completed continue!");
continue;
+ }
OTodoXMLContainer* con = new OTodoXMLContainer();
con->todo = (*it);
vector.insert(item, con );
item++;
}
+ qWarning("XXX %d Items added", item);
vector.resize( item );
/* sort it now */
vector.sort();
/* now get the uids */
QArray<int> array( vector.count() );
for (uint i= 0; i < vector.count(); i++ ) {
array[i] = ( vector.at(i) )->todo.uid();
}
qWarning("array count = %d %d", array.count(), vector.count() );
return array;
};