summaryrefslogtreecommitdiff
path: root/libopie2
authormickeyl <mickeyl>2004-02-23 13:15:42 (UTC)
committer mickeyl <mickeyl>2004-02-23 13:15:42 (UTC)
commitf9f0c26d9ac94586ffc36efa1b582ece3dbc43cf (patch) (side-by-side diff)
tree4044006e676c78370fdeccf960ea4214f13eabd2 /libopie2
parent2d37d653310da0a9d6e2e2e6c9f5bf092e54cbbb (diff)
downloadopie-f9f0c26d9ac94586ffc36efa1b582ece3dbc43cf.zip
opie-f9f0c26d9ac94586ffc36efa1b582ece3dbc43cf.tar.gz
opie-f9f0c26d9ac94586ffc36efa1b582ece3dbc43cf.tar.bz2
cosmetics
Diffstat (limited to 'libopie2') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/core/opimnotify.cpp251
-rw-r--r--libopie2/opiepim/core/opimnotify.h67
-rw-r--r--libopie2/opiepim/core/opimnotifymanager.cpp240
-rw-r--r--libopie2/opiepim/core/opimnotifymanager.h40
-rw-r--r--libopie2/opiepim/core/opimrecord.cpp141
-rw-r--r--libopie2/opiepim/core/opimrecord.h66
-rw-r--r--libopie2/opiepim/ocontact.cpp749
-rw-r--r--libopie2/opiepim/ocontact.h43
-rw-r--r--libopie2/opiepim/ocontactfields.cpp496
-rw-r--r--libopie2/opiepim/ocontactfields.h32
-rw-r--r--libopie2/opiepim/oevent.cpp870
-rw-r--r--libopie2/opiepim/oevent.h165
-rw-r--r--libopie2/opiepim/orecordlist.h230
-rw-r--r--libopie2/opiepim/otodo.cpp602
-rw-r--r--libopie2/opiepim/otodo.h147
15 files changed, 2491 insertions, 1648 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
@@ -26,15 +26,19 @@
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;
@@ -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 <qdatetime.h>
#include <qvaluelist.h>
-
-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<OPimNotify> 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 <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( 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<const OPimReminder&>(noti);
+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") ) {
- const OPimAlarm& al = static_cast<const OPimAlarm&>(noti);
+ }
+ 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") ) {
- const OPimReminder& rem = static_cast<const OPimReminder&>(noti);
+
+
+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") ) {
- const OPimAlarm& al = static_cast<const OPimAlarm&>(noti);
+ }
+ 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") ) {
- const OPimReminder& rem = static_cast<const OPimReminder&>(noti);
+
+
+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") ) {
- const OPimAlarm& al = static_cast<const OPimAlarm&>(noti);
+ }
+ 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 {
- 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 <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 {
-public:
+class OPimNotifyManager
+{
+ public:
typedef QValueList<OPimReminder> Reminders;
- typedef QValueList<OPimAlarm> Alarms;
+ typedef QValueList<OPimAlarm> 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 <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 )
+ : 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<int> 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<QString, QArray<int> >::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<int> array(UInt);
- for (uint i = 0; i < UInt; i++ ) {
- stream >> array[i];
+ QArray<int> 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<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
@@ -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 <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...
*/
@@ -41,22 +39,28 @@
#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 {
-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 &regexp ) 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<int, QString> toMap()const = 0;
+ virtual QMap<int, QString> toMap() const = 0;
// virtual fromMap( const <int, QString>& map ) = 0; // Should be added in the future (eilers)
/**
* key value representation of extra items
*/
- QMap<QString, QString> toExtraMap()const;
+ QMap<QString, QString> toExtraMap() const;
void setExtraMap( const QMap<QString, QString>& );
/**
* 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& );
};
diff --git a/libopie2/opiepim/ocontact.cpp b/libopie2/opiepim/ocontact.cpp
index f1a22a7..fa5313f 100644
--- a/libopie2/opiepim/ocontact.cpp
+++ b/libopie2/opiepim/ocontact.cpp
@@ -1,6 +1,6 @@
/*
This file is part of the Opie Project
- Copyright (C) The Main Author <main-author@whereever.org>
+ Copyright (C) Stefan Eilers <eilers.stefan@epost.de>
=. Copyright (C) The Opie Team <opie-devel@handhelds.org>
.=l.
.>+-=
@@ -27,41 +27,25 @@
Boston, MA 02111-1307, USA.
*/
-/**********************************************************************
-** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
-** Copyright (C) 2002-2003 by Stefan Eilers (eilers.stefan@epost.de)
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.trolltech.com/gpl/ for GPL licensing information.
-**
-** Contact info@trolltech.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
#define QTOPIA_INTERNAL_CONTACT_MRE
-#include <opie2/ocontact.h>
+#include "ocontact.h"
+
+/* OPIE */
#include <opie2/opimresolver.h>
#include <opie2/oconversion.h>
-
#include <qpe/stringutil.h>
#include <qpe/timestring.h>
#include <qpe/config.h>
+/* QT */
#include <qobject.h>
#include <qregexp.h>
#include <qstylesheet.h>
#include <qfileinfo.h>
#include <qmap.h>
+/* STD */
#include <stdio.h>
/*!
@@ -76,45 +60,44 @@
*/
-namespace Opie {
+namespace Opie
+{
/*!
Creates a new, empty contact.
*/
-OContact::OContact()
- : OPimRecord(), mMap(), d( 0 )
-{
-}
+OContact::OContact():OPimRecord(), mMap(), d( 0 )
+{}
/*!
\internal
Creates a new contact. The properties of the contact are
set from \a fromMap.
*/
-OContact::OContact( const QMap<int, QString> &fromMap ) :
- OPimRecord(), mMap( fromMap ), d( 0 )
+OContact::OContact( const QMap<int, QString> &fromMap ):OPimRecord(), mMap( fromMap ), d( 0 )
{
QString cats = mMap[ Qtopia::AddressCategory ];
if ( !cats.isEmpty() )
- setCategories( idsFromString( cats ) );
+ setCategories( idsFromString( cats ) );
QString uidStr = find( Qtopia::AddressUid );
- if ( uidStr.isEmpty() || (uidStr.toInt() == 0) ){
- qWarning( "Invalid UID found. Generate new one.." );
- setUid( uidGen().generate() );
- }else
- setUid( uidStr.toInt() );
+ if ( uidStr.isEmpty() || ( uidStr.toInt() == 0 ) )
+ {
+ qWarning( "Invalid UID found. Generate new one.." );
+ setUid( uidGen().generate() );
+ }
+ else
+ setUid( uidStr.toInt() );
-// if ( !uidStr.isEmpty() )
-// setUid( uidStr.toInt() );
+ // if ( !uidStr.isEmpty() )
+ // setUid( uidStr.toInt() );
}
/*!
Destroys a contact.
*/
OContact::~OContact()
-{
-}
+{}
/*! \fn void OContact::setTitle( const QString &str )
Sets the title of the contact to \a str.
@@ -455,7 +438,7 @@ QMap<int, QString> OContact::toMap() const
QMap<int, QString> map = mMap;
QString cats = idsToString( categories() );
if ( !cats.isEmpty() )
- map.insert( Qtopia::AddressCategory, cats );
+ map.insert( Qtopia::AddressCategory, cats );
return map;
}
@@ -469,281 +452,327 @@ QString OContact::toRichText() const
QString str;
bool marker = false;
- Config cfg("qpe");
- cfg.setGroup("Appearance");
+ Config cfg( "qpe" );
+ cfg.setGroup( "Appearance" );
int addressformat = cfg.readNumEntry( "AddressFormat", Zip_City_State );
// name, jobtitle and company
- if ( !(value = fullName()).isEmpty() )
- text += "<b><h3><img src=\"addressbook/AddressBook\"> " + Qtopia::escapeString(value) + "</h3></b>";
-
- if ( !(value = jobTitle()).isEmpty() )
- text += Qtopia::escapeString(value) + " ";
+ if ( !( value = fullName() ).isEmpty() )
+ text += "<b><h3><img src=\"addressbook/AddressBook\"> " + Qtopia::escapeString( value ) + "</h3></b>";
+
+ if ( !( value = jobTitle() ).isEmpty() )
+ text += Qtopia::escapeString( value ) + " ";
comp = company();
- if ( !(value = department()).isEmpty() ) {
- text += Qtopia::escapeString(value);
- if ( comp )
- text += ", " + Qtopia::escapeString(comp);
- }else if ( comp )
- text += "<br>" + Qtopia::escapeString(comp);
+ if ( !( value = department() ).isEmpty() )
+ {
+ text += Qtopia::escapeString( value );
+ if ( comp )
+ text += ", " + Qtopia::escapeString( comp );
+ }
+ else if ( comp )
+ text += "<br>" + Qtopia::escapeString( comp );
text += "<br><hr>";
// defailt email
QString defEmail = defaultEmail();
- if ( !defEmail.isEmpty() ){
- text += "<b><img src=\"addressbook/email\"> " + QObject::tr("Default Email: ") + "</b>"
- + Qtopia::escapeString(defEmail);
- marker = true;
+ if ( !defEmail.isEmpty() )
+ {
+ text += "<b><img src=\"addressbook/email\"> " + QObject::tr( "Default Email: " ) + "</b>"
+ + Qtopia::escapeString( defEmail );
+ marker = true;
}
// business address
if ( !businessStreet().isEmpty() || !businessCity().isEmpty() ||
- !businessZip().isEmpty() || !businessCountry().isEmpty() ) {
- text += QObject::tr( "<br><b>Work Address:</b>" );
- marker = true;
+ !businessZip().isEmpty() || !businessCountry().isEmpty() )
+ {
+ text += QObject::tr( "<br><b>Work Address:</b>" );
+ marker = true;
}
- if ( !(value = businessStreet()).isEmpty() ){
- text += "<br>" + Qtopia::escapeString(value);
- marker = true;
+ if ( !( value = businessStreet() ).isEmpty() )
+ {
+ text += "<br>" + Qtopia::escapeString( value );
+ marker = true;
}
- switch( addressformat ){
- case Zip_City_State:{ // Zip_Code City, State
- state = businessState();
- if ( !(value = businessZip()).isEmpty() ){
- text += "<br>" + Qtopia::escapeString(value) + " ";
- marker = true;
-
- }
- if ( !(value = businessCity()).isEmpty() ) {
- marker = true;
- if ( businessZip().isEmpty() && !businessStreet().isEmpty() )
- text += "<br>";
- text += Qtopia::escapeString(value);
- if ( state )
- text += ", " + Qtopia::escapeString(state);
- } else if ( !state.isEmpty() ){
- text += "<br>" + Qtopia::escapeString(state);
- marker = true;
- }
- break;
- }
- case City_State_Zip:{ // City, State Zip_Code
- state = businessState();
- if ( !(value = businessCity()).isEmpty() ) {
- marker = true;
- text += "<br>" + Qtopia::escapeString(value);
- if ( state )
- text += ", " + Qtopia::escapeString(state);
- } else if ( !state.isEmpty() ){
- text += "<br>" + Qtopia::escapeString(state);
- marker = true;
- }
- if ( !(value = businessZip()).isEmpty() ){
- text += " " + Qtopia::escapeString(value);
- marker = true;
- }
- break;
- }
+ switch ( addressformat )
+ {
+ case Zip_City_State:
+ { // Zip_Code City, State
+ state = businessState();
+ if ( !( value = businessZip() ).isEmpty() )
+ {
+ text += "<br>" + Qtopia::escapeString( value ) + " ";
+ marker = true;
+
+ }
+ if ( !( value = businessCity() ).isEmpty() )
+ {
+ marker = true;
+ if ( businessZip().isEmpty() && !businessStreet().isEmpty() )
+ text += "<br>";
+ text += Qtopia::escapeString( value );
+ if ( state )
+ text += ", " + Qtopia::escapeString( state );
+ }
+ else if ( !state.isEmpty() )
+ {
+ text += "<br>" + Qtopia::escapeString( state );
+ marker = true;
+ }
+ break;
+ }
+ case City_State_Zip:
+ { // City, State Zip_Code
+ state = businessState();
+ if ( !( value = businessCity() ).isEmpty() )
+ {
+ marker = true;
+ text += "<br>" + Qtopia::escapeString( value );
+ if ( state )
+ text += ", " + Qtopia::escapeString( state );
+ }
+ else if ( !state.isEmpty() )
+ {
+ text += "<br>" + Qtopia::escapeString( state );
+ marker = true;
+ }
+ if ( !( value = businessZip() ).isEmpty() )
+ {
+ text += " " + Qtopia::escapeString( value );
+ marker = true;
+ }
+ break;
+ }
}
- if ( !(value = businessCountry()).isEmpty() ){
- text += "<br>" + Qtopia::escapeString(value);
- marker = true;
+ if ( !( value = businessCountry() ).isEmpty() )
+ {
+ text += "<br>" + Qtopia::escapeString( value );
+ marker = true;
}
// rest of Business data
str = office();
- if ( !str.isEmpty() ){
- text += "<br><b>" + QObject::tr("Office: ") + "</b>"
- + Qtopia::escapeString(str);
- marker = true;
+ if ( !str.isEmpty() )
+ {
+ text += "<br><b>" + QObject::tr( "Office: " ) + "</b>"
+ + Qtopia::escapeString( str );
+ marker = true;
}
str = businessWebpage();
- if ( !str.isEmpty() ){
- text += "<br><b><img src=\"addressbook/webpagework\"> " + QObject::tr("Business Web Page: ") + "</b>"
- + Qtopia::escapeString(str);
- marker = true;
+ if ( !str.isEmpty() )
+ {
+ text += "<br><b><img src=\"addressbook/webpagework\"> " + QObject::tr( "Business Web Page: " ) + "</b>"
+ + Qtopia::escapeString( str );
+ marker = true;
}
str = businessPhone();
- if ( !str.isEmpty() ){
- text += "<br><b><img src=\"addressbook/phonework\"> " + QObject::tr("Business Phone: ") + "</b>"
- + Qtopia::escapeString(str);
- marker = true;
+ if ( !str.isEmpty() )
+ {
+ text += "<br><b><img src=\"addressbook/phonework\"> " + QObject::tr( "Business Phone: " ) + "</b>"
+ + Qtopia::escapeString( str );
+ marker = true;
}
str = businessFax();
- if ( !str.isEmpty() ){
- text += "<br><b><img src=\"addressbook/faxwork\"> " + QObject::tr("Business Fax: ") + "</b>"
- + Qtopia::escapeString(str);
- marker = true;
+ if ( !str.isEmpty() )
+ {
+ text += "<br><b><img src=\"addressbook/faxwork\"> " + QObject::tr( "Business Fax: " ) + "</b>"
+ + Qtopia::escapeString( str );
+ marker = true;
}
str = businessMobile();
- if ( !str.isEmpty() ){
- text += "<br><b><img src=\"addressbook/mobilework\"> " + QObject::tr("Business Mobile: ") + "</b>"
- + Qtopia::escapeString(str);
- marker = true;
+ if ( !str.isEmpty() )
+ {
+ text += "<br><b><img src=\"addressbook/mobilework\"> " + QObject::tr( "Business Mobile: " ) + "</b>"
+ + Qtopia::escapeString( str );
+ marker = true;
}
str = businessPager();
- if ( !str.isEmpty() ){
- text += "<br><b>" + QObject::tr("Business Pager: ") + "</b>"
- + Qtopia::escapeString(str);
- marker = true;
+ if ( !str.isEmpty() )
+ {
+ text += "<br><b>" + QObject::tr( "Business Pager: " ) + "</b>"
+ + Qtopia::escapeString( str );
+ marker = true;
}
// text += "<br>";
// home address
if ( !homeStreet().isEmpty() || !homeCity().isEmpty() ||
- !homeZip().isEmpty() || !homeCountry().isEmpty() ) {
- text += QObject::tr( "<br><b>Home Address:</b>" );
- marker = true;
+ !homeZip().isEmpty() || !homeCountry().isEmpty() )
+ {
+ text += QObject::tr( "<br><b>Home Address:</b>" );
+ marker = true;
}
- if ( !(value = homeStreet()).isEmpty() ){
- text += "<br>" + Qtopia::escapeString(value);
- marker = true;
+ if ( !( value = homeStreet() ).isEmpty() )
+ {
+ text += "<br>" + Qtopia::escapeString( value );
+ marker = true;
}
- switch( addressformat ){
- case Zip_City_State:{ // Zip_Code City, State
- state = homeState();
- if ( !(value = homeZip()).isEmpty() ){
- text += "<br>" + Qtopia::escapeString(value) + " ";
- marker = true;
- }
- if ( !(value = homeCity()).isEmpty() ) {
- marker = true;
- if ( homeZip().isEmpty() && !homeStreet().isEmpty() )
- text += "<br>";
- text += Qtopia::escapeString(value);
- if ( !state.isEmpty() )
- text += ", " + Qtopia::escapeString(state);
- } else if (!state.isEmpty()) {
- text += "<br>" + Qtopia::escapeString(state);
- marker = true;
- }
- break;
- }
- case City_State_Zip:{ // City, State Zip_Code
- state = homeState();
- if ( !(value = homeCity()).isEmpty() ) {
- marker = true;
- text += "<br>" + Qtopia::escapeString(value);
- if ( state )
- text += ", " + Qtopia::escapeString(state);
- } else if ( !state.isEmpty() ){
- text += "<br>" + Qtopia::escapeString(state);
- marker = true;
- }
- if ( !(value = homeZip()).isEmpty() ){
- text += " " + Qtopia::escapeString(value);
- marker = true;
- }
- break;
- }
+ switch ( addressformat )
+ {
+ case Zip_City_State:
+ { // Zip_Code City, State
+ state = homeState();
+ if ( !( value = homeZip() ).isEmpty() )
+ {
+ text += "<br>" + Qtopia::escapeString( value ) + " ";
+ marker = true;
+ }
+ if ( !( value = homeCity() ).isEmpty() )
+ {
+ marker = true;
+ if ( homeZip().isEmpty() && !homeStreet().isEmpty() )
+ text += "<br>";
+ text += Qtopia::escapeString( value );
+ if ( !state.isEmpty() )
+ text += ", " + Qtopia::escapeString( state );
+ }
+ else if ( !state.isEmpty() )
+ {
+ text += "<br>" + Qtopia::escapeString( state );
+ marker = true;
+ }
+ break;
+ }
+ case City_State_Zip:
+ { // City, State Zip_Code
+ state = homeState();
+ if ( !( value = homeCity() ).isEmpty() )
+ {
+ marker = true;
+ text += "<br>" + Qtopia::escapeString( value );
+ if ( state )
+ text += ", " + Qtopia::escapeString( state );
+ }
+ else if ( !state.isEmpty() )
+ {
+ text += "<br>" + Qtopia::escapeString( state );
+ marker = true;
+ }
+ if ( !( value = homeZip() ).isEmpty() )
+ {
+ text += " " + Qtopia::escapeString( value );
+ marker = true;
+ }
+ break;
+ }
}
-
- if ( !(value = homeCountry()).isEmpty() ){
- text += "<br>" + Qtopia::escapeString(value);
- marker = true;
+
+ if ( !( value = homeCountry() ).isEmpty() )
+ {
+ text += "<br>" + Qtopia::escapeString( value );
+ marker = true;
}
// rest of Home data
str = homeWebpage();
- if ( !str.isEmpty() ){
- text += "<br><b><img src=\"addressbook/webpagehome\"> " + QObject::tr("Home Web Page: ") + "</b>"
- + Qtopia::escapeString(str);
- marker = true;
+ if ( !str.isEmpty() )
+ {
+ text += "<br><b><img src=\"addressbook/webpagehome\"> " + QObject::tr( "Home Web Page: " ) + "</b>"
+ + Qtopia::escapeString( str );
+ marker = true;
}
str = homePhone();
- if ( !str.isEmpty() ){
- text += "<br><b><img src=\"addressbook/phonehome\"> " + QObject::tr("Home Phone: ") + "</b>"
- + Qtopia::escapeString(str);
- marker = true;
+ if ( !str.isEmpty() )
+ {
+ text += "<br><b><img src=\"addressbook/phonehome\"> " + QObject::tr( "Home Phone: " ) + "</b>"
+ + Qtopia::escapeString( str );
+ marker = true;
}
str = homeFax();
- if ( !str.isEmpty() ){
- text += "<br><b><img src=\"addressbook/faxhome\"> " + QObject::tr("Home Fax: ") + "</b>"
- + Qtopia::escapeString(str);
- marker = true;
+ if ( !str.isEmpty() )
+ {
+ text += "<br><b><img src=\"addressbook/faxhome\"> " + QObject::tr( "Home Fax: " ) + "</b>"
+ + Qtopia::escapeString( str );
+ marker = true;
}
str = homeMobile();
- if ( !str.isEmpty() ){
- text += "<br><b><img src=\"addressbook/mobilehome\"> " + QObject::tr("Home Mobile: ") + "</b>"
- + Qtopia::escapeString(str);
- marker = true;
+ if ( !str.isEmpty() )
+ {
+ text += "<br><b><img src=\"addressbook/mobilehome\"> " + QObject::tr( "Home Mobile: " ) + "</b>"
+ + Qtopia::escapeString( str );
+ marker = true;
}
if ( marker )
- text += "<br><hr>";
+ text += "<br><hr>";
// the rest...
str = emails();
if ( !str.isEmpty() && ( str != defEmail ) )
- text += "<br><b>" + QObject::tr("All Emails: ") + "</b>"
- + Qtopia::escapeString(str);
+ text += "<br><b>" + QObject::tr( "All Emails: " ) + "</b>"
+ + Qtopia::escapeString( str );
str = profession();
if ( !str.isEmpty() )
- text += "<br><b>" + QObject::tr("Profession: ") + "</b>"
- + Qtopia::escapeString(str);
+ text += "<br><b>" + QObject::tr( "Profession: " ) + "</b>"
+ + Qtopia::escapeString( str );
str = assistant();
if ( !str.isEmpty() )
- text += "<br><b>" + QObject::tr("Assistant: ") + "</b>"
- + Qtopia::escapeString(str);
+ text += "<br><b>" + QObject::tr( "Assistant: " ) + "</b>"
+ + Qtopia::escapeString( str );
str = manager();
if ( !str.isEmpty() )
- text += "<br><b>" + QObject::tr("Manager: ") + "</b>"
- + Qtopia::escapeString(str);
+ text += "<br><b>" + QObject::tr( "Manager: " ) + "</b>"
+ + Qtopia::escapeString( str );
str = gender();
- if ( !str.isEmpty() && str.toInt() != 0 ) {
- text += "<br>";
- if ( str.toInt() == 1 )
- str = QObject::tr( "Male" );
- else if ( str.toInt() == 2 )
- str = QObject::tr( "Female" );
- text += "<b>" + QObject::tr("Gender: ") + "</b>" + str;
+ if ( !str.isEmpty() && str.toInt() != 0 )
+ {
+ text += "<br>";
+ if ( str.toInt() == 1 )
+ str = QObject::tr( "Male" );
+ else if ( str.toInt() == 2 )
+ str = QObject::tr( "Female" );
+ text += "<b>" + QObject::tr( "Gender: " ) + "</b>" + str;
}
str = spouse();
if ( !str.isEmpty() )
- text += "<br><b>" + QObject::tr("Spouse: ") + "</b>"
- + Qtopia::escapeString(str);
- if ( birthday().isValid() ){
- str = TimeString::numberDateString( birthday() );
- text += "<br><b>" + QObject::tr("Birthday: ") + "</b>"
- + Qtopia::escapeString(str);
+ text += "<br><b>" + QObject::tr( "Spouse: " ) + "</b>"
+ + Qtopia::escapeString( str );
+ if ( birthday().isValid() )
+ {
+ str = TimeString::numberDateString( birthday() );
+ text += "<br><b>" + QObject::tr( "Birthday: " ) + "</b>"
+ + Qtopia::escapeString( str );
}
- if ( anniversary().isValid() ){
- str = TimeString::numberDateString( anniversary() );
- text += "<br><b>" + QObject::tr("Anniversary: ") + "</b>"
- + Qtopia::escapeString(str);
+ if ( anniversary().isValid() )
+ {
+ str = TimeString::numberDateString( anniversary() );
+ text += "<br><b>" + QObject::tr( "Anniversary: " ) + "</b>"
+ + Qtopia::escapeString( str );
}
str = children();
if ( !str.isEmpty() )
- text += "<br><b>" + QObject::tr("Children: ") + "</b>"
- + Qtopia::escapeString(str);
+ text += "<br><b>" + QObject::tr( "Children: " ) + "</b>"
+ + Qtopia::escapeString( str );
str = nickname();
if ( !str.isEmpty() )
- text += "<br><b>" + QObject::tr("Nickname: ") + "</b>"
- + Qtopia::escapeString(str);
+ text += "<br><b>" + QObject::tr( "Nickname: " ) + "</b>"
+ + Qtopia::escapeString( str );
// categories
- if ( categoryNames("Contacts").count() ){
- text += "<br><b>" + QObject::tr( "Category:") + "</b> ";
- text += categoryNames("Contacts").join(", ");
+ if ( categoryNames( "Contacts" ).count() )
+ {
+ text += "<br><b>" + QObject::tr( "Category:" ) + "</b> ";
+ text += categoryNames( "Contacts" ).join( ", " );
}
// notes last
- if ( !(value = notes()).isEmpty() ) {
- text += "<br><hr><b>" + QObject::tr( "Notes:") + "</b> ";
- QRegExp reg("\n");
-
- //QString tmp = Qtopia::escapeString(value);
- QString tmp = QStyleSheet::convertFromPlainText(value);
- //tmp.replace( reg, "<br>" );
- text += "<br>" + tmp + "<br>";
+ if ( !( value = notes() ).isEmpty() )
+ {
+ text += "<br><hr><b>" + QObject::tr( "Notes:" ) + "</b> ";
+ QRegExp reg( "\n" );
+
+ //QString tmp = Qtopia::escapeString(value);
+ QString tmp = QStyleSheet::convertFromPlainText( value );
+ //tmp.replace( reg, "<br>" );
+ text += "<br>" + tmp + "<br>";
}
return text;
}
@@ -755,9 +784,9 @@ void OContact::insert( int key, const QString &v )
{
QString value = v.stripWhiteSpace();
if ( value.isEmpty() )
- mMap.remove( key );
+ mMap.remove( key );
else
- mMap.insert( key, value );
+ mMap.insert( key, value );
}
/*!
@@ -767,9 +796,9 @@ void OContact::replace( int key, const QString & v )
{
QString value = v.stripWhiteSpace();
if ( value.isEmpty() )
- mMap.remove( key );
+ mMap.remove( key );
else
- mMap.replace( key, value );
+ mMap.replace( key, value );
}
/*!
@@ -777,30 +806,30 @@ void OContact::replace( int key, const QString & v )
*/
QString OContact::find( int key ) const
{
- return mMap[key];
+ return mMap[ key ];
}
/*!
\internal
*/
QString OContact::displayAddress( const QString &street,
- const QString &city,
- const QString &state,
- const QString &zip,
- const QString &country ) const
+ const QString &city,
+ const QString &state,
+ const QString &zip,
+ const QString &country ) const
{
QString s = street;
if ( !street.isEmpty() )
- s+= "\n";
+ s += "\n";
s += city;
if ( !city.isEmpty() && !state.isEmpty() )
- s += ", ";
+ s += ", ";
s += state;
if ( !state.isEmpty() && !zip.isEmpty() )
- s += " ";
+ s += " ";
s += zip;
if ( !country.isEmpty() && !s.isEmpty() )
- s += "\n";
+ s += "\n";
s += country;
return s;
}
@@ -811,8 +840,8 @@ QString OContact::displayAddress( const QString &street,
QString OContact::displayBusinessAddress() const
{
return displayAddress( businessStreet(), businessCity(),
- businessState(), businessZip(),
- businessCountry() );
+ businessState(), businessZip(),
+ businessCountry() );
}
/*!
@@ -821,8 +850,8 @@ QString OContact::displayBusinessAddress() const
QString OContact::displayHomeAddress() const
{
return displayAddress( homeStreet(), homeCity(),
- homeState(), homeZip(),
- homeCountry() );
+ homeState(), homeZip(),
+ homeCountry() );
}
/*!
@@ -837,25 +866,29 @@ QString OContact::fullName() const
QString suffix = find( Qtopia::Suffix );
QString name = title;
- if ( !firstName.isEmpty() ) {
- if ( !name.isEmpty() )
- name += " ";
- name += firstName;
+ if ( !firstName.isEmpty() )
+ {
+ if ( !name.isEmpty() )
+ name += " ";
+ name += firstName;
}
- if ( !middleName.isEmpty() ) {
- if ( !name.isEmpty() )
- name += " ";
- name += middleName;
+ if ( !middleName.isEmpty() )
+ {
+ if ( !name.isEmpty() )
+ name += " ";
+ name += middleName;
}
- if ( !lastName.isEmpty() ) {
- if ( !name.isEmpty() )
- name += " ";
- name += lastName;
+ if ( !lastName.isEmpty() )
+ {
+ if ( !name.isEmpty() )
+ name += " ";
+ name += lastName;
}
- if ( !suffix.isEmpty() ) {
- if ( !name.isEmpty() )
- name += " ";
- name += suffix;
+ if ( !suffix.isEmpty() )
+ {
+ if ( !name.isEmpty() )
+ name += " ";
+ name += suffix;
}
return name.simplifyWhiteSpace();
}
@@ -900,11 +933,12 @@ QStringList OContact::emailList() const
QString emailStr = emails();
QStringList r;
- if ( !emailStr.isEmpty() ) {
- qDebug(" emailstr ");
- QStringList l = QStringList::split( emailSeparator(), emailStr );
- for ( QStringList::ConstIterator it = l.begin();it != l.end();++it )
- r += (*it).simplifyWhiteSpace();
+ if ( !emailStr.isEmpty() )
+ {
+ qDebug( " emailstr " );
+ QStringList l = QStringList::split( emailSeparator(), emailStr );
+ for ( QStringList::ConstIterator it = l.begin();it != l.end();++it )
+ r += ( *it ).simplifyWhiteSpace();
}
return r;
@@ -924,15 +958,15 @@ void OContact::setFileAs()
firstName = find( Qtopia::FirstName );
middleName = find( Qtopia::MiddleName );
if ( !lastName.isEmpty() && !firstName.isEmpty()
- && !middleName.isEmpty() )
- fileas = lastName + ", " + firstName + " " + middleName;
+ && !middleName.isEmpty() )
+ fileas = lastName + ", " + firstName + " " + middleName;
else if ( !lastName.isEmpty() && !firstName.isEmpty() )
- fileas = lastName + ", " + firstName;
+ fileas = lastName + ", " + firstName;
else if ( !lastName.isEmpty() || !firstName.isEmpty() ||
- !middleName.isEmpty() )
- fileas = firstName + ( firstName.isEmpty() ? "" : " " )
- + middleName + ( middleName.isEmpty() ? "" : " " )
- + lastName;
+ !middleName.isEmpty() )
+ fileas = firstName + ( firstName.isEmpty() ? "" : " " )
+ + middleName + ( middleName.isEmpty() ? "" : " " )
+ + lastName;
replace( Qtopia::FileAs, fileas );
}
@@ -946,21 +980,23 @@ void OContact::save( QString &buf ) const
static const QStringList SLFIELDS = fields();
// I'm expecting "<Contact " in front of this...
for ( QMap<int, QString>::ConstIterator it = mMap.begin();
- it != mMap.end(); ++it ) {
- const QString &value = it.data();
- int key = it.key();
- if ( !value.isEmpty() ) {
- if ( key == Qtopia::AddressCategory || key == Qtopia::AddressUid)
- continue;
-
- key -= Qtopia::AddressCategory+1;
- buf += SLFIELDS[key];
- buf += "=\"" + Qtopia::escapeString(value) + "\" ";
- }
+ it != mMap.end(); ++it )
+ {
+ const QString &value = it.data();
+ int key = it.key();
+ if ( !value.isEmpty() )
+ {
+ if ( key == Qtopia::AddressCategory || key == Qtopia::AddressUid )
+ continue;
+
+ key -= Qtopia::AddressCategory + 1;
+ buf += SLFIELDS[ key ];
+ buf += "=\"" + Qtopia::escapeString( value ) + "\" ";
+ }
}
buf += customToXml();
if ( categories().count() > 0 )
- buf += "Categories=\"" + idsToString( categories() ) + "\" ";
+ buf += "Categories=\"" + idsToString( categories() ) + "\" ";
buf += "Uid=\"" + QString::number( uid() ) + "\" ";
// You need to close this yourself
}
@@ -1061,12 +1097,14 @@ bool OContact::match( const QRegExp &r ) const
bool match;
match = false;
QMap<int, QString>::ConstIterator it;
- for ( it = mMap.begin(); it != mMap.end(); ++it ) {
- if ( (*it).find( r ) > -1 ) {
+ for ( it = mMap.begin(); it != mMap.end(); ++it )
+ {
+ if ( ( *it ).find( r ) > -1 )
+ {
setLastHitField( it.key() );
- match = true;
- break;
- }
+ match = true;
+ break;
+ }
}
return match;
}
@@ -1074,19 +1112,20 @@ bool OContact::match( const QRegExp &r ) const
QString OContact::toShortText() const
{
- return ( fullName() );
+ return ( fullName() );
}
+
+
QString OContact::type() const
{
- return QString::fromLatin1( "OContact" );
+ return QString::fromLatin1( "OContact" );
}
-
class QString OContact::recordField( int pos ) const
{
- QStringList SLFIELDS = fields(); // ?? why this ? (se)
- return SLFIELDS[pos];
+ QStringList SLFIELDS = fields(); // ?? why this ? (se)
+ return SLFIELDS[ pos ];
}
// In future releases, we should store birthday and anniversary
@@ -1099,14 +1138,15 @@ class QString OContact::recordField( int pos ) const
*/
void OContact::setBirthday( const QDate &v )
{
- if ( v.isNull() ){
- qWarning( "Remove Birthday");
- replace( Qtopia::Birthday, QString::null );
- return;
- }
+ if ( v.isNull() )
+ {
+ qWarning( "Remove Birthday" );
+ replace( Qtopia::Birthday, QString::null );
+ return ;
+ }
- if ( v.isValid() )
- replace( Qtopia::Birthday, OConversion::dateToString( v ) );
+ if ( v.isValid() )
+ replace( Qtopia::Birthday, OConversion::dateToString( v ) );
}
@@ -1117,27 +1157,29 @@ void OContact::setBirthday( const QDate &v )
*/
void OContact::setAnniversary( const QDate &v )
{
- if ( v.isNull() ){
- qWarning( "Remove Anniversary");
- replace( Qtopia::Anniversary, QString::null );
- return;
- }
-
- if ( v.isValid() )
- replace( Qtopia::Anniversary, OConversion::dateToString( v ) );
+ if ( v.isNull() )
+ {
+ qWarning( "Remove Anniversary" );
+ replace( Qtopia::Anniversary, QString::null );
+ return ;
+ }
+
+ if ( v.isValid() )
+ replace( Qtopia::Anniversary, OConversion::dateToString( v ) );
}
+
/*! \fn QDate OContact::birthday() const
Returns the birthday of the contact.
*/
QDate OContact::birthday() const
{
- QString str = find( Qtopia::Birthday );
- // qWarning ("Birthday %s", str.latin1() );
- if ( !str.isEmpty() )
- return OConversion::dateFromString ( str );
- else
- return QDate();
+ QString str = find( Qtopia::Birthday );
+ // qWarning ("Birthday %s", str.latin1() );
+ if ( !str.isEmpty() )
+ return OConversion::dateFromString ( str );
+ else
+ return QDate();
}
@@ -1146,13 +1188,13 @@ QDate OContact::birthday() const
*/
QDate OContact::anniversary() const
{
- QDate empty;
- QString str = find( Qtopia::Anniversary );
- // qWarning ("Anniversary %s", str.latin1() );
- if ( !str.isEmpty() )
- return OConversion::dateFromString ( str );
- else
- return empty;
+ QDate empty;
+ QString str = find( Qtopia::Anniversary );
+ // qWarning ("Anniversary %s", str.latin1() );
+ if ( !str.isEmpty() )
+ return OConversion::dateFromString ( str );
+ else
+ return empty;
}
@@ -1163,22 +1205,24 @@ void OContact::insertEmail( const QString &v )
QString def = defaultEmail();
// if no default, set it as the default email and don't insert
- if ( def.isEmpty() ) {
- setDefaultEmail( e ); // will insert into the list for us
- return;
+ if ( def.isEmpty() )
+ {
+ setDefaultEmail( e ); // will insert into the list for us
+ return ;
}
// otherwise, insert assuming doesn't already exist
QString emailsStr = find( Qtopia::Emails );
- if ( emailsStr.contains( e ))
- return;
+ if ( emailsStr.contains( e ) )
+ return ;
if ( !emailsStr.isEmpty() )
- emailsStr += emailSeparator();
+ emailsStr += emailSeparator();
emailsStr += e;
replace( Qtopia::Emails, emailsStr );
}
-void OContact::removeEmail( const QString &v )
+
+ void OContact::removeEmail( const QString &v )
{
QString e = v.simplifyWhiteSpace();
QString def = defaultEmail();
@@ -1187,29 +1231,34 @@ void OContact::removeEmail( const QString &v )
// otherwise, must first contain it
if ( !emailsStr.contains( e ) )
- return;
+ return ;
// remove it
//qDebug(" removing email from list %s", e.latin1());
emails.remove( e );
// reset the string
- emailsStr = emails.join(emailSeparator()); // Sharp's brain dead separator
+ emailsStr = emails.join( emailSeparator() ); // Sharp's brain dead separator
replace( Qtopia::Emails, emailsStr );
// if default, then replace the default email with the first one
- if ( def == e ) {
- //qDebug("removeEmail is default; setting new default");
- if ( !emails.count() )
- clearEmails();
- else // setDefaultEmail will remove e from the list
- setDefaultEmail( emails.first() );
+ if ( def == e )
+ {
+ //qDebug("removeEmail is default; setting new default");
+ if ( !emails.count() )
+ clearEmails();
+ else // setDefaultEmail will remove e from the list
+ setDefaultEmail( emails.first() );
}
}
+
+
void OContact::clearEmails()
{
mMap.remove( Qtopia::DefaultEmail );
mMap.remove( Qtopia::Emails );
}
+
+
void OContact::setDefaultEmail( const QString &v )
{
QString e = v.simplifyWhiteSpace();
@@ -1218,21 +1267,27 @@ void OContact::setDefaultEmail( const QString &v )
replace( Qtopia::DefaultEmail, e );
if ( !e.isEmpty() )
- insertEmail( e );
+ insertEmail( e );
}
+
void OContact::insertEmails( const QStringList &v )
{
for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it )
- insertEmail( *it );
+ insertEmail( *it );
}
-int OContact::rtti() {
+
+
+int OContact::rtti()
+{
return OPimResolver::AddressBook;
}
+
+
void OContact::setUid( int i )
{
- OPimRecord::setUid(i);
- replace( Qtopia::AddressUid , QString::number(i));
+ OPimRecord::setUid( i );
+ replace( Qtopia::AddressUid , QString::number( i ) );
}
}
diff --git a/libopie2/opiepim/ocontact.h b/libopie2/opiepim/ocontact.h
index 34888dc..445fd7d 100644
--- a/libopie2/opiepim/ocontact.h
+++ b/libopie2/opiepim/ocontact.h
@@ -26,12 +26,15 @@
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
-#ifndef __OCONTACT_H__
-#define __OCONTACT_H__
+#ifndef OCONTACT_H
+#define OCONTACT_H
+
+/* OPIE */
#include <opie2/opimrecord.h>
#include <qpe/recordfields.h>
+/* QT */
#include <qdatetime.h>
#include <qstringlist.h>
@@ -41,7 +44,8 @@ QPC_TEMPLATEEXTERN template class QPC_EXPORT QMap<int, QString>;
// MOC_SKIP_END
#endif
-namespace Opie {
+namespace Opie
+{
class OContactPrivate;
/**
@@ -54,14 +58,15 @@ class OContactPrivate;
class QPC_EXPORT OContact : public OPimRecord
{
friend class DataSet;
-public:
+
+ public:
OContact();
OContact( const QMap<int, QString> &fromMap );
virtual ~OContact();
enum DateFormat{
- Zip_City_State = 0,
- City_State_Zip
+ Zip_City_State = 0,
+ City_State_Zip
};
/*
@@ -124,13 +129,13 @@ public:
void setChildren( const QString &v );
// other
- void setNotes( const QString &v ) { replace( Qtopia::Notes, v); }
+ void setNotes( const QString &v ) { replace( Qtopia::Notes, v ); }
virtual bool match( const QRegExp &regexp ) const;
-// // custom
-// void setCustomField( const QString &key, const QString &v )
-// { replace(Custom- + key, v ); }
+ // // custom
+ // void setCustomField( const QString &key, const QString &v )
+ // { replace(Custom- + key, v ); }
// name
QString fullName() const;
@@ -185,7 +190,7 @@ public:
QString profession() const { return find( Qtopia::Profession ); }
QString assistant() const { return find( Qtopia::Assistant ); }
QString manager() const { return find( Qtopia::Manager ); }
- /** Multi line string containing all non-empty address info in the form
+ /** Multi line string containing all non-empty address info in the form
* Street
* City, State Zip
* Country
@@ -213,9 +218,9 @@ public:
void setUid( int i );
- QString toShortText()const;
- QString type()const;
- class QString recordField(int) const;
+ QString toShortText() const;
+ QString type() const;
+ class QString recordField( int ) const;
// Why private ? (eilers,se)
QString emailSeparator() const { return " "; }
@@ -225,7 +230,7 @@ public:
QString emails() const { return find( Qtopia::Emails ); }
static int rtti();
-private:
+ private:
// The XML Backend needs some access to the private functions
friend class OContactAccessBackend_XML;
@@ -237,10 +242,10 @@ private:
void save( QString &buf ) const;
QString displayAddress( const QString &street,
- const QString &city,
- const QString &state,
- const QString &zip,
- const QString &country ) const;
+ const QString &city,
+ const QString &state,
+ const QString &zip,
+ const QString &country ) const;
QMap<int, QString> mMap;
OContactPrivate *d;
diff --git a/libopie2/opiepim/ocontactfields.cpp b/libopie2/opiepim/ocontactfields.cpp
index deaa1e5..bec00f7 100644
--- a/libopie2/opiepim/ocontactfields.cpp
+++ b/libopie2/opiepim/ocontactfields.cpp
@@ -1,6 +1,6 @@
/*
This file is part of the Opie Project
- Copyright (C) The Main Author <main-author@whereever.org>
+ Copyright (C) Stefan Eilers <eilers.stefan@epost.de>
=. Copyright (C) The Opie Team <opie-devel@handhelds.org>
.=l.
.>+-=
@@ -27,17 +27,20 @@
Boston, MA 02111-1307, USA.
*/
-#include <opie2/ocontactfields.h>
+#include "ocontactfields.h"
-#include <qstringlist.h>
+/* OPIE */
+#include <opie2/ocontact.h>
+#include <qpe/recordfields.h> // We should use our own enum in the future ..
+#include <qpe/config.h>
+
+/* QT */
#include <qobject.h>
+#include <qstringlist.h>
-// We should use our own enum in the future ..
-#include <qpe/recordfields.h>
-#include <qpe/config.h>
-#include <opie2/ocontact.h>
-namespace Opie {
+namespace Opie
+{
/*!
\internal
Returns a list of personal field names for a contact.
@@ -47,9 +50,9 @@ QStringList OContactFields::personalfields( bool sorted, bool translated )
QStringList list;
QMap<int, QString> mapIdToStr;
if ( translated )
- mapIdToStr = idToTrFields();
+ mapIdToStr = idToTrFields();
else
- mapIdToStr = idToUntrFields();
+ mapIdToStr = idToUntrFields();
list.append( mapIdToStr[ Qtopia::AddressUid ] );
list.append( mapIdToStr[ Qtopia::AddressCategory ] );
@@ -68,7 +71,7 @@ QStringList OContactFields::personalfields( bool sorted, bool translated )
list.append( mapIdToStr[ Qtopia::Notes ] );
list.append( mapIdToStr[ Qtopia::Groups ] );
- if (sorted) list.sort();
+ if ( sorted ) list.sort();
return list;
}
@@ -81,9 +84,9 @@ QStringList OContactFields::detailsfields( bool sorted, bool translated )
QStringList list;
QMap<int, QString> mapIdToStr;
if ( translated )
- mapIdToStr = idToTrFields();
+ mapIdToStr = idToTrFields();
else
- mapIdToStr = idToUntrFields();
+ mapIdToStr = idToUntrFields();
list.append( mapIdToStr[ Qtopia::Office ] );
list.append( mapIdToStr[ Qtopia::Profession ] );
@@ -97,7 +100,7 @@ QStringList OContactFields::detailsfields( bool sorted, bool translated )
list.append( mapIdToStr[ Qtopia::Nickname ] );
list.append( mapIdToStr[ Qtopia::Children ] );
- if (sorted) list.sort();
+ if ( sorted ) list.sort();
return list;
}
@@ -110,26 +113,26 @@ QStringList OContactFields::phonefields( bool sorted, bool translated )
QStringList list;
QMap<int, QString> mapIdToStr;
if ( translated )
- mapIdToStr = idToTrFields();
+ mapIdToStr = idToTrFields();
else
- mapIdToStr = idToUntrFields();
+ mapIdToStr = idToUntrFields();
- list.append( mapIdToStr[Qtopia::BusinessPhone] );
- list.append( mapIdToStr[Qtopia::BusinessFax] );
- list.append( mapIdToStr[Qtopia::BusinessMobile] );
- list.append( mapIdToStr[Qtopia::BusinessPager] );
- list.append( mapIdToStr[Qtopia::BusinessWebPage] );
+ list.append( mapIdToStr[ Qtopia::BusinessPhone ] );
+ list.append( mapIdToStr[ Qtopia::BusinessFax ] );
+ list.append( mapIdToStr[ Qtopia::BusinessMobile ] );
+ list.append( mapIdToStr[ Qtopia::BusinessPager ] );
+ list.append( mapIdToStr[ Qtopia::BusinessWebPage ] );
- list.append( mapIdToStr[Qtopia::DefaultEmail] );
- list.append( mapIdToStr[Qtopia::Emails] );
+ list.append( mapIdToStr[ Qtopia::DefaultEmail ] );
+ list.append( mapIdToStr[ Qtopia::Emails ] );
- list.append( mapIdToStr[Qtopia::HomePhone] );
- list.append( mapIdToStr[Qtopia::HomeFax] );
- list.append( mapIdToStr[Qtopia::HomeMobile] );
+ list.append( mapIdToStr[ Qtopia::HomePhone ] );
+ list.append( mapIdToStr[ Qtopia::HomeFax ] );
+ list.append( mapIdToStr[ Qtopia::HomeMobile ] );
// list.append( mapIdToStr[Qtopia::HomePager] );
- list.append( mapIdToStr[Qtopia::HomeWebPage] );
+ list.append( mapIdToStr[ Qtopia::HomeWebPage ] );
- if (sorted) list.sort();
+ if ( sorted ) list.sort();
return list;
}
@@ -143,29 +146,29 @@ QStringList OContactFields::fields( bool sorted, bool translated )
QStringList list;
QMap<int, QString> mapIdToStr;
if ( translated )
- mapIdToStr = idToTrFields();
+ mapIdToStr = idToTrFields();
else
- mapIdToStr = idToUntrFields();
+ mapIdToStr = idToUntrFields();
list += personalfields( sorted, translated );
list += phonefields( sorted, translated );
- list.append( mapIdToStr[Qtopia::BusinessStreet] );
- list.append( mapIdToStr[Qtopia::BusinessCity] );
- list.append( mapIdToStr[Qtopia::BusinessState] );
- list.append( mapIdToStr[Qtopia::BusinessZip] );
- list.append( mapIdToStr[Qtopia::BusinessCountry] );
+ list.append( mapIdToStr[ Qtopia::BusinessStreet ] );
+ list.append( mapIdToStr[ Qtopia::BusinessCity ] );
+ list.append( mapIdToStr[ Qtopia::BusinessState ] );
+ list.append( mapIdToStr[ Qtopia::BusinessZip ] );
+ list.append( mapIdToStr[ Qtopia::BusinessCountry ] );
- list.append( mapIdToStr[Qtopia::HomeStreet] );
- list.append( mapIdToStr[Qtopia::HomeCity] );
- list.append( mapIdToStr[Qtopia::HomeState] );
- list.append( mapIdToStr[Qtopia::HomeZip] );
- list.append( mapIdToStr[Qtopia::HomeCountry] );
+ list.append( mapIdToStr[ Qtopia::HomeStreet ] );
+ list.append( mapIdToStr[ Qtopia::HomeCity ] );
+ list.append( mapIdToStr[ Qtopia::HomeState ] );
+ list.append( mapIdToStr[ Qtopia::HomeZip ] );
+ list.append( mapIdToStr[ Qtopia::HomeCountry ] );
list += detailsfields( sorted, translated );
- if (sorted) list.sort();
+ if ( sorted ) list.sort();
return list;
}
@@ -177,7 +180,7 @@ QStringList OContactFields::fields( bool sorted, bool translated )
*/
QStringList OContactFields::untrpersonalfields( bool sorted )
{
- return personalfields( sorted, false );
+ return personalfields( sorted, false );
}
@@ -187,7 +190,7 @@ QStringList OContactFields::untrpersonalfields( bool sorted )
*/
QStringList OContactFields::trpersonalfields( bool sorted )
{
- return personalfields( sorted, true );
+ return personalfields( sorted, true );
}
@@ -197,7 +200,7 @@ QStringList OContactFields::trpersonalfields( bool sorted )
*/
QStringList OContactFields::untrdetailsfields( bool sorted )
{
- return detailsfields( sorted, false );
+ return detailsfields( sorted, false );
}
@@ -207,7 +210,7 @@ QStringList OContactFields::untrdetailsfields( bool sorted )
*/
QStringList OContactFields::trdetailsfields( bool sorted )
{
- return detailsfields( sorted, true );
+ return detailsfields( sorted, true );
}
@@ -217,7 +220,7 @@ QStringList OContactFields::trdetailsfields( bool sorted )
*/
QStringList OContactFields::trphonefields( bool sorted )
{
- return phonefields( sorted, true );
+ return phonefields( sorted, true );
}
/*!
@@ -226,7 +229,7 @@ QStringList OContactFields::trphonefields( bool sorted )
*/
QStringList OContactFields::untrphonefields( bool sorted )
{
- return phonefields( sorted, false );
+ return phonefields( sorted, false );
}
@@ -236,7 +239,7 @@ QStringList OContactFields::untrphonefields( bool sorted )
*/
QStringList OContactFields::trfields( bool sorted )
{
- return fields( sorted, true );
+ return fields( sorted, true );
}
/*!
@@ -250,258 +253,265 @@ QStringList OContactFields::untrfields( bool sorted )
QMap<int, QString> OContactFields::idToTrFields()
{
- QMap<int, QString> ret_map;
-
- ret_map.insert( Qtopia::AddressUid, QObject::tr( "User Id" ) );
- ret_map.insert( Qtopia::AddressCategory, QObject::tr( "Categories" ) );
-
- ret_map.insert( Qtopia::Title, QObject::tr( "Name Title") );
- ret_map.insert( Qtopia::FirstName, QObject::tr( "First Name" ) );
- ret_map.insert( Qtopia::MiddleName, QObject::tr( "Middle Name" ) );
- ret_map.insert( Qtopia::LastName, QObject::tr( "Last Name" ) );
- ret_map.insert( Qtopia::Suffix, QObject::tr( "Suffix" ));
- ret_map.insert( Qtopia::FileAs, QObject::tr( "File As" ) );
-
- ret_map.insert( Qtopia::JobTitle, QObject::tr( "Job Title" ) );
- ret_map.insert( Qtopia::Department, QObject::tr( "Department" ) );
- ret_map.insert( Qtopia::Company, QObject::tr( "Company" ) );
- ret_map.insert( Qtopia::BusinessPhone, QObject::tr( "Business Phone" ) );
- ret_map.insert( Qtopia::BusinessFax, QObject::tr( "Business Fax" ) );
- ret_map.insert( Qtopia::BusinessMobile, QObject::tr( "Business Mobile" ));
-
- // email
- ret_map.insert( Qtopia::DefaultEmail, QObject::tr( "Default Email" ) );
- ret_map.insert( Qtopia::Emails, QObject::tr( "Emails" ) );
-
- ret_map.insert( Qtopia::HomePhone, QObject::tr( "Home Phone" ) );
- ret_map.insert( Qtopia::HomeFax, QObject::tr( "Home Fax" ) );
- ret_map.insert( Qtopia::HomeMobile, QObject::tr( "Home Mobile" ) );
-
- // business
- ret_map.insert( Qtopia::BusinessStreet, QObject::tr( "Business Street" ) );
- ret_map.insert( Qtopia::BusinessCity, QObject::tr( "Business City" ) );
- ret_map.insert( Qtopia::BusinessState, QObject::tr( "Business State" ) );
- ret_map.insert( Qtopia::BusinessZip, QObject::tr( "Business Zip" ) );
- ret_map.insert( Qtopia::BusinessCountry, QObject::tr( "Business Country" ) );
- ret_map.insert( Qtopia::BusinessPager, QObject::tr( "Business Pager" ) );
- ret_map.insert( Qtopia::BusinessWebPage, QObject::tr( "Business WebPage" ) );
-
- ret_map.insert( Qtopia::Office, QObject::tr( "Office" ) );
- ret_map.insert( Qtopia::Profession, QObject::tr( "Profession" ) );
- ret_map.insert( Qtopia::Assistant, QObject::tr( "Assistant" ) );
- ret_map.insert( Qtopia::Manager, QObject::tr( "Manager" ) );
-
- // home
- ret_map.insert( Qtopia::HomeStreet, QObject::tr( "Home Street" ) );
- ret_map.insert( Qtopia::HomeCity, QObject::tr( "Home City" ) );
- ret_map.insert( Qtopia::HomeState, QObject::tr( "Home State" ) );
- ret_map.insert( Qtopia::HomeZip, QObject::tr( "Home Zip" ) );
- ret_map.insert( Qtopia::HomeCountry, QObject::tr( "Home Country" ) );
- ret_map.insert( Qtopia::HomeWebPage, QObject::tr( "Home Web Page" ) );
-
- //personal
- ret_map.insert( Qtopia::Spouse, QObject::tr( "Spouse" ) );
- ret_map.insert( Qtopia::Gender, QObject::tr( "Gender" ) );
- ret_map.insert( Qtopia::Birthday, QObject::tr( "Birthday" ) );
- ret_map.insert( Qtopia::Anniversary, QObject::tr( "Anniversary" ) );
- ret_map.insert( Qtopia::Nickname, QObject::tr( "Nickname" ) );
- ret_map.insert( Qtopia::Children, QObject::tr( "Children" ) );
-
- // other
- ret_map.insert( Qtopia::Notes, QObject::tr( "Notes" ) );
-
-
- return ret_map;
+ QMap<int, QString> ret_map;
+
+ ret_map.insert( Qtopia::AddressUid, QObject::tr( "User Id" ) );
+ ret_map.insert( Qtopia::AddressCategory, QObject::tr( "Categories" ) );
+
+ ret_map.insert( Qtopia::Title, QObject::tr( "Name Title" ) );
+ ret_map.insert( Qtopia::FirstName, QObject::tr( "First Name" ) );
+ ret_map.insert( Qtopia::MiddleName, QObject::tr( "Middle Name" ) );
+ ret_map.insert( Qtopia::LastName, QObject::tr( "Last Name" ) );
+ ret_map.insert( Qtopia::Suffix, QObject::tr( "Suffix" ) );
+ ret_map.insert( Qtopia::FileAs, QObject::tr( "File As" ) );
+
+ ret_map.insert( Qtopia::JobTitle, QObject::tr( "Job Title" ) );
+ ret_map.insert( Qtopia::Department, QObject::tr( "Department" ) );
+ ret_map.insert( Qtopia::Company, QObject::tr( "Company" ) );
+ ret_map.insert( Qtopia::BusinessPhone, QObject::tr( "Business Phone" ) );
+ ret_map.insert( Qtopia::BusinessFax, QObject::tr( "Business Fax" ) );
+ ret_map.insert( Qtopia::BusinessMobile, QObject::tr( "Business Mobile" ) );
+
+ // email
+ ret_map.insert( Qtopia::DefaultEmail, QObject::tr( "Default Email" ) );
+ ret_map.insert( Qtopia::Emails, QObject::tr( "Emails" ) );
+
+ ret_map.insert( Qtopia::HomePhone, QObject::tr( "Home Phone" ) );
+ ret_map.insert( Qtopia::HomeFax, QObject::tr( "Home Fax" ) );
+ ret_map.insert( Qtopia::HomeMobile, QObject::tr( "Home Mobile" ) );
+
+ // business
+ ret_map.insert( Qtopia::BusinessStreet, QObject::tr( "Business Street" ) );
+ ret_map.insert( Qtopia::BusinessCity, QObject::tr( "Business City" ) );
+ ret_map.insert( Qtopia::BusinessState, QObject::tr( "Business State" ) );
+ ret_map.insert( Qtopia::BusinessZip, QObject::tr( "Business Zip" ) );
+ ret_map.insert( Qtopia::BusinessCountry, QObject::tr( "Business Country" ) );
+ ret_map.insert( Qtopia::BusinessPager, QObject::tr( "Business Pager" ) );
+ ret_map.insert( Qtopia::BusinessWebPage, QObject::tr( "Business WebPage" ) );
+
+ ret_map.insert( Qtopia::Office, QObject::tr( "Office" ) );
+ ret_map.insert( Qtopia::Profession, QObject::tr( "Profession" ) );
+ ret_map.insert( Qtopia::Assistant, QObject::tr( "Assistant" ) );
+ ret_map.insert( Qtopia::Manager, QObject::tr( "Manager" ) );
+
+ // home
+ ret_map.insert( Qtopia::HomeStreet, QObject::tr( "Home Street" ) );
+ ret_map.insert( Qtopia::HomeCity, QObject::tr( "Home City" ) );
+ ret_map.insert( Qtopia::HomeState, QObject::tr( "Home State" ) );
+ ret_map.insert( Qtopia::HomeZip, QObject::tr( "Home Zip" ) );
+ ret_map.insert( Qtopia::HomeCountry, QObject::tr( "Home Country" ) );
+ ret_map.insert( Qtopia::HomeWebPage, QObject::tr( "Home Web Page" ) );
+
+ //personal
+ ret_map.insert( Qtopia::Spouse, QObject::tr( "Spouse" ) );
+ ret_map.insert( Qtopia::Gender, QObject::tr( "Gender" ) );
+ ret_map.insert( Qtopia::Birthday, QObject::tr( "Birthday" ) );
+ ret_map.insert( Qtopia::Anniversary, QObject::tr( "Anniversary" ) );
+ ret_map.insert( Qtopia::Nickname, QObject::tr( "Nickname" ) );
+ ret_map.insert( Qtopia::Children, QObject::tr( "Children" ) );
+
+ // other
+ ret_map.insert( Qtopia::Notes, QObject::tr( "Notes" ) );
+
+
+ return ret_map;
}
QMap<int, QString> OContactFields::idToUntrFields()
{
- QMap<int, QString> ret_map;
-
- ret_map.insert( Qtopia::AddressUid, "User Id" );
- ret_map.insert( Qtopia::AddressCategory, "Categories" );
-
- ret_map.insert( Qtopia::Title, "Name Title" );
- ret_map.insert( Qtopia::FirstName, "First Name" );
- ret_map.insert( Qtopia::MiddleName, "Middle Name" );
- ret_map.insert( Qtopia::LastName, "Last Name" );
- ret_map.insert( Qtopia::Suffix, "Suffix" );
- ret_map.insert( Qtopia::FileAs, "File As" );
-
- ret_map.insert( Qtopia::JobTitle, "Job Title" );
- ret_map.insert( Qtopia::Department, "Department" );
- ret_map.insert( Qtopia::Company, "Company" );
- ret_map.insert( Qtopia::BusinessPhone, "Business Phone" );
- ret_map.insert( Qtopia::BusinessFax, "Business Fax" );
- ret_map.insert( Qtopia::BusinessMobile, "Business Mobile" );
-
- // email
- ret_map.insert( Qtopia::DefaultEmail, "Default Email" );
- ret_map.insert( Qtopia::Emails, "Emails" );
-
- ret_map.insert( Qtopia::HomePhone, "Home Phone" );
- ret_map.insert( Qtopia::HomeFax, "Home Fax" );
- ret_map.insert( Qtopia::HomeMobile, "Home Mobile" );
-
- // business
- ret_map.insert( Qtopia::BusinessStreet, "Business Street" );
- ret_map.insert( Qtopia::BusinessCity, "Business City" );
- ret_map.insert( Qtopia::BusinessState, "Business State" );
- ret_map.insert( Qtopia::BusinessZip, "Business Zip" );
- ret_map.insert( Qtopia::BusinessCountry, "Business Country" );
- ret_map.insert( Qtopia::BusinessPager, "Business Pager" );
- ret_map.insert( Qtopia::BusinessWebPage, "Business WebPage" );
-
- ret_map.insert( Qtopia::Office, "Office" );
- ret_map.insert( Qtopia::Profession, "Profession" );
- ret_map.insert( Qtopia::Assistant, "Assistant" );
- ret_map.insert( Qtopia::Manager, "Manager" );
-
- // home
- ret_map.insert( Qtopia::HomeStreet, "Home Street" );
- ret_map.insert( Qtopia::HomeCity, "Home City" );
- ret_map.insert( Qtopia::HomeState, "Home State" );
- ret_map.insert( Qtopia::HomeZip, "Home Zip" );
- ret_map.insert( Qtopia::HomeCountry, "Home Country" );
- ret_map.insert( Qtopia::HomeWebPage, "Home Web Page" );
-
- //personal
- ret_map.insert( Qtopia::Spouse, "Spouse" );
- ret_map.insert( Qtopia::Gender, "Gender" );
- ret_map.insert( Qtopia::Birthday, "Birthday" );
- ret_map.insert( Qtopia::Anniversary, "Anniversary" );
- ret_map.insert( Qtopia::Nickname, "Nickname" );
- ret_map.insert( Qtopia::Children, "Children" );
-
- // other
- ret_map.insert( Qtopia::Notes, "Notes" );
- ret_map.insert( Qtopia::Groups, "Groups" );
-
-
- return ret_map;
+ QMap<int, QString> ret_map;
+
+ ret_map.insert( Qtopia::AddressUid, "User Id" );
+ ret_map.insert( Qtopia::AddressCategory, "Categories" );
+
+ ret_map.insert( Qtopia::Title, "Name Title" );
+ ret_map.insert( Qtopia::FirstName, "First Name" );
+ ret_map.insert( Qtopia::MiddleName, "Middle Name" );
+ ret_map.insert( Qtopia::LastName, "Last Name" );
+ ret_map.insert( Qtopia::Suffix, "Suffix" );
+ ret_map.insert( Qtopia::FileAs, "File As" );
+
+ ret_map.insert( Qtopia::JobTitle, "Job Title" );
+ ret_map.insert( Qtopia::Department, "Department" );
+ ret_map.insert( Qtopia::Company, "Company" );
+ ret_map.insert( Qtopia::BusinessPhone, "Business Phone" );
+ ret_map.insert( Qtopia::BusinessFax, "Business Fax" );
+ ret_map.insert( Qtopia::BusinessMobile, "Business Mobile" );
+
+ // email
+ ret_map.insert( Qtopia::DefaultEmail, "Default Email" );
+ ret_map.insert( Qtopia::Emails, "Emails" );
+
+ ret_map.insert( Qtopia::HomePhone, "Home Phone" );
+ ret_map.insert( Qtopia::HomeFax, "Home Fax" );
+ ret_map.insert( Qtopia::HomeMobile, "Home Mobile" );
+
+ // business
+ ret_map.insert( Qtopia::BusinessStreet, "Business Street" );
+ ret_map.insert( Qtopia::BusinessCity, "Business City" );
+ ret_map.insert( Qtopia::BusinessState, "Business State" );
+ ret_map.insert( Qtopia::BusinessZip, "Business Zip" );
+ ret_map.insert( Qtopia::BusinessCountry, "Business Country" );
+ ret_map.insert( Qtopia::BusinessPager, "Business Pager" );
+ ret_map.insert( Qtopia::BusinessWebPage, "Business WebPage" );
+
+ ret_map.insert( Qtopia::Office, "Office" );
+ ret_map.insert( Qtopia::Profession, "Profession" );
+ ret_map.insert( Qtopia::Assistant, "Assistant" );
+ ret_map.insert( Qtopia::Manager, "Manager" );
+
+ // home
+ ret_map.insert( Qtopia::HomeStreet, "Home Street" );
+ ret_map.insert( Qtopia::HomeCity, "Home City" );
+ ret_map.insert( Qtopia::HomeState, "Home State" );
+ ret_map.insert( Qtopia::HomeZip, "Home Zip" );
+ ret_map.insert( Qtopia::HomeCountry, "Home Country" );
+ ret_map.insert( Qtopia::HomeWebPage, "Home Web Page" );
+
+ //personal
+ ret_map.insert( Qtopia::Spouse, "Spouse" );
+ ret_map.insert( Qtopia::Gender, "Gender" );
+ ret_map.insert( Qtopia::Birthday, "Birthday" );
+ ret_map.insert( Qtopia::Anniversary, "Anniversary" );
+ ret_map.insert( Qtopia::Nickname, "Nickname" );
+ ret_map.insert( Qtopia::Children, "Children" );
+
+ // other
+ ret_map.insert( Qtopia::Notes, "Notes" );
+ ret_map.insert( Qtopia::Groups, "Groups" );
+
+
+ return ret_map;
}
QMap<QString, int> OContactFields::trFieldsToId()
{
- QMap<int, QString> idtostr = idToTrFields();
- QMap<QString, int> ret_map;
+ QMap<int, QString> idtostr = idToTrFields();
+ QMap<QString, int> ret_map;
- QMap<int, QString>::Iterator it;
- for( it = idtostr.begin(); it != idtostr.end(); ++it )
- ret_map.insert( *it, it.key() );
+ QMap<int, QString>::Iterator it;
+ for ( it = idtostr.begin(); it != idtostr.end(); ++it )
+ ret_map.insert( *it, it.key() );
- return ret_map;
+ return ret_map;
}
/* ======================================================================= */
QMap<QString, int> OContactFields::untrFieldsToId()
{
- QMap<int, QString> idtostr = idToUntrFields();
- QMap<QString, int> ret_map;
+ QMap<int, QString> idtostr = idToUntrFields();
+ QMap<QString, int> ret_map;
- QMap<int, QString>::Iterator it;
- for( it = idtostr.begin(); it != idtostr.end(); ++it )
- ret_map.insert( *it, it.key() );
+ QMap<int, QString>::Iterator it;
+ for ( it = idtostr.begin(); it != idtostr.end(); ++it )
+ ret_map.insert( *it, it.key() );
- return ret_map;
+ return ret_map;
}
-OContactFields::OContactFields():
- fieldOrder( DEFAULT_FIELD_ORDER ),
- changedFieldOrder( false )
+OContactFields::OContactFields() :
+ fieldOrder( DEFAULT_FIELD_ORDER ),
+ changedFieldOrder( false )
{
- // Get the global field order from the config file and
- // use it as a start pattern
- Config cfg ( "AddressBook" );
- cfg.setGroup( "ContactFieldOrder" );
- globalFieldOrder = cfg.readEntry( "General", DEFAULT_FIELD_ORDER );
+ // Get the global field order from the config file and
+ // use it as a start pattern
+ Config cfg ( "AddressBook" );
+ cfg.setGroup( "ContactFieldOrder" );
+ globalFieldOrder = cfg.readEntry( "General", DEFAULT_FIELD_ORDER );
}
-OContactFields::~OContactFields(){
+OContactFields::~OContactFields()
+{
- // We will store the fieldorder into the config file
- // to reuse it for the future..
- if ( changedFieldOrder ){
- Config cfg ( "AddressBook" );
- cfg.setGroup( "ContactFieldOrder" );
- cfg.writeEntry( "General", globalFieldOrder );
- }
+ // We will store the fieldorder into the config file
+ // to reuse it for the future..
+ if ( changedFieldOrder )
+ {
+ Config cfg ( "AddressBook" );
+ cfg.setGroup( "ContactFieldOrder" );
+ cfg.writeEntry( "General", globalFieldOrder );
+ }
}
-void OContactFields::saveToRecord( OContact &cnt ){
+void OContactFields::saveToRecord( OContact &cnt )
+{
- qDebug("ocontactfields saveToRecord: >%s<",fieldOrder.latin1());
+ qDebug( "ocontactfields saveToRecord: >%s<", fieldOrder.latin1() );
- // Store fieldorder into this contact.
- cnt.setCustomField( CONTACT_FIELD_ORDER_NAME, fieldOrder );
+ // Store fieldorder into this contact.
+ cnt.setCustomField( CONTACT_FIELD_ORDER_NAME, fieldOrder );
- globalFieldOrder = fieldOrder;
- changedFieldOrder = true;
+ globalFieldOrder = fieldOrder;
+ changedFieldOrder = true;
}
-void OContactFields::loadFromRecord( const OContact &cnt ){
- qDebug("ocontactfields loadFromRecord");
- qDebug("loading >%s<",cnt.fullName().latin1());
+void OContactFields::loadFromRecord( const OContact &cnt )
+{
+ qDebug( "ocontactfields loadFromRecord" );
+ qDebug( "loading >%s<", cnt.fullName().latin1() );
- // Get fieldorder for this contact. If none is defined,
- // we will use the global one from the config file..
+ // Get fieldorder for this contact. If none is defined,
+ // we will use the global one from the config file..
- fieldOrder = cnt.customField( CONTACT_FIELD_ORDER_NAME );
+ fieldOrder = cnt.customField( CONTACT_FIELD_ORDER_NAME );
- qDebug("fieldOrder from contact>%s<",fieldOrder.latin1());
+ qDebug( "fieldOrder from contact>%s<", fieldOrder.latin1() );
- if (fieldOrder.isEmpty()){
- fieldOrder = globalFieldOrder;
- }
+ if ( fieldOrder.isEmpty() )
+ {
+ fieldOrder = globalFieldOrder;
+ }
- qDebug("effective fieldOrder in loadFromRecord >%s<",fieldOrder.latin1());
+ qDebug( "effective fieldOrder in loadFromRecord >%s<", fieldOrder.latin1() );
}
-void OContactFields::setFieldOrder( int num, int index ){
- qDebug("qcontactfields setfieldorder pos %i -> %i",num,index);
+void OContactFields::setFieldOrder( int num, int index )
+{
+ qDebug( "qcontactfields setfieldorder pos %i -> %i", num, index );
- fieldOrder[num] = QString::number( index, 16 )[0];
+ fieldOrder[ num ] = QString::number( index, 16 ) [ 0 ];
- // We will store this new fieldorder globally to
- // remember it for contacts which have none
- globalFieldOrder = fieldOrder;
- changedFieldOrder = true;
+ // We will store this new fieldorder globally to
+ // remember it for contacts which have none
+ globalFieldOrder = fieldOrder;
+ changedFieldOrder = true;
- qDebug("fieldOrder >%s<",fieldOrder.latin1());
+ qDebug( "fieldOrder >%s<", fieldOrder.latin1() );
}
-int OContactFields::getFieldOrder( int num, int defIndex ){
- qDebug("ocontactfields getFieldOrder");
- qDebug("fieldOrder >%s<",fieldOrder.latin1());
+int OContactFields::getFieldOrder( int num, int defIndex )
+{
+ qDebug( "ocontactfields getFieldOrder" );
+ qDebug( "fieldOrder >%s<", fieldOrder.latin1() );
- // Get index of combo as char..
- QChar poschar = fieldOrder[num];
+ // Get index of combo as char..
+ QChar poschar = fieldOrder[ num ];
- bool ok;
- int ret = 0;
- // Convert char to number..
- if ( !( poschar == QChar::null ) )
- ret = QString( poschar ).toInt(&ok, 16);
- else
- ok = false;
+ bool ok;
+ int ret = 0;
+ // Convert char to number..
+ if ( !( poschar == QChar::null ) )
+ ret = QString( poschar ).toInt( &ok, 16 );
+ else
+ ok = false;
- // Return default value if index for
- // num was not set or if anything else happened..
- if ( !ok ) ret = defIndex;
+ // Return default value if index for
+ // num was not set or if anything else happened..
+ if ( !ok ) ret = defIndex;
- qDebug("returning >%i<",ret);
+ qDebug( "returning >%i<", ret );
- return ret;
+ return ret;
}
diff --git a/libopie2/opiepim/ocontactfields.h b/libopie2/opiepim/ocontactfields.h
index 993ce3b..9e89532 100644
--- a/libopie2/opiepim/ocontactfields.h
+++ b/libopie2/opiepim/ocontactfields.h
@@ -26,22 +26,28 @@
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
-#ifndef OPIE_CONTACTS_FIELDS
-#define OPIE_CONTACTS_FIELDS
+
+#ifndef OCONTACTFIELDS_H
+#define OCONTACTFIELDS_H
class QStringList;
+/* OPIE */
+#include <opie2/ocontact.h>
+
+/* QT */
#include <qmap.h>
#include <qstring.h>
-#include <opie2/ocontact.h>
#define CONTACT_FIELD_ORDER_NAME "opie-contactfield-order"
#define DEFAULT_FIELD_ORDER "__________"
-
-namespace Opie {
-class OContactFields{
- public:
+namespace Opie
+{
+class OContactFields
+{
+
+ public:
OContactFields();
~OContactFields();
/** Set the index for combo boxes.
@@ -55,28 +61,28 @@ class OContactFields{
* Returns the index of combo <b>num</b> or defindex
* if none was defined..
* @param num Selects the number of the combo
- * @param defIndex will be returned if none was defined (either
- * globally in the config file, nor by the contact which was used
+ * @param defIndex will be returned if none was defined (either
+ * globally in the config file, nor by the contact which was used
* by loadFromRecord() )
*/
- int getFieldOrder( int num, int defIndex);
+ int getFieldOrder( int num, int defIndex );
/** Store fieldorder to contact. */
void saveToRecord( OContact& );
/** Get Fieldorder from contact. */
void loadFromRecord( const OContact& );
- private:
+ private:
QString fieldOrder;
QString globalFieldOrder;
bool changedFieldOrder;
- public:
+ public:
static QStringList personalfields( bool sorted = true, bool translated = false );
static QStringList phonefields( bool sorted = true, bool translated = false );
static QStringList detailsfields( bool sorted = true, bool translated = false );
static QStringList fields( bool sorted = true, bool translated = false );
-
+
static QStringList trpersonalfields( bool sorted = true );
static QStringList untrpersonalfields( bool sorted = true );
static QStringList trphonefields( bool sorted = true );
diff --git a/libopie2/opiepim/oevent.cpp b/libopie2/opiepim/oevent.cpp
index de5e30b..d9cee2b 100644
--- a/libopie2/opiepim/oevent.cpp
+++ b/libopie2/opiepim/oevent.cpp
@@ -1,6 +1,6 @@
/*
This file is part of the Opie Project
- Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de)
+ Copyright (C) Stefan Eilers <Eilers.Stefan@epost.de>
=. Copyright (C) The Opie Team <opie-devel@handhelds.org>
.=l.
.>+-=
@@ -26,22 +26,26 @@
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
-#include <qshared.h>
-#include <qarray.h>
-#include <qpe/palmtopuidgen.h>
-#include <qpe/categories.h>
-#include <qpe/stringutil.h>
+#include "oevent.h"
+/* OPIE */
#include <opie2/orecur.h>
#include <opie2/opimresolver.h>
#include <opie2/opimnotifymanager.h>
+#include <qpe/categories.h>
+#include <qpe/palmtopuidgen.h>
+#include <qpe/stringutil.h>
-#include <opie2/oevent.h>
+/* QT */
+#include <qshared.h>
+#include <qarray.h>
-namespace Opie {
+namespace Opie
+{
-int OCalendarHelper::week( const QDate& date) {
+int OCalendarHelper::week( const QDate& date )
+{
// Calculates the week this date is in within that
// month. Equals the "row" is is in in the month view
int week = 1;
@@ -53,34 +57,48 @@ int OCalendarHelper::week( const QDate& date) {
return week;
}
-int OCalendarHelper::ocurrence( const QDate& date) {
+
+
+int OCalendarHelper::ocurrence( const QDate& date )
+{
// calculates the number of occurrances of this day of the
// week till the given date (e.g 3rd Wednesday of the month)
return ( date.day() - 1 ) / 7 + 1;
}
-int OCalendarHelper::dayOfWeek( char day ) {
+
+
+int OCalendarHelper::dayOfWeek( char day )
+{
int dayOfWeek = 1;
char i = ORecur::MON;
- while ( !( i & day ) && i <= ORecur::SUN ) {
+ while ( !( i & day ) && i <= ORecur::SUN )
+ {
i <<= 1;
++dayOfWeek;
}
return dayOfWeek;
}
-int OCalendarHelper::monthDiff( const QDate& first, const QDate& second ) {
+
+
+int OCalendarHelper::monthDiff( const QDate& first, const QDate& second )
+{
return ( second.year() - first.year() ) * 12 +
- second.month() - first.month();
+ second.month() - first.month();
}
-struct OEvent::Data : public QShared {
- Data() : QShared() {
+
+struct OEvent::Data : public QShared
+{
+ Data() : QShared()
+ {
child = 0;
recur = 0;
manager = 0;
isAllDay = false;
parent = 0;
}
- ~Data() {
+ ~Data()
+ {
delete manager;
delete recur;
}
@@ -92,38 +110,49 @@ struct OEvent::Data : public QShared {
QDateTime created;
QDateTime start;
QDateTime end;
- bool isAllDay : 1;
+bool isAllDay : 1;
QString timezone;
QArray<int>* child;
int parent;
};
+
OEvent::OEvent( int uid )
- : OPimRecord( uid ) {
+ : OPimRecord( uid )
+{
data = new Data;
}
-OEvent::OEvent( const OEvent& ev)
- : OPimRecord( ev ), data( ev.data )
+
+
+OEvent::OEvent( const OEvent& ev )
+ : OPimRecord( ev ), data( ev.data )
{
data->ref();
}
+
OEvent::OEvent( const QMap<int, QString> map )
- : OPimRecord( 0 )
+ : OPimRecord( 0 )
{
- data = new Data;
+ data = new Data;
- fromMap( map );
+ fromMap( map );
}
-OEvent::~OEvent() {
- if ( data->deref() ) {
+
+OEvent::~OEvent()
+{
+ if ( data->deref() )
+ {
delete data;
data = 0;
}
}
-OEvent& OEvent::operator=( const OEvent& ev) {
- if ( this == &ev ) return *this;
+
+
+OEvent& OEvent::operator=( const OEvent& ev )
+{
+ if ( this == &ev ) return * this;
OPimRecord::operator=( ev );
ev.data->ref();
@@ -133,205 +162,300 @@ OEvent& OEvent::operator=( const OEvent& ev) {
return *this;
}
-QString OEvent::description()const {
+
+
+QString OEvent::description() const
+{
return data->description;
}
-void OEvent::setDescription( const QString& description ) {
+
+
+void OEvent::setDescription( const QString& description )
+{
changeOrModify();
data->description = description;
}
-void OEvent::setLocation( const QString& loc ) {
+
+
+void OEvent::setLocation( const QString& loc )
+{
changeOrModify();
data->location = loc;
}
-QString OEvent::location()const {
+
+
+QString OEvent::location() const
+{
return data->location;
}
-OPimNotifyManager &OEvent::notifiers()const {
+
+
+OPimNotifyManager &OEvent::notifiers() const
+{
// I hope we can skip the changeOrModify here
// the notifier should take care of it
// and OPimNotify is shared too
- if (!data->manager )
+ if ( !data->manager )
data->manager = new OPimNotifyManager;
return *data->manager;
}
-bool OEvent::hasNotifiers()const {
- if (!data->manager )
+
+
+bool OEvent::hasNotifiers() const
+{
+ if ( !data->manager )
return false;
- if (data->manager->reminders().isEmpty() &&
- data->manager->alarms().isEmpty() )
+ if ( data->manager->reminders().isEmpty() &&
+ data->manager->alarms().isEmpty() )
return false;
return true;
}
-ORecur OEvent::recurrence()const {
- if (!data->recur)
+
+
+ORecur OEvent::recurrence() const
+{
+ if ( !data->recur )
data->recur = new ORecur;
return *data->recur;
}
-void OEvent::setRecurrence( const ORecur& rec) {
+
+
+void OEvent::setRecurrence( const ORecur& rec )
+{
changeOrModify();
- if (data->recur )
- (*data->recur) = rec;
+ if ( data->recur )
+ ( *data->recur ) = rec;
else
data->recur = new ORecur( rec );
}
-bool OEvent::hasRecurrence()const {
- if (!data->recur ) return false;
+
+
+bool OEvent::hasRecurrence() const
+{
+ if ( !data->recur ) return false;
return data->recur->doesRecur();
}
-QString OEvent::note()const {
+
+
+QString OEvent::note() const
+{
return data->note;
}
-void OEvent::setNote( const QString& note ) {
+
+
+void OEvent::setNote( const QString& note )
+{
changeOrModify();
data->note = note;
}
-QDateTime OEvent::createdDateTime()const {
+
+
+QDateTime OEvent::createdDateTime() const
+{
return data->created;
}
-void OEvent::setCreatedDateTime( const QDateTime& time ) {
+
+
+void OEvent::setCreatedDateTime( const QDateTime& time )
+{
changeOrModify();
data->created = time;
}
-QDateTime OEvent::startDateTime()const {
+
+
+QDateTime OEvent::startDateTime() const
+{
if ( data->isAllDay )
- return QDateTime( data->start.date(), QTime(0, 0, 0 ) );
+ return QDateTime( data->start.date(), QTime( 0, 0, 0 ) );
return data->start;
}
-QDateTime OEvent::startDateTimeInZone()const {
+
+
+QDateTime OEvent::startDateTimeInZone() const
+{
/* if no timezone, or all day event or if the current and this timeZone match... */
- if (data->timezone.isEmpty() || data->isAllDay || data->timezone == OTimeZone::current().timeZone() ) return startDateTime();
+ if ( data->timezone.isEmpty() || data->isAllDay || data->timezone == OTimeZone::current().timeZone() ) return startDateTime();
- OTimeZone zone(data->timezone );
+ OTimeZone zone( data->timezone );
return zone.toDateTime( data->start, OTimeZone::current() );
}
-void OEvent::setStartDateTime( const QDateTime& dt ) {
+
+
+void OEvent::setStartDateTime( const QDateTime& dt )
+{
changeOrModify();
data->start = dt;
}
-QDateTime OEvent::endDateTime()const {
+
+
+QDateTime OEvent::endDateTime() const
+{
/*
* if all Day event the end time needs
* to be on the same day as the start
*/
if ( data->isAllDay )
- return QDateTime( data->start.date(), QTime(23, 59, 59 ) );
+ return QDateTime( data->start.date(), QTime( 23, 59, 59 ) );
return data->end;
}
-QDateTime OEvent::endDateTimeInZone()const {
+
+
+QDateTime OEvent::endDateTimeInZone() const
+{
/* if no timezone, or all day event or if the current and this timeZone match... */
- if (data->timezone.isEmpty() || data->isAllDay || data->timezone == OTimeZone::current().timeZone() ) return endDateTime();
+ if ( data->timezone.isEmpty() || data->isAllDay || data->timezone == OTimeZone::current().timeZone() ) return endDateTime();
- OTimeZone zone(data->timezone );
+ OTimeZone zone( data->timezone );
return zone.toDateTime( data->end, OTimeZone::current() );
}
-void OEvent::setEndDateTime( const QDateTime& dt ) {
+
+
+void OEvent::setEndDateTime( const QDateTime& dt )
+{
changeOrModify();
- data->end = dt;
+ data->end = dt;
}
-bool OEvent::isMultipleDay()const {
+
+
+bool OEvent::isMultipleDay() const
+{
return data->end.date().day() - data->start.date().day();
}
-bool OEvent::isAllDay()const {
+
+
+bool OEvent::isAllDay() const
+{
return data->isAllDay;
}
-void OEvent::setAllDay( bool allDay ) {
+
+
+void OEvent::setAllDay( bool allDay )
+{
changeOrModify();
data->isAllDay = allDay;
- if (allDay ) data->timezone = "UTC";
+ if ( allDay ) data->timezone = "UTC";
}
-void OEvent::setTimeZone( const QString& tz ) {
+
+
+void OEvent::setTimeZone( const QString& tz )
+{
changeOrModify();
data->timezone = tz;
}
-QString OEvent::timeZone()const {
- if (data->isAllDay ) return QString::fromLatin1("UTC");
+
+
+QString OEvent::timeZone() const
+{
+ if ( data->isAllDay ) return QString::fromLatin1( "UTC" );
return data->timezone;
}
-bool OEvent::match( const QRegExp& re )const {
- if ( re.match( data->description ) != -1 ){
+
+
+bool OEvent::match( const QRegExp& re ) const
+{
+ if ( re.match( data->description ) != -1 )
+ {
setLastHitField( Qtopia::DatebookDescription );
return true;
}
- if ( re.match( data->note ) != -1 ){
+ if ( re.match( data->note ) != -1 )
+ {
setLastHitField( Qtopia::Note );
return true;
}
- if ( re.match( data->location ) != -1 ){
+ if ( re.match( data->location ) != -1 )
+ {
setLastHitField( Qtopia::Location );
return true;
}
- if ( re.match( data->start.toString() ) != -1 ){
+ if ( re.match( data->start.toString() ) != -1 )
+ {
setLastHitField( Qtopia::StartDateTime );
return true;
}
- if ( re.match( data->end.toString() ) != -1 ){
+ if ( re.match( data->end.toString() ) != -1 )
+ {
setLastHitField( Qtopia::EndDateTime );
return true;
}
return false;
}
-QString OEvent::toRichText()const {
+
+
+QString OEvent::toRichText() const
+{
QString text, value;
// description
text += "<b><h3><img src=\"datebook/DateBook\">";
- if ( !description().isEmpty() ) {
- text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "" );
+ if ( !description().isEmpty() )
+ {
+ text += Qtopia::escapeString( description() ).replace( QRegExp( "[\n]" ), "" );
}
text += "</h3></b><br><hr><br>";
// location
- if ( !(value = location()).isEmpty() ) {
+ if ( !( value = location() ).isEmpty() )
+ {
text += "<b>" + QObject::tr( "Location:" ) + "</b> ";
- text += Qtopia::escapeString(value) + "<br>";
+ text += Qtopia::escapeString( value ) + "<br>";
}
// all day event
- if ( isAllDay() ) {
+ if ( isAllDay() )
+ {
text += "<b><i>" + QObject::tr( "This is an all day event" ) + "</i></b><br>";
}
// multiple day event
- else if ( isMultipleDay () ) {
+ else if ( isMultipleDay () )
+ {
text += "<b><i>" + QObject::tr( "This is a multiple day event" ) + "</i></b><br>";
}
// start & end times
- else {
+ else
+ {
// start time
- if ( startDateTime().isValid() ) {
- text += "<b>" + QObject::tr( "Start:") + "</b> ";
- text += Qtopia::escapeString(startDateTime().toString() ).
- replace(QRegExp( "[\n]"), "<br>" ) + "<br>";
+ if ( startDateTime().isValid() )
+ {
+ text += "<b>" + QObject::tr( "Start:" ) + "</b> ";
+ text += Qtopia::escapeString( startDateTime().toString() ).
+ replace( QRegExp( "[\n]" ), "<br>" ) + "<br>";
}
// end time
- if ( endDateTime().isValid() ) {
- text += "<b>" + QObject::tr( "End:") + "</b> ";
- text += Qtopia::escapeString(endDateTime().toString() ).
- replace(QRegExp( "[\n]"), "<br>" ) + "<br>";
+ if ( endDateTime().isValid() )
+ {
+ text += "<b>" + QObject::tr( "End:" ) + "</b> ";
+ text += Qtopia::escapeString( endDateTime().toString() ).
+ replace( QRegExp( "[\n]" ), "<br>" ) + "<br>";
}
}
// categories
- if ( categoryNames("Calendar").count() ){
- text += "<b>" + QObject::tr( "Category:") + "</b> ";
- text += categoryNames("Calendar").join(", ");
- text += "<br>";
+ if ( categoryNames( "Calendar" ).count() )
+ {
+ text += "<b>" + QObject::tr( "Category:" ) + "</b> ";
+ text += categoryNames( "Calendar" ).join( ", " );
+ text += "<br>";
}
//notes
- if ( !note().isEmpty() ) {
- text += "<b>" + QObject::tr( "Note:") + "</b><br>";
+ if ( !note().isEmpty() )
+ {
+ text += "<b>" + QObject::tr( "Note:" ) + "</b><br>";
text += note();
-// text += Qtopia::escapeString(note() ).
-// replace(QRegExp( "[\n]"), "<br>" ) + "<br>";
+ // text += Qtopia::escapeString(note() ).
+ // replace(QRegExp( "[\n]"), "<br>" ) + "<br>";
}
return text;
}
-QString OEvent::toShortText()const {
+
+
+QString OEvent::toShortText() const
+{
QString text;
text += QString::number( startDateTime().date().day() );
text += ".";
@@ -346,29 +470,48 @@ QString OEvent::toShortText()const {
text += description();
return text;
}
-QString OEvent::type()const {
- return QString::fromLatin1("OEvent");
+
+
+QString OEvent::type() const
+{
+ return QString::fromLatin1( "OEvent" );
}
-QString OEvent::recordField( int /*id */ )const {
+
+
+QString OEvent::recordField( int /*id */ ) const
+{
return QString::null;
}
-int OEvent::rtti() {
+
+
+int OEvent::rtti()
+{
return OPimResolver::DateBook;
}
-bool OEvent::loadFromStream( QDataStream& ) {
+
+
+bool OEvent::loadFromStream( QDataStream& )
+{
return true;
}
-bool OEvent::saveToStream( QDataStream& )const {
+
+
+bool OEvent::saveToStream( QDataStream& ) const
+{
return true;
}
-void OEvent::changeOrModify() {
- if ( data->count != 1 ) {
+
+
+void OEvent::changeOrModify()
+{
+ if ( data->count != 1 )
+ {
data->deref();
Data* d2 = new Data;
d2->description = data->description;
d2->location = data->location;
- if (data->manager )
+ if ( data->manager )
d2->manager = new OPimNotifyManager( *data->manager );
if ( data->recur )
@@ -382,7 +525,8 @@ void OEvent::changeOrModify() {
d2->timezone = data->timezone;
d2->parent = data->parent;
- if ( data->child ) {
+ if ( data->child )
+ {
d2->child = new QArray<int>( *data->child );
d2->child->detach();
}
@@ -390,8 +534,12 @@ void OEvent::changeOrModify() {
data = d2;
}
}
-void OEvent::deref() {
- if ( data->deref() ) {
+
+
+void OEvent::deref()
+{
+ if ( data->deref() )
+ {
delete data;
data = 0;
}
@@ -401,197 +549,241 @@ void OEvent::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> OEvent::toMap()const {
+QMap<int, QString> OEvent::toMap() const
+{
QMap<int, QString> retMap;
retMap.insert( OEvent::FUid, QString::number( uid() ) );
- retMap.insert( OEvent::FCategories, Qtopia::escapeString( Qtopia::Record::idsToString( categories() ) ));
+ retMap.insert( OEvent::FCategories, Qtopia::escapeString( Qtopia::Record::idsToString( categories() ) ) );
retMap.insert( OEvent::FDescription, Qtopia::escapeString( description() ) );
retMap.insert( OEvent::FLocation, Qtopia::escapeString( location() ) );
retMap.insert( OEvent::FType, isAllDay() ? "AllDay" : "" );
- OPimAlarm alarm = notifiers().alarms()[0];
- retMap.insert( OEvent::FAlarm, QString::number( alarm.dateTime().secsTo( startDateTime() ) / 60 ) );
- retMap.insert( OEvent::FSound, (alarm.sound() == OPimAlarm::Loud) ? "loud" : "silent" );
+ OPimAlarm alarm = notifiers().alarms() [ 0 ];
+ retMap.insert( OEvent::FAlarm, QString::number( alarm.dateTime().secsTo( startDateTime() ) / 60 ) );
+ retMap.insert( OEvent::FSound, ( alarm.sound() == OPimAlarm::Loud ) ? "loud" : "silent" );
- OTimeZone zone( timeZone().isEmpty() ? OTimeZone::current() : timeZone() );
- retMap.insert( OEvent::FStart, QString::number( zone.fromUTCDateTime( zone.toDateTime( startDateTime(), OTimeZone::utc() ) ) ) );
- retMap.insert( OEvent::FEnd, QString::number( zone.fromUTCDateTime( zone.toDateTime( endDateTime(), OTimeZone::utc() ) ) ) );
+ OTimeZone zone( timeZone().isEmpty() ? OTimeZone::current() : timeZone() );
+ retMap.insert( OEvent::FStart, QString::number( zone.fromUTCDateTime( zone.toDateTime( startDateTime(), OTimeZone::utc() ) ) ) );
+ retMap.insert( OEvent::FEnd, QString::number( zone.fromUTCDateTime( zone.toDateTime( endDateTime(), OTimeZone::utc() ) ) ) );
retMap.insert( OEvent::FNote, Qtopia::escapeString( note() ) );
retMap.insert( OEvent::FTimeZone, timeZone().isEmpty() ? QString( "None" ) : timeZone() );
- if( parent() )
- retMap.insert( OEvent::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] );
- }
- retMap.insert( OEvent::FRecChildren, buf );
- }
-
+ if ( parent() )
+ retMap.insert( OEvent::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 ] );
+ }
+ retMap.insert( OEvent::FRecChildren, buf );
+ }
+
// Add recurrence stuff
- if( hasRecurrence() ){
- ORecur recur = recurrence();
- QMap<int, QString> recFields = recur.toMap();
- retMap.insert( OEvent::FRType, recFields[ORecur::RType] );
- retMap.insert( OEvent::FRWeekdays, recFields[ORecur::RWeekdays] );
- retMap.insert( OEvent::FRPosition, recFields[ORecur::RPosition] );
- retMap.insert( OEvent::FRFreq, recFields[ORecur::RFreq] );
- retMap.insert( OEvent::FRHasEndDate, recFields[ORecur::RHasEndDate] );
- retMap.insert( OEvent::FREndDate, recFields[ORecur::EndDate] );
- retMap.insert( OEvent::FRCreated, recFields[ORecur::Created] );
- retMap.insert( OEvent::FRExceptions, recFields[ORecur::Exceptions] );
- } else {
- ORecur recur = recurrence();
- QMap<int, QString> recFields = recur.toMap();
- retMap.insert( OEvent::FRType, recFields[ORecur::RType] );
- }
-
+ if ( hasRecurrence() )
+ {
+ ORecur recur = recurrence();
+ QMap<int, QString> recFields = recur.toMap();
+ retMap.insert( OEvent::FRType, recFields[ ORecur::RType ] );
+ retMap.insert( OEvent::FRWeekdays, recFields[ ORecur::RWeekdays ] );
+ retMap.insert( OEvent::FRPosition, recFields[ ORecur::RPosition ] );
+ retMap.insert( OEvent::FRFreq, recFields[ ORecur::RFreq ] );
+ retMap.insert( OEvent::FRHasEndDate, recFields[ ORecur::RHasEndDate ] );
+ retMap.insert( OEvent::FREndDate, recFields[ ORecur::EndDate ] );
+ retMap.insert( OEvent::FRCreated, recFields[ ORecur::Created ] );
+ retMap.insert( OEvent::FRExceptions, recFields[ ORecur::Exceptions ] );
+ }
+ else
+ {
+ ORecur recur = recurrence();
+ QMap<int, QString> recFields = recur.toMap();
+ retMap.insert( OEvent::FRType, recFields[ ORecur::RType ] );
+ }
+
return retMap;
}
+
void OEvent::fromMap( const QMap<int, QString>& map )
{
- // We just want to set the UID if it is really stored.
- if ( !map[OEvent::FUid].isEmpty() )
- setUid( map[OEvent::FUid].toInt() );
-
- setCategories( idsFromString( map[OEvent::FCategories] ) );
- setDescription( map[OEvent::FDescription] );
- setLocation( map[OEvent::FLocation] );
-
- if ( map[OEvent::FType] == "AllDay" )
- setAllDay( true );
- else
- setAllDay( false );
-
- int alarmTime = -1;
- if( !map[OEvent::FAlarm].isEmpty() )
- alarmTime = map[OEvent::FAlarm].toInt();
-
- int sound = ( ( map[OEvent::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[OEvent::FTimeZone].isEmpty() && ( map[OEvent::FTimeZone] != "None" ) ){
- setTimeZone( map[OEvent::FTimeZone] );
- }
-
- time_t start = (time_t) map[OEvent::FStart].toLong();
- time_t end = (time_t) map[OEvent::FEnd].toLong();
-
- /* AllDay is always in UTC */
- if ( isAllDay() ) {
- OTimeZone utc = OTimeZone::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 );
- OTimeZone zone( timeZone().isEmpty() ? OTimeZone::current() : timeZone() );
- QDateTime date = zone.toDateTime( start );
- qWarning(" Start is %s", date.toString().latin1() );
- setStartDateTime( zone.toDateTime( date, OTimeZone::current() ) );
-
- date = zone.toDateTime( end );
- setEndDateTime ( zone.toDateTime( date, OTimeZone::current() ) );
- }
-
- if ( !map[OEvent::FRecParent].isEmpty() )
- setParent( map[OEvent::FRecParent].toInt() );
-
- if ( !map[OEvent::FRecChildren].isEmpty() ){
- QStringList list = QStringList::split(' ', map[OEvent::FRecChildren] );
- for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
- addChild( (*it).toInt() );
- }
- }
-
- // Fill recurrence stuff and put it directly into the ORecur-Object using fromMap..
- if( !map[OEvent::FRType].isEmpty() ){
- QMap<int, QString> recFields;
- recFields.insert( ORecur::RType, map[OEvent::FRType] );
- recFields.insert( ORecur::RWeekdays, map[OEvent::FRWeekdays] );
- recFields.insert( ORecur::RPosition, map[OEvent::FRPosition] );
- recFields.insert( ORecur::RFreq, map[OEvent::FRFreq] );
- recFields.insert( ORecur::RHasEndDate, map[OEvent::FRHasEndDate] );
- recFields.insert( ORecur::EndDate, map[OEvent::FREndDate] );
- recFields.insert( ORecur::Created, map[OEvent::FRCreated] );
- recFields.insert( ORecur::Exceptions, map[OEvent::FRExceptions] );
- ORecur recur( recFields );
- setRecurrence( recur );
- }
-
-}
-
-
-int OEvent::parent()const {
+ // We just want to set the UID if it is really stored.
+ if ( !map[ OEvent::FUid ].isEmpty() )
+ setUid( map[ OEvent::FUid ].toInt() );
+
+ setCategories( idsFromString( map[ OEvent::FCategories ] ) );
+ setDescription( map[ OEvent::FDescription ] );
+ setLocation( map[ OEvent::FLocation ] );
+
+ if ( map[ OEvent::FType ] == "AllDay" )
+ setAllDay( true );
+ else
+ setAllDay( false );
+
+ int alarmTime = -1;
+ if ( !map[ OEvent::FAlarm ].isEmpty() )
+ alarmTime = map[ OEvent::FAlarm ].toInt();
+
+ int sound = ( ( map[ OEvent::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[ OEvent::FTimeZone ].isEmpty() && ( map[ OEvent::FTimeZone ] != "None" ) )
+ {
+ setTimeZone( map[ OEvent::FTimeZone ] );
+ }
+
+ time_t start = ( time_t ) map[ OEvent::FStart ].toLong();
+ time_t end = ( time_t ) map[ OEvent::FEnd ].toLong();
+
+ /* AllDay is always in UTC */
+ if ( isAllDay() )
+ {
+ OTimeZone utc = OTimeZone::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 );
+ OTimeZone zone( timeZone().isEmpty() ? OTimeZone::current() : timeZone() );
+ QDateTime date = zone.toDateTime( start );
+ qWarning( " Start is %s", date.toString().latin1() );
+ setStartDateTime( zone.toDateTime( date, OTimeZone::current() ) );
+
+ date = zone.toDateTime( end );
+ setEndDateTime ( zone.toDateTime( date, OTimeZone::current() ) );
+ }
+
+ if ( !map[ OEvent::FRecParent ].isEmpty() )
+ setParent( map[ OEvent::FRecParent ].toInt() );
+
+ if ( !map[ OEvent::FRecChildren ].isEmpty() )
+ {
+ QStringList list = QStringList::split( ' ', map[ OEvent::FRecChildren ] );
+ for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it )
+ {
+ addChild( ( *it ).toInt() );
+ }
+ }
+
+ // Fill recurrence stuff and put it directly into the ORecur-Object using fromMap..
+ if ( !map[ OEvent::FRType ].isEmpty() )
+ {
+ QMap<int, QString> recFields;
+ recFields.insert( ORecur::RType, map[ OEvent::FRType ] );
+ recFields.insert( ORecur::RWeekdays, map[ OEvent::FRWeekdays ] );
+ recFields.insert( ORecur::RPosition, map[ OEvent::FRPosition ] );
+ recFields.insert( ORecur::RFreq, map[ OEvent::FRFreq ] );
+ recFields.insert( ORecur::RHasEndDate, map[ OEvent::FRHasEndDate ] );
+ recFields.insert( ORecur::EndDate, map[ OEvent::FREndDate ] );
+ recFields.insert( ORecur::Created, map[ OEvent::FRCreated ] );
+ recFields.insert( ORecur::Exceptions, map[ OEvent::FRExceptions ] );
+ ORecur recur( recFields );
+ setRecurrence( recur );
+ }
+
+}
+
+
+int OEvent::parent() const
+{
return data->parent;
}
-void OEvent::setParent( int uid ) {
+
+
+void OEvent::setParent( int uid )
+{
changeOrModify();
data->parent = uid;
}
-QArray<int> OEvent::children() const{
- if (!data->child) return QArray<int>();
+
+
+QArray<int> OEvent::children() const
+{
+ if ( !data->child ) return QArray<int>();
else
return data->child->copy();
}
-void OEvent::setChildren( const QArray<int>& arr ) {
+
+
+void OEvent::setChildren( const QArray<int>& arr )
+{
changeOrModify();
- if (data->child) delete data->child;
+ if ( data->child ) delete data->child;
data->child = new QArray<int>( arr );
data->child->detach();
}
-void OEvent::addChild( int uid ) {
+
+
+void OEvent::addChild( int uid )
+{
changeOrModify();
- if (!data->child ) {
- data->child = new QArray<int>(1);
- (*data->child)[0] = uid;
- }else{
+ if ( !data->child )
+ {
+ data->child = new QArray<int>( 1 );
+ ( *data->child ) [ 0 ] = uid;
+ }
+ else
+ {
int count = data->child->count();
data->child->resize( count + 1 );
- (*data->child)[count] = uid;
+ ( *data->child ) [ count ] = uid;
}
}
-void OEvent::removeChild( int uid ) {
- if (!data->child || !data->child->contains( uid ) ) return;
+
+
+void OEvent::removeChild( int uid )
+{
+ if ( !data->child || !data->child->contains( uid ) ) return ;
changeOrModify();
QArray<int> newAr( data->child->count() - 1 );
int j = 0;
uint count = data->child->count();
- for ( uint i = 0; i < count; i++ ) {
- if ( (*data->child)[i] != uid ) {
- newAr[j] = (*data->child)[i];
+ for ( uint i = 0; i < count; i++ )
+ {
+ if ( ( *data->child ) [ i ] != uid )
+ {
+ newAr[ j ] = ( *data->child ) [ i ];
j++;
}
}
- (*data->child) = newAr;
+ ( *data->child ) = newAr;
}
-struct OEffectiveEvent::Data : public QShared {
- Data() : QShared() {
- }
+
+
+struct OEffectiveEvent::Data : public QShared
+{
+ Data() : QShared()
+ {}
OEvent event;
QDate date;
QTime start, end;
QDate startDate, endDate;
- bool dates : 1;
+bool dates : 1;
};
-OEffectiveEvent::OEffectiveEvent() {
+
+OEffectiveEvent::OEffectiveEvent()
+{
data = new Data;
data->date = QDate::currentDate();
data->start = data->end = QTime::currentTime();
data->dates = false;
}
+
+
OEffectiveEvent::OEffectiveEvent( const OEvent& ev, const QDate& startDate,
- Position pos ) {
+ Position pos )
+{
data = new Data;
data->event = ev;
data->date = startDate;
@@ -607,18 +799,28 @@ OEffectiveEvent::OEffectiveEvent( const OEvent& ev, const QDate& startDate,
data->dates = false;
}
-OEffectiveEvent::OEffectiveEvent( const OEffectiveEvent& ev) {
+
+
+OEffectiveEvent::OEffectiveEvent( const OEffectiveEvent& ev )
+{
data = ev.data;
data->ref();
}
-OEffectiveEvent::~OEffectiveEvent() {
- if ( data->deref() ) {
+
+
+OEffectiveEvent::~OEffectiveEvent()
+{
+ if ( data->deref() )
+ {
delete data;
data = 0;
}
}
-OEffectiveEvent& OEffectiveEvent::operator=( const OEffectiveEvent& ev ) {
- if ( *this == ev ) return *this;
+
+
+OEffectiveEvent& OEffectiveEvent::operator=( const OEffectiveEvent& ev )
+{
+ if ( *this == ev ) return * this;
ev.data->ref();
deref();
@@ -627,71 +829,119 @@ OEffectiveEvent& OEffectiveEvent::operator=( const OEffectiveEvent& ev ) {
return *this;
}
-void OEffectiveEvent::setStartTime( const QTime& ti) {
+
+void OEffectiveEvent::setStartTime( const QTime& ti )
+{
changeOrModify();
data->start = ti;
}
-void OEffectiveEvent::setEndTime( const QTime& en) {
+
+
+void OEffectiveEvent::setEndTime( const QTime& en )
+{
changeOrModify();
data->end = en;
}
-void OEffectiveEvent::setEvent( const OEvent& ev) {
+
+
+void OEffectiveEvent::setEvent( const OEvent& ev )
+{
changeOrModify();
data->event = ev;
}
-void OEffectiveEvent::setDate( const QDate& da) {
+
+
+void OEffectiveEvent::setDate( const QDate& da )
+{
changeOrModify();
data->date = da;
}
+
+
void OEffectiveEvent::setEffectiveDates( const QDate& from,
- const QDate& to ) {
- if (!from.isValid() ) {
+ const QDate& to )
+{
+ if ( !from.isValid() )
+ {
data->dates = false;
- return;
+ return ;
}
data->startDate = from;
data->endDate = to;
}
-QString OEffectiveEvent::description()const {
+
+
+QString OEffectiveEvent::description() const
+{
return data->event.description();
}
-QString OEffectiveEvent::location()const {
+
+
+QString OEffectiveEvent::location() const
+{
return data->event.location();
}
-QString OEffectiveEvent::note()const {
+
+
+QString OEffectiveEvent::note() const
+{
return data->event.note();
}
-OEvent OEffectiveEvent::event()const {
+
+
+OEvent OEffectiveEvent::event() const
+{
return data->event;
}
-QTime OEffectiveEvent::startTime()const {
+
+
+QTime OEffectiveEvent::startTime() const
+{
return data->start;
}
-QTime OEffectiveEvent::endTime()const {
+
+
+QTime OEffectiveEvent::endTime() const
+{
return data->end;
}
-QDate OEffectiveEvent::date()const {
+
+
+QDate OEffectiveEvent::date() const
+{
return data->date;
}
-int OEffectiveEvent::length()const {
- return (data->end.hour() * 60 - data->start.hour() * 60)
- + QABS(data->start.minute() - data->end.minute() );
+
+
+int OEffectiveEvent::length() const
+{
+ return ( data->end.hour() * 60 - data->start.hour() * 60 )
+ + QABS( data->start.minute() - data->end.minute() );
}
-int OEffectiveEvent::size()const {
+
+
+int OEffectiveEvent::size() const
+{
return ( data->end.hour() - data->start.hour() ) * 3600
- + (data->end.minute() - data->start.minute() * 60
- + data->end.second() - data->start.second() );
+ + ( data->end.minute() - data->start.minute() * 60
+ + data->end.second() - data->start.second() );
}
-QDate OEffectiveEvent::startDate()const {
+
+
+QDate OEffectiveEvent::startDate() const
+{
if ( data->dates )
return data->startDate;
- else if ( data->event.hasRecurrence() ) // single day, since multi-day should have a d pointer
+ else if ( data->event.hasRecurrence() ) // single day, since multi-day should have a d pointer
return data->date;
else
return data->event.startDateTime().date();
}
-QDate OEffectiveEvent::endDate()const {
+
+
+QDate OEffectiveEvent::endDate() const
+{
if ( data->dates )
return data->endDate;
else if ( data->event.hasRecurrence() )
@@ -699,14 +949,22 @@ QDate OEffectiveEvent::endDate()const {
else
return data->event.endDateTime().date();
}
-void OEffectiveEvent::deref() {
- if ( data->deref() ) {
+
+
+void OEffectiveEvent::deref()
+{
+ if ( data->deref() )
+ {
delete data;
data = 0;
}
}
-void OEffectiveEvent::changeOrModify() {
- if ( data->count != 1 ) {
+
+
+void OEffectiveEvent::changeOrModify()
+{
+ if ( data->count != 1 )
+ {
data->deref();
Data* d2 = new Data;
d2->event = data->event;
@@ -719,31 +977,49 @@ void OEffectiveEvent::changeOrModify() {
data = d2;
}
}
-bool OEffectiveEvent::operator<( const OEffectiveEvent &e ) const{
+
+
+bool OEffectiveEvent::operator<( const OEffectiveEvent &e ) const
+{
if ( data->date < e.date() )
- return TRUE;
+ return TRUE;
if ( data->date == e.date() )
- return ( startTime() < e.startTime() );
+ return ( startTime() < e.startTime() );
else
- return FALSE;
+ return FALSE;
}
-bool OEffectiveEvent::operator<=( const OEffectiveEvent &e ) const{
- return (data->date <= e.date() );
+
+
+bool OEffectiveEvent::operator<=( const OEffectiveEvent &e ) const
+{
+ return ( data->date <= e.date() );
}
-bool OEffectiveEvent::operator==( const OEffectiveEvent &e ) const {
+
+
+bool OEffectiveEvent::operator==( const OEffectiveEvent &e ) const
+{
return ( date() == e.date()
- && startTime() == e.startTime()
- && endTime()== e.endTime()
- && event() == e.event() );
+ && startTime() == e.startTime()
+ && endTime() == e.endTime()
+ && event() == e.event() );
}
-bool OEffectiveEvent::operator!=( const OEffectiveEvent &e ) const {
- return !(*this == e );
+
+
+bool OEffectiveEvent::operator!=( const OEffectiveEvent &e ) const
+{
+ return !( *this == e );
}
-bool OEffectiveEvent::operator>( const OEffectiveEvent &e ) const {
- return !(*this <= e );
+
+
+bool OEffectiveEvent::operator>( const OEffectiveEvent &e ) const
+{
+ return !( *this <= e );
}
-bool OEffectiveEvent::operator>= ( const OEffectiveEvent &e ) const {
- return !(*this < e);
+
+
+bool OEffectiveEvent::operator>= ( const OEffectiveEvent &e ) const
+{
+ return !( *this < e );
}
}
diff --git a/libopie2/opiepim/oevent.h b/libopie2/opiepim/oevent.h
index 9502efa..dc5e4d6 100644
--- a/libopie2/opiepim/oevent.h
+++ b/libopie2/opiepim/oevent.h
@@ -1,6 +1,6 @@
/*
This file is part of the Opie Project
- Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de)
+ Copyright (C) Stefan Eilers <Eilers.Stefan@epost.de>
=. Copyright (C) The Opie Team <opie-devel@handhelds.org>
.=l.
.>+-=
@@ -28,21 +28,24 @@
*/
// CONTAINS GPLed code of TT
-#ifndef OPIE_PIM_EVENT_H
-#define OPIE_PIM_EVENT_H
-
-#include <qstring.h>
-#include <qdatetime.h>
-#include <qvaluelist.h>
+#ifndef OEVENT_H
+#define OEVENT_H
+/* OPIE */
+#include <opie2/otimezone.h>
+#include <opie2/opimrecord.h>
#include <qpe/recordfields.h>
#include <qpe/palmtopuidgen.h>
-#include <opie2/otimezone.h>
-#include <opie2/opimrecord.h>
+/* QT */
+#include <qstring.h>
+#include <qdatetime.h>
+#include <qvaluelist.h>
-namespace Opie {
-struct OCalendarHelper {
+namespace Opie
+{
+struct OCalendarHelper
+{
/** calculate the week number of the date */
static int week( const QDate& );
/** calculate the occurence of week days since the start of the month */
@@ -65,8 +68,9 @@ class ORecur;
* available information for a single Event
* @short container for events.
*/
-class OEvent : public OPimRecord {
-public:
+class OEvent : public OPimRecord
+{
+ public:
typedef QValueList<OEvent> ValueList;
/**
* RecordFields contain possible attributes
@@ -77,20 +81,20 @@ public:
FCategories = Qtopia::CATEGORY_ID,
FDescription = 0,
FLocation,
- FType,
- FAlarm,
- FSound,
- FRType,
- FRWeekdays,
- FRPosition,
- FRFreq,
- FRHasEndDate,
- FREndDate,
- FRCreated,
- FRExceptions,
- FStart,
- FEnd,
- FNote,
+ FType,
+ FAlarm,
+ FSound,
+ FRType,
+ FRWeekdays,
+ FRPosition,
+ FRFreq,
+ FRHasEndDate,
+ FREndDate,
+ FRCreated,
+ FRExceptions,
+ FStart,
+ FEnd,
+ FNote,
FTimeZone,
FRecParent,
FRecChildren,
@@ -99,7 +103,7 @@ public:
/**
* Start with an Empty OEvent. UID == 0 means that it is empty
*/
- OEvent(int uid = 0);
+ OEvent( int uid = 0 );
/**
* copy c'tor
@@ -114,84 +118,85 @@ public:
~OEvent();
OEvent &operator=( const OEvent& );
- QString description()const;
+ QString description() const;
void setDescription( const QString& description );
- QString location()const;
- void setLocation( const QString& loc );
+ QString location() const;
+ void setLocation( const QString& loc );
- bool hasNotifiers()const;
- OPimNotifyManager &notifiers()const;
+ bool hasNotifiers() const;
+ OPimNotifyManager &notifiers() const;
- ORecur recurrence()const;
+ ORecur recurrence() const;
void setRecurrence( const ORecur& );
- bool hasRecurrence()const;
+ bool hasRecurrence() const;
- QString note()const;
+ QString note() const;
void setNote( const QString& note );
- QDateTime createdDateTime()const;
- void setCreatedDateTime( const QDateTime& dt);
+ QDateTime createdDateTime() const;
+ void setCreatedDateTime( const QDateTime& dt );
/** set the date to dt. dt is the QDateTime in localtime */
void setStartDateTime( const QDateTime& );
/** returns the datetime in the local timeZone */
- QDateTime startDateTime()const;
+ QDateTime startDateTime() const;
/** returns the start datetime in the current zone */
- QDateTime startDateTimeInZone()const;
+ QDateTime startDateTimeInZone() const;
/** in current timezone */
void setEndDateTime( const QDateTime& );
/** in current timezone */
- QDateTime endDateTime()const;
- QDateTime endDateTimeInZone()const;
+ QDateTime endDateTime() const;
+ QDateTime endDateTimeInZone() const;
- bool isMultipleDay()const;
- bool isAllDay()const;
+ bool isMultipleDay() const;
+ bool isAllDay() const;
void setAllDay( bool isAllDay );
/* pin this event to a timezone! FIXME */
void setTimeZone( const QString& timeZone );
- QString timeZone()const;
+ QString timeZone() const;
- virtual bool match( const QRegExp& )const;
+ virtual bool match( const QRegExp& ) const;
/** For exception to recurrence here is a list of children... */
- QArray<int> children()const;
+ QArray<int> children() const;
void setChildren( const QArray<int>& );
void addChild( int uid );
void removeChild( int uid );
/** return the parent OEvent */
- int parent()const;
+ int parent() const;
void setParent( int uid );
/* needed reimp */
- QString toRichText()const;
- QString toShortText()const;
- QString type()const;
+ QString toRichText() const;
+ QString toShortText() const;
+ QString type() const;
- QMap<int, QString> toMap()const;
+ QMap<int, QString> toMap() const;
void fromMap( const QMap<int, QString>& map );
- QString recordField(int )const;
+ QString recordField( int ) const;
static int rtti();
bool loadFromStream( QDataStream& );
- bool saveToStream( QDataStream& )const;
-
-/* bool operator==( const OEvent& );
- bool operator!=( const OEvent& );
- bool operator<( const OEvent& );
- bool operator<=( const OEvent& );
- bool operator>( const OEvent& );
- bool operator>=(const OEvent& );
-*/
-private:
+ bool saveToStream( QDataStream& ) const;
+
+ /* bool operator==( const OEvent& );
+ bool operator!=( const OEvent& );
+ bool operator<( const OEvent& );
+ bool operator<=( const OEvent& );
+ bool operator>( const OEvent& );
+ bool operator>=(const OEvent& );
+ */
+
+ private:
inline void changeOrModify();
void deref();
struct Data;
@@ -204,11 +209,13 @@ private:
/**
* AN Event can span through multiple days. We split up a multiday eve
*/
-class OEffectiveEvent {
-public:
+class OEffectiveEvent
+{
+
+ public:
typedef QValueList<OEffectiveEvent> ValueList;
enum Position { MidWay, Start, End, StartEnd };
- // If we calculate the effective event of a multi-day event
+ // If we calculate the effective event of a multi-day event
// we have to figure out whether we are at the first day,
// at the end, or anywhere else ("middle"). This is important
// for the start/end times (00:00/23:59)
@@ -221,7 +228,7 @@ public:
OEffectiveEvent();
OEffectiveEvent( const OEvent& event, const QDate& startDate, Position pos = StartEnd );
OEffectiveEvent( const OEffectiveEvent& );
- OEffectiveEvent &operator=(const OEffectiveEvent& );
+ OEffectiveEvent &operator=( const OEffectiveEvent& );
~OEffectiveEvent();
void setStartTime( const QTime& );
@@ -231,20 +238,20 @@ public:
void setEffectiveDates( const QDate& from, const QDate& to );
- QString description()const;
- QString location()const;
- QString note()const;
- OEvent event()const;
- QTime startTime()const;
- QTime endTime()const;
- QDate date()const;
+ QString description() const;
+ QString location() const;
+ QString note() const;
+ OEvent event() const;
+ QTime startTime() const;
+ QTime endTime() const;
+ QDate date() const;
/* return the length in hours */
- int length()const;
- int size()const;
+ int length() const;
+ int size() const;
- QDate startDate()const;
- QDate endDate()const;
+ QDate startDate() const;
+ QDate endDate() const;
bool operator<( const OEffectiveEvent &e ) const;
bool operator<=( const OEffectiveEvent &e ) const;
@@ -253,7 +260,7 @@ public:
bool operator>( const OEffectiveEvent &e ) const;
bool operator>= ( const OEffectiveEvent &e ) const;
-private:
+ private:
void deref();
inline void changeOrModify();
class Private;
diff --git a/libopie2/opiepim/orecordlist.h b/libopie2/opiepim/orecordlist.h
index 8f0011b..1742dcc 100644
--- a/libopie2/opiepim/orecordlist.h
+++ b/libopie2/opiepim/orecordlist.h
@@ -27,15 +27,18 @@
Boston, MA 02111-1307, USA.
*/
-#ifndef OPIE_RECORD_LIST_H
-#define OPIE_RECORD_LIST_H
-
-#include <qarray.h>
+#ifndef ORECORDLIST_H
+#define ORECORDLIST_H
+/* OPIE */
#include <opie2/otemplatebase.h>
#include <opie2/opimrecord.h>
-namespace Opie {
+/* QT */
+#include <qarray.h>
+
+namespace Opie
+{
class ORecordListIteratorPrivate;
/**
@@ -47,9 +50,11 @@ class ORecordListIteratorPrivate;
*/
template <class T> class ORecordList;
template <class T = OPimRecord>
-class ORecordListIterator {
+class ORecordListIterator
+{
friend class ORecordList<T>;
-public:
+
+ public:
typedef OTemplateBase<T> Base;
/**
@@ -65,7 +70,7 @@ public:
~ORecordListIterator();
ORecordListIterator( const ORecordListIterator& );
- ORecordListIterator &operator=(const ORecordListIterator& );
+ ORecordListIterator &operator=( const ORecordListIterator& );
/**
* a * operator ;)
@@ -81,47 +86,49 @@ public:
/**
* the current item
*/
- uint current()const;
+ uint current() const;
/**
* the number of items
*/
- uint count()const;
+ uint count() const;
/**
* sets the current item
*/
void setCurrent( uint cur );
-private:
+ private:
QArray<int> m_uids;
uint m_current;
const Base* m_temp;
bool m_end : 1;
T m_record;
- bool m_direction :1;
+ bool m_direction : 1;
/* d pointer for future versions */
ORecordListIteratorPrivate *d;
};
+
class ORecordListPrivate;
/**
* The recordlist used as a return type
* from OPimAccessTemplate
*/
template <class T = OPimRecord >
-class ORecordList {
-public:
+class ORecordList
+{
+ public:
typedef OTemplateBase<T> Base;
typedef ORecordListIterator<T> Iterator;
/**
* c'tor
*/
- ORecordList () {
- }
-ORecordList( const QArray<int>& ids,
+ ORecordList ()
+ {}
+ ORecordList( const QArray<int>& ids,
const Base* );
~ORecordList();
@@ -138,29 +145,31 @@ ORecordList( const QArray<int>& ids,
/**
* the number of items in the list
*/
- uint count()const;
+ uint count() const;
- T operator[]( uint i );
- int uidAt(uint i );
+ T operator[] ( uint i );
+ int uidAt( uint i );
- /**
- * Remove the contact with given uid
- */
+ /**
+ * Remove the contact with given uid
+ */
bool remove( int uid );
/*
ConstIterator begin()const;
ConstIterator end()const;
*/
-private:
+ private:
QArray<int> m_ids;
const Base* m_acc;
ORecordListPrivate *d;
};
+
/* ok now implement it */
template <class T>
-ORecordListIterator<T>::ORecordListIterator() {
+ORecordListIterator<T>::ORecordListIterator()
+{
m_current = 0;
m_temp = 0l;
m_end = true;
@@ -168,14 +177,19 @@ ORecordListIterator<T>::ORecordListIterator() {
/* forward */
m_direction = TRUE;
}
+
+
template <class T>
-ORecordListIterator<T>::~ORecordListIterator() {
-/* nothing to delete */
+ORecordListIterator<T>::~ORecordListIterator()
+{
+ /* nothing to delete */
}
+
template <class T>
-ORecordListIterator<T>::ORecordListIterator( const ORecordListIterator<T>& it) {
-// qWarning("ORecordListIterator copy c'tor");
+ORecordListIterator<T>::ORecordListIterator( const ORecordListIterator<T>& it )
+{
+ // qWarning("ORecordListIterator copy c'tor");
m_uids = it.m_uids;
m_current = it.m_current;
m_temp = it.m_temp;
@@ -184,8 +198,10 @@ ORecordListIterator<T>::ORecordListIterator( const ORecordListIterator<T>& it) {
m_direction = it.m_direction;
}
+
template <class T>
-ORecordListIterator<T> &ORecordListIterator<T>::operator=( const ORecordListIterator<T>& it) {
+ORecordListIterator<T> &ORecordListIterator<T>::operator=( const ORecordListIterator<T>& it )
+{
m_uids = it.m_uids;
m_current = it.m_current;
m_temp = it.m_temp;
@@ -195,44 +211,57 @@ ORecordListIterator<T> &ORecordListIterator<T>::operator=( const ORecordListIter
return *this;
}
+
template <class T>
-T ORecordListIterator<T>::operator*() {
- //qWarning("operator* %d %d", m_current, m_uids[m_current] );
- if (!m_end )
- m_record = m_temp->find( m_uids[m_current], m_uids, m_current,
+T ORecordListIterator<T>::operator*()
+{
+ //qWarning("operator* %d %d", m_current, m_uids[m_current] );
+ if ( !m_end )
+ m_record = m_temp->find( m_uids[ m_current ], m_uids, m_current,
m_direction ? Base::Forward :
- Base::Reverse );
+ Base::Reverse );
else
m_record = T();
return m_record;
}
+
template <class T>
-ORecordListIterator<T> &ORecordListIterator<T>::operator++() {
+ORecordListIterator<T> &ORecordListIterator<T>::operator++()
+{
m_direction = true;
- if (m_current < m_uids.count() ) {
+ if ( m_current < m_uids.count() )
+ {
m_end = false;
++m_current;
- }else
+ }
+ else
m_end = true;
return *this;
}
+
+
template <class T>
-ORecordListIterator<T> &ORecordListIterator<T>::operator--() {
+ORecordListIterator<T> &ORecordListIterator<T>::operator--()
+{
m_direction = false;
- if ( m_current > 0 ) {
+ if ( m_current > 0 )
+ {
--m_current;
m_end = false;
- } else
+ }
+ else
m_end = true;
return *this;
}
+
template <class T>
-bool ORecordListIterator<T>::operator==( const ORecordListIterator<T>& it ) {
+bool ORecordListIterator<T>::operator==( const ORecordListIterator<T>& it )
+{
/* if both are at we're the same.... */
if ( m_end == it.m_end ) return true;
@@ -243,93 +272,130 @@ bool ORecordListIterator<T>::operator==( const ORecordListIterator<T>& it ) {
return true;
}
+
+
template <class T>
-bool ORecordListIterator<T>::operator!=( const ORecordListIterator<T>& it ) {
- return !(*this == it );
+bool ORecordListIterator<T>::operator!=( const ORecordListIterator<T>& it )
+{
+ return !( *this == it );
}
+
+
template <class T>
ORecordListIterator<T>::ORecordListIterator( const QArray<int> uids,
- const Base* t )
- : m_uids( uids ), m_current( 0 ), m_temp( t ), m_end( false ),
- m_direction( false )
+ const Base* t )
+ : m_uids( uids ), m_current( 0 ), m_temp( t ), m_end( false ),
+ m_direction( false )
{
/* if the list is empty we're already at the end of the list */
- if (uids.count() == 0 )
+ if ( uids.count() == 0 )
m_end = true;
}
+
+
template <class T>
-uint ORecordListIterator<T>::current()const {
+uint ORecordListIterator<T>::current() const
+{
return m_current;
}
+
+
template <class T>
-void ORecordListIterator<T>::setCurrent( uint cur ) {
- if( cur < m_uids.count() ) {
- m_end = false;
- m_current= cur;
+void ORecordListIterator<T>::setCurrent( uint cur )
+{
+ if ( cur < m_uids.count() )
+ {
+ m_end = false;
+ m_current = cur;
}
}
template <class T>
-uint ORecordListIterator<T>::count()const {
+uint ORecordListIterator<T>::count() const
+{
return m_uids.count();
}
+
+
template <class T>
ORecordList<T>::ORecordList( const QArray<int>& ids,
const Base* acc )
- : m_ids( ids ), m_acc( acc )
-{
-}
+ : m_ids( ids ), m_acc( acc )
+{}
+
+
template <class T>
-ORecordList<T>::~ORecordList() {
-/* nothing to do here */
+ORecordList<T>::~ORecordList()
+{
+ /* nothing to do here */
}
+
+
template <class T>
-typename ORecordList<T>::Iterator ORecordList<T>::begin() {
+typename ORecordList<T>::Iterator ORecordList<T>::begin()
+{
Iterator it( m_ids, m_acc );
return it;
}
+
+
template <class T>
-typename ORecordList<T>::Iterator ORecordList<T>::end() {
+typename ORecordList<T>::Iterator ORecordList<T>::end()
+{
Iterator it( m_ids, m_acc );
it.m_end = true;
it.m_current = m_ids.count();
return it;
}
+
+
template <class T>
-uint ORecordList<T>::count()const {
-return m_ids.count();
+uint ORecordList<T>::count() const
+{
+ return m_ids.count();
}
+
+
template <class T>
-T ORecordList<T>::operator[]( uint i ) {
+T ORecordList<T>::operator[] ( uint i )
+{
if ( i >= m_ids.count() )
return T();
/* forward */
- return m_acc->find( m_ids[i], m_ids, i );
-}
-template <class T>
-int ORecordList<T>::uidAt( uint i ) {
- return m_ids[i];
+ return m_acc->find( m_ids[ i ], m_ids, i );
}
+
template <class T>
-bool ORecordList<T>::remove( int uid ) {
- QArray<int> copy( m_ids.count() );
- int counter = 0;
- bool ret_val = false;
+int ORecordList<T>::uidAt( uint i )
+{
+ return m_ids[ i ];
+}
- for (uint i = 0; i < m_ids.count(); i++){
- if ( m_ids[i] != uid ){
- copy[counter++] = m_ids[i];
- }else
- ret_val = true;
- }
+template <class T>
+bool ORecordList<T>::remove( int uid )
+{
+ QArray<int> copy( m_ids.count() );
+ int counter = 0;
+ bool ret_val = false;
+
+ for ( uint i = 0; i < m_ids.count(); i++ )
+ {
+ if ( m_ids[ i ] != uid )
+ {
+ copy[ counter++ ] = m_ids[ i ];
+
+ }
+ else
+ ret_val = true;
+ }
- copy.resize( counter );
- m_ids = copy;
+ copy.resize( counter );
+ m_ids = copy;
- return ret_val;
+ return ret_val;
}
}
diff --git a/libopie2/opiepim/otodo.cpp b/libopie2/opiepim/otodo.cpp
index 3eb0026..f534067 100644
--- a/libopie2/opiepim/otodo.cpp
+++ b/libopie2/opiepim/otodo.cpp
@@ -26,11 +26,15 @@
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
-#include <qobject.h>
-#include <qshared.h>
-
+#include "otodo.h"
+/* OPIE */
+#include <opie2/opimstate.h>
+#include <opie2/orecur.h>
+#include <opie2/opimmaintainer.h>
+#include <opie2/opimnotifymanager.h>
+#include <opie2/opimresolver.h>
#include <qpe/palmtopuidgen.h>
#include <qpe/stringutil.h>
#include <qpe/palmtoprecord.h>
@@ -38,33 +42,32 @@
#include <qpe/categories.h>
#include <qpe/categoryselect.h>
+/* QT */
+#include <qobject.h>
+#include <qshared.h>
-#include <opie2/opimstate.h>
-#include <opie2/orecur.h>
-#include <opie2/opimmaintainer.h>
-#include <opie2/opimnotifymanager.h>
-#include <opie2/opimresolver.h>
-
-#include <opie2/otodo.h>
-
-namespace Opie {
+namespace Opie
+{
-struct OTodo::OTodoData : public QShared {
- OTodoData() : QShared() {
+struct OTodo::OTodoData : public QShared
+{
+ OTodoData() : QShared()
+ {
recur = 0;
state = 0;
maintainer = 0;
notifiers = 0;
};
- ~OTodoData() {
+ ~OTodoData()
+ {
delete recur;
delete maintainer;
delete notifiers;
}
QDate date;
- bool isCompleted:1;
- bool hasDate:1;
+ bool isCompleted: 1;
+ bool hasDate: 1;
int priority;
QString desc;
QString sum;
@@ -78,30 +81,37 @@ struct OTodo::OTodoData : public QShared {
OPimNotifyManager *notifiers;
};
-OTodo::OTodo(const OTodo &event )
- : OPimRecord( event ), data( event.data )
+
+OTodo::OTodo( const OTodo &event )
+ : OPimRecord( event ), data( event.data )
{
data->ref();
-// qWarning("ref up");
+ // qWarning("ref up");
}
-OTodo::~OTodo() {
-// qWarning("~OTodo " );
- if ( data->deref() ) {
-// qWarning("OTodo::dereffing");
+
+OTodo::~OTodo()
+{
+
+ // qWarning("~OTodo " );
+ if ( data->deref() )
+ {
+ // qWarning("OTodo::dereffing");
delete data;
data = 0l;
}
}
-OTodo::OTodo(bool completed, int priority,
- const QArray<int> &category,
- const QString& summary,
- const QString &description,
- ushort progress,
- bool hasDate, QDate date, int uid )
- : OPimRecord( uid )
+
+
+OTodo::OTodo( bool completed, int priority,
+ const QArray<int> &category,
+ const QString& summary,
+ const QString &description,
+ ushort progress,
+ bool hasDate, QDate date, int uid )
+ : OPimRecord( uid )
{
-// qWarning("OTodoData " + summary);
+ // qWarning("OTodoData " + summary);
setCategories( category );
data = new OTodoData;
@@ -112,18 +122,20 @@ OTodo::OTodo(bool completed, int priority,
data->priority = priority;
data->sum = summary;
data->prog = progress;
- data->desc = Qtopia::simplifyMultiLineSpace(description );
+ data->desc = Qtopia::simplifyMultiLineSpace( description );
}
-OTodo::OTodo(bool completed, int priority,
- const QStringList &category,
- const QString& summary,
- const QString &description,
- ushort progress,
- bool hasDate, QDate date, int uid )
- : OPimRecord( uid )
+
+
+OTodo::OTodo( bool completed, int priority,
+ const QStringList &category,
+ const QString& summary,
+ const QString &description,
+ ushort progress,
+ bool hasDate, QDate date, int uid )
+ : OPimRecord( uid )
{
-// qWarning("OTodoData" + summary);
- setCategories( idsFromString( category.join(";") ) );
+ // qWarning("OTodoData" + summary);
+ setCategories( idsFromString( category.join( ";" ) ) );
data = new OTodoData;
@@ -133,199 +145,291 @@ OTodo::OTodo(bool completed, int priority,
data->priority = priority;
data->sum = summary;
data->prog = progress;
- data->desc = Qtopia::simplifyMultiLineSpace(description );
+ data->desc = Qtopia::simplifyMultiLineSpace( description );
}
-bool OTodo::match( const QRegExp &regExp )const
+
+
+bool OTodo::match( const QRegExp &regExp ) const
{
- if( QString::number( data->priority ).find( regExp ) != -1 ){
- setLastHitField( Priority );
- return true;
- }else if( data->hasDate && data->date.toString().find( regExp) != -1 ){
- setLastHitField( HasDate );
- return true;
- }else if(data->desc.find( regExp ) != -1 ){
+ if ( QString::number( data->priority ).find( regExp ) != -1 )
+ {
+ setLastHitField( Priority );
+ return true;
+ }
+ else if ( data->hasDate && data->date.toString().find( regExp ) != -1 )
+ {
+ setLastHitField( HasDate );
+ return true;
+ }
+ else if ( data->desc.find( regExp ) != -1 )
+ {
setLastHitField( Description );
return true;
- }else if(data->sum.find( regExp ) != -1 ) {
+ }
+ else if ( data->sum.find( regExp ) != -1 )
+ {
setLastHitField( Summary );
return true;
- }
- return false;
+ }
+ return false;
}
+
+
bool OTodo::isCompleted() const
{
return data->isCompleted;
}
+
+
bool OTodo::hasDueDate() const
{
return data->hasDate;
}
-bool OTodo::hasStartDate()const {
+
+
+bool OTodo::hasStartDate() const
+{
return data->start.isValid();
}
-bool OTodo::hasCompletedDate()const {
+
+
+bool OTodo::hasCompletedDate() const
+{
return data->completed.isValid();
}
-int OTodo::priority()const
+
+
+int OTodo::priority() const
{
return data->priority;
}
+
+
QString OTodo::summary() const
{
return data->sum;
}
+
+
ushort OTodo::progress() const
{
return data->prog;
}
-QDate OTodo::dueDate()const
+
+
+QDate OTodo::dueDate() const
{
return data->date;
}
-QDate OTodo::startDate()const {
+
+
+QDate OTodo::startDate() const
+{
return data->start;
}
-QDate OTodo::completedDate()const {
+
+
+QDate OTodo::completedDate() const
+{
return data->completed;
}
-QString OTodo::description()const
+
+
+QString OTodo::description() const
{
return data->desc;
}
-bool OTodo::hasState() const{
- if (!data->state ) return false;
+
+
+bool OTodo::hasState() const
+{
+ if ( !data->state ) return false;
return ( data->state->state() != OPimState::Undefined );
}
-OPimState OTodo::state()const {
- if (!data->state ) {
+
+
+OPimState OTodo::state() const
+{
+ if ( !data->state )
+ {
OPimState state;
return state;
}
- return (*data->state);
+ return ( *data->state );
}
-bool OTodo::hasRecurrence()const {
- if (!data->recur) return false;
+
+
+bool OTodo::hasRecurrence() const
+{
+ if ( !data->recur ) return false;
return data->recur->doesRecur();
}
-ORecur OTodo::recurrence()const {
- if (!data->recur) return ORecur();
- return (*data->recur);
+
+ORecur OTodo::recurrence() const
+{
+ if ( !data->recur ) return ORecur();
+
+ return ( *data->recur );
}
-bool OTodo::hasMaintainer()const {
- if (!data->maintainer) return false;
- return (data->maintainer->mode() != OPimMaintainer::Undefined );
+
+bool OTodo::hasMaintainer() const
+{
+ if ( !data->maintainer ) return false;
+
+ return ( data->maintainer->mode() != OPimMaintainer::Undefined );
}
-OPimMaintainer OTodo::maintainer()const {
- if (!data->maintainer) return OPimMaintainer();
- return (*data->maintainer);
+
+OPimMaintainer OTodo::maintainer() const
+{
+ if ( !data->maintainer ) return OPimMaintainer();
+
+ return ( *data->maintainer );
}
+
+
void OTodo::setCompleted( bool completed )
{
changeOrModify();
data->isCompleted = completed;
}
+
+
void OTodo::setHasDueDate( bool hasDate )
{
changeOrModify();
data->hasDate = hasDate;
}
-void OTodo::setDescription(const QString &desc )
+
+
+void OTodo::setDescription( const QString &desc )
{
-// qWarning( "desc " + desc );
+ // qWarning( "desc " + desc );
changeOrModify();
- data->desc = Qtopia::simplifyMultiLineSpace(desc );
+ data->desc = Qtopia::simplifyMultiLineSpace( desc );
}
+
+
void OTodo::setSummary( const QString& sum )
{
changeOrModify();
data->sum = sum;
}
-void OTodo::setPriority(int prio )
+
+
+void OTodo::setPriority( int prio )
{
changeOrModify();
data->priority = prio;
}
+
+
void OTodo::setDueDate( const QDate& date )
{
changeOrModify();
data->date = date;
}
-void OTodo::setStartDate( const QDate& date ) {
+
+
+void OTodo::setStartDate( const QDate& date )
+{
changeOrModify();
data->start = date;
}
-void OTodo::setCompletedDate( const QDate& date ) {
+
+
+void OTodo::setCompletedDate( const QDate& date )
+{
changeOrModify();
data->completed = date;
}
-void OTodo::setState( const OPimState& state ) {
+
+
+void OTodo::setState( const OPimState& state )
+{
changeOrModify();
- if (data->state )
- (*data->state) = state;
+ if ( data->state )
+ ( *data->state ) = state;
else
data->state = new OPimState( state );
}
-void OTodo::setRecurrence( const ORecur& rec) {
+
+
+void OTodo::setRecurrence( const ORecur& rec )
+{
changeOrModify();
- if (data->recur )
- (*data->recur) = rec;
+ if ( data->recur )
+ ( *data->recur ) = rec;
else
data->recur = new ORecur( rec );
}
-void OTodo::setMaintainer( const OPimMaintainer& pim ) {
+
+
+void OTodo::setMaintainer( const OPimMaintainer& pim )
+{
changeOrModify();
- if (data->maintainer )
- (*data->maintainer) = pim;
+ if ( data->maintainer )
+ ( *data->maintainer ) = pim;
else
data->maintainer = new OPimMaintainer( pim );
}
+
+
bool OTodo::isOverdue( )
{
- if( data->hasDate && !data->isCompleted)
- return QDate::currentDate() > data->date;
+ if ( data->hasDate && !data->isCompleted )
+ return QDate::currentDate() > data->date;
return false;
}
-void OTodo::setProgress(ushort progress )
+
+
+void OTodo::setProgress( ushort progress )
{
changeOrModify();
data->prog = progress;
}
-QString OTodo::toShortText() const {
- return summary();
+
+
+QString OTodo::toShortText() const
+{
+ return summary();
}
+
+
/*!
Returns a richt text string
*/
QString OTodo::toRichText() const
{
- QString text;
- QStringList catlist;
-
- // summary
- text += "<b><h3><img src=\"todo/TodoList\"> ";
- if ( !summary().isEmpty() ) {
- text += Qtopia::escapeString(summary() ).replace(QRegExp( "[\n]"), "" );
- }
- text += "</h3></b><br><hr><br>";
-
- // description
- if( !description().isEmpty() ){
- text += "<b>" + QObject::tr( "Description:" ) + "</b><br>";
- text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "<br>" ) + "<br>";
- }
-
- // priority
- int priorityval = priority();
- text += "<b>" + QObject::tr( "Priority:") +" </b><img src=\"todo/priority" +
- QString::number( priorityval ) + "\"> ";
-
- switch ( priorityval )
- {
+ QString text;
+ QStringList catlist;
+
+ // summary
+ text += "<b><h3><img src=\"todo/TodoList\"> ";
+ if ( !summary().isEmpty() )
+ {
+ text += Qtopia::escapeString( summary() ).replace( QRegExp( "[\n]" ), "" );
+ }
+ text += "</h3></b><br><hr><br>";
+
+ // description
+ if ( !description().isEmpty() )
+ {
+ text += "<b>" + QObject::tr( "Description:" ) + "</b><br>";
+ text += Qtopia::escapeString( description() ).replace( QRegExp( "[\n]" ), "<br>" ) + "<br>";
+ }
+
+ // priority
+ int priorityval = priority();
+ text += "<b>" + QObject::tr( "Priority:" ) + " </b><img src=\"todo/priority" +
+ QString::number( priorityval ) + "\"> ";
+
+ switch ( priorityval )
+ {
case 1 : text += QObject::tr( "Very high" );
break;
case 2 : text += QObject::tr( "High" );
@@ -336,104 +440,140 @@ QString OTodo::toRichText() const
break;
case 5 : text += QObject::tr( "Very low" );
break;
- };
- text += "<br>";
-
- // progress
- text += "<b>" + QObject::tr( "Progress:") + " </b>"
- + QString::number( progress() ) + " %<br>";
-
- // due date
- if (hasDueDate() ){
- QDate dd = dueDate();
- int off = QDate::currentDate().daysTo( dd );
-
- text += "<b>" + QObject::tr( "Deadline:" ) + " </b><font color=\"";
- if ( off < 0 )
- text += "#FF0000";
- else if ( off == 0 )
- text += "#FFFF00";
- else if ( off > 0 )
- text += "#00FF00";
-
- text += "\">" + dd.toString() + "</font><br>";
- }
-
- // categories
- text += "<b>" + QObject::tr( "Category:") + "</b> ";
- text += categoryNames( "Todo List" ).join(", ");
- text += "<br>";
-
- return text;
-}
-bool OTodo::hasNotifiers()const {
- if (!data->notifiers) return false;
+ };
+ text += "<br>";
+
+ // progress
+ text += "<b>" + QObject::tr( "Progress:" ) + " </b>"
+ + QString::number( progress() ) + " %<br>";
+
+ // due date
+ if ( hasDueDate() )
+ {
+ QDate dd = dueDate();
+ int off = QDate::currentDate().daysTo( dd );
+
+ text += "<b>" + QObject::tr( "Deadline:" ) + " </b><font color=\"";
+ if ( off < 0 )
+ text += "#FF0000";
+ else if ( off == 0 )
+ text += "#FFFF00";
+ else if ( off > 0 )
+ text += "#00FF00";
+
+ text += "\">" + dd.toString() + "</font><br>";
+ }
+
+ // categories
+ text += "<b>" + QObject::tr( "Category:" ) + "</b> ";
+ text += categoryNames( "Todo List" ).join( ", " );
+ text += "<br>";
+
+ return text;
+}
+
+
+bool OTodo::hasNotifiers() const
+{
+ if ( !data->notifiers ) return false;
return !data->notifiers->isEmpty();
}
-OPimNotifyManager& OTodo::notifiers() {
- if (!data->notifiers )
+
+
+OPimNotifyManager& OTodo::notifiers()
+{
+ if ( !data->notifiers )
data->notifiers = new OPimNotifyManager;
- return (*data->notifiers);
+ return ( *data->notifiers );
}
-const OPimNotifyManager& OTodo::notifiers()const{
- if (!data->notifiers )
+
+
+const OPimNotifyManager& OTodo::notifiers() const
+{
+ if ( !data->notifiers )
data->notifiers = new OPimNotifyManager;
- return (*data->notifiers);
+ return ( *data->notifiers );
}
-bool OTodo::operator<( const OTodo &toDoEvent )const{
- if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true;
- if( !hasDueDate() && toDoEvent.hasDueDate() ) return false;
- if( hasDueDate() && toDoEvent.hasDueDate() ){
- if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide
- return priority() < toDoEvent.priority();
- }else{
- return dueDate() < toDoEvent.dueDate();
- }
+
+bool OTodo::operator<( const OTodo &toDoEvent ) const
+{
+ if ( !hasDueDate() && !toDoEvent.hasDueDate() ) return true;
+ if ( !hasDueDate() && toDoEvent.hasDueDate() ) return false;
+ if ( hasDueDate() && toDoEvent.hasDueDate() )
+ {
+ if ( dueDate() == toDoEvent.dueDate() )
+ { // let's the priority decide
+ return priority() < toDoEvent.priority();
+ }
+ else
+ {
+ return dueDate() < toDoEvent.dueDate();
+ }
}
return false;
}
-bool OTodo::operator<=(const OTodo &toDoEvent )const
+
+
+bool OTodo::operator<=( const OTodo &toDoEvent ) const
{
- if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true;
- if( !hasDueDate() && toDoEvent.hasDueDate() ) return true;
- if( hasDueDate() && toDoEvent.hasDueDate() ){
- if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide
- return priority() <= toDoEvent.priority();
- }else{
- return dueDate() <= toDoEvent.dueDate();
- }
+ if ( !hasDueDate() && !toDoEvent.hasDueDate() ) return true;
+ if ( !hasDueDate() && toDoEvent.hasDueDate() ) return true;
+ if ( hasDueDate() && toDoEvent.hasDueDate() )
+ {
+ if ( dueDate() == toDoEvent.dueDate() )
+ { // let's the priority decide
+ return priority() <= toDoEvent.priority();
+ }
+ else
+ {
+ return dueDate() <= toDoEvent.dueDate();
+ }
}
return true;
}
-bool OTodo::operator>(const OTodo &toDoEvent )const
+
+
+bool OTodo::operator>( const OTodo &toDoEvent ) const
{
- if( !hasDueDate() && !toDoEvent.hasDueDate() ) return false;
- if( !hasDueDate() && toDoEvent.hasDueDate() ) return false;
- if( hasDueDate() && toDoEvent.hasDueDate() ){
- if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide
- return priority() > toDoEvent.priority();
- }else{
- return dueDate() > toDoEvent.dueDate();
- }
+ if ( !hasDueDate() && !toDoEvent.hasDueDate() ) return false;
+ if ( !hasDueDate() && toDoEvent.hasDueDate() ) return false;
+ if ( hasDueDate() && toDoEvent.hasDueDate() )
+ {
+ if ( dueDate() == toDoEvent.dueDate() )
+ { // let's the priority decide
+ return priority() > toDoEvent.priority();
+ }
+ else
+ {
+ return dueDate() > toDoEvent.dueDate();
+ }
}
return false;
}
-bool OTodo::operator>=(const OTodo &toDoEvent )const
+
+
+bool OTodo::operator>=( const OTodo &toDoEvent ) const
{
- if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true;
- if( !hasDueDate() && toDoEvent.hasDueDate() ) return false;
- if( hasDueDate() && toDoEvent.hasDueDate() ){
- if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide
- return priority() > toDoEvent.priority();
- }else{
- return dueDate() > toDoEvent.dueDate();
- }
+ if ( !hasDueDate() && !toDoEvent.hasDueDate() ) return true;
+ if ( !hasDueDate() && toDoEvent.hasDueDate() ) return false;
+ if ( hasDueDate() && toDoEvent.hasDueDate() )
+ {
+ if ( dueDate() == toDoEvent.dueDate() )
+ { // let's the priority decide
+ return priority() > toDoEvent.priority();
+ }
+ else
+ {
+ return dueDate() > toDoEvent.dueDate();
+ }
}
return true;
}
-bool OTodo::operator==(const OTodo &toDoEvent )const
+
+
+bool OTodo::operator==( const OTodo &toDoEvent ) const
{
if ( data->priority != toDoEvent.data->priority ) return false;
if ( data->priority != toDoEvent.data->prog ) return false;
@@ -442,23 +582,29 @@ bool OTodo::operator==(const OTodo &toDoEvent )const
if ( data->date != toDoEvent.data->date ) return false;
if ( data->sum != toDoEvent.data->sum ) return false;
if ( data->desc != toDoEvent.data->desc ) return false;
- if ( data->maintainer != toDoEvent.data->maintainer )
+ if ( data->maintainer != toDoEvent.data->maintainer )
return false;
return OPimRecord::operator==( toDoEvent );
}
-void OTodo::deref() {
-// qWarning("deref in ToDoEvent");
- if ( data->deref() ) {
-// qWarning("deleting");
+
+void OTodo::deref()
+{
+
+ // qWarning("deref in ToDoEvent");
+ if ( data->deref() )
+ {
+ // qWarning("deleting");
delete data;
- data= 0;
+ data = 0;
}
}
-OTodo &OTodo::operator=(const OTodo &item )
+
+
+OTodo &OTodo::operator=( const OTodo &item )
{
- if ( this == &item ) return *this;
+ if ( this == &item ) return * this;
OPimRecord::operator=( item );
//qWarning("operator= ref ");
@@ -469,21 +615,23 @@ OTodo &OTodo::operator=(const OTodo &item )
return *this;
}
-QMap<int, QString> OTodo::toMap() const {
+
+QMap<int, QString> OTodo::toMap() const
+{
QMap<int, QString> map;
map.insert( Uid, QString::number( uid() ) );
- map.insert( Category, idsToString( categories() ) );
+ map.insert( Category, idsToString( categories() ) );
map.insert( HasDate, QString::number( data->hasDate ) );
map.insert( Completed, QString::number( data->isCompleted ) );
map.insert( Description, data->desc );
map.insert( Summary, data->sum );
map.insert( Priority, QString::number( data->priority ) );
- map.insert( DateDay, QString::number( data->date.day() ) );
+ map.insert( DateDay, QString::number( data->date.day() ) );
map.insert( DateMonth, QString::number( data->date.month() ) );
map.insert( DateYear, QString::number( data->date.year() ) );
map.insert( Progress, QString::number( data->prog ) );
-// map.insert( CrossReference, crossToString() );
+ // map.insert( CrossReference, crossToString() );
/* FIXME!!! map.insert( State, );
map.insert( Recurrence, );
map.insert( Reminders, );
@@ -492,26 +640,32 @@ QMap<int, QString> OTodo::toMap() const {
return map;
}
+
/**
* change or modify looks at the ref count and either
* creates a new QShared Object or it can modify it
* right in place
*/
-void OTodo::changeOrModify() {
- if ( data->count != 1 ) {
- qWarning("changeOrModify");
+void OTodo::changeOrModify()
+{
+ if ( data->count != 1 )
+ {
+ qWarning( "changeOrModify" );
data->deref();
OTodoData* d2 = new OTodoData();
- copy(data, d2 );
+ copy( data, d2 );
data = d2;
}
}
+
+
// WATCHOUT
/*
* if you add something to the Data struct
* be sure to copy it here
*/
-void OTodo::copy( OTodoData* src, OTodoData* dest ) {
+void OTodo::copy( OTodoData* src, OTodoData* dest )
+{
dest->date = src->date;
dest->isCompleted = src->isCompleted;
dest->hasDate = src->hasDate;
@@ -521,29 +675,37 @@ void OTodo::copy( OTodoData* src, OTodoData* dest ) {
dest->extra = src->extra;
dest->prog = src->prog;
- if (src->state )
+ if ( src->state )
dest->state = new OPimState( *src->state );
- if (src->recur )
+ if ( src->recur )
dest->recur = new ORecur( *src->recur );
- if (src->maintainer )
+ if ( src->maintainer )
dest->maintainer = new OPimMaintainer( *src->maintainer )
;
dest->start = src->start;
dest->completed = src->completed;
- if (src->notifiers )
+ if ( src->notifiers )
dest->notifiers = new OPimNotifyManager( *src->notifiers );
}
-QString OTodo::type() const {
- return QString::fromLatin1("OTodo");
+
+
+QString OTodo::type() const
+{
+ return QString::fromLatin1( "OTodo" );
}
-QString OTodo::recordField(int /*id*/ )const {
+
+
+QString OTodo::recordField( int /*id*/ ) const
+{
return QString::null;
}
-int OTodo::rtti(){
+
+int OTodo::rtti()
+{
return OPimResolver::TodoList;
}
diff --git a/libopie2/opiepim/otodo.h b/libopie2/opiepim/otodo.h
index 61add04..04dd269 100644
--- a/libopie2/opiepim/otodo.h
+++ b/libopie2/opiepim/otodo.h
@@ -1,35 +1,41 @@
/*
- This file is part of the Opie Project
- Copyright (C) The Main Author <main-author@whereever.org>
- =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
- .=l.
- .>+-=
- _;:, .> :=|. This program is free software; you can
+ This file is part of the Opie Project
+ Copyright (C) The Main Author <main-author@whereever.org>
+ =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
+ .=l.
+ .>+-=
+_;:, .> :=|. This program is free software; you can
.> <`_, > . <= redistribute it and/or modify it under
:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
.="- .-=="i, .._ License as published by the Free Software
- - . .-<_> .<> Foundation; either version 2 of the License,
- ._= =} : or (at your option) any later version.
- .%`+i> _;_.
- .i_,=:_. -<s. This program is distributed in the hope that
- + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
- : .. .:, . . . without even the implied warranty of
- =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
- _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
+- . .-<_> .<> Foundation; either version 2 of the License,
+ ._= =} : or (at your option) any later version.
+ .%`+i> _;_.
+ .i_,=:_. -<s. This program is distributed in the hope that
+ + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
+ : .. .:, . . . without even the implied warranty of
+ =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
+ _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.= = ; Library General Public License for more
++= -. .` .: details.
- : = ...= . :.=-
- -. .:....=;==+<; You should have received a copy of the GNU
- -_. . . )=. = 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.
+: = ...= . :.=-
+-. .:....=;==+<; You should have received a copy of the GNU
+ -_. . . )=. = 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_TODO_EVENT_H
-#define OPIE_TODO_EVENT_H
+#ifndef OTODOEVENT_H
+#define OTODOEVENT_H
+/* OPIE */
+#include <opie2/opimrecord.h>
+#include <qpe/recordfields.h>
+#include <qpe/palmtopuidgen.h>
+
+/* QT */
#include <qarray.h>
#include <qmap.h>
#include <qregexp.h>
@@ -37,20 +43,16 @@
#include <qdatetime.h>
#include <qvaluelist.h>
-#include <qpe/recordfields.h>
-#include <qpe/palmtopuidgen.h>
-
-#include <opie2/opimrecord.h>
-
-
-namespace Opie {
+namespace Opie
+{
class OPimState;
class ORecur;
class OPimMaintainer;
class OPimNotifyManager;
-class OTodo : public OPimRecord {
-public:
+class OTodo : public OPimRecord
+{
+ public:
typedef QValueList<OTodo> ValueList;
enum RecordFields {
Uid = Qtopia::UID_ID,
@@ -74,9 +76,9 @@ public:
StartDate,
CompletedDate
};
- public:
+ public:
// priorities from Very low to very high
- enum TaskPriority { VeryHigh=1, High, Normal, Low, VeryLow };
+ enum TaskPriority { VeryHigh = 1, High, Normal, Low, VeryLow };
/* Constructs a new ToDoEvent
@param completed Is the TodoEvent completed
@@ -101,13 +103,13 @@ public:
const QString& summary = QString::null,
const QString& description = QString::null,
ushort progress = 0,
- bool hasDate = false, QDate date = QDate::currentDate(),
+ bool hasDate = false, QDate date = QDate::currentDate(),
int uid = 0 /* empty */ );
/** Copy c'tor
*
*/
- OTodo(const OTodo & );
+ OTodo( const OTodo & );
/**
*destructor
@@ -123,13 +125,13 @@ public:
* Does this Event have a deadline
*/
bool hasDueDate() const;
- bool hasStartDate()const;
- bool hasCompletedDate()const;
+ bool hasStartDate() const;
+ bool hasCompletedDate() const;
/**
* What is the priority?
*/
- int priority()const ;
+ int priority() const ;
/**
* progress as ushort 0, 20, 40, 60, 80 or 100%
@@ -139,52 +141,52 @@ public:
/**
* The due Date
*/
- QDate dueDate()const;
+ QDate dueDate() const;
/**
* When did it start?
*/
- QDate startDate()const;
+ QDate startDate() const;
/**
* When was it completed?
*/
- QDate completedDate()const;
+ QDate completedDate() const;
/**
* does it have a state?
*/
- bool hasState()const;
+ bool hasState() const;
/**
* What is the state of this OTodo?
*/
- OPimState state()const;
+ OPimState state() const;
/**
* has recurrence?
*/
- bool hasRecurrence()const;
+ bool hasRecurrence() const;
/**
* the recurrance of this
*/
- ORecur recurrence()const;
+ ORecur recurrence() const;
/**
* does this OTodo have a maintainer?
*/
- bool hasMaintainer()const;
+ bool hasMaintainer() const;
/**
* the Maintainer of this OTodo
*/
- OPimMaintainer maintainer()const;
+ OPimMaintainer maintainer() const;
/**
* The description of the todo
*/
- QString description()const;
+ QString description() const;
/**
* A small summary of the todo
@@ -197,7 +199,7 @@ public:
*/
QString toRichText() const;
- bool hasNotifiers()const;
+ bool hasNotifiers() const;
/*
* FIXME check if the sharing is still fine!! -zecke
* ### CHECK If API is fine
@@ -210,25 +212,25 @@ public:
/**
*
*/
- const OPimNotifyManager &notifiers()const;
+ const OPimNotifyManager &notifiers() const;
/**
* reimplementations
*/
- QString type()const;
- QString toShortText()const;
- QString recordField(int id )const;
+ QString type() const;
+ QString toShortText() const;
+ QString recordField( int id ) const;
/**
* toMap puts all data into the map. int relates
* to ToDoEvent RecordFields enum
*/
- QMap<int, QString> toMap()const;
+ QMap<int, QString> toMap() const;
/**
* Set if this Todo is completed
*/
- void setCompleted(bool completed );
+ void setCompleted( bool completed );
/**
* set if this todo got an end data
@@ -242,7 +244,7 @@ public:
/**
* Set the priority of the Todo
*/
- void setPriority(int priority );
+ void setPriority( int priority );
/**
* Set the progress.
@@ -266,14 +268,14 @@ public:
void setRecurrence( const ORecur& );
- void setDescription(const QString& );
- void setSummary(const QString& );
+ void setDescription( const QString& );
+ void setSummary( const QString& );
/**
* set the state of a Todo
* @param state State what the todo should take
*/
- void setState( const OPimState& state);
+ void setState( const OPimState& state );
/**
* set the Maintainer Mode
@@ -283,19 +285,19 @@ public:
bool isOverdue();
- virtual bool match( const QRegExp &r )const;
+ virtual bool match( const QRegExp &r ) const;
- bool operator<(const OTodo &toDoEvent )const;
- bool operator<=(const OTodo &toDoEvent )const;
- bool operator!=(const OTodo &toDoEvent )const;
- bool operator>(const OTodo &toDoEvent )const;
- bool operator>=(const OTodo &toDoEvent)const;
- bool operator==(const OTodo &toDoEvent )const;
- OTodo &operator=(const OTodo &toDoEvent );
+ bool operator<( const OTodo &toDoEvent ) const;
+ bool operator<=( const OTodo &toDoEvent ) const;
+ bool operator!=( const OTodo &toDoEvent ) const;
+ bool operator>( const OTodo &toDoEvent ) const;
+ bool operator>=( const OTodo &toDoEvent ) const;
+ bool operator==( const OTodo &toDoEvent ) const;
+ OTodo &operator=( const OTodo &toDoEvent );
static int rtti();
- private:
+ private:
class OTodoPrivate;
struct OTodoData;
@@ -306,8 +308,11 @@ public:
OTodoData *data;
};
-inline bool OTodo::operator!=(const OTodo &toDoEvent )const {
- return !(*this == toDoEvent);
+
+
+inline bool OTodo::operator!=( const OTodo &toDoEvent ) const
+{
+ return !( *this == toDoEvent );
}
}