summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/backend/otodoaccesssql.cpp
Side-by-side diff
Diffstat (limited to 'libopie2/opiepim/backend/otodoaccesssql.cpp') (more/less context) (show whitespace changes)
-rw-r--r--libopie2/opiepim/backend/otodoaccesssql.cpp129
1 files changed, 32 insertions, 97 deletions
diff --git a/libopie2/opiepim/backend/otodoaccesssql.cpp b/libopie2/opiepim/backend/otodoaccesssql.cpp
index 4e3e47b..2bcab29 100644
--- a/libopie2/opiepim/backend/otodoaccesssql.cpp
+++ b/libopie2/opiepim/backend/otodoaccesssql.cpp
@@ -457,3 +457,2 @@ OPimTodo OPimTodoAccessBackendSQL::find(int uid ) const{
return parseResultAndCache( uid, m_driver->query(&query) );
-
}
@@ -467,3 +466,2 @@ OPimTodo OPimTodoAccessBackendSQL::find( int uid, const QArray<int>& ints,
uint size =0;
- OPimTodo to;
@@ -474,3 +472,2 @@ OPimTodo OPimTodoAccessBackendSQL::find( int uid, const QArray<int>& ints,
for (uint i = cur; i < ints.count() && size < CACHE; i++ ) {
- odebug << "size " << size << " " << ints[i] << "" << oendl;
search[size] = ints[i];
@@ -492,3 +489,3 @@ OPimTodo OPimTodoAccessBackendSQL::find( int uid, const QArray<int>& ints,
if ( res.state() != OSQLResult::Success )
- return to;
+ return OPimTodo();
@@ -509,2 +506,3 @@ bool OPimTodoAccessBackendSQL::add( const OPimTodo& t) {
return false;
+
int c = m_uids.count();
@@ -536,3 +534,3 @@ bool OPimTodoAccessBackendSQL::replace( const OPimTodo& t) {
}
-QArray<int> OPimTodoAccessBackendSQL::overDue() {
+QArray<int> OPimTodoAccessBackendSQL::overDue()const {
OverDueQuery qu;
@@ -542,3 +540,3 @@ QArray<int> OPimTodoAccessBackendSQL::effectiveToDos( const QDate& s,
const QDate& t,
- bool u) {
+ bool u)const {
EffQuery ef(s, t, u );
@@ -546,2 +544,4 @@ QArray<int> OPimTodoAccessBackendSQL::effectiveToDos( const QDate& s,
}
+
+#if 0
/*
@@ -562,3 +562,3 @@ QArray<int> OPimTodoAccessBackendSQL::sorted( bool asc, int sortOrder,
/* Category */
- if ( sortFilter & 1 ) {
+ if ( sortFilter & OPimTodoAccess::FilterCategory ) {
QString str;
@@ -568,3 +568,3 @@ QArray<int> OPimTodoAccessBackendSQL::sorted( bool asc, int sortOrder,
/* Show only overdue */
- if ( sortFilter & 2 ) {
+ if ( sortFilter & OPimTodoAccess::OnlyOverDue ) {
QDate date = QDate::currentDate();
@@ -579,3 +579,3 @@ QArray<int> OPimTodoAccessBackendSQL::sorted( bool asc, int sortOrder,
/* not show completed */
- if ( sortFilter & 4 ) {
+ if ( sortFilter & OPimTodoAccess::DoNotShowCompleted ) {
query += " completed = 0 AND";
@@ -595,12 +595,12 @@ QArray<int> OPimTodoAccessBackendSQL::sorted( bool asc, int sortOrder,
/* completed */
- case 0:
+ case OPimTodoAccess::Completed:
query += "completed";
break;
- case 1:
+ case OPimTodoAccess::Priority:
query += "priority";
break;
- case 2:
+ case OPimTodoAccess::SortSummary:
query += "summary";
break;
- case 3:
+ case OPimTodoAccess::Deadline:
query += "DueDate";
@@ -609,6 +609,5 @@ QArray<int> OPimTodoAccessBackendSQL::sorted( bool asc, int sortOrder,
- if ( !asc ) {
- odebug << "not ascending!" << oendl;
+ if ( !asc )
query += " DESC";
- }
+
@@ -618,2 +617,5 @@ QArray<int> OPimTodoAccessBackendSQL::sorted( bool asc, int sortOrder,
}
+#endif
+
+
bool OPimTodoAccessBackendSQL::date( QDate& da, const QString& str ) const{
@@ -631,2 +633,4 @@ bool OPimTodoAccessBackendSQL::date( QDate& da, const QString& str ) const{
}
+
+
OPimTodo OPimTodoAccessBackendSQL::parseResultAndCache( int uid, const OSQLResult& res ) const{
@@ -641,10 +645,6 @@ OPimTodo OPimTodoAccessBackendSQL::parseResultAndCache( int uid, const OSQLResul
OSQLResultItem::ValueList::Iterator it = list.begin();
- odebug << "todo1" << oendl;
- OPimTodo to = todo( (*it) );
- cache( to );
- ++it;
+ OPimTodo to, tmp;
for ( ; it != list.end(); ++it ) {
- odebug << "caching" << oendl;
- OPimTodo newTodo = todo( (*it) );
+ OPimTodo newTodo = parse( (*it) );
cache( newTodo );
@@ -655,4 +655,3 @@ OPimTodo OPimTodoAccessBackendSQL::parseResultAndCache( int uid, const OSQLResul
}
-OPimTodo OPimTodoAccessBackendSQL::todo( OSQLResultItem& item )const {
- odebug << "todo(ResultItem)" << oendl;
+OPimTodo OPimTodoAccessBackendSQL::parse( OSQLResultItem& item )const {
@@ -664,4 +663,2 @@ OPimTodo OPimTodoAccessBackendSQL::todo( OSQLResultItem& item )const {
- odebug << "Item is completed: " << item.data("completed").toInt() << "" << oendl;
-
OPimTodo to( (bool)item.data("completed").toInt(), item.data("priority").toInt(),
@@ -719,32 +716,4 @@ OPimTodo OPimTodoAccessBackendSQL::todo( int uid )const {
}
-/*
- * update the dict
- */
-void OPimTodoAccessBackendSQL::fillDict() {
-#if 0
- /* initialize dict */
- /*
- * UPDATE dict if you change anything!!!
- * FIXME: Isn't this dict obsolete ? (eilers)
- */
- m_dict.setAutoDelete( TRUE );
- m_dict.insert("Categories" , new int(OPimTodo::Category) );
- m_dict.insert("Uid" , new int(OPimTodo::Uid) );
- m_dict.insert("HasDate" , new int(OPimTodo::HasDate) );
- m_dict.insert("Completed" , new int(OPimTodo::Completed) );
- m_dict.insert("Description" , new int(OPimTodo::Description) );
- m_dict.insert("Summary" , new int(OPimTodo::Summary) );
- m_dict.insert("Priority" , new int(OPimTodo::Priority) );
- m_dict.insert("DateDay" , new int(OPimTodo::DateDay) );
- m_dict.insert("DateMonth" , new int(OPimTodo::DateMonth) );
- m_dict.insert("DateYear" , new int(OPimTodo::DateYear) );
- m_dict.insert("Progress" , new int(OPimTodo::Progress) );
- m_dict.insert("Completed", new int(OPimTodo::Completed) ); // Why twice ? (eilers)
- m_dict.insert("CrossReference", new int(OPimTodo::CrossReference) );
-// m_dict.insert("HasAlarmDateTime",new int(OPimTodo::HasAlarmDateTime) ); // old stuff (eilers)
-// m_dict.insert("AlarmDateTime", new int(OPimTodo::AlarmDateTime) ); // old stuff (eilers)
-#endif
-}
/*
@@ -767,3 +736,2 @@ QArray<int> OPimTodoAccessBackendSQL::uids( const OSQLResult& res) const{
QArray<int> ints(list.count() );
- odebug << " count = " << list.count() << "" << oendl;
@@ -779,11 +747,5 @@ QArray<int> OPimTodoAccessBackendSQL::matchRegexp( const QRegExp &r ) const
{
-
-#if 0
- QArray<int> empty;
- return empty;
-
-#else
QString qu = "SELECT uid FROM todolist WHERE (";
- // Do it make sense to search other fields, too ?
+ // Does it make sense to search other fields, too ?
qu += " rlike(\""+ r.pattern() + "\",\"description\") OR";
@@ -793,4 +755,2 @@ QArray<int> OPimTodoAccessBackendSQL::matchRegexp( const QRegExp &r ) const
- odebug << "query: " << qu << "" << oendl;
-
OSQLRawQuery raw( qu );
@@ -799,23 +759,2 @@ QArray<int> OPimTodoAccessBackendSQL::matchRegexp( const QRegExp &r ) const
return uids( res );
-
-
-#endif
-
-}
-QBitArray OPimTodoAccessBackendSQL::supports()const {
-
- return sup();
-}
-
-QBitArray OPimTodoAccessBackendSQL::sup() const{
-
- QBitArray ar( OPimTodo::CompletedDate + 1 );
- ar.fill( true );
- ar[OPimTodo::CrossReference] = false;
- ar[OPimTodo::State ] = false;
- ar[OPimTodo::Reminders] = false;
- ar[OPimTodo::Notifiers] = false;
- ar[OPimTodo::Maintainer] = false;
-
- return ar;
}
@@ -833,4 +772,2 @@ void OPimTodoAccessBackendSQL::removeAllCompleted(){
- odebug << "Number of completed: " << completed_uids.size() << "" << oendl;
-
if ( completed_uids.size() == 0 )
@@ -841,3 +778,3 @@ void OPimTodoAccessBackendSQL::removeAllCompleted(){
- for ( int i = 0; i < completed_uids.size(); i++ ){
+ for ( uint i = 0; i < completed_uids.size(); i++ ){
if ( !query.isEmpty() )
@@ -852,3 +789,3 @@ void OPimTodoAccessBackendSQL::removeAllCompleted(){
- for ( int i = 0; i < completed_uids.size(); i++ ){
+ for ( uint i = 0; i < completed_uids.size(); i++ ){
if ( !query.isEmpty() )
@@ -859,9 +796,8 @@ void OPimTodoAccessBackendSQL::removeAllCompleted(){
- odebug << "query: " << qu << "" << oendl;
-
OSQLRawQuery raw2( qu );
res = m_driver->query( &raw2 );
- if ( res.state() == OSQLResult::Failure ) {
+
+ if ( res.state() == OSQLResult::Failure )
owarn << "OPimTodoAccessBackendSQL::removeAllCompleted():Failure in query: " << qu << "" << oendl;
- }
+
}
@@ -878,4 +814,3 @@ QMap<QString, QString> OPimTodoAccessBackendSQL::requestCustom( int uid ) const
owarn << "OSQLResult::Failure in find query !!" << oendl;
- QMap<QString, QString> empty;
- return empty;
+ return QMap<QString, QString>();
}
@@ -884,5 +819,5 @@ QMap<QString, QString> OPimTodoAccessBackendSQL::requestCustom( int uid ) const
OSQLResultItem::ValueList::Iterator it = list.begin();
- for ( ; it != list.end(); ++it ) {
+ for ( ; it != list.end(); ++it )
customMap.insert( (*it).data( "type" ), (*it).data( "value" ) );
- }
+