summaryrefslogtreecommitdiff
authoreilers <eilers>2004-05-08 12:38:51 (UTC)
committer eilers <eilers>2004-05-08 12:38:51 (UTC)
commit81bc0cecdeb7c49f4f2950c1e5649bad05593d0c (patch) (unidiff)
treeb687e3562c432414df407d5d4e776b7c785588a3
parent91eccd3d535a8fb0022865bd1e1c100628a65431 (diff)
downloadopie-81bc0cecdeb7c49f4f2950c1e5649bad05593d0c.zip
opie-81bc0cecdeb7c49f4f2950c1e5649bad05593d0c.tar.gz
opie-81bc0cecdeb7c49f4f2950c1e5649bad05593d0c.tar.bz2
Fixed a lot of worse bugs in the databook-backend for SQL.
It was found by doing equivalence checks between events, moved between xml and sql backend, using opimconverter.. More bugfixes will follow..
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp2
-rw-r--r--libopie2/opiepim/core/opimevent.cpp30
-rw-r--r--libopie2/opiepim/core/opimevent.h2
3 files changed, 21 insertions, 13 deletions
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp b/libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp
index 6c32b40..f4f3c94 100644
--- a/libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp
+++ b/libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp
@@ -135,13 +135,13 @@ void ODateBookAccessBackend_SQL::initFields()
135 m_fieldMap.insert( OPimEvent::FTimeZone, "TimeZone" ); 135 m_fieldMap.insert( OPimEvent::FTimeZone, "TimeZone" );
136 m_fieldMap.insert( OPimEvent::FRecParent, "RecParent" ); 136 m_fieldMap.insert( OPimEvent::FRecParent, "RecParent" );
137 m_fieldMap.insert( OPimEvent::FRecChildren, "Recchildren" ); 137 m_fieldMap.insert( OPimEvent::FRecChildren, "Recchildren" );
138 138
139 // Create a map that maps the column name to the id 139 // Create a map that maps the column name to the id
140 QMapConstIterator<int, QString> it; 140 QMapConstIterator<int, QString> it;
141 for ( it = ++m_fieldMap.begin(); it != m_fieldMap.end(); ++it ){ 141 for ( it = m_fieldMap.begin(); it != m_fieldMap.end(); ++it ){
142 m_reverseFieldMap.insert( it.data(), it.key() ); 142 m_reverseFieldMap.insert( it.data(), it.key() );
143 } 143 }
144 144
145} 145}
146 146
147bool ODateBookAccessBackend_SQL::load() 147bool ODateBookAccessBackend_SQL::load()
diff --git a/libopie2/opiepim/core/opimevent.cpp b/libopie2/opiepim/core/opimevent.cpp
index 8bf8b25..9d46651 100644
--- a/libopie2/opiepim/core/opimevent.cpp
+++ b/libopie2/opiepim/core/opimevent.cpp
@@ -552,15 +552,18 @@ QMap<int, QString> OPimEvent::toMap() const
552 552
553 retMap.insert( OPimEvent::FUid, QString::number( uid() ) ); 553 retMap.insert( OPimEvent::FUid, QString::number( uid() ) );
554 retMap.insert( OPimEvent::FCategories, Qtopia::escapeString( Qtopia::Record::idsToString( categories() ) ) ); 554 retMap.insert( OPimEvent::FCategories, Qtopia::escapeString( Qtopia::Record::idsToString( categories() ) ) );
555 retMap.insert( OPimEvent::FDescription, Qtopia::escapeString( description() ) ); 555 retMap.insert( OPimEvent::FDescription, Qtopia::escapeString( description() ) );
556 retMap.insert( OPimEvent::FLocation, Qtopia::escapeString( location() ) ); 556 retMap.insert( OPimEvent::FLocation, Qtopia::escapeString( location() ) );
557 retMap.insert( OPimEvent::FType, isAllDay() ? "AllDay" : "" ); 557 retMap.insert( OPimEvent::FType, isAllDay() ? "AllDay" : "" );
558 if ( notifiers().alarms().count() ){
559 // Currently we just support one alarm.. (eilers)
558 OPimAlarm alarm = notifiers().alarms() [ 0 ]; 560 OPimAlarm alarm = notifiers().alarms() [ 0 ];
559 retMap.insert( OPimEvent::FAlarm, QString::number( alarm.dateTime().secsTo( startDateTime() ) / 60 ) ); 561 retMap.insert( OPimEvent::FAlarm, QString::number( alarm.dateTime().secsTo( startDateTime() ) / 60 ) );
560 retMap.insert( OPimEvent::FSound, ( alarm.sound() == OPimAlarm::Loud ) ? "loud" : "silent" ); 562 retMap.insert( OPimEvent::FSound, ( alarm.sound() == OPimAlarm::Loud ) ? "loud" : "silent" );
563 }
561 564
562 OPimTimeZone zone( timeZone().isEmpty() ? OPimTimeZone::current() : timeZone() ); 565 OPimTimeZone zone( timeZone().isEmpty() ? OPimTimeZone::current() : timeZone() );
563 retMap.insert( OPimEvent::FStart, QString::number( zone.fromUTCDateTime( zone.toDateTime( startDateTime(), OPimTimeZone::utc() ) ) ) ); 566 retMap.insert( OPimEvent::FStart, QString::number( zone.fromUTCDateTime( zone.toDateTime( startDateTime(), OPimTimeZone::utc() ) ) ) );
564 retMap.insert( OPimEvent::FEnd, QString::number( zone.fromUTCDateTime( zone.toDateTime( endDateTime(), OPimTimeZone::utc() ) ) ) ); 567 retMap.insert( OPimEvent::FEnd, QString::number( zone.fromUTCDateTime( zone.toDateTime( endDateTime(), OPimTimeZone::utc() ) ) ) );
565 retMap.insert( OPimEvent::FNote, Qtopia::escapeString( note() ) ); 568 retMap.insert( OPimEvent::FNote, Qtopia::escapeString( note() ) );
566 retMap.insert( OPimEvent::FTimeZone, timeZone().isEmpty() ? QString( "None" ) : timeZone() ); 569 retMap.insert( OPimEvent::FTimeZone, timeZone().isEmpty() ? QString( "None" ) : timeZone() );
@@ -616,23 +619,12 @@ void OPimEvent::fromMap( const QMap<int, QString>& map )
616 619
617 if ( map[ OPimEvent::FType ] == "AllDay" ) 620 if ( map[ OPimEvent::FType ] == "AllDay" )
618 setAllDay( true ); 621 setAllDay( true );
619 else 622 else
620 setAllDay( false ); 623 setAllDay( false );
621 624
622 int alarmTime = -1;
623 if ( !map[ OPimEvent::FAlarm ].isEmpty() )
624 alarmTime = map[ OPimEvent::FAlarm ].toInt();
625
626 int sound = ( ( map[ OPimEvent::FSound ] == "loud" ) ? OPimAlarm::Loud : OPimAlarm::Silent );
627 if ( ( alarmTime != -1 ) )
628 {
629 QDateTime dt = startDateTime().addSecs( -1 * alarmTime * 60 );
630 OPimAlarm al( sound , dt );
631 notifiers().add( al );
632 }
633 if ( !map[ OPimEvent::FTimeZone ].isEmpty() && ( map[ OPimEvent::FTimeZone ] != "None" ) ) 625 if ( !map[ OPimEvent::FTimeZone ].isEmpty() && ( map[ OPimEvent::FTimeZone ] != "None" ) )
634 { 626 {
635 setTimeZone( map[ OPimEvent::FTimeZone ] ); 627 setTimeZone( map[ OPimEvent::FTimeZone ] );
636 } 628 }
637 629
638 time_t start = ( time_t ) map[ OPimEvent::FStart ].toLong(); 630 time_t start = ( time_t ) map[ OPimEvent::FStart ].toLong();
@@ -656,12 +648,28 @@ void OPimEvent::fromMap( const QMap<int, QString>& map )
656 setStartDateTime( zone.toDateTime( date, OPimTimeZone::current() ) ); 648 setStartDateTime( zone.toDateTime( date, OPimTimeZone::current() ) );
657 649
658 date = zone.toDateTime( end ); 650 date = zone.toDateTime( end );
659 setEndDateTime ( zone.toDateTime( date, OPimTimeZone::current() ) ); 651 setEndDateTime ( zone.toDateTime( date, OPimTimeZone::current() ) );
660 } 652 }
661 653
654 int alarmTime = -1;
655 if ( !map[ OPimEvent::FAlarm ].isEmpty() )
656 alarmTime = map[ OPimEvent::FAlarm ].toInt();
657
658 int sound = ( ( map[ OPimEvent::FSound ] == "loud" ) ? OPimAlarm::Loud : OPimAlarm::Silent );
659 if ( ( alarmTime != -1 ) )
660 {
661 QDateTime dt = startDateTime().addSecs( -1 * alarmTime * 60 );
662 OPimAlarm al( sound , dt );
663 notifiers().add( al );
664 }
665
666
667 if ( !map[ OPimEvent::FNote ].isEmpty() )
668 setNote( map[ OPimEvent::FNote ] );
669
662 if ( !map[ OPimEvent::FRecParent ].isEmpty() ) 670 if ( !map[ OPimEvent::FRecParent ].isEmpty() )
663 setParent( map[ OPimEvent::FRecParent ].toInt() ); 671 setParent( map[ OPimEvent::FRecParent ].toInt() );
664 672
665 if ( !map[ OPimEvent::FRecChildren ].isEmpty() ) 673 if ( !map[ OPimEvent::FRecChildren ].isEmpty() )
666 { 674 {
667 QStringList list = QStringList::split( ' ', map[ OPimEvent::FRecChildren ] ); 675 QStringList list = QStringList::split( ' ', map[ OPimEvent::FRecChildren ] );
diff --git a/libopie2/opiepim/core/opimevent.h b/libopie2/opiepim/core/opimevent.h
index 56fe917..5553cac 100644
--- a/libopie2/opiepim/core/opimevent.h
+++ b/libopie2/opiepim/core/opimevent.h
@@ -76,13 +76,13 @@ class OPimEvent : public OPimRecord
76 * RecordFields contain possible attributes 76 * RecordFields contain possible attributes
77 * used in the Results of toMap().. 77 * used in the Results of toMap()..
78 */ 78 */
79 enum RecordFields { 79 enum RecordFields {
80 FUid = Qtopia::UID_ID, 80 FUid = Qtopia::UID_ID,
81 FCategories = Qtopia::CATEGORY_ID, 81 FCategories = Qtopia::CATEGORY_ID,
82 FDescription = 0, 82 FDescription /* = 0 Why this ? (eilers) */,
83 FLocation, 83 FLocation,
84 FType, 84 FType,
85 FAlarm, 85 FAlarm,
86 FSound, 86 FSound,
87 FRType, 87 FRType,
88 FRWeekdays, 88 FRWeekdays,