Diffstat (limited to 'libopie2/opiepim/core/opimnotify.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiepim/core/opimnotify.cpp | 251 |
1 files changed, 186 insertions, 65 deletions
diff --git a/libopie2/opiepim/core/opimnotify.cpp b/libopie2/opiepim/core/opimnotify.cpp index c61f9da..43858f0 100644 --- a/libopie2/opiepim/core/opimnotify.cpp +++ b/libopie2/opiepim/core/opimnotify.cpp @@ -27,13 +27,17 @@ Boston, MA 02111-1307, USA. */ -#include <qshared.h> -#include <opie2/opimnotify.h> +#include "opimnotify.h" -namespace Opie { +/* QT */ +#include <qshared.h> -struct OPimNotify::Data : public QShared { - Data() : QShared(),dur(-1),parent(0) { +namespace Opie +{ +struct OPimNotify::Data : public QShared +{ + Data() : QShared(), dur( -1 ), parent( 0 ) + { } QDateTime start; @@ -43,5 +47,6 @@ struct OPimNotify::Data : public QShared { }; -OPimNotify::OPimNotify( const QDateTime& start, int duration, int parent ) { +OPimNotify::OPimNotify( const QDateTime& start, int duration, int parent ) +{ data = new Data; data->start = start; @@ -49,11 +54,17 @@ OPimNotify::OPimNotify( const QDateTime& start, int duration, int parent ) { data->parent = parent; } -OPimNotify::OPimNotify( const OPimNotify& noti) - : data( noti.data ) + + +OPimNotify::OPimNotify( const OPimNotify& noti ) + : data( noti.data ) { data->ref(); } -OPimNotify::~OPimNotify() { - if ( data->deref() ) { + + +OPimNotify::~OPimNotify() +{ + if ( data->deref() ) + { delete data; data = 0l; @@ -61,5 +72,7 @@ OPimNotify::~OPimNotify() { } -OPimNotify &OPimNotify::operator=( const OPimNotify& noti) { + +OPimNotify &OPimNotify::operator=( const OPimNotify& noti ) +{ noti.data->ref(); deref(); @@ -68,5 +81,8 @@ OPimNotify &OPimNotify::operator=( const OPimNotify& noti) { return *this; } -bool OPimNotify::operator==( const OPimNotify& noti ) { + + +bool OPimNotify::operator==( const OPimNotify& noti ) +{ if ( data == noti.data ) return true; if ( data->dur != noti.data->dur ) return false; @@ -77,41 +93,72 @@ bool OPimNotify::operator==( const OPimNotify& noti ) { return true; } -QDateTime OPimNotify::dateTime()const { + + +QDateTime OPimNotify::dateTime() const +{ return data->start; } -QString OPimNotify::service()const { + + +QString OPimNotify::service() const +{ return data->application; } -int OPimNotify::parent()const { + + +int OPimNotify::parent() const +{ return data->parent; } -int OPimNotify::duration()const { + + +int OPimNotify::duration() const +{ return data->dur; } -QDateTime OPimNotify::endTime()const { - return QDateTime( data->start.date(), data->start.time().addSecs( data->dur) ); + + +QDateTime OPimNotify::endTime() const +{ + return QDateTime( data->start.date(), data->start.time().addSecs( data->dur ) ); } -void OPimNotify::setDateTime( const QDateTime& time ) { + + +void OPimNotify::setDateTime( const QDateTime& time ) +{ copyIntern(); data->start = time; } -void OPimNotify::setDuration( int dur ) { + + +void OPimNotify::setDuration( int dur ) +{ copyIntern(); data->dur = dur; } -void OPimNotify::setParent( int uid ) { + + +void OPimNotify::setParent( int uid ) +{ copyIntern(); data->parent = uid; } -void OPimNotify::setService( const QString& str ) { + + +void OPimNotify::setService( const QString& str ) +{ copyIntern(); data->application = str; } -void OPimNotify::copyIntern() { - if ( data->count != 1 ) { + + +void OPimNotify::copyIntern() +{ + if ( data->count != 1 ) + { data->deref(); Data* dat = new Data; dat->start = data->start; - dat->dur = data->dur; + dat->dur = data->dur; dat->application = data->application; dat->parent = data->parent; @@ -119,6 +166,10 @@ void OPimNotify::copyIntern() { } } -void OPimNotify::deref() { - if ( data->deref() ) { + + +void OPimNotify::deref() +{ + if ( data->deref() ) + { delete data; data = 0; @@ -126,7 +177,10 @@ void OPimNotify::deref() { } + /***********************************************************/ -struct OPimAlarm::Data : public QShared { - Data() : QShared() { +struct OPimAlarm::Data : public QShared +{ + Data() : QShared() + { sound = 1; } @@ -134,22 +188,32 @@ struct OPimAlarm::Data : public QShared { QString file; }; + + OPimAlarm::OPimAlarm( int sound, const QDateTime& start, int duration, int parent ) - : OPimNotify( start, duration, parent ) + : OPimNotify( start, duration, parent ) { data = new Data; data->sound = sound; } -OPimAlarm::OPimAlarm( const OPimAlarm& al) - : OPimNotify(al), data( al.data ) + + +OPimAlarm::OPimAlarm( const OPimAlarm& al ) + : OPimNotify( al ), data( al.data ) { data->ref(); } -OPimAlarm::~OPimAlarm() { - if ( data->deref() ) { + + +OPimAlarm::~OPimAlarm() +{ + if ( data->deref() ) + { delete data; data = 0l; } } -OPimAlarm &OPimAlarm::operator=( const OPimAlarm& al) + + +OPimAlarm &OPimAlarm::operator=( const OPimAlarm& al ) { OPimNotify::operator=( al ); @@ -162,5 +226,8 @@ OPimAlarm &OPimAlarm::operator=( const OPimAlarm& al) return *this; } -bool OPimAlarm::operator==( const OPimAlarm& al) { + + +bool OPimAlarm::operator==( const OPimAlarm& al ) +{ if ( data->sound != al.data->sound ) return false; else if ( data->sound == Custom && data->file != al.data->file ) @@ -169,56 +236,89 @@ bool OPimAlarm::operator==( const OPimAlarm& al) { return OPimNotify::operator==( al ); } -QString OPimAlarm::type()const { - return QString::fromLatin1("OPimAlarm"); + + +QString OPimAlarm::type() const +{ + return QString::fromLatin1( "OPimAlarm" ); } -int OPimAlarm::sound()const { + + +int OPimAlarm::sound() const +{ return data->sound; } -QString OPimAlarm::file()const { + + +QString OPimAlarm::file() const +{ return data->file; } -void OPimAlarm::setSound( int snd) { + + +void OPimAlarm::setSound( int snd ) +{ copyIntern(); data->sound = snd; } -void OPimAlarm::setFile( const QString& sound ) { + + +void OPimAlarm::setFile( const QString& sound ) +{ copyIntern(); data->file = sound; } -void OPimAlarm::deref() { - if ( data->deref() ) { + + +void OPimAlarm::deref() +{ + if ( data->deref() ) + { delete data; data = 0l; } } -void OPimAlarm::copyIntern() { - if ( data->count != 1 ) { + + +void OPimAlarm::copyIntern() +{ + if ( data->count != 1 ) + { data->deref(); Data *newDat = new Data; newDat->sound = data->sound; - newDat->file = data->file; + newDat->file = data->file; data = newDat; } } + + /************************/ -struct OPimReminder::Data : public QShared { - Data() : QShared(), record( 0) { - } +struct OPimReminder::Data : public QShared +{ + Data() : QShared(), record( 0 ) + {} int record; }; -OPimReminder::OPimReminder( int uid, const QDateTime& start, int dur, int parent ) - : OPimNotify( start, dur, parent ) + + +OPimReminder::OPimReminder( int uid, const QDateTime& start, int dur, int parent ) + : OPimNotify( start, dur, parent ) { data = new Data; data->record = uid; } + + OPimReminder::OPimReminder( const OPimReminder& rem ) - : OPimNotify( rem ), data( rem.data ) + : OPimNotify( rem ), data( rem.data ) { data->ref(); } -OPimReminder& OPimReminder::operator=( const OPimReminder& rem) { - OPimNotify::operator=(rem ); + + +OPimReminder& OPimReminder::operator=( const OPimReminder& rem ) +{ + OPimNotify::operator=( rem ); deref(); @@ -228,31 +328,52 @@ OPimReminder& OPimReminder::operator=( const OPimReminder& rem) { return *this; } -bool OPimReminder::operator==( const OPimReminder& rem) { + + +bool OPimReminder::operator==( const OPimReminder& rem ) +{ if ( data->record != rem.data->record ) return false; return OPimNotify::operator==( rem ); } -QString OPimReminder::type()const { - return QString::fromLatin1("OPimReminder"); + + +QString OPimReminder::type() const +{ + return QString::fromLatin1( "OPimReminder" ); } -int OPimReminder::recordUid()const { + + +int OPimReminder::recordUid() const +{ return data->record; } -void OPimReminder::setRecordUid( int uid ) { + + +void OPimReminder::setRecordUid( int uid ) +{ copyIntern(); data->record = uid; } -void OPimReminder::deref() { - if ( data->deref() ) { + + +void OPimReminder::deref() +{ + if ( data->deref() ) + { delete data; data = 0l; } } -void OPimReminder::copyIntern() { - if ( data->count != 1 ) { - Data* da = new Data; + + +void OPimReminder::copyIntern() +{ + if ( data->count != 1 ) + { + Data * da = new Data; da->record = data->record; data = da; } } + } |