-rw-r--r-- | libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp | 2 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimevent.cpp | 30 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimevent.h | 2 |
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 @@ -129,25 +129,25 @@ void ODateBookAccessBackend_SQL::initFields() m_fieldMap.insert( OPimEvent::FREndDate, "REndDate" ); m_fieldMap.insert( OPimEvent::FRCreated, "RCreated" ); m_fieldMap.insert( OPimEvent::FRExceptions, "RExceptions" ); m_fieldMap.insert( OPimEvent::FStart, "Start" ); m_fieldMap.insert( OPimEvent::FEnd, "End" ); m_fieldMap.insert( OPimEvent::FNote, "Note" ); m_fieldMap.insert( OPimEvent::FTimeZone, "TimeZone" ); m_fieldMap.insert( OPimEvent::FRecParent, "RecParent" ); m_fieldMap.insert( OPimEvent::FRecChildren, "Recchildren" ); // Create a map that maps the column name to the id QMapConstIterator<int, QString> it; - for ( it = ++m_fieldMap.begin(); it != m_fieldMap.end(); ++it ){ + for ( it = m_fieldMap.begin(); it != m_fieldMap.end(); ++it ){ m_reverseFieldMap.insert( it.data(), it.key() ); } } bool ODateBookAccessBackend_SQL::load() { if (!m_driver->open() ) return false; // Don't expect that the database exists. // It is save here to create the table, even if it 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 @@ -546,27 +546,30 @@ void OPimEvent::deref() // Thus, we could remove the stuff there and use this // for it and for all other places.. // Encoding should happen at one place, only ! (eilers) QMap<int, QString> OPimEvent::toMap() const { QMap<int, QString> retMap; retMap.insert( OPimEvent::FUid, QString::number( uid() ) ); retMap.insert( OPimEvent::FCategories, Qtopia::escapeString( Qtopia::Record::idsToString( categories() ) ) ); retMap.insert( OPimEvent::FDescription, Qtopia::escapeString( description() ) ); retMap.insert( OPimEvent::FLocation, Qtopia::escapeString( location() ) ); retMap.insert( OPimEvent::FType, isAllDay() ? "AllDay" : "" ); + if ( notifiers().alarms().count() ){ + // Currently we just support one alarm.. (eilers) OPimAlarm alarm = notifiers().alarms() [ 0 ]; retMap.insert( OPimEvent::FAlarm, QString::number( alarm.dateTime().secsTo( startDateTime() ) / 60 ) ); retMap.insert( OPimEvent::FSound, ( alarm.sound() == OPimAlarm::Loud ) ? "loud" : "silent" ); + } OPimTimeZone zone( timeZone().isEmpty() ? OPimTimeZone::current() : timeZone() ); retMap.insert( OPimEvent::FStart, QString::number( zone.fromUTCDateTime( zone.toDateTime( startDateTime(), OPimTimeZone::utc() ) ) ) ); retMap.insert( OPimEvent::FEnd, QString::number( zone.fromUTCDateTime( zone.toDateTime( endDateTime(), OPimTimeZone::utc() ) ) ) ); retMap.insert( OPimEvent::FNote, Qtopia::escapeString( note() ) ); retMap.insert( OPimEvent::FTimeZone, timeZone().isEmpty() ? QString( "None" ) : timeZone() ); if ( parent() ) retMap.insert( OPimEvent::FRecParent, QString::number( parent() ) ); if ( children().count() ) { QArray<int> childr = children(); QString buf; @@ -610,35 +613,24 @@ void OPimEvent::fromMap( const QMap<int, QString>& map ) if ( !map[ OPimEvent::FUid ].isEmpty() ) setUid( map[ OPimEvent::FUid ].toInt() ); setCategories( idsFromString( map[ OPimEvent::FCategories ] ) ); setDescription( map[ OPimEvent::FDescription ] ); setLocation( map[ OPimEvent::FLocation ] ); if ( map[ OPimEvent::FType ] == "AllDay" ) setAllDay( true ); else setAllDay( false ); - int alarmTime = -1; - if ( !map[ OPimEvent::FAlarm ].isEmpty() ) - alarmTime = map[ OPimEvent::FAlarm ].toInt(); - - int sound = ( ( map[ OPimEvent::FSound ] == "loud" ) ? OPimAlarm::Loud : OPimAlarm::Silent ); - if ( ( alarmTime != -1 ) ) - { - QDateTime dt = startDateTime().addSecs( -1 * alarmTime * 60 ); - OPimAlarm al( sound , dt ); - notifiers().add( al ); - } if ( !map[ OPimEvent::FTimeZone ].isEmpty() && ( map[ OPimEvent::FTimeZone ] != "None" ) ) { setTimeZone( map[ OPimEvent::FTimeZone ] ); } time_t start = ( time_t ) map[ OPimEvent::FStart ].toLong(); time_t end = ( time_t ) map[ OPimEvent::FEnd ].toLong(); /* AllDay is always in UTC */ if ( isAllDay() ) { OPimTimeZone utc = OPimTimeZone::utc(); @@ -650,24 +642,40 @@ void OPimEvent::fromMap( const QMap<int, QString>& map ) { /* to current date time */ // qWarning(" Start is %d", start ); OPimTimeZone zone( timeZone().isEmpty() ? OPimTimeZone::current() : timeZone() ); QDateTime date = zone.toDateTime( start ); qWarning( " Start is %s", date.toString().latin1() ); setStartDateTime( zone.toDateTime( date, OPimTimeZone::current() ) ); date = zone.toDateTime( end ); setEndDateTime ( zone.toDateTime( date, OPimTimeZone::current() ) ); } + int alarmTime = -1; + if ( !map[ OPimEvent::FAlarm ].isEmpty() ) + alarmTime = map[ OPimEvent::FAlarm ].toInt(); + + int sound = ( ( map[ OPimEvent::FSound ] == "loud" ) ? OPimAlarm::Loud : OPimAlarm::Silent ); + if ( ( alarmTime != -1 ) ) + { + QDateTime dt = startDateTime().addSecs( -1 * alarmTime * 60 ); + OPimAlarm al( sound , dt ); + notifiers().add( al ); + } + + + if ( !map[ OPimEvent::FNote ].isEmpty() ) + setNote( map[ OPimEvent::FNote ] ); + if ( !map[ OPimEvent::FRecParent ].isEmpty() ) setParent( map[ OPimEvent::FRecParent ].toInt() ); if ( !map[ OPimEvent::FRecChildren ].isEmpty() ) { QStringList list = QStringList::split( ' ', map[ OPimEvent::FRecChildren ] ); for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { addChild( ( *it ).toInt() ); } } 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 @@ -70,25 +70,25 @@ class OPimRecurrence; */ class OPimEvent : public OPimRecord { public: typedef QValueList<OPimEvent> ValueList; /** * RecordFields contain possible attributes * used in the Results of toMap().. */ enum RecordFields { FUid = Qtopia::UID_ID, FCategories = Qtopia::CATEGORY_ID, - FDescription = 0, + FDescription /* = 0 Why this ? (eilers) */, FLocation, FType, FAlarm, FSound, FRType, FRWeekdays, FRPosition, FRFreq, FRHasEndDate, FREndDate, FRCreated, FRExceptions, |