author | zecke <zecke> | 2004-05-22 10:17:20 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-05-22 10:17:20 (UTC) |
commit | 77f189ec4b959a2874942b00b070ea60c091a7fa (patch) (side-by-side diff) | |
tree | 57e36d30a275db1b139ccc5995080b553f33b0f0 /libopie2/opiepim/backend/otodoaccesssql.cpp | |
parent | 35b6ab7a844145378a6e427c4666fa65b63d3cfd (diff) | |
download | opie-77f189ec4b959a2874942b00b070ea60c091a7fa.zip opie-77f189ec4b959a2874942b00b070ea60c091a7fa.tar.gz opie-77f189ec4b959a2874942b00b070ea60c091a7fa.tar.bz2 |
Fix inserting data with custom tables
Also I don't like the string comparsions. Are they really needed?
Diffstat (limited to 'libopie2/opiepim/backend/otodoaccesssql.cpp') (more/less context) (ignore whitespace changes)
-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 @@ -167,5 +167,5 @@ namespace { int m_uid; }; - + @@ -177,5 +177,5 @@ namespace { 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) );"; @@ -221,5 +221,5 @@ namespace { sMonth= sDate.month(); sDay = sDate.day(); - } + } int eYear = 0, eMonth = 0, eDay = 0; @@ -229,15 +229,15 @@ namespace { 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' )+ "'" + "," @@ -252,8 +252,8 @@ namespace { + "'" + recMap[ OPimRecurrence::Created ] + "'" + "," + "'" + recMap[ OPimRecurrence::Exceptions ] + "'" + ","; - + if ( m_todo.hasNotifiers() ) { OPimNotifyManager manager = m_todo.notifiers(); - qu += "'" + manager.remindersToString() + "'" + "," + qu += "'" + manager.remindersToString() + "'" + "," + "'" + manager.alarmsToString() + "'" + ","; } @@ -264,5 +264,5 @@ namespace { 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' )+ "'" + "," @@ -270,5 +270,5 @@ namespace { + QString::number(eMonth).rightJustify( 2, '0' ) + "-"+QString::number(eDay).rightJustify( 2, '0' ) + "'" - + ")"; + + "); "; // Save custom Entries: @@ -276,19 +276,19 @@ namespace { 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() ); @@ -645,5 +645,5 @@ OPimTodo OPimTodoAccessBackendSQL::todo( OSQLResultItem& item )const { // Request information from addressbook table and create the OPimTodo-object. - + bool hasDueDate = false; QDate dueDate = QDate::currentDate(); hasDueDate = date( dueDate, item.data("DueDate") ); @@ -671,5 +671,5 @@ OPimTodo OPimTodoAccessBackendSQL::todo( OSQLResultItem& item )const { if ( hasCompletedDate ) to.setCompletedDate( completedDate ); - + OPimNotifyManager& manager = to.notifiers(); manager.alarmsFromString( item.data("alarms") ); @@ -689,5 +689,5 @@ OPimTodo OPimTodoAccessBackendSQL::todo( OSQLResultItem& item )const { recMap.insert( OPimRecurrence::Created , item.data("Created") ); recMap.insert( OPimRecurrence::Exceptions , item.data("Exceptions") ); - + OPimRecurrence recur; recur.fromMap( recMap ); @@ -774,5 +774,5 @@ QArray<int> OPimTodoAccessBackendSQL::matchRegexp( const QRegExp &r ) const qu += " rlike(\""+ r.pattern() + "\",\"description\") OR"; qu += " rlike(\""+ r.pattern() + "\",\"summary\")"; - + qu += ")"; @@ -802,10 +802,10 @@ QBitArray OPimTodoAccessBackendSQL::sup() const{ 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... @@ -856,5 +856,5 @@ QMap<QString, QString> OPimTodoAccessBackendSQL::requestCustom( int uid ) const { QMap<QString, QString> customMap; - + FindCustomQuery query( uid ); OSQLResult res_custom = m_driver->query( &query ); |