From f9f0c26d9ac94586ffc36efa1b582ece3dbc43cf Mon Sep 17 00:00:00 2001 From: mickeyl Date: Mon, 23 Feb 2004 13:15:42 +0000 Subject: cosmetics --- (limited to 'libopie2/opiepim/core') 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 @@ -26,15 +26,19 @@ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include -#include +#include "opimnotify.h" -namespace Opie { +/* QT */ +#include -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; int dur; @@ -42,32 +46,44 @@ struct OPimNotify::Data : public QShared { int parent; }; -OPimNotify::OPimNotify( const QDateTime& start, int duration, int parent ) { +OPimNotify::OPimNotify( const QDateTime& start, int duration, int parent ) +{ data = new Data; data->start = start; data->dur = duration; 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; } } -OPimNotify &OPimNotify::operator=( const OPimNotify& noti) { + +OPimNotify &OPimNotify::operator=( const OPimNotify& noti ) +{ noti.data->ref(); deref(); data = noti.data; 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; if ( data->parent != noti.data->parent ) return false; @@ -76,81 +92,129 @@ 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; data = dat; } } -void OPimNotify::deref() { - if ( data->deref() ) { + + +void OPimNotify::deref() +{ + if ( data->deref() ) + { delete data; data = 0; } } + /***********************************************************/ -struct OPimAlarm::Data : public QShared { - Data() : QShared() { +struct OPimAlarm::Data : public QShared +{ + Data() : QShared() + { sound = 1; } int sound; 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 ); deref(); @@ -161,65 +225,101 @@ 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 ) return false; 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(); rem.data->ref(); @@ -227,32 +327,53 @@ 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; } } + } diff --git a/libopie2/opiepim/core/opimnotify.h b/libopie2/opiepim/core/opimnotify.h index fed3970..d0e40ca 100644 --- a/libopie2/opiepim/core/opimnotify.h +++ b/libopie2/opiepim/core/opimnotify.h @@ -26,14 +26,16 @@ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#ifndef OPIE_PIM_NOTIFY_H -#define OPIE_PIM_NOTIFY_H +#ifndef OPIMNOTIFY_H +#define OPIMNOTIFY_H + +/* QT */ #include #include - -namespace Opie { +namespace Opie +{ /** * This is the base class of Notifiers. Possible * notifiers would be Alarms, Reminders @@ -47,44 +49,46 @@ namespace Opie { * given on the Due/Start Date? -zecke * discuss: do we need a uid for the notify? -zecke */ -class OPimNotify { -public: +class OPimNotify +{ + + public: typedef QValueList ValueList; OPimNotify( const QDateTime& start = QDateTime(), int duration = 0, int parent = 0 ); OPimNotify( const OPimNotify& ); virtual ~OPimNotify(); - OPimNotify &operator=(const OPimNotify& ); + OPimNotify &operator=( const OPimNotify& ); bool operator==( const OPimNotify& ); - virtual QString type()const = 0; + virtual QString type() const = 0; /** start date */ - QDateTime dateTime()const; - QString service()const; + QDateTime dateTime() const; + QString service() const; /** * RETURN the parent uid */ - int parent()const; + int parent() const; /** * in Seconds */ - int duration()const; + int duration() const; /** * Start Time + Duration */ - QDateTime endTime()const; + QDateTime endTime() const; void setDateTime( const QDateTime& ); void setDuration( int dur ); - void setParent(int uid ); + void setParent( int uid ); void setService( const QString& ); -private: + private: inline void copyIntern(); void deref(); struct Data; @@ -100,25 +104,26 @@ private: * at a given time to inform about * an Event */ -class OPimAlarm : public OPimNotify { -public: - enum Sound{Loud=1, Silent=0, Custom=2 }; +class OPimAlarm : public OPimNotify +{ + public: + enum Sound{Loud = 1, Silent = 0, Custom = 2 }; OPimAlarm( int sound = Silent, const QDateTime& start = QDateTime(), int duration = 0, int parent = 0 ); OPimAlarm( const OPimAlarm& ); ~OPimAlarm(); OPimAlarm &operator=( const OPimAlarm& ); bool operator==( const OPimAlarm& ); - QString type()const; + QString type() const; - int sound()const; - QString file()const; + int sound() const; + QString file() const; void setSound( int ); /* only when sound is custom... */ void setFile( const QString& sound ); -private: + private: void deref(); void copyIntern(); struct Data; @@ -135,9 +140,9 @@ private: * Note that the returned dateTime() may be not valid. * In these cases one must resolve the uid and get the OEvent */ -class OPimReminder : public OPimNotify { -public: - +class OPimReminder : public OPimNotify +{ + public: /** * c'tor of a reminder * @param uid The uid of the Record inside the Datebook @@ -145,12 +150,12 @@ public: * @param duration The duration of the event ( -1 for all day ) * @param parent The 'parent' record of this reminder */ - OPimReminder( int uid = 0, const QDateTime& start = QDateTime(), - int duration = 0, int parent = 0 ); + OPimReminder( int uid = 0, const QDateTime& start = QDateTime(), + int duration = 0, int parent = 0 ); OPimReminder( const OPimReminder& ); - OPimReminder &operator=(const OPimReminder& ); + OPimReminder &operator=( const OPimReminder& ); - QString type()const; + QString type() const; bool operator==( const OPimReminder& ); @@ -158,10 +163,10 @@ public: * the uid of the alarm * inside the 'datebook' application */ - int recordUid()const; + int recordUid() const; void setRecordUid( int uid ); -private: + private: void deref(); void copyIntern(); diff --git a/libopie2/opiepim/core/opimnotifymanager.cpp b/libopie2/opiepim/core/opimnotifymanager.cpp index 1771fad..a54d597 100644 --- a/libopie2/opiepim/core/opimnotifymanager.cpp +++ b/libopie2/opiepim/core/opimnotifymanager.cpp @@ -26,77 +26,117 @@ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include +#include "opimnotifymanager.h" + +/* OPIE */ #include +/* QT */ #include -namespace Opie { +namespace Opie +{ -OPimNotifyManager::OPimNotifyManager( const Reminders& rem, const Alarms& al) - : m_rem( rem ), m_al( al ) +OPimNotifyManager::OPimNotifyManager( const Reminders& rem, const Alarms& al ) + : m_rem( rem ), m_al( al ) {} -OPimNotifyManager::~OPimNotifyManager() { -} + + +OPimNotifyManager::~OPimNotifyManager() +{} + + /* use static_cast and type instead of dynamic... */ -void OPimNotifyManager::add( const OPimNotify& noti) { - if ( noti.type() == QString::fromLatin1("OPimReminder") ) { - const OPimReminder& rem = static_cast(noti); +void OPimNotifyManager::add( const OPimNotify& noti ) +{ + if ( noti.type() == QString::fromLatin1( "OPimReminder" ) ) + { + const OPimReminder & rem = static_cast( noti ); m_rem.append( rem ); - }else if ( noti.type() == QString::fromLatin1("OPimAlarm") ) { - const OPimAlarm& al = static_cast(noti); + } + else if ( noti.type() == QString::fromLatin1( "OPimAlarm" ) ) + { + const OPimAlarm & al = static_cast( noti ); m_al.append( al ); } } -void OPimNotifyManager::remove( const OPimNotify& noti) { - if ( noti.type() == QString::fromLatin1("OPimReminder") ) { - const OPimReminder& rem = static_cast(noti); + + +void OPimNotifyManager::remove( const OPimNotify& noti ) +{ + if ( noti.type() == QString::fromLatin1( "OPimReminder" ) ) + { + const OPimReminder & rem = static_cast( noti ); m_rem.remove( rem ); - }else if ( noti.type() == QString::fromLatin1("OPimAlarm") ) { - const OPimAlarm& al = static_cast(noti); + } + else if ( noti.type() == QString::fromLatin1( "OPimAlarm" ) ) + { + const OPimAlarm & al = static_cast( noti ); m_al.remove( al ); } } -void OPimNotifyManager::replace( const OPimNotify& noti) { - if ( noti.type() == QString::fromLatin1("OPimReminder") ) { - const OPimReminder& rem = static_cast(noti); + + +void OPimNotifyManager::replace( const OPimNotify& noti ) +{ + if ( noti.type() == QString::fromLatin1( "OPimReminder" ) ) + { + const OPimReminder & rem = static_cast( noti ); m_rem.remove( rem ); m_rem.append( rem ); - }else if ( noti.type() == QString::fromLatin1("OPimAlarm") ) { - const OPimAlarm& al = static_cast(noti); + } + else if ( noti.type() == QString::fromLatin1( "OPimAlarm" ) ) + { + const OPimAlarm & al = static_cast( noti ); m_al.remove( al ); m_al.append( al ); } } -OPimNotifyManager::Reminders OPimNotifyManager::reminders()const { + + +OPimNotifyManager::Reminders OPimNotifyManager::reminders() const +{ return m_rem; } -OPimNotifyManager::Alarms OPimNotifyManager::alarms()const { + + +OPimNotifyManager::Alarms OPimNotifyManager::alarms() const +{ return m_al; } -OPimAlarm OPimNotifyManager::alarmAtDateTime( const QDateTime& when, bool& found ) const { - Alarms::ConstIterator it; - found = true; - for ( it = m_al.begin(); it != m_al.end(); ++it ){ - if ( (*it).dateTime() == when ) - return (*it); - } - // Fall through if nothing could be found - found = false; - OPimAlarm empty; - return empty; +OPimAlarm OPimNotifyManager::alarmAtDateTime( const QDateTime& when, bool& found ) const +{ + Alarms::ConstIterator it; + found = true; + + for ( it = m_al.begin(); it != m_al.end(); ++it ) + { + if ( ( *it ).dateTime() == when ) + return ( *it ); + } + + // Fall through if nothing could be found + found = false; + OPimAlarm empty; + return empty; } -void OPimNotifyManager::setAlarms( const Alarms& al) { +void OPimNotifyManager::setAlarms( const Alarms& al ) +{ m_al = al; } -void OPimNotifyManager::setReminders( const Reminders& rem) { + + +void OPimNotifyManager::setReminders( const Reminders& rem ) +{ m_rem = rem; } + + /* FIXME!!! */ /** * The idea is to check if the provider for our service @@ -105,89 +145,105 @@ void OPimNotifyManager::setReminders( const Reminders& rem) { * if not the Factory to get the backend... * Qtopia1.6 services would be kewl to have here.... */ -void OPimNotifyManager::registerNotify( const OPimNotify& ) { - +void OPimNotifyManager::registerNotify( const OPimNotify& ) +{ } + + /* FIXME!!! */ /** * same as above... * Also implement Url model * have a MainWindow.... */ -void OPimNotifyManager::deregister( const OPimNotify& ) { - +void OPimNotifyManager::deregister( const OPimNotify& ) +{ } -bool OPimNotifyManager::isEmpty()const { - qWarning("is Empty called on OPimNotifyManager %d %d", m_rem.count(), m_al.count() ); + +bool OPimNotifyManager::isEmpty() const +{ + qWarning( "is Empty called on OPimNotifyManager %d %d", m_rem.count(), m_al.count() ); if ( m_rem.isEmpty() && m_al.isEmpty() ) return true; else return false; } -// Taken from otodoaccessxml.. + +// Taken from otodoaccessxml.. code duplication bad. any alternative? QString OPimNotifyManager::alarmsToString() const { - QString str; - - OPimNotifyManager::Alarms alarms = m_al; - if ( !alarms.isEmpty() ) { - QStringList als; - OPimNotifyManager::Alarms::Iterator it = alarms.begin(); - for ( ; it != alarms.end(); ++it ) { - /* only if time is valid */ - if ( (*it).dateTime().isValid() ) { - als << OConversion::dateTimeToString( (*it).dateTime() ) - + ":" + QString::number( (*it).duration() ) - + ":" + QString::number( (*it).sound() ) - + ":"; - } - } - // now write the list - qWarning("als: %s", als.join("____________").latin1() ); - str = als.join(";"); - } - - return str; + QString str; + + OPimNotifyManager::Alarms alarms = m_al; + if ( !alarms.isEmpty() ) + { + QStringList als; + OPimNotifyManager::Alarms::Iterator it = alarms.begin(); + for ( ; it != alarms.end(); ++it ) + { + /* only if time is valid */ + if ( ( *it ).dateTime().isValid() ) + { + als << OConversion::dateTimeToString( ( *it ).dateTime() ) + + ":" + QString::number( ( *it ).duration() ) + + ":" + QString::number( ( *it ).sound() ) + + ":"; + } + } + // now write the list + qWarning( "als: %s", als.join( "____________" ).latin1() ); + str = als.join( ";" ); + } + + return str; } + + QString OPimNotifyManager::remindersToString() const { - QString str; - - OPimNotifyManager::Reminders reminders = m_rem; - if (!reminders.isEmpty() ) { - OPimNotifyManager::Reminders::Iterator it = reminders.begin(); - QStringList records; - for ( ; it != reminders.end(); ++it ) { - records << QString::number( (*it).recordUid() ); - } - str = records.join(";"); - } + QString str; + + OPimNotifyManager::Reminders reminders = m_rem; + if ( !reminders.isEmpty() ) + { + OPimNotifyManager::Reminders::Iterator it = reminders.begin(); + QStringList records; + for ( ; it != reminders.end(); ++it ) + { + records << QString::number( ( *it ).recordUid() ); + } + str = records.join( ";" ); + } - return str; + return str; } + void OPimNotifyManager::alarmsFromString( const QString& str ) { - QStringList als = QStringList::split(";", str ); - for (QStringList::Iterator it = als.begin(); it != als.end(); ++it ) { - QStringList alarm = QStringList::split(":", (*it), TRUE ); // allow empty - qWarning("alarm: %s", alarm.join("___").latin1() ); - qWarning("alarm[0]: %s %s", alarm[0].latin1(), - OConversion::dateTimeFromString( alarm[0] ).toString().latin1() ); - OPimAlarm al( alarm[2].toInt(), OConversion::dateTimeFromString( alarm[0] ), - alarm[1].toInt() ); - add( al ); - } + QStringList als = QStringList::split( ";", str ); + for ( QStringList::Iterator it = als.begin(); it != als.end(); ++it ) + { + QStringList alarm = QStringList::split( ":", ( *it ), TRUE ); // allow empty + qWarning( "alarm: %s", alarm.join( "___" ).latin1() ); + qWarning( "alarm[0]: %s %s", alarm[ 0 ].latin1(), + OConversion::dateTimeFromString( alarm[ 0 ] ).toString().latin1() ); + OPimAlarm al( alarm[ 2 ].toInt(), OConversion::dateTimeFromString( alarm[ 0 ] ), + alarm[ 1 ].toInt() ); + add( al ); + } } + void OPimNotifyManager::remindersFromString( const QString& str ) { - QStringList rems = QStringList::split(";", str ); - for (QStringList::Iterator it = rems.begin(); it != rems.end(); ++it ) { - OPimReminder rem( (*it).toInt() ); - add( rem ); - } - + QStringList rems = QStringList::split( ";", str ); + for ( QStringList::Iterator it = rems.begin(); it != rems.end(); ++it ) + { + OPimReminder rem( ( *it ).toInt() ); + add( rem ); + } + } } diff --git a/libopie2/opiepim/core/opimnotifymanager.h b/libopie2/opiepim/core/opimnotifymanager.h index 0272e5d..9241ea2 100644 --- a/libopie2/opiepim/core/opimnotifymanager.h +++ b/libopie2/opiepim/core/opimnotifymanager.h @@ -26,21 +26,25 @@ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#ifndef OPIE_PIM_NOTIFY_MANAGER_H -#define OPIE_PIM_NOTIFY_MANAGER_H - -#include +#ifndef OPIMNOTIFYMANAGER_H +#define OPIMNOTIFYMANAGER_H +/* OPIE */ #include -namespace Opie { +/* QT */ +#include + +namespace Opie +{ /** * The notify manager keeps track of the Notifiers.... */ -class OPimNotifyManager { -public: +class OPimNotifyManager +{ + public: typedef QValueList Reminders; - typedef QValueList Alarms; + typedef QValueList Alarms; OPimNotifyManager( const Reminders& rems = Reminders(), const Alarms& alarms = Alarms() ); ~OPimNotifyManager(); @@ -50,12 +54,12 @@ public: /* replaces all with this one! */ void replace( const OPimNotify& ); - Reminders reminders()const; + Reminders reminders() const; /** - * Return + * Return */ - Alarms alarms()const; + Alarms alarms() const; /** * Return alarm at DateTime "when". If more than one is registered at this @@ -63,7 +67,7 @@ public: * If none was found, an empty Alarm is returned. * @param when The date and time of the returned alarm * @param found Returns true if anything was found. - * @return Returns the found alarm at given DateTime. It is empty if found is false + * @return Returns the found alarm at given DateTime. It is empty if found is false * (nothing could be found at given date and time) */ OPimAlarm alarmAtDateTime( const QDateTime& when, bool& found ) const; @@ -83,19 +87,19 @@ public: */ void deregister( const OPimNotify& ); - bool isEmpty()const; + bool isEmpty() const; - /** + /** * Return all alarms as string */ QString alarmsToString() const; - /** + /** * Return all notifiers as string */ QString remindersToString() const; /** - * Convert string to alarms + * Convert string to alarms * @param str String created by alarmsToString() */ void alarmsFromString( const QString& str ); @@ -106,9 +110,7 @@ public: */ void remindersFromString( const QString& str ); - - -private: + private: Reminders m_rem; Alarms m_al; diff --git a/libopie2/opiepim/core/opimrecord.cpp b/libopie2/opiepim/core/opimrecord.cpp index 72bb372..c603f44 100644 --- a/libopie2/opiepim/core/opimrecord.cpp +++ b/libopie2/opiepim/core/opimrecord.cpp @@ -26,67 +26,92 @@ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include +#include "opimrecord.h" + +/* OPIE */ #include #include -#include +/* QT */ +#include -namespace Opie { +namespace Opie +{ Qtopia::UidGen OPimRecord::m_uidGen( Qtopia::UidGen::Qtopia ); OPimRecord::OPimRecord( int uid ) - : Qtopia::Record() { + : Qtopia::Record() +{ m_lastHit = -1; setUid( uid ); } -OPimRecord::~OPimRecord() { -} + + +OPimRecord::~OPimRecord() +{} + + OPimRecord::OPimRecord( const OPimRecord& rec ) - : Qtopia::Record( rec ) + : Qtopia::Record( rec ) { - (*this) = rec; + ( *this ) = rec; } -OPimRecord &OPimRecord::operator=( const OPimRecord& rec) { - if ( this == &rec ) return *this; + +OPimRecord &OPimRecord::operator=( const OPimRecord& rec ) +{ + if ( this == &rec ) return * this; Qtopia::Record::operator=( rec ); m_xrefman = rec.m_xrefman; m_lastHit = rec.m_lastHit; - return *this; + return *this; } + + /* * category names */ -QStringList OPimRecord::categoryNames( const QString& appname ) const { +QStringList OPimRecord::categoryNames( const QString& appname ) const +{ QStringList list; QArray cats = categories(); Categories catDB; catDB.load( categoryFileName() ); - for (uint i = 0; i < cats.count(); i++ ) { - list << catDB.label( appname, cats[i] ); + for ( uint i = 0; i < cats.count(); i++ ) + { + list << catDB.label( appname, cats[ i ] ); } return list; } -void OPimRecord::setCategoryNames( const QStringList& ) { + +void OPimRecord::setCategoryNames( const QStringList& ) +{ } -void OPimRecord::addCategoryName( const QString& ) { + + +void OPimRecord::addCategoryName( const QString& ) +{ Categories catDB; catDB.load( categoryFileName() ); } -bool OPimRecord::isEmpty()const { + + +bool OPimRecord::isEmpty() const +{ return ( uid() == 0 ); } + + /*QString OPimRecord::crossToString()const { QString str; QMap >::ConstIterator it; @@ -102,19 +127,29 @@ bool OPimRecord::isEmpty()const { return str; }*/ /* if uid = 1 assign a new one */ -void OPimRecord::setUid( int uid ) { - if ( uid == 1) +void OPimRecord::setUid( int uid ) +{ + if ( uid == 1 ) uid = uidGen().generate(); Qtopia::Record::setUid( uid ); }; -Qtopia::UidGen &OPimRecord::uidGen() { + + +Qtopia::UidGen &OPimRecord::uidGen() +{ return m_uidGen; } -OPimXRefManager &OPimRecord::xrefmanager() { + + +OPimXRefManager &OPimRecord::xrefmanager() +{ return m_xrefman; } -int OPimRecord::rtti(){ + + +int OPimRecord::rtti() +{ return 0; } @@ -126,17 +161,19 @@ int OPimRecord::rtti(){ * Categories * XRef */ -bool OPimRecord::loadFromStream( QDataStream& stream ) { +bool OPimRecord::loadFromStream( QDataStream& stream ) +{ int Int; uint UInt; stream >> Int; - setUid(Int); + setUid( Int ); /** Categories */ stream >> UInt; - QArray array(UInt); - for (uint i = 0; i < UInt; i++ ) { - stream >> array[i]; + QArray array( UInt ); + for ( uint i = 0; i < UInt; i++ ) + { + stream >> array[ i ]; } setCategories( array ); @@ -145,7 +182,8 @@ bool OPimRecord::loadFromStream( QDataStream& stream ) { */ OPimXRef xref; stream >> UInt; - for ( uint i = 0; i < UInt; i++ ) { + for ( uint i = 0; i < UInt; i++ ) + { xref.setPartner( OPimXRef::One, partner( stream ) ); xref.setPartner( OPimXRef::Two, partner( stream ) ); m_xrefman.add( xref ); @@ -153,15 +191,19 @@ bool OPimRecord::loadFromStream( QDataStream& stream ) { return true; } -bool OPimRecord::saveToStream( QDataStream& stream )const { + + +bool OPimRecord::saveToStream( QDataStream& stream ) const +{ /** UIDs */ stream << uid(); /** Categories */ stream << categories().count(); - for ( uint i = 0; i < categories().count(); i++ ) { - stream << categories()[i]; + for ( uint i = 0; i < categories().count(); i++ ) + { + stream << categories() [ i ]; } /* @@ -170,18 +212,25 @@ bool OPimRecord::saveToStream( QDataStream& stream )const { */ stream << m_xrefman.list().count(); for ( OPimXRef::ValueList::ConstIterator it = m_xrefman.list().begin(); - it != m_xrefman.list().end(); ++it ) { - flush( (*it).partner( OPimXRef::One), stream ); - flush( (*it).partner( OPimXRef::Two), stream ); + it != m_xrefman.list().end(); ++it ) + { + flush( ( *it ).partner( OPimXRef::One ), stream ); + flush( ( *it ).partner( OPimXRef::Two ), stream ); } return true; } -void OPimRecord::flush( const OPimXRefPartner& par, QDataStream& str ) const{ + + +void OPimRecord::flush( const OPimXRefPartner& par, QDataStream& str ) const +{ str << par.service(); str << par.uid(); str << par.field(); } -OPimXRefPartner OPimRecord::partner( QDataStream& stream ) { + + +OPimXRefPartner OPimRecord::partner( QDataStream& stream ) +{ OPimXRefPartner par; QString str; int i; @@ -197,16 +246,28 @@ OPimXRefPartner OPimRecord::partner( QDataStream& stream ) { return par; } -void OPimRecord::setLastHitField( int lastHit )const { + + +void OPimRecord::setLastHitField( int lastHit ) const +{ m_lastHit = lastHit; } -int OPimRecord::lastHitField()const{ + + +int OPimRecord::lastHitField() const +{ return m_lastHit; } -QMap OPimRecord::toExtraMap()const { + + +QMap OPimRecord::toExtraMap() const +{ return customMap; } -void OPimRecord::setExtraMap( const QMap& map) { + + +void OPimRecord::setExtraMap( const QMap& map ) +{ customMap = map; } diff --git a/libopie2/opiepim/core/opimrecord.h b/libopie2/opiepim/core/opimrecord.h index 63a3a98..4981a41 100644 --- a/libopie2/opiepim/core/opimrecord.h +++ b/libopie2/opiepim/core/opimrecord.h @@ -26,14 +26,12 @@ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#ifndef OPIE_PIM_RECORD_H -#define OPIE_PIM_RECORD_H -#include -#include -#include -#include +#ifndef OPIMRECORD_H +#define OPIMRECORD_H +/* OPIE */ +#include /* * we need to get customMap which is private... */ @@ -41,22 +39,28 @@ #include #undef private -#include +/* QT */ +#include +#include +#include +#include -namespace Opie { +namespace Opie +{ /** * This is the base class for * all PIM Records * */ -class OPimRecord : public Qtopia::Record { -public: +class OPimRecord : public Qtopia::Record +{ + public: /** * c'tor * uid of 0 isEmpty * uid of 1 will be assigned a new one */ - OPimRecord(int uid = 0); + OPimRecord( int uid = 0 ); ~OPimRecord(); /** @@ -72,7 +76,7 @@ public: /** * category names resolved */ - QStringList categoryNames( const QString& appname )const; + QStringList categoryNames( const QString& appname ) const; /** * set category names they will be resolved @@ -89,53 +93,55 @@ public: * if a Record isEmpty * it's empty if it's 0 */ - virtual bool isEmpty()const; + virtual bool isEmpty() const; /** * toRichText summary */ - virtual QString toRichText()const = 0; + virtual QString toRichText() const = 0; /** * a small one line summary */ - virtual QString toShortText()const = 0; + virtual QString toShortText() const = 0; /** * the name of the Record */ - virtual QString type()const = 0; + virtual QString type() const = 0; /** * matches the Records the regular expression? */ virtual bool match( const QString ®exp ) const - {setLastHitField( -1 ); - return Qtopia::Record::match(QRegExp(regexp));}; + { + setLastHitField( -1 ); + return Qtopia::Record::match( QRegExp( regexp ) ); + }; /** * if implemented this function returns which item has been * last hit by the match() function. * or -1 if not implemented or no hit has occured */ - int lastHitField()const; + int lastHitField() const; /** * converts the internal structure to a map */ - virtual QMap toMap()const = 0; + virtual QMap toMap() const = 0; // virtual fromMap( const & map ) = 0; // Should be added in the future (eilers) /** * key value representation of extra items */ - QMap toExtraMap()const; + QMap toExtraMap() const; void setExtraMap( const QMap& ); /** * the name for a recordField */ - virtual QString recordField(int)const = 0; + virtual QString recordField( int ) const = 0; /** * returns a reference of the @@ -161,24 +167,24 @@ public: * saves the OPimRecord * to and from a DataStream */ - virtual bool loadFromStream(QDataStream& ); - virtual bool saveToStream( QDataStream& stream )const; + virtual bool loadFromStream( QDataStream& ); + virtual bool saveToStream( QDataStream& stream ) const; -protected: + protected: // need to be const cause it is called from const methods mutable int m_lastHit; - void setLastHitField( int lastHit )const; + void setLastHitField( int lastHit ) const; Qtopia::UidGen &uidGen(); -// QString crossToString()const; + // QString crossToString()const; -private: + private: class OPimRecordPrivate; OPimRecordPrivate *d; OPimXRefManager m_xrefman; static Qtopia::UidGen m_uidGen; -private: - void flush( const OPimXRefPartner&, QDataStream& stream )const; + private: + void flush( const OPimXRefPartner&, QDataStream& stream ) const; OPimXRefPartner partner( QDataStream& ); }; -- cgit v0.9.0.2