summaryrefslogtreecommitdiff
path: root/libopie2
Side-by-side diff
Diffstat (limited to 'libopie2') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp2
-rw-r--r--libopie2/opiepim/core/opimevent.cpp36
-rw-r--r--libopie2/opiepim/core/opimevent.h2
3 files changed, 24 insertions, 16 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
@@ -125,33 +125,33 @@ void ODateBookAccessBackend_SQL::initFields()
m_fieldMap.insert( OPimEvent::FRWeekdays, "RWeekdays" );
m_fieldMap.insert( OPimEvent::FRPosition, "RPosition" );
m_fieldMap.insert( OPimEvent::FRFreq, "RFreq" );
m_fieldMap.insert( OPimEvent::FRHasEndDate, "RHasEndDate" );
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
// do exist. ( Is that correct for all databases ?? )
QString qu = "create table datebook( uid INTEGER PRIMARY KEY ";
QMap<int, QString>::Iterator 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
@@ -542,35 +542,38 @@ void OPimEvent::deref()
}
}
// Exporting Event data to map. Using the same
// encoding as ODateBookAccessBackend_xml does..
// 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" : "" );
- 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" );
+ 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;
for ( uint i = 0; i < childr.count(); i++ )
{
if ( i != 0 ) buf += " ";
buf += QString::number( childr[ i ] );
@@ -606,72 +609,77 @@ QMap<int, QString> OPimEvent::toMap() const
void OPimEvent::fromMap( const QMap<int, QString>& map )
{
// We just want to set the UID if it is really stored.
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();
setStartDateTime( utc.fromUTCDateTime( start ) );
setEndDateTime ( utc.fromUTCDateTime( end ) );
setTimeZone( "UTC" ); // make sure it is really utc
}
else
{
/* 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() );
}
}
// Fill recurrence stuff and put it directly into the OPimRecurrence-Object using fromMap..
if ( !map[ OPimEvent::FRType ].isEmpty() )
{
QMap<int, QString> recFields;
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
@@ -66,33 +66,33 @@ class OPimRecurrence;
/**
* This is the container for all Events. It encapsules all
* available information for a single Event
* @short container for events.
*/
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,
FStart,
FEnd,
FNote,
FTimeZone,