summaryrefslogtreecommitdiff
path: root/libopie2
authorzecke <zecke>2002-10-07 14:59:44 (UTC)
committer zecke <zecke>2002-10-07 14:59:44 (UTC)
commite68537563c9950654b9a771730f0fc3890803a54 (patch) (side-by-side diff)
treefd64fada00405ca8ad65e9334bcdb4c3da3f1a9a /libopie2
parent645b377506fb32f4519e70d43c020084943debae (diff)
downloadopie-e68537563c9950654b9a771730f0fc3890803a54.zip
opie-e68537563c9950654b9a771730f0fc3890803a54.tar.gz
opie-e68537563c9950654b9a771730f0fc3890803a54.tar.bz2
Fix sorted SQL query
Diffstat (limited to 'libopie2') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/backend/otodoaccesssql.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/libopie2/opiepim/backend/otodoaccesssql.cpp b/libopie2/opiepim/backend/otodoaccesssql.cpp
index 25536e0..8add9f7 100644
--- a/libopie2/opiepim/backend/otodoaccesssql.cpp
+++ b/libopie2/opiepim/backend/otodoaccesssql.cpp
@@ -302,56 +302,58 @@ QArray<int> OTodoAccessBackendSQL::overDue() {
OverDueQuery qu;
return uids( m_driver->query(&qu ) );
}
QArray<int> OTodoAccessBackendSQL::effectiveToDos( const QDate& s,
const QDate& t,
bool u) {
EffQuery ef(s, t, u );
return uids (m_driver->query(&ef) );
}
/*
*
*/
QArray<int> OTodoAccessBackendSQL::sorted( bool asc, int sortOrder,
int sortFilter, int cat ) {
QString query;
query = "select uid from todolist WHERE ";
/*
* Sort Filter stuff
* not that straight forward
*
*/
/* Category */
if ( sortFilter & 1 ) {
- query += " categories like '%" +QString::number(cat)+"%' AND";
+ QString str;
+ if (cat != 0 ) str = QString::number( cat );
+ query += " categories like '%" +str+"%' AND";
}
/* Show only overdue */
if ( sortFilter & 2 ) {
QDate date = QDate::currentDate();
QString due;
QString base;
- base = QString("DueDate <= '%1-%2-%3' AND WHERE completed = 0").arg( date.year() ).arg( date.month() ).arg( date.day() );
+ base = QString("DueDate <= '%1-%2-%3' AND completed = 0").arg( date.year() ).arg( date.month() ).arg( date.day() );
query += " " + base + " AND";
}
/* not show completed */
if ( sortFilter & 4 ) {
query += " completed = 0 AND";
}else{
query += " ( completed = 1 OR completed = 0) AND";
}
/* srtip the end */
query = query.remove( query.length()-3, 3 );
/*
* sort order stuff
* quite straight forward
*/
query += "ORDER BY ";
switch( sortOrder ) {
/* completed */
case 0:
query += "completed";
break;
case 1:
query += "priority";
@@ -422,33 +424,34 @@ void OTodoAccessBackendSQL::fillDict() {
m_dict.insert("Summary" , new int(OTodo::Summary) );
m_dict.insert("Priority" , new int(OTodo::Priority) );
m_dict.insert("DateDay" , new int(OTodo::DateDay) );
m_dict.insert("DateMonth" , new int(OTodo::DateMonth) );
m_dict.insert("DateYear" , new int(OTodo::DateYear) );
m_dict.insert("Progress" , new int(OTodo::Progress) );
m_dict.insert("Completed", new int(OTodo::Completed) );
m_dict.insert("CrossReference", new int(OTodo::CrossReference) );
m_dict.insert("HasAlarmDateTime",new int(OTodo::HasAlarmDateTime) );
m_dict.insert("AlarmDateTime", new int(OTodo::AlarmDateTime) );
}
void OTodoAccessBackendSQL::update() {
LoadQuery lo;
OSQLResult res = m_driver->query(&lo);
if ( res.state() != OSQLResult::Success )
return;
m_uids = uids( res );
}
QArray<int> OTodoAccessBackendSQL::uids( const OSQLResult& res) const{
OSQLResultItem::ValueList list = res.results();
OSQLResultItem::ValueList::Iterator it;
QArray<int> ints(list.count() );
+ qWarning(" count = %d", list.count() );
int i = 0;
for (it = list.begin(); it != list.end(); ++it ) {
ints[i] = (*it).data("uid").toInt();
i++;
}
return ints;
}