-rw-r--r-- | libopie2/opiepim/backend/otodoaccesssql.cpp | 54 |
1 files changed, 27 insertions, 27 deletions
diff --git a/libopie2/opiepim/backend/otodoaccesssql.cpp b/libopie2/opiepim/backend/otodoaccesssql.cpp index ef036d5..132b5a6 100644 --- a/libopie2/opiepim/backend/otodoaccesssql.cpp +++ b/libopie2/opiepim/backend/otodoaccesssql.cpp @@ -163,23 +163,23 @@ namespace { private: QString single()const; QString multi()const; QArray<int> m_uids; int m_uid; }; - + CreateQuery::CreateQuery() : OSQLQuery() {} CreateQuery::~CreateQuery() {} QString CreateQuery::query()const { QString qu; qu += "create table todolist( uid PRIMARY KEY, categories, completed, "; qu += "description, summary, priority, DueDate, progress , state, "; // This is the recurrance-stuff .. Exceptions are currently not supported (see OPimRecurrence.cpp) ! (eilers) - qu += "RType, RWeekdays, RPosition, RFreq, RHasEndDate, EndDate, Created, Exceptions, "; + qu += "RType, RWeekdays, RPosition, RFreq, RHasEndDate, EndDate, Created, Exceptions, "; qu += "reminders, alarms, maintainer, startdate, completeddate);"; qu += "create table custom_data( uid INTEGER, id INTEGER, type VARCHAR(10), priority INTEGER, value VARCHAR(10), PRIMARY KEY /* identifier */ (uid, id) );"; return qu; } LoadQuery::LoadQuery() : OSQLQuery() {} @@ -217,82 +217,82 @@ namespace { int sYear = 0, sMonth = 0, sDay = 0; if( m_todo.hasStartDate() ){ QDate sDate = m_todo.startDate(); sYear = sDate.year(); sMonth= sDate.month(); sDay = sDate.day(); - } + } int eYear = 0, eMonth = 0, eDay = 0; if( m_todo.hasCompletedDate() ){ QDate eDate = m_todo.completedDate(); eYear = eDate.year(); eMonth= eDate.month(); eDay = eDate.day(); - } + } QString qu; QMap<int, QString> recMap = m_todo.recurrence().toMap(); - qu = "insert into todolist VALUES(" - + QString::number( m_todo.uid() ) + "," + qu = "insert into todolist VALUES(" + + QString::number( m_todo.uid() ) + "," + "'" + m_todo.idsToString( m_todo.categories() ) + "'" + "," - + QString::number( m_todo.isCompleted() ) + "," + + QString::number( m_todo.isCompleted() ) + "," + "'" + m_todo.description() + "'" + "," - + "'" + m_todo.summary() + "'" + "," + + "'" + m_todo.summary() + "'" + "," + QString::number(m_todo.priority() ) + "," - + "'" + QString::number(year).rightJustify( 4, '0' ) + "-" + + "'" + QString::number(year).rightJustify( 4, '0' ) + "-" + QString::number(month).rightJustify( 2, '0' ) + "-" + QString::number( day ).rightJustify( 2, '0' )+ "'" + "," + QString::number( m_todo.progress() ) + "," + QString::number( m_todo.state().state() ) + "," + "'" + recMap[ OPimRecurrence::RType ] + "'" + "," + "'" + recMap[ OPimRecurrence::RWeekdays ] + "'" + "," + "'" + recMap[ OPimRecurrence::RPosition ] + "'" + "," + "'" + recMap[ OPimRecurrence::RFreq ] + "'" + "," + "'" + recMap[ OPimRecurrence::RHasEndDate ] + "'" + "," + "'" + recMap[ OPimRecurrence::EndDate ] + "'" + "," + "'" + recMap[ OPimRecurrence::Created ] + "'" + "," + "'" + recMap[ OPimRecurrence::Exceptions ] + "'" + ","; - + if ( m_todo.hasNotifiers() ) { OPimNotifyManager manager = m_todo.notifiers(); - qu += "'" + manager.remindersToString() + "'" + "," + qu += "'" + manager.remindersToString() + "'" + "," + "'" + manager.alarmsToString() + "'" + ","; } else{ qu += QString( "''" ) + "," + "''" + ","; } qu += QString( "''" ) + QString( "," ) // Maintainers (cur. not supported !) - + "'" + QString::number(sYear).rightJustify( 4, '0' ) + "-" + + "'" + QString::number(sYear).rightJustify( 4, '0' ) + "-" + QString::number(sMonth).rightJustify( 2, '0' ) + "-" + QString::number(sDay).rightJustify( 2, '0' )+ "'" + "," + "'" + QString::number(eYear).rightJustify( 4, '0' ) + "-" + QString::number(eMonth).rightJustify( 2, '0' ) + "-"+QString::number(eDay).rightJustify( 2, '0' ) + "'" - + ")"; + + "); "; // Save custom Entries: int id = 0; id = 0; QMap<QString, QString> customMap = m_todo.toExtraMap(); - for( QMap<QString, QString>::Iterator it = customMap.begin(); + for( QMap<QString, QString>::Iterator it = customMap.begin(); it != customMap.end(); ++it ){ - qu += "insert into custom_data VALUES(" + qu += "insert into custom_data VALUES(" + QString::number( m_todo.uid() ) + "," - + QString::number( id++ ) - + ",'" + + QString::number( id++ ) + + ",'" + it.key() + "'," + "0" // Priority for future enhancements - + ",'" + + ",'" + it.data() + "');"; - } - + } + qDebug("add %s", qu.latin1() ); return qu; } RemoveQuery::RemoveQuery(int uid ) @@ -641,13 +641,13 @@ OPimTodo OPimTodoAccessBackendSQL::todo( const OSQLResult& res ) const{ return to; } OPimTodo OPimTodoAccessBackendSQL::todo( OSQLResultItem& item )const { qDebug("todo(ResultItem)"); // Request information from addressbook table and create the OPimTodo-object. - + bool hasDueDate = false; QDate dueDate = QDate::currentDate(); hasDueDate = date( dueDate, item.data("DueDate") ); QStringList cats = QStringList::split(";", item.data("categories") ); qDebug("Item is completed: %d", item.data("completed").toInt() ); @@ -667,13 +667,13 @@ OPimTodo OPimTodoAccessBackendSQL::todo( OSQLResultItem& item )const { hasCompletedDate = date( completedDate, item.data("completeddate") ); if ( hasStartDate ) to.setStartDate( startDate ); if ( hasCompletedDate ) to.setCompletedDate( completedDate ); - + OPimNotifyManager& manager = to.notifiers(); manager.alarmsFromString( item.data("alarms") ); manager.remindersFromString( item.data("reminders") ); OPimState pimState; pimState.setState( QString( item.data("state") ).toInt() ); @@ -685,13 +685,13 @@ OPimTodo OPimTodoAccessBackendSQL::todo( OSQLResultItem& item )const { recMap.insert( OPimRecurrence::RPosition , item.data("RPosition") ); recMap.insert( OPimRecurrence::RFreq , item.data("RFreq") ); recMap.insert( OPimRecurrence::RHasEndDate, item.data("RHasEndDate") ); recMap.insert( OPimRecurrence::EndDate , item.data("EndDate") ); recMap.insert( OPimRecurrence::Created , item.data("Created") ); recMap.insert( OPimRecurrence::Exceptions , item.data("Exceptions") ); - + OPimRecurrence recur; recur.fromMap( recMap ); to.setRecurrence( recur ); // Finally load the custom-entries for this UID and put it into the created object to.setExtraMap( requestCustom( to.uid() ) ); @@ -770,13 +770,13 @@ QArray<int> OPimTodoAccessBackendSQL::matchRegexp( const QRegExp &r ) const #else QString qu = "SELECT uid FROM todolist WHERE ("; // Do it make sense to search other fields, too ? qu += " rlike(\""+ r.pattern() + "\",\"description\") OR"; qu += " rlike(\""+ r.pattern() + "\",\"summary\")"; - + qu += ")"; qDebug( "query: %s", qu.latin1() ); OSQLRawQuery raw( qu ); OSQLResult res = m_driver->query( &raw ); @@ -798,18 +798,18 @@ QBitArray OPimTodoAccessBackendSQL::sup() const{ 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; } void OPimTodoAccessBackendSQL::removeAllCompleted(){ - // First we need the uids from all entries which are + // First we need the uids from all entries which are // completed. Then, we just have to remove them... QString qu = "SELECT uid FROM todolist WHERE completed = 1"; OSQLRawQuery raw( qu ); OSQLResult res = m_driver->query( &raw ); @@ -852,13 +852,13 @@ void OPimTodoAccessBackendSQL::removeAllCompleted(){ } QMap<QString, QString> OPimTodoAccessBackendSQL::requestCustom( int uid ) const { QMap<QString, QString> customMap; - + FindCustomQuery query( uid ); OSQLResult res_custom = m_driver->query( &query ); if ( res_custom.state() == OSQLResult::Failure ) { qWarning("OSQLResult::Failure in find query !!"); QMap<QString, QString> empty; |