-rw-r--r-- | libopie2/opiepim/core/opimnotify.cpp | 219 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimnotify.h | 21 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimnotifymanager.cpp | 120 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimnotifymanager.h | 18 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimrecord.cpp | 117 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimrecord.h | 28 |
6 files changed, 387 insertions, 136 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 @@ -23,236 +23,357 @@ -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 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; int dur; QString application; 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 ) { 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; if ( data->application != noti.data->application ) return false; if ( data->start != noti.data->start ) return false; 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 { + + +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->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 ) { data = new Data; data->sound = sound; } + + 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) { OPimNotify::operator=( al ); deref(); al.data->ref(); data = al.data; 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 { + + +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; 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 ) { data = new Data; data->record = uid; } + + OPimReminder::OPimReminder( const OPimReminder& rem ) : OPimNotify( rem ), data( rem.data ) { data->ref(); } -OPimReminder& OPimReminder::operator=( const OPimReminder& rem) { + + +OPimReminder& OPimReminder::operator=( const OPimReminder& rem ) +{ OPimNotify::operator=(rem ); deref(); rem.data->ref(); data = rem.data; 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 { + + +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 ) { + + +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 @@ -23,20 +23,22 @@ -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, 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 <qdatetime.h> #include <qvaluelist.h> - -namespace Opie { +namespace Opie +{ /** * This is the base class of Notifiers. Possible * notifiers would be Alarms, Reminders * What they share is that they have * A DateTime, Type, Duration * This is what this base class takes care of @@ -44,13 +46,15 @@ namespace Opie { */ /* * TALK to eilers: have a class OPimDuration which sets the Duration * given on the Due/Start Date? -zecke * discuss: do we need a uid for the notify? -zecke */ -class OPimNotify { +class OPimNotify +{ + public: typedef QValueList<OPimNotify> ValueList; OPimNotify( const QDateTime& start = QDateTime(), int duration = 0, int parent = 0 ); OPimNotify( const OPimNotify& ); virtual ~OPimNotify(); @@ -97,13 +101,14 @@ private: }; /** * An alarm is a sound/mail/buzzer played/send * at a given time to inform about * an Event */ -class OPimAlarm : public OPimNotify { +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(); @@ -132,15 +137,15 @@ private: /** * A Reminder will be put into the * datebook * 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 { +class OPimReminder : public OPimNotify +{ public: - /** * c'tor of a reminder * @param uid The uid of the Record inside the Datebook * @param start the StartDate invalid for all day... * @param duration The duration of the event ( -1 for all day ) * @param parent The 'parent' record of this reminder 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 @@ -23,122 +23,170 @@ -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include <opie2/opimnotifymanager.h> +#include "opimnotifymanager.h" + +/* OPIE */ #include <opie2/oconversion.h> +/* QT */ #include <qstringlist.h> -namespace Opie { +namespace Opie +{ 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") ) { +void OPimNotifyManager::add( const OPimNotify& noti ) +{ + if ( noti.type() == QString::fromLatin1( "OPimReminder" ) ) + { const OPimReminder& rem = static_cast<const OPimReminder&>(noti); m_rem.append( rem ); - }else if ( noti.type() == QString::fromLatin1("OPimAlarm") ) { + } + else if ( noti.type() == QString::fromLatin1( "OPimAlarm" ) ) + { const OPimAlarm& al = static_cast<const OPimAlarm&>(noti); m_al.append( al ); } } -void OPimNotifyManager::remove( const OPimNotify& noti) { - if ( noti.type() == QString::fromLatin1("OPimReminder") ) { + + +void OPimNotifyManager::remove( const OPimNotify& noti ) +{ + if ( noti.type() == QString::fromLatin1( "OPimReminder" ) ) + { const OPimReminder& rem = static_cast<const OPimReminder&>(noti); m_rem.remove( rem ); - }else if ( noti.type() == QString::fromLatin1("OPimAlarm") ) { + } + else if ( noti.type() == QString::fromLatin1( "OPimAlarm" ) ) + { const OPimAlarm& al = static_cast<const OPimAlarm&>(noti); m_al.remove( al ); } } -void OPimNotifyManager::replace( const OPimNotify& noti) { - if ( noti.type() == QString::fromLatin1("OPimReminder") ) { + + +void OPimNotifyManager::replace( const OPimNotify& noti ) +{ + if ( noti.type() == QString::fromLatin1( "OPimReminder" ) ) + { const OPimReminder& rem = static_cast<const OPimReminder&>(noti); m_rem.remove( rem ); m_rem.append( rem ); - }else if ( noti.type() == QString::fromLatin1("OPimAlarm") ) { + } + else if ( noti.type() == QString::fromLatin1( "OPimAlarm" ) ) + { const OPimAlarm& al = static_cast<const OPimAlarm&>(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 { + + +OPimAlarm OPimNotifyManager::alarmAtDateTime( const QDateTime& when, bool& found ) const +{ Alarms::ConstIterator it; found = true; - for ( it = m_al.begin(); it != m_al.end(); ++it ){ + 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 * is online * if it is we will use QCOP * 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 { + +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() ) { + if ( !alarms.isEmpty() ) + { QStringList als; OPimNotifyManager::Alarms::Iterator it = alarms.begin(); - for ( ; it != alarms.end(); ++it ) { + for ( ; it != alarms.end(); ++it ) + { /* only if time is valid */ - if ( (*it).dateTime().isValid() ) { + if ( ( *it ).dateTime().isValid() ) + { als << OConversion::dateTimeToString( (*it).dateTime() ) + ":" + QString::number( (*it).duration() ) + ":" + QString::number( (*it).sound() ) + ":"; } } @@ -146,48 +194,56 @@ QString OPimNotifyManager::alarmsToString() const 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() ) { + if ( !reminders.isEmpty() ) + { OPimNotifyManager::Reminders::Iterator it = reminders.begin(); QStringList records; - for ( ; it != reminders.end(); ++it ) { + for ( ; it != reminders.end(); ++it ) + { records << QString::number( (*it).recordUid() ); } str = records.join(";"); } return str; } + void OPimNotifyManager::alarmsFromString( const QString& str ) { QStringList als = QStringList::split(";", str ); - for (QStringList::Iterator it = als.begin(); it != als.end(); ++it ) { + 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 ) { + 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 @@ -23,24 +23,28 @@ -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#ifndef OPIE_PIM_NOTIFY_MANAGER_H -#define OPIE_PIM_NOTIFY_MANAGER_H - -#include <qvaluelist.h> +#ifndef OPIMNOTIFYMANAGER_H +#define OPIMNOTIFYMANAGER_H +/* OPIE */ #include <opie2/opimnotify.h> -namespace Opie { +/* QT */ +#include <qvaluelist.h> + +namespace Opie +{ /** * The notify manager keeps track of the Notifiers.... */ -class OPimNotifyManager { +class OPimNotifyManager +{ public: typedef QValueList<OPimReminder> Reminders; typedef QValueList<OPimAlarm> Alarms; OPimNotifyManager( const Reminders& rems = Reminders(), const Alarms& alarms = Alarms() ); ~OPimNotifyManager(); @@ -103,14 +107,12 @@ public: /** * Convert string to reminders * @param str String created by remindersToString() */ void remindersFromString( const QString& str ); - - private: Reminders m_rem; Alarms m_al; class Private; Private *d; 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 @@ -23,73 +23,98 @@ -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include <qarray.h> +#include "opimrecord.h" + +/* OPIE */ #include <qpe/categories.h> #include <qpe/categoryselect.h> -#include <opie2/opimrecord.h> +/* QT */ +#include <qarray.h> -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 ) { (*this) = rec; } -OPimRecord &OPimRecord::operator=( const OPimRecord& rec) { + +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; } + + /* * category names */ -QStringList OPimRecord::categoryNames( const QString& appname ) const { +QStringList OPimRecord::categoryNames( const QString& appname ) const +{ QStringList list; QArray<int> cats = categories(); Categories catDB; catDB.load( categoryFileName() ); - for (uint i = 0; i < cats.count(); 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<QString, QArray<int> >::ConstIterator it; for (it = m_relations.begin(); it != m_relations.end(); ++it ) { QArray<int> id = it.data(); for ( uint i = 0; i < id.size(); ++i ) { @@ -99,92 +124,116 @@ bool OPimRecord::isEmpty()const { str = str.remove( str.length()-1, 1); // strip the ; //qWarning("IDS " + str ); return str; }*/ /* if uid = 1 assign a new one */ -void OPimRecord::setUid( int uid ) { +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; } /** * now let's put our data into the stream */ /* * First read UID * Categories * XRef */ -bool OPimRecord::loadFromStream( QDataStream& stream ) { +bool OPimRecord::loadFromStream( QDataStream& stream ) +{ int Int; uint UInt; stream >> Int; setUid(Int); /** Categories */ stream >> UInt; QArray<int> array(UInt); - for (uint i = 0; i < UInt; i++ ) { + for ( uint i = 0; i < UInt; i++ ) + { stream >> array[i]; } setCategories( array ); /* * now we do the X-Ref stuff */ 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 ); } 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++ ) { + for ( uint i = 0; i < categories().count(); i++ ) + { stream << categories()[i]; } /* * first the XRef count * then the xrefs */ stream << m_xrefman.list().count(); for ( OPimXRef::ValueList::ConstIterator it = m_xrefman.list().begin(); - it != m_xrefman.list().end(); ++it ) { + 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; stream >> str; par.setService( str ); @@ -194,20 +243,32 @@ OPimXRefPartner OPimRecord::partner( QDataStream& stream ) { stream >> i ; par.setField( i ); 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<QString, QString> OPimRecord::toExtraMap()const { + + +QMap<QString, QString> OPimRecord::toExtraMap() const +{ return customMap; } -void OPimRecord::setExtraMap( const QMap<QString, QString>& map) { + + +void OPimRecord::setExtraMap( const QMap<QString, QString>& 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 @@ -23,36 +23,40 @@ -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#ifndef OPIE_PIM_RECORD_H -#define OPIE_PIM_RECORD_H -#include <qdatastream.h> -#include <qmap.h> -#include <qstring.h> -#include <qstringlist.h> +#ifndef OPIMRECORD_H +#define OPIMRECORD_H +/* OPIE */ +#include <opie2/opimxrefmanager.h> /* * we need to get customMap which is private... */ #define private protected #include <qpe/palmtoprecord.h> #undef private -#include <opie2/opimxrefmanager.h> +/* QT */ +#include <qdatastream.h> +#include <qmap.h> +#include <qstring.h> +#include <qstringlist.h> -namespace Opie { +namespace Opie +{ /** * This is the base class for * all PIM Records * */ -class OPimRecord : public Qtopia::Record { +class OPimRecord : public Qtopia::Record +{ public: /** * c'tor * uid of 0 isEmpty * uid of 1 will be assigned a new one */ @@ -107,14 +111,16 @@ public: 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 */ |