summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--libopie2/opiepim/core/opimnotify.cpp219
-rw-r--r--libopie2/opiepim/core/opimnotify.h21
-rw-r--r--libopie2/opiepim/core/opimnotifymanager.cpp120
-rw-r--r--libopie2/opiepim/core/opimnotifymanager.h18
-rw-r--r--libopie2/opiepim/core/opimrecord.cpp117
-rw-r--r--libopie2/opiepim/core/opimrecord.h28
-rw-r--r--libopie2/opiepim/ocontact.cpp235
-rw-r--r--libopie2/opiepim/ocontact.h11
-rw-r--r--libopie2/opiepim/ocontactfields.cpp40
-rw-r--r--libopie2/opiepim/ocontactfields.h16
-rw-r--r--libopie2/opiepim/oevent.cpp534
-rw-r--r--libopie2/opiepim/oevent.h33
-rw-r--r--libopie2/opiepim/orecordlist.h142
-rw-r--r--libopie2/opiepim/otodo.cpp294
-rw-r--r--libopie2/opiepim/otodo.h27
15 files changed, 1349 insertions, 506 deletions
diff --git a/libopie2/opiepim/core/opimnotify.cpp b/libopie2/opiepim/core/opimnotify.cpp
index c61f9da..43858f0 100644
--- a/libopie2/opiepim/core/opimnotify.cpp
+++ b/libopie2/opiepim/core/opimnotify.cpp
@@ -27,13 +27,17 @@
Boston, MA 02111-1307, USA.
*/
-#include <qshared.h>
-#include <opie2/opimnotify.h>
+#include "opimnotify.h"
-namespace Opie {
+/* QT */
+#include <qshared.h>
-struct OPimNotify::Data : public QShared {
- Data() : QShared(),dur(-1),parent(0) {
+namespace Opie
+{
+struct OPimNotify::Data : public QShared
+{
+ Data() : QShared(), dur( -1 ), parent( 0 )
+ {
}
QDateTime start;
@@ -43,5 +47,6 @@ struct OPimNotify::Data : public QShared {
};
-OPimNotify::OPimNotify( const QDateTime& start, int duration, int parent ) {
+OPimNotify::OPimNotify( const QDateTime& start, int duration, int parent )
+{
data = new Data;
data->start = start;
@@ -49,4 +54,6 @@ OPimNotify::OPimNotify( const QDateTime& start, int duration, int parent ) {
data->parent = parent;
}
+
+
OPimNotify::OPimNotify( const OPimNotify& noti)
: data( noti.data )
@@ -54,6 +61,10 @@ OPimNotify::OPimNotify( const OPimNotify& noti)
data->ref();
}
-OPimNotify::~OPimNotify() {
- if ( data->deref() ) {
+
+
+OPimNotify::~OPimNotify()
+{
+ if ( data->deref() )
+ {
delete data;
data = 0l;
@@ -61,5 +72,7 @@ OPimNotify::~OPimNotify() {
}
-OPimNotify &OPimNotify::operator=( const OPimNotify& noti) {
+
+OPimNotify &OPimNotify::operator=( const OPimNotify& noti )
+{
noti.data->ref();
deref();
@@ -68,5 +81,8 @@ OPimNotify &OPimNotify::operator=( const OPimNotify& noti) {
return *this;
}
-bool OPimNotify::operator==( const OPimNotify& noti ) {
+
+
+bool OPimNotify::operator==( const OPimNotify& noti )
+{
if ( data == noti.data ) return true;
if ( data->dur != noti.data->dur ) return false;
@@ -77,37 +93,68 @@ 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 {
+
+
+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;
@@ -119,6 +166,10 @@ void OPimNotify::copyIntern() {
}
}
-void OPimNotify::deref() {
- if ( data->deref() ) {
+
+
+void OPimNotify::deref()
+{
+ if ( data->deref() )
+ {
delete data;
data = 0;
@@ -126,7 +177,10 @@ void OPimNotify::deref() {
}
+
/***********************************************************/
-struct OPimAlarm::Data : public QShared {
- Data() : QShared() {
+struct OPimAlarm::Data : public QShared
+{
+ Data() : QShared()
+ {
sound = 1;
}
@@ -134,4 +188,6 @@ struct OPimAlarm::Data : public QShared {
QString file;
};
+
+
OPimAlarm::OPimAlarm( int sound, const QDateTime& start, int duration, int parent )
: OPimNotify( start, duration, parent )
@@ -140,4 +196,6 @@ OPimAlarm::OPimAlarm( int sound, const QDateTime& start, int duration, int paren
data->sound = sound;
}
+
+
OPimAlarm::OPimAlarm( const OPimAlarm& al)
: OPimNotify(al), data( al.data )
@@ -145,10 +203,16 @@ OPimAlarm::OPimAlarm( const OPimAlarm& al)
data->ref();
}
-OPimAlarm::~OPimAlarm() {
- if ( data->deref() ) {
+
+
+OPimAlarm::~OPimAlarm()
+{
+ if ( data->deref() )
+ {
delete data;
data = 0l;
}
}
+
+
OPimAlarm &OPimAlarm::operator=( const OPimAlarm& al)
{
@@ -162,5 +226,8 @@ OPimAlarm &OPimAlarm::operator=( const OPimAlarm& al)
return *this;
}
-bool OPimAlarm::operator==( const OPimAlarm& al) {
+
+
+bool OPimAlarm::operator==( const OPimAlarm& al )
+{
if ( data->sound != al.data->sound ) return false;
else if ( data->sound == Custom && data->file != al.data->file )
@@ -169,29 +236,52 @@ bool OPimAlarm::operator==( const OPimAlarm& al) {
return OPimNotify::operator==( al );
}
-QString OPimAlarm::type()const {
+
+
+QString OPimAlarm::type() const
+{
return QString::fromLatin1("OPimAlarm");
}
-int OPimAlarm::sound()const {
+
+
+int OPimAlarm::sound() const
+{
return data->sound;
}
-QString OPimAlarm::file()const {
+
+
+QString OPimAlarm::file() const
+{
return data->file;
}
-void OPimAlarm::setSound( int snd) {
+
+
+void OPimAlarm::setSound( int snd )
+{
copyIntern();
data->sound = snd;
}
-void OPimAlarm::setFile( const QString& sound ) {
+
+
+void OPimAlarm::setFile( const QString& sound )
+{
copyIntern();
data->file = sound;
}
-void OPimAlarm::deref() {
- if ( data->deref() ) {
+
+
+void OPimAlarm::deref()
+{
+ if ( data->deref() )
+ {
delete data;
data = 0l;
}
}
-void OPimAlarm::copyIntern() {
- if ( data->count != 1 ) {
+
+
+void OPimAlarm::copyIntern()
+{
+ if ( data->count != 1 )
+ {
data->deref();
Data *newDat = new Data;
@@ -201,11 +291,16 @@ void OPimAlarm::copyIntern() {
}
}
+
+
/************************/
-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 )
@@ -214,4 +309,6 @@ OPimReminder::OPimReminder( int uid, const QDateTime& start, int dur, int paren
data->record = uid;
}
+
+
OPimReminder::OPimReminder( const OPimReminder& rem )
: OPimNotify( rem ), data( rem.data )
@@ -219,5 +316,8 @@ OPimReminder::OPimReminder( const OPimReminder& rem )
data->ref();
}
-OPimReminder& OPimReminder::operator=( const OPimReminder& rem) {
+
+
+OPimReminder& OPimReminder::operator=( const OPimReminder& rem )
+{
OPimNotify::operator=(rem );
@@ -228,27 +328,47 @@ 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 {
+
+
+QString OPimReminder::type() const
+{
return QString::fromLatin1("OPimReminder");
}
-int OPimReminder::recordUid()const {
+
+
+int OPimReminder::recordUid() const
+{
return data->record;
}
-void OPimReminder::setRecordUid( int uid ) {
+
+
+void OPimReminder::setRecordUid( int uid )
+{
copyIntern();
data->record = uid;
}
-void OPimReminder::deref() {
- if ( data->deref() ) {
+
+
+void OPimReminder::deref()
+{
+ if ( data->deref() )
+ {
delete data;
data = 0l;
}
}
-void OPimReminder::copyIntern() {
- if ( data->count != 1 ) {
+
+
+void OPimReminder::copyIntern()
+{
+ if ( data->count != 1 )
+ {
Data* da = new Data;
da->record = data->record;
@@ -256,3 +376,4 @@ void OPimReminder::copyIntern() {
}
}
+
}
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
@@ -27,12 +27,14 @@
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
@@ -48,5 +50,7 @@ namespace Opie {
* discuss: do we need a uid for the notify? -zecke
*/
-class OPimNotify {
+class OPimNotify
+{
+
public:
typedef QValueList<OPimNotify> ValueList;
@@ -101,5 +105,6 @@ private:
* an Event
*/
-class OPimAlarm : public OPimNotify {
+class OPimAlarm : public OPimNotify
+{
public:
enum Sound{Loud=1, Silent=0, Custom=2 };
@@ -136,7 +141,7 @@ private:
* In these cases one must resolve the uid and get the OEvent
*/
-class OPimReminder : public OPimNotify {
+class OPimReminder : public OPimNotify
+{
public:
-
/**
* c'tor of a reminder
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
@@ -27,42 +27,66 @@
Boston, MA 02111-1307, USA.
*/
-#include <opie2/opimnotifymanager.h>
+#include "opimnotifymanager.h"
+
+/* OPIE */
#include <opie2/oconversion.h>
+/* QT */
#include <qstringlist.h>
-namespace Opie {
+namespace Opie
+{
OPimNotifyManager::OPimNotifyManager( const Reminders& rem, const Alarms& al)
: m_rem( rem ), m_al( al )
{}
-OPimNotifyManager::~OPimNotifyManager() {
-}
+
+
+OPimNotifyManager::~OPimNotifyManager()
+{}
+
+
/* use static_cast and type instead of dynamic... */
-void OPimNotifyManager::add( const OPimNotify& noti) {
- if ( noti.type() == QString::fromLatin1("OPimReminder") ) {
+void OPimNotifyManager::add( const OPimNotify& noti )
+{
+ if ( noti.type() == QString::fromLatin1( "OPimReminder" ) )
+ {
const OPimReminder& rem = static_cast<const OPimReminder&>(noti);
m_rem.append( rem );
- }else if ( noti.type() == QString::fromLatin1("OPimAlarm") ) {
+ }
+ else if ( noti.type() == QString::fromLatin1( "OPimAlarm" ) )
+ {
const OPimAlarm& al = static_cast<const OPimAlarm&>(noti);
m_al.append( al );
}
}
-void OPimNotifyManager::remove( const OPimNotify& noti) {
- if ( noti.type() == QString::fromLatin1("OPimReminder") ) {
+
+
+void OPimNotifyManager::remove( const OPimNotify& noti )
+{
+ if ( noti.type() == QString::fromLatin1( "OPimReminder" ) )
+ {
const OPimReminder& rem = static_cast<const OPimReminder&>(noti);
m_rem.remove( rem );
- }else if ( noti.type() == QString::fromLatin1("OPimAlarm") ) {
+ }
+ else if ( noti.type() == QString::fromLatin1( "OPimAlarm" ) )
+ {
const OPimAlarm& al = static_cast<const OPimAlarm&>(noti);
m_al.remove( al );
}
}
-void OPimNotifyManager::replace( const OPimNotify& noti) {
- if ( noti.type() == QString::fromLatin1("OPimReminder") ) {
+
+
+void OPimNotifyManager::replace( const OPimNotify& noti )
+{
+ if ( noti.type() == QString::fromLatin1( "OPimReminder" ) )
+ {
const OPimReminder& rem = static_cast<const OPimReminder&>(noti);
m_rem.remove( rem );
m_rem.append( rem );
- }else if ( noti.type() == QString::fromLatin1("OPimAlarm") ) {
+ }
+ else if ( noti.type() == QString::fromLatin1( "OPimAlarm" ) )
+ {
const OPimAlarm& al = static_cast<const OPimAlarm&>(noti);
m_al.remove( al );
@@ -70,15 +94,25 @@ void OPimNotifyManager::replace( const OPimNotify& noti) {
}
}
-OPimNotifyManager::Reminders OPimNotifyManager::reminders()const {
+
+
+OPimNotifyManager::Reminders OPimNotifyManager::reminders() const
+{
return m_rem;
}
-OPimNotifyManager::Alarms OPimNotifyManager::alarms()const {
+
+
+OPimNotifyManager::Alarms OPimNotifyManager::alarms() const
+{
return m_al;
}
-OPimAlarm OPimNotifyManager::alarmAtDateTime( const QDateTime& when, bool& found ) const {
+
+
+OPimAlarm OPimNotifyManager::alarmAtDateTime( const QDateTime& when, bool& found ) const
+{
Alarms::ConstIterator it;
found = true;
- for ( it = m_al.begin(); it != m_al.end(); ++it ){
+ for ( it = m_al.begin(); it != m_al.end(); ++it )
+ {
if ( (*it).dateTime() == when )
return (*it);
@@ -92,10 +126,16 @@ OPimAlarm OPimNotifyManager::alarmAtDateTime( const QDateTime& when, bool& found
-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!!! */
/**
@@ -106,7 +146,9 @@ void OPimNotifyManager::setReminders( const Reminders& rem) {
* Qtopia1.6 services would be kewl to have here....
*/
-void OPimNotifyManager::registerNotify( const OPimNotify& ) {
-
+void OPimNotifyManager::registerNotify( const OPimNotify& )
+{
}
+
+
/* FIXME!!! */
/**
@@ -115,9 +157,11 @@ void OPimNotifyManager::registerNotify( const OPimNotify& ) {
* have a MainWindow....
*/
-void OPimNotifyManager::deregister( const OPimNotify& ) {
-
+void OPimNotifyManager::deregister( const OPimNotify& )
+{
}
-bool OPimNotifyManager::isEmpty()const {
+
+bool OPimNotifyManager::isEmpty() const
+{
qWarning("is Empty called on OPimNotifyManager %d %d", m_rem.count(), m_al.count() );
if ( m_rem.isEmpty() && m_al.isEmpty() ) return true;
@@ -125,5 +169,6 @@ bool OPimNotifyManager::isEmpty()const {
}
-// Taken from otodoaccessxml..
+
+// Taken from otodoaccessxml.. code duplication bad. any alternative?
QString OPimNotifyManager::alarmsToString() const
{
@@ -131,10 +176,13 @@ QString OPimNotifyManager::alarmsToString() const
OPimNotifyManager::Alarms alarms = m_al;
- if ( !alarms.isEmpty() ) {
+ if ( !alarms.isEmpty() )
+ {
QStringList als;
OPimNotifyManager::Alarms::Iterator it = alarms.begin();
- for ( ; it != alarms.end(); ++it ) {
+ for ( ; it != alarms.end(); ++it )
+ {
/* only if time is valid */
- if ( (*it).dateTime().isValid() ) {
+ if ( ( *it ).dateTime().isValid() )
+ {
als << OConversion::dateTimeToString( (*it).dateTime() )
+ ":" + QString::number( (*it).duration() )
@@ -150,4 +198,6 @@ QString OPimNotifyManager::alarmsToString() const
return str;
}
+
+
QString OPimNotifyManager::remindersToString() const
{
@@ -155,8 +205,10 @@ QString OPimNotifyManager::remindersToString() const
OPimNotifyManager::Reminders reminders = m_rem;
- if (!reminders.isEmpty() ) {
+ if ( !reminders.isEmpty() )
+ {
OPimNotifyManager::Reminders::Iterator it = reminders.begin();
QStringList records;
- for ( ; it != reminders.end(); ++it ) {
+ for ( ; it != reminders.end(); ++it )
+ {
records << QString::number( (*it).recordUid() );
}
@@ -167,8 +219,10 @@ QString OPimNotifyManager::remindersToString() const
}
+
void OPimNotifyManager::alarmsFromString( const QString& str )
{
QStringList als = QStringList::split(";", str );
- for (QStringList::Iterator it = als.begin(); it != als.end(); ++it ) {
+ for ( QStringList::Iterator it = als.begin(); it != als.end(); ++it )
+ {
QStringList alarm = QStringList::split(":", (*it), TRUE ); // allow empty
qWarning("alarm: %s", alarm.join("___").latin1() );
@@ -181,9 +235,11 @@ void OPimNotifyManager::alarmsFromString( const QString& str )
}
+
void OPimNotifyManager::remindersFromString( const QString& str )
{
QStringList rems = QStringList::split(";", str );
- for (QStringList::Iterator it = rems.begin(); it != rems.end(); ++it ) {
+ for ( QStringList::Iterator it = rems.begin(); it != rems.end(); ++it )
+ {
OPimReminder rem( (*it).toInt() );
add( rem );
diff --git a/libopie2/opiepim/core/opimnotifymanager.h b/libopie2/opiepim/core/opimnotifymanager.h
index 0272e5d..9241ea2 100644
--- a/libopie2/opiepim/core/opimnotifymanager.h
+++ b/libopie2/opiepim/core/opimnotifymanager.h
@@ -27,16 +27,20 @@
Boston, MA 02111-1307, USA.
*/
-#ifndef OPIE_PIM_NOTIFY_MANAGER_H
-#define OPIE_PIM_NOTIFY_MANAGER_H
-
-#include <qvaluelist.h>
+#ifndef OPIMNOTIFYMANAGER_H
+#define OPIMNOTIFYMANAGER_H
+/* OPIE */
#include <opie2/opimnotify.h>
-namespace Opie {
+/* QT */
+#include <qvaluelist.h>
+
+namespace Opie
+{
/**
* The notify manager keeps track of the Notifiers....
*/
-class OPimNotifyManager {
+class OPimNotifyManager
+{
public:
typedef QValueList<OPimReminder> Reminders;
@@ -107,6 +111,4 @@ public:
void remindersFromString( const QString& str );
-
-
private:
Reminders m_rem;
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
@@ -27,23 +27,32 @@
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 )
@@ -52,5 +61,7 @@ OPimRecord::OPimRecord( const OPimRecord& rec )
}
-OPimRecord &OPimRecord::operator=( const OPimRecord& rec) {
+
+OPimRecord &OPimRecord::operator=( const OPimRecord& rec )
+{
if ( this == &rec ) return *this;
@@ -61,8 +72,11 @@ OPimRecord &OPimRecord::operator=( const OPimRecord& rec) {
return *this;
}
+
+
/*
* category names
*/
-QStringList OPimRecord::categoryNames( const QString& appname ) const {
+QStringList OPimRecord::categoryNames( const QString& appname ) const
+{
QStringList list;
QArray<int> cats = categories();
@@ -70,5 +84,6 @@ QStringList OPimRecord::categoryNames( const QString& appname ) const {
catDB.load( categoryFileName() );
- for (uint i = 0; i < cats.count(); i++ ) {
+ for ( uint i = 0; i < cats.count(); i++ )
+ {
list << catDB.label( appname, cats[i] );
}
@@ -76,8 +91,13 @@ QStringList OPimRecord::categoryNames( const QString& appname ) const {
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() );
@@ -85,7 +105,12 @@ void OPimRecord::addCategoryName( const QString& ) {
}
-bool OPimRecord::isEmpty()const {
+
+
+bool OPimRecord::isEmpty() const
+{
return ( uid() == 0 );
}
+
+
/*QString OPimRecord::crossToString()const {
QString str;
@@ -103,5 +128,6 @@ bool OPimRecord::isEmpty()const {
}*/
/* if uid = 1 assign a new one */
-void OPimRecord::setUid( int uid ) {
+void OPimRecord::setUid( int uid )
+{
if ( uid == 1)
uid = uidGen().generate();
@@ -109,11 +135,20 @@ void OPimRecord::setUid( int uid ) {
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;
}
@@ -127,5 +162,6 @@ int OPimRecord::rtti(){
* XRef
*/
-bool OPimRecord::loadFromStream( QDataStream& stream ) {
+bool OPimRecord::loadFromStream( QDataStream& stream )
+{
int Int;
uint UInt;
@@ -136,5 +172,6 @@ bool OPimRecord::loadFromStream( QDataStream& stream ) {
stream >> UInt;
QArray<int> array(UInt);
- for (uint i = 0; i < UInt; i++ ) {
+ for ( uint i = 0; i < UInt; i++ )
+ {
stream >> array[i];
}
@@ -146,5 +183,6 @@ 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 ) );
@@ -154,5 +192,8 @@ bool OPimRecord::loadFromStream( QDataStream& stream ) {
return true;
}
-bool OPimRecord::saveToStream( QDataStream& stream )const {
+
+
+bool OPimRecord::saveToStream( QDataStream& stream ) const
+{
/** UIDs */
@@ -161,5 +202,6 @@ bool OPimRecord::saveToStream( QDataStream& stream )const {
/** Categories */
stream << categories().count();
- for ( uint i = 0; i < categories().count(); i++ ) {
+ for ( uint i = 0; i < categories().count(); i++ )
+ {
stream << categories()[i];
}
@@ -171,5 +213,6 @@ 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 ) {
+ it != m_xrefman.list().end(); ++it )
+ {
flush( (*it).partner( OPimXRef::One), stream );
flush( (*it).partner( OPimXRef::Two), stream );
@@ -177,10 +220,16 @@ bool OPimRecord::saveToStream( QDataStream& stream )const {
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;
@@ -198,14 +247,26 @@ 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
@@ -27,12 +27,10 @@
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...
@@ -42,7 +40,12 @@
#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
@@ -50,5 +53,6 @@ namespace Opie {
*
*/
-class OPimRecord : public Qtopia::Record {
+class OPimRecord : public Qtopia::Record
+{
public:
/**
@@ -111,6 +115,8 @@ public:
*/
virtual bool match( const QString &regexp ) const
- {setLastHitField( -1 );
- return Qtopia::Record::match(QRegExp(regexp));};
+ {
+ setLastHitField( -1 );
+ return Qtopia::Record::match( QRegExp( regexp ) );
+ };
/**
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,5 +1,5 @@
/*
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.
@@ -28,33 +28,16 @@
*/
-/**********************************************************************
-** 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>
@@ -63,4 +46,5 @@
#include <qmap.h>
+/* STD */
#include <stdio.h>
@@ -77,12 +61,11 @@
-namespace Opie {
+namespace Opie
+{
/*!
Creates a new, empty contact.
*/
-OContact::OContact()
- : OPimRecord(), mMap(), d( 0 )
-{
-}
+OContact::OContact():OPimRecord(), mMap(), d( 0 )
+{}
/*!
@@ -91,6 +74,5 @@ OContact::OContact()
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 ];
@@ -100,8 +82,10 @@ OContact::OContact( const QMap<int, QString> &fromMap ) :
QString uidStr = find( Qtopia::AddressUid );
- if ( uidStr.isEmpty() || (uidStr.toInt() == 0) ){
+ if ( uidStr.isEmpty() || ( uidStr.toInt() == 0 ) )
+ {
qWarning( "Invalid UID found. Generate new one.." );
setUid( uidGen().generate() );
- }else
+ }
+ else
setUid( uidStr.toInt() );
@@ -114,6 +98,5 @@ OContact::OContact( const QMap<int, QString> &fromMap ) :
*/
OContact::~OContact()
-{
-}
+{}
/*! \fn void OContact::setTitle( const QString &str )
@@ -482,9 +465,11 @@ QString OContact::toRichText() const
comp = company();
- if ( !(value = department()).isEmpty() ) {
+ if ( !( value = department() ).isEmpty() )
+ {
text += Qtopia::escapeString(value);
if ( comp )
text += ", " + Qtopia::escapeString(comp);
- }else if ( comp )
+ }
+ else if ( comp )
text += "<br>" + Qtopia::escapeString(comp);
text += "<br><hr>";
@@ -492,5 +477,6 @@ QString OContact::toRichText() const
// defailt email
QString defEmail = defaultEmail();
- if ( !defEmail.isEmpty() ){
+ if ( !defEmail.isEmpty() )
+ {
text += "<b><img src=\"addressbook/email\"> " + QObject::tr("Default Email: ") + "</b>"
+ Qtopia::escapeString(defEmail);
@@ -500,23 +486,29 @@ QString OContact::toRichText() const
// business address
if ( !businessStreet().isEmpty() || !businessCity().isEmpty() ||
- !businessZip().isEmpty() || !businessCountry().isEmpty() ) {
+ !businessZip().isEmpty() || !businessCountry().isEmpty() )
+ {
text += QObject::tr( "<br><b>Work Address:</b>" );
marker = true;
}
- if ( !(value = businessStreet()).isEmpty() ){
+ if ( !( value = businessStreet() ).isEmpty() )
+ {
text += "<br>" + Qtopia::escapeString(value);
marker = true;
}
- switch( addressformat ){
- case Zip_City_State:{ // Zip_Code City, State
+ switch ( addressformat )
+ {
+ case Zip_City_State:
+ { // Zip_Code City, State
state = businessState();
- if ( !(value = businessZip()).isEmpty() ){
+ if ( !( value = businessZip() ).isEmpty() )
+ {
text += "<br>" + Qtopia::escapeString(value) + " ";
marker = true;
}
- if ( !(value = businessCity()).isEmpty() ) {
+ if ( !( value = businessCity() ).isEmpty() )
+ {
marker = true;
if ( businessZip().isEmpty() && !businessStreet().isEmpty() )
@@ -525,5 +517,7 @@ QString OContact::toRichText() const
if ( state )
text += ", " + Qtopia::escapeString(state);
- } else if ( !state.isEmpty() ){
+ }
+ else if ( !state.isEmpty() )
+ {
text += "<br>" + Qtopia::escapeString(state);
marker = true;
@@ -531,16 +525,21 @@ QString OContact::toRichText() const
break;
}
- case City_State_Zip:{ // City, State Zip_Code
+ case City_State_Zip:
+ { // City, State Zip_Code
state = businessState();
- if ( !(value = businessCity()).isEmpty() ) {
+ if ( !( value = businessCity() ).isEmpty() )
+ {
marker = true;
text += "<br>" + Qtopia::escapeString(value);
if ( state )
text += ", " + Qtopia::escapeString(state);
- } else if ( !state.isEmpty() ){
+ }
+ else if ( !state.isEmpty() )
+ {
text += "<br>" + Qtopia::escapeString(state);
marker = true;
}
- if ( !(value = businessZip()).isEmpty() ){
+ if ( !( value = businessZip() ).isEmpty() )
+ {
text += " " + Qtopia::escapeString(value);
marker = true;
@@ -550,5 +549,6 @@ QString OContact::toRichText() const
}
- if ( !(value = businessCountry()).isEmpty() ){
+ if ( !( value = businessCountry() ).isEmpty() )
+ {
text += "<br>" + Qtopia::escapeString(value);
marker = true;
@@ -557,5 +557,6 @@ QString OContact::toRichText() const
// rest of Business data
str = office();
- if ( !str.isEmpty() ){
+ if ( !str.isEmpty() )
+ {
text += "<br><b>" + QObject::tr("Office: ") + "</b>"
+ Qtopia::escapeString(str);
@@ -563,5 +564,6 @@ QString OContact::toRichText() const
}
str = businessWebpage();
- if ( !str.isEmpty() ){
+ if ( !str.isEmpty() )
+ {
text += "<br><b><img src=\"addressbook/webpagework\"> " + QObject::tr("Business Web Page: ") + "</b>"
+ Qtopia::escapeString(str);
@@ -569,5 +571,6 @@ QString OContact::toRichText() const
}
str = businessPhone();
- if ( !str.isEmpty() ){
+ if ( !str.isEmpty() )
+ {
text += "<br><b><img src=\"addressbook/phonework\"> " + QObject::tr("Business Phone: ") + "</b>"
+ Qtopia::escapeString(str);
@@ -575,5 +578,6 @@ QString OContact::toRichText() const
}
str = businessFax();
- if ( !str.isEmpty() ){
+ if ( !str.isEmpty() )
+ {
text += "<br><b><img src=\"addressbook/faxwork\"> " + QObject::tr("Business Fax: ") + "</b>"
+ Qtopia::escapeString(str);
@@ -581,5 +585,6 @@ QString OContact::toRichText() const
}
str = businessMobile();
- if ( !str.isEmpty() ){
+ if ( !str.isEmpty() )
+ {
text += "<br><b><img src=\"addressbook/mobilework\"> " + QObject::tr("Business Mobile: ") + "</b>"
+ Qtopia::escapeString(str);
@@ -587,5 +592,6 @@ QString OContact::toRichText() const
}
str = businessPager();
- if ( !str.isEmpty() ){
+ if ( !str.isEmpty() )
+ {
text += "<br><b>" + QObject::tr("Business Pager: ") + "</b>"
+ Qtopia::escapeString(str);
@@ -597,22 +603,28 @@ QString OContact::toRichText() const
// home address
if ( !homeStreet().isEmpty() || !homeCity().isEmpty() ||
- !homeZip().isEmpty() || !homeCountry().isEmpty() ) {
+ !homeZip().isEmpty() || !homeCountry().isEmpty() )
+ {
text += QObject::tr( "<br><b>Home Address:</b>" );
marker = true;
}
- if ( !(value = homeStreet()).isEmpty() ){
+ if ( !( value = homeStreet() ).isEmpty() )
+ {
text += "<br>" + Qtopia::escapeString(value);
marker = true;
}
- switch( addressformat ){
- case Zip_City_State:{ // Zip_Code City, State
+ switch ( addressformat )
+ {
+ case Zip_City_State:
+ { // Zip_Code City, State
state = homeState();
- if ( !(value = homeZip()).isEmpty() ){
+ if ( !( value = homeZip() ).isEmpty() )
+ {
text += "<br>" + Qtopia::escapeString(value) + " ";
marker = true;
}
- if ( !(value = homeCity()).isEmpty() ) {
+ if ( !( value = homeCity() ).isEmpty() )
+ {
marker = true;
if ( homeZip().isEmpty() && !homeStreet().isEmpty() )
@@ -621,5 +633,7 @@ QString OContact::toRichText() const
if ( !state.isEmpty() )
text += ", " + Qtopia::escapeString(state);
- } else if (!state.isEmpty()) {
+ }
+ else if ( !state.isEmpty() )
+ {
text += "<br>" + Qtopia::escapeString(state);
marker = true;
@@ -627,16 +641,21 @@ QString OContact::toRichText() const
break;
}
- case City_State_Zip:{ // City, State Zip_Code
+ case City_State_Zip:
+ { // City, State Zip_Code
state = homeState();
- if ( !(value = homeCity()).isEmpty() ) {
+ if ( !( value = homeCity() ).isEmpty() )
+ {
marker = true;
text += "<br>" + Qtopia::escapeString(value);
if ( state )
text += ", " + Qtopia::escapeString(state);
- } else if ( !state.isEmpty() ){
+ }
+ else if ( !state.isEmpty() )
+ {
text += "<br>" + Qtopia::escapeString(state);
marker = true;
}
- if ( !(value = homeZip()).isEmpty() ){
+ if ( !( value = homeZip() ).isEmpty() )
+ {
text += " " + Qtopia::escapeString(value);
marker = true;
@@ -646,5 +665,6 @@ QString OContact::toRichText() const
}
- if ( !(value = homeCountry()).isEmpty() ){
+ if ( !( value = homeCountry() ).isEmpty() )
+ {
text += "<br>" + Qtopia::escapeString(value);
marker = true;
@@ -653,5 +673,6 @@ QString OContact::toRichText() const
// rest of Home data
str = homeWebpage();
- if ( !str.isEmpty() ){
+ if ( !str.isEmpty() )
+ {
text += "<br><b><img src=\"addressbook/webpagehome\"> " + QObject::tr("Home Web Page: ") + "</b>"
+ Qtopia::escapeString(str);
@@ -659,5 +680,6 @@ QString OContact::toRichText() const
}
str = homePhone();
- if ( !str.isEmpty() ){
+ if ( !str.isEmpty() )
+ {
text += "<br><b><img src=\"addressbook/phonehome\"> " + QObject::tr("Home Phone: ") + "</b>"
+ Qtopia::escapeString(str);
@@ -665,5 +687,6 @@ QString OContact::toRichText() const
}
str = homeFax();
- if ( !str.isEmpty() ){
+ if ( !str.isEmpty() )
+ {
text += "<br><b><img src=\"addressbook/faxhome\"> " + QObject::tr("Home Fax: ") + "</b>"
+ Qtopia::escapeString(str);
@@ -671,5 +694,6 @@ QString OContact::toRichText() const
}
str = homeMobile();
- if ( !str.isEmpty() ){
+ if ( !str.isEmpty() )
+ {
text += "<br><b><img src=\"addressbook/mobilehome\"> " + QObject::tr("Home Mobile: ") + "</b>"
+ Qtopia::escapeString(str);
@@ -698,5 +722,6 @@ QString OContact::toRichText() const
+ Qtopia::escapeString(str);
str = gender();
- if ( !str.isEmpty() && str.toInt() != 0 ) {
+ if ( !str.isEmpty() && str.toInt() != 0 )
+ {
text += "<br>";
if ( str.toInt() == 1 )
@@ -710,10 +735,12 @@ QString OContact::toRichText() const
text += "<br><b>" + QObject::tr("Spouse: ") + "</b>"
+ Qtopia::escapeString(str);
- if ( birthday().isValid() ){
+ if ( birthday().isValid() )
+ {
str = TimeString::numberDateString( birthday() );
text += "<br><b>" + QObject::tr("Birthday: ") + "</b>"
+ Qtopia::escapeString(str);
}
- if ( anniversary().isValid() ){
+ if ( anniversary().isValid() )
+ {
str = TimeString::numberDateString( anniversary() );
text += "<br><b>" + QObject::tr("Anniversary: ") + "</b>"
@@ -731,5 +758,6 @@ QString OContact::toRichText() const
// categories
- if ( categoryNames("Contacts").count() ){
+ if ( categoryNames( "Contacts" ).count() )
+ {
text += "<br><b>" + QObject::tr( "Category:") + "</b> ";
text += categoryNames("Contacts").join(", ");
@@ -737,5 +765,6 @@ QString OContact::toRichText() const
// notes last
- if ( !(value = notes()).isEmpty() ) {
+ if ( !( value = notes() ).isEmpty() )
+ {
text += "<br><hr><b>" + QObject::tr( "Notes:") + "</b> ";
QRegExp reg("\n");
@@ -838,20 +867,24 @@ QString OContact::fullName() const
QString name = title;
- if ( !firstName.isEmpty() ) {
+ if ( !firstName.isEmpty() )
+ {
if ( !name.isEmpty() )
name += " ";
name += firstName;
}
- if ( !middleName.isEmpty() ) {
+ if ( !middleName.isEmpty() )
+ {
if ( !name.isEmpty() )
name += " ";
name += middleName;
}
- if ( !lastName.isEmpty() ) {
+ if ( !lastName.isEmpty() )
+ {
if ( !name.isEmpty() )
name += " ";
name += lastName;
}
- if ( !suffix.isEmpty() ) {
+ if ( !suffix.isEmpty() )
+ {
if ( !name.isEmpty() )
name += " ";
@@ -901,5 +934,6 @@ QStringList OContact::emailList() const
QStringList r;
- if ( !emailStr.isEmpty() ) {
+ if ( !emailStr.isEmpty() )
+ {
qDebug(" emailstr ");
QStringList l = QStringList::split( emailSeparator(), emailStr );
@@ -947,8 +981,10 @@ void OContact::save( QString &buf ) const
// I'm expecting "<Contact " in front of this...
for ( QMap<int, QString>::ConstIterator it = mMap.begin();
- it != mMap.end(); ++it ) {
+ it != mMap.end(); ++it )
+ {
const QString &value = it.data();
int key = it.key();
- if ( !value.isEmpty() ) {
+ if ( !value.isEmpty() )
+ {
if ( key == Qtopia::AddressCategory || key == Qtopia::AddressUid)
continue;
@@ -1062,6 +1098,8 @@ bool OContact::match( const QRegExp &r ) const
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;
@@ -1077,4 +1115,6 @@ QString OContact::toShortText() const
return ( fullName() );
}
+
+
QString OContact::type() const
{
@@ -1083,5 +1123,4 @@ QString OContact::type() const
-
class QString OContact::recordField( int pos ) const
{
@@ -1100,5 +1139,6 @@ class QString OContact::recordField( int pos ) const
void OContact::setBirthday( const QDate &v )
{
- if ( v.isNull() ){
+ if ( v.isNull() )
+ {
qWarning( "Remove Birthday");
replace( Qtopia::Birthday, QString::null );
@@ -1118,5 +1158,6 @@ void OContact::setBirthday( const QDate &v )
void OContact::setAnniversary( const QDate &v )
{
- if ( v.isNull() ){
+ if ( v.isNull() )
+ {
qWarning( "Remove Anniversary");
replace( Qtopia::Anniversary, QString::null );
@@ -1128,4 +1169,5 @@ void OContact::setAnniversary( const QDate &v )
}
+
/*! \fn QDate OContact::birthday() const
Returns the birthday of the contact.
@@ -1164,5 +1206,6 @@ void OContact::insertEmail( const QString &v )
// if no default, set it as the default email and don't insert
- if ( def.isEmpty() ) {
+ if ( def.isEmpty() )
+ {
setDefaultEmail( e ); // will insert into the list for us
return;
@@ -1179,4 +1222,5 @@ void OContact::insertEmail( const QString &v )
}
+
void OContact::removeEmail( const QString &v )
{
@@ -1198,5 +1242,6 @@ void OContact::removeEmail( const QString &v )
// if default, then replace the default email with the first one
- if ( def == e ) {
+ if ( def == e )
+ {
//qDebug("removeEmail is default; setting new default");
if ( !emails.count() )
@@ -1206,4 +1251,6 @@ void OContact::removeEmail( const QString &v )
}
}
+
+
void OContact::clearEmails()
{
@@ -1211,4 +1258,6 @@ void OContact::clearEmails()
mMap.remove( Qtopia::Emails );
}
+
+
void OContact::setDefaultEmail( const QString &v )
{
@@ -1223,4 +1272,5 @@ void OContact::setDefaultEmail( const QString &v )
}
+
void OContact::insertEmails( const QStringList &v )
{
@@ -1228,7 +1278,12 @@ void OContact::insertEmails( const QStringList &v )
insertEmail( *it );
}
-int OContact::rtti() {
+
+
+int OContact::rtti()
+{
return OPimResolver::AddressBook;
}
+
+
void OContact::setUid( int 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
@@ -27,10 +27,13 @@
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>
@@ -42,5 +45,6 @@ QPC_TEMPLATEEXTERN template class QPC_EXPORT QMap<int, QString>;
#endif
-namespace Opie {
+namespace Opie
+{
class OContactPrivate;
@@ -55,4 +59,5 @@ class QPC_EXPORT OContact : public OPimRecord
{
friend class DataSet;
+
public:
OContact();
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,5 +1,5 @@
/*
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.
@@ -28,15 +28,18 @@
*/
-#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
@@ -424,9 +427,11 @@ OContactFields::OContactFields():
}
-OContactFields::~OContactFields(){
+OContactFields::~OContactFields()
+{
// We will store the fieldorder into the config file
// to reuse it for the future..
- if ( changedFieldOrder ){
+ if ( changedFieldOrder )
+ {
Config cfg ( "AddressBook" );
cfg.setGroup( "ContactFieldOrder" );
@@ -437,5 +442,6 @@ OContactFields::~OContactFields(){
-void OContactFields::saveToRecord( OContact &cnt ){
+void OContactFields::saveToRecord( OContact &cnt )
+{
qDebug("ocontactfields saveToRecord: >%s<",fieldOrder.latin1());
@@ -449,5 +455,6 @@ void OContactFields::saveToRecord( OContact &cnt ){
}
-void OContactFields::loadFromRecord( const OContact &cnt ){
+void OContactFields::loadFromRecord( const OContact &cnt )
+{
qDebug("ocontactfields loadFromRecord");
qDebug("loading >%s<",cnt.fullName().latin1());
@@ -460,5 +467,6 @@ void OContactFields::loadFromRecord( const OContact &cnt ){
qDebug("fieldOrder from contact>%s<",fieldOrder.latin1());
- if (fieldOrder.isEmpty()){
+ if ( fieldOrder.isEmpty() )
+ {
fieldOrder = globalFieldOrder;
}
@@ -468,5 +476,6 @@ void OContactFields::loadFromRecord( const OContact &cnt ){
}
-void OContactFields::setFieldOrder( int num, int index ){
+void OContactFields::setFieldOrder( int num, int index )
+{
qDebug("qcontactfields setfieldorder pos %i -> %i",num,index);
@@ -481,5 +490,6 @@ void OContactFields::setFieldOrder( int num, int index ){
}
-int OContactFields::getFieldOrder( int num, int defIndex ){
+int OContactFields::getFieldOrder( int num, int defIndex )
+{
qDebug("ocontactfields getFieldOrder");
qDebug("fieldOrder >%s<",fieldOrder.latin1());
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
@@ -27,18 +27,24 @@
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{
+namespace Opie
+{
+class OContactFields
+{
public:
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,5 +1,5 @@
/*
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.
@@ -27,20 +27,24 @@
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
@@ -54,13 +58,20 @@ 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;
@@ -68,11 +79,17 @@ int OCalendarHelper::dayOfWeek( char day ) {
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();
}
-struct OEvent::Data : public QShared {
- Data() : QShared() {
+
+struct OEvent::Data : public QShared
+{
+ Data() : QShared()
+ {
child = 0;
recur = 0;
@@ -81,5 +98,6 @@ struct OEvent::Data : public QShared {
parent = 0;
}
- ~Data() {
+ ~Data()
+ {
delete manager;
delete recur;
@@ -99,8 +117,12 @@ struct OEvent::Data : public QShared {
};
+
OEvent::OEvent( int uid )
- : OPimRecord( uid ) {
+ : OPimRecord( uid )
+{
data = new Data;
}
+
+
OEvent::OEvent( const OEvent& ev)
: OPimRecord( ev ), data( ev.data )
@@ -109,4 +131,5 @@ OEvent::OEvent( const OEvent& ev)
}
+
OEvent::OEvent( const QMap<int, QString> map )
: OPimRecord( 0 )
@@ -117,11 +140,17 @@ OEvent::OEvent( const QMap<int, QString> map )
}
-OEvent::~OEvent() {
- if ( data->deref() ) {
+
+OEvent::~OEvent()
+{
+ if ( data->deref() )
+ {
delete data;
data = 0;
}
}
-OEvent& OEvent::operator=( const OEvent& ev) {
+
+
+OEvent& OEvent::operator=( const OEvent& ev )
+{
if ( this == &ev ) return *this;
@@ -134,19 +163,34 @@ 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
@@ -157,5 +201,8 @@ OPimNotifyManager &OEvent::notifiers()const {
return *data->manager;
}
-bool OEvent::hasNotifiers()const {
+
+
+bool OEvent::hasNotifiers() const
+{
if (!data->manager )
return false;
@@ -166,5 +213,8 @@ bool OEvent::hasNotifiers()const {
return true;
}
-ORecur OEvent::recurrence()const {
+
+
+ORecur OEvent::recurrence() const
+{
if (!data->recur)
data->recur = new ORecur;
@@ -172,5 +222,8 @@ ORecur OEvent::recurrence()const {
return *data->recur;
}
-void OEvent::setRecurrence( const ORecur& rec) {
+
+
+void OEvent::setRecurrence( const ORecur& rec )
+{
changeOrModify();
if (data->recur )
@@ -179,28 +232,49 @@ void OEvent::setRecurrence( const ORecur& rec) {
data->recur = new ORecur( rec );
}
-bool OEvent::hasRecurrence()const {
+
+
+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 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();
@@ -209,9 +283,15 @@ QDateTime OEvent::startDateTimeInZone()const {
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
@@ -222,5 +302,8 @@ QDateTime OEvent::endDateTime()const {
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();
@@ -229,45 +312,71 @@ QDateTime OEvent::endDateTimeInZone()const {
return zone.toDateTime( data->end, OTimeZone::current() );
}
-void OEvent::setEndDateTime( const QDateTime& dt ) {
+
+
+void OEvent::setEndDateTime( const QDateTime& dt )
+{
changeOrModify();
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";
}
-void OEvent::setTimeZone( const QString& tz ) {
+
+
+void OEvent::setTimeZone( const QString& tz )
+{
changeOrModify();
data->timezone = tz;
}
-QString OEvent::timeZone()const {
+
+
+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;
@@ -275,10 +384,14 @@ bool OEvent::match( const QRegExp& re )const {
return false;
}
-QString OEvent::toRichText()const {
+
+
+QString OEvent::toRichText() const
+{
QString text, value;
// description
text += "<b><h3><img src=\"datebook/DateBook\">";
- if ( !description().isEmpty() ) {
+ if ( !description().isEmpty() )
+ {
text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "" );
}
@@ -286,5 +399,6 @@ QString OEvent::toRichText()const {
// location
- if ( !(value = location()).isEmpty() ) {
+ if ( !( value = location() ).isEmpty() )
+ {
text += "<b>" + QObject::tr( "Location:" ) + "</b> ";
text += Qtopia::escapeString(value) + "<br>";
@@ -292,15 +406,19 @@ QString OEvent::toRichText()const {
// 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() ) {
+ if ( startDateTime().isValid() )
+ {
text += "<b>" + QObject::tr( "Start:") + "</b> ";
text += Qtopia::escapeString(startDateTime().toString() ).
@@ -309,5 +427,6 @@ QString OEvent::toRichText()const {
// end time
- if ( endDateTime().isValid() ) {
+ if ( endDateTime().isValid() )
+ {
text += "<b>" + QObject::tr( "End:") + "</b> ";
text += Qtopia::escapeString(endDateTime().toString() ).
@@ -317,5 +436,6 @@ QString OEvent::toRichText()const {
// categories
- if ( categoryNames("Calendar").count() ){
+ if ( categoryNames( "Calendar" ).count() )
+ {
text += "<b>" + QObject::tr( "Category:") + "</b> ";
text += categoryNames("Calendar").join(", ");
@@ -324,5 +444,6 @@ QString OEvent::toRichText()const {
//notes
- if ( !note().isEmpty() ) {
+ if ( !note().isEmpty() )
+ {
text += "<b>" + QObject::tr( "Note:") + "</b><br>";
text += note();
@@ -332,5 +453,8 @@ QString OEvent::toRichText()const {
return text;
}
-QString OEvent::toShortText()const {
+
+
+QString OEvent::toShortText() const
+{
QString text;
text += QString::number( startDateTime().date().day() );
@@ -347,21 +471,40 @@ QString OEvent::toShortText()const {
return text;
}
-QString OEvent::type()const {
+
+
+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;
@@ -383,5 +526,6 @@ void OEvent::changeOrModify() {
d2->parent = data->parent;
- if ( data->child ) {
+ if ( data->child )
+ {
d2->child = new QArray<int>( *data->child );
d2->child->detach();
@@ -391,6 +535,10 @@ void OEvent::changeOrModify() {
}
}
-void OEvent::deref() {
- if ( data->deref() ) {
+
+
+void OEvent::deref()
+{
+ if ( data->deref() )
+ {
delete data;
data = 0;
@@ -402,5 +550,6 @@ void OEvent::deref() {
// 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;
@@ -421,8 +570,10 @@ QMap<int, QString> OEvent::toMap()const {
if( parent() )
retMap.insert( OEvent::FRecParent, QString::number( parent() ) );
- if( children().count() ){
+ if ( children().count() )
+ {
QArray<int> childr = children();
QString buf;
- for ( uint i = 0; i < childr.count(); i++ ) {
+ for ( uint i = 0; i < childr.count(); i++ )
+ {
if ( i != 0 ) buf += " ";
buf += QString::number( childr[i] );
@@ -432,5 +583,6 @@ QMap<int, QString> OEvent::toMap()const {
// Add recurrence stuff
- if( hasRecurrence() ){
+ if ( hasRecurrence() )
+ {
ORecur recur = recurrence();
QMap<int, QString> recFields = recur.toMap();
@@ -443,5 +595,7 @@ QMap<int, QString> OEvent::toMap()const {
retMap.insert( OEvent::FRCreated, recFields[ORecur::Created] );
retMap.insert( OEvent::FRExceptions, recFields[ORecur::Exceptions] );
- } else {
+ }
+ else
+ {
ORecur recur = recurrence();
QMap<int, QString> recFields = recur.toMap();
@@ -452,4 +606,5 @@ QMap<int, QString> OEvent::toMap()const {
}
+
void OEvent::fromMap( const QMap<int, QString>& map )
{
@@ -473,10 +628,12 @@ void OEvent::fromMap( const QMap<int, QString>& map )
int sound = ( ( map[OEvent::FSound] == "loud" ) ? OPimAlarm::Loud : OPimAlarm::Silent );
- if ( ( alarmTime != -1 ) ){
+ 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" ) ){
+ if ( !map[ OEvent::FTimeZone ].isEmpty() && ( map[ OEvent::FTimeZone ] != "None" ) )
+ {
setTimeZone( map[OEvent::FTimeZone] );
}
@@ -486,10 +643,13 @@ void OEvent::fromMap( const QMap<int, QString>& map )
/* AllDay is always in UTC */
- if ( isAllDay() ) {
+ if ( isAllDay() )
+ {
OTimeZone utc = OTimeZone::utc();
setStartDateTime( utc.fromUTCDateTime( start ) );
setEndDateTime ( utc.fromUTCDateTime( end ) );
setTimeZone( "UTC"); // make sure it is really utc
- }else {
+ }
+ else
+ {
/* to current date time */
// qWarning(" Start is %d", start );
@@ -506,7 +666,9 @@ void OEvent::fromMap( const QMap<int, QString>& map )
setParent( map[OEvent::FRecParent].toInt() );
- if ( !map[OEvent::FRecChildren].isEmpty() ){
+ if ( !map[ OEvent::FRecChildren ].isEmpty() )
+ {
QStringList list = QStringList::split(' ', map[OEvent::FRecChildren] );
- for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
+ for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it )
+ {
addChild( (*it).toInt() );
}
@@ -514,5 +676,6 @@ void OEvent::fromMap( const QMap<int, QString>& map )
// Fill recurrence stuff and put it directly into the ORecur-Object using fromMap..
- if( !map[OEvent::FRType].isEmpty() ){
+ if ( !map[ OEvent::FRType ].isEmpty() )
+ {
QMap<int, QString> recFields;
recFields.insert( ORecur::RType, map[OEvent::FRType] );
@@ -531,17 +694,27 @@ void OEvent::fromMap( const QMap<int, QString>& map )
-int OEvent::parent()const {
+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{
+
+
+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;
@@ -550,10 +723,16 @@ void OEvent::setChildren( const QArray<int>& arr ) {
data->child->detach();
}
-void OEvent::addChild( int uid ) {
+
+
+void OEvent::addChild( int uid )
+{
changeOrModify();
- if (!data->child ) {
+ if ( !data->child )
+ {
data->child = new QArray<int>(1);
(*data->child)[0] = uid;
- }else{
+ }
+ else
+ {
int count = data->child->count();
data->child->resize( count + 1 );
@@ -561,5 +740,8 @@ void OEvent::addChild( int uid ) {
}
}
-void OEvent::removeChild( int uid ) {
+
+
+void OEvent::removeChild( int uid )
+{
if (!data->child || !data->child->contains( uid ) ) return;
changeOrModify();
@@ -567,6 +749,8 @@ void OEvent::removeChild( int uid ) {
int j = 0;
uint count = data->child->count();
- for ( uint i = 0; i < count; i++ ) {
- if ( (*data->child)[i] != uid ) {
+ for ( uint i = 0; i < count; i++ )
+ {
+ if ( ( *data->child ) [ i ] != uid )
+ {
newAr[j] = (*data->child)[i];
j++;
@@ -575,7 +759,10 @@ void OEvent::removeChild( int uid ) {
(*data->child) = newAr;
}
-struct OEffectiveEvent::Data : public QShared {
- Data() : QShared() {
- }
+
+
+struct OEffectiveEvent::Data : public QShared
+{
+ Data() : QShared()
+ {}
OEvent event;
QDate date;
@@ -585,5 +772,7 @@ struct OEffectiveEvent::Data : public QShared {
};
-OEffectiveEvent::OEffectiveEvent() {
+
+OEffectiveEvent::OEffectiveEvent()
+{
data = new Data;
data->date = QDate::currentDate();
@@ -591,6 +780,9 @@ OEffectiveEvent::OEffectiveEvent() {
data->dates = false;
}
+
+
OEffectiveEvent::OEffectiveEvent( const OEvent& ev, const QDate& startDate,
- Position pos ) {
+ Position pos )
+{
data = new Data;
data->event = ev;
@@ -608,15 +800,25 @@ 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 ) {
+
+
+OEffectiveEvent& OEffectiveEvent::operator=( const OEffectiveEvent& ev )
+{
if ( *this == ev ) return *this;
@@ -628,23 +830,38 @@ OEffectiveEvent& OEffectiveEvent::operator=( const OEffectiveEvent& ev ) {
}
-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;
@@ -654,35 +871,65 @@ void OEffectiveEvent::setEffectiveDates( const QDate& 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 {
+
+
+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() );
}
-QDate OEffectiveEvent::startDate()const {
+
+
+QDate OEffectiveEvent::startDate() const
+{
if ( data->dates )
return data->startDate;
@@ -692,5 +939,8 @@ QDate OEffectiveEvent::startDate()const {
return data->event.startDateTime().date();
}
-QDate OEffectiveEvent::endDate()const {
+
+
+QDate OEffectiveEvent::endDate() const
+{
if ( data->dates )
return data->endDate;
@@ -700,12 +950,20 @@ QDate OEffectiveEvent::endDate()const {
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;
@@ -720,5 +978,8 @@ void OEffectiveEvent::changeOrModify() {
}
}
-bool OEffectiveEvent::operator<( const OEffectiveEvent &e ) const{
+
+
+bool OEffectiveEvent::operator<( const OEffectiveEvent &e ) const
+{
if ( data->date < e.date() )
return TRUE;
@@ -728,8 +989,14 @@ bool OEffectiveEvent::operator<( const OEffectiveEvent &e ) const{
return FALSE;
}
-bool OEffectiveEvent::operator<=( const OEffectiveEvent &e ) const{
+
+
+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()
@@ -737,11 +1004,20 @@ bool OEffectiveEvent::operator==( const OEffectiveEvent &e ) const {
&& event() == e.event() );
}
-bool OEffectiveEvent::operator!=( const OEffectiveEvent &e ) const {
+
+
+bool OEffectiveEvent::operator!=( const OEffectiveEvent &e ) const
+{
return !(*this == e );
}
-bool OEffectiveEvent::operator>( const OEffectiveEvent &e ) const {
+
+
+bool OEffectiveEvent::operator>( const OEffectiveEvent &e ) const
+{
return !(*this <= e );
}
-bool OEffectiveEvent::operator>= ( const OEffectiveEvent &e ) const {
+
+
+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,5 +1,5 @@
/*
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.
@@ -29,19 +29,22 @@
// 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& );
@@ -66,5 +69,6 @@ class ORecur;
* @short container for events.
*/
-class OEvent : public OPimRecord {
+class OEvent : public OPimRecord
+{
public:
typedef QValueList<OEvent> ValueList;
@@ -192,4 +196,5 @@ public:
bool operator>=(const OEvent& );
*/
+
private:
inline void changeOrModify();
@@ -205,5 +210,7 @@ private:
* AN Event can span through multiple days. We split up a multiday eve
*/
-class OEffectiveEvent {
+class OEffectiveEvent
+{
+
public:
typedef QValueList<OEffectiveEvent> ValueList;
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
@@ -28,13 +28,16 @@
*/
-#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;
@@ -48,6 +51,8 @@ class ORecordListIteratorPrivate;
template <class T> class ORecordList;
template <class T = OPimRecord>
-class ORecordListIterator {
+class ORecordListIterator
+{
friend class ORecordList<T>;
+
public:
typedef OTemplateBase<T> Base;
@@ -106,4 +111,5 @@ private:
};
+
class ORecordListPrivate;
/**
@@ -112,5 +118,6 @@ class ORecordListPrivate;
*/
template <class T = OPimRecord >
-class ORecordList {
+class ORecordList
+{
public:
typedef OTemplateBase<T> Base;
@@ -120,6 +127,6 @@ public:
* c'tor
*/
- ORecordList () {
- }
+ ORecordList ()
+ {}
ORecordList( const QArray<int>& ids,
const Base* );
@@ -159,7 +166,9 @@ private:
};
+
/* ok now implement it */
template <class T>
-ORecordListIterator<T>::ORecordListIterator() {
+ORecordListIterator<T>::ORecordListIterator()
+{
m_current = 0;
m_temp = 0l;
@@ -169,11 +178,16 @@ ORecordListIterator<T>::ORecordListIterator() {
m_direction = TRUE;
}
+
+
template <class T>
-ORecordListIterator<T>::~ORecordListIterator() {
+ORecordListIterator<T>::~ORecordListIterator()
+{
/* nothing to delete */
}
+
template <class T>
-ORecordListIterator<T>::ORecordListIterator( const ORecordListIterator<T>& it) {
+ORecordListIterator<T>::ORecordListIterator( const ORecordListIterator<T>& it )
+{
// qWarning("ORecordListIterator copy c'tor");
m_uids = it.m_uids;
@@ -185,6 +199,8 @@ ORecordListIterator<T>::ORecordListIterator( const ORecordListIterator<T>& it) {
}
+
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;
@@ -196,6 +212,8 @@ ORecordListIterator<T> &ORecordListIterator<T>::operator=( const ORecordListIter
}
+
template <class T>
-T ORecordListIterator<T>::operator*() {
+T ORecordListIterator<T>::operator*()
+{
//qWarning("operator* %d %d", m_current, m_uids[m_current] );
if (!m_end )
@@ -209,22 +227,31 @@ T ORecordListIterator<T>::operator*() {
}
+
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;
@@ -232,6 +259,8 @@ ORecordListIterator<T> &ORecordListIterator<T>::operator--() {
}
+
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.... */
@@ -244,8 +273,13 @@ bool ORecordListIterator<T>::operator==( const ORecordListIterator<T>& it ) {
return true;
}
+
+
template <class T>
-bool ORecordListIterator<T>::operator!=( const ORecordListIterator<T>& it ) {
+bool ORecordListIterator<T>::operator!=( const ORecordListIterator<T>& it )
+{
return !(*this == it );
}
+
+
template <class T>
ORecordListIterator<T>::ORecordListIterator( const QArray<int> uids,
@@ -258,11 +292,18 @@ ORecordListIterator<T>::ORecordListIterator( const QArray<int> uids,
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() ) {
+void ORecordListIterator<T>::setCurrent( uint cur )
+{
+ if ( cur < m_uids.count() )
+ {
m_end = false;
m_current= cur;
@@ -270,24 +311,35 @@ void ORecordListIterator<T>::setCurrent( uint 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 )
-{
-}
+{}
+
+
template <class T>
-ORecordList<T>::~ORecordList() {
+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;
@@ -296,10 +348,16 @@ typename ORecordList<T>::Iterator ORecordList<T>::end() {
return it;
}
+
+
template <class T>
-uint ORecordList<T>::count()const {
+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();
@@ -307,20 +365,28 @@ T ORecordList<T>::operator[]( uint i ) {
return m_acc->find( m_ids[i], m_ids, i );
}
+
+
template <class T>
-int ORecordList<T>::uidAt( uint i ) {
+int ORecordList<T>::uidAt( uint i )
+{
return m_ids[i];
}
+
template <class T>
-bool ORecordList<T>::remove( int uid ) {
+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 ){
+ for ( uint i = 0; i < m_ids.count(); i++ )
+ {
+ if ( m_ids[ i ] != uid )
+ {
copy[counter++] = m_ids[i];
- }else
+ }
+ else
ret_val = true;
}
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
@@ -27,9 +27,13 @@
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>
@@ -39,17 +43,15 @@
#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;
@@ -57,5 +59,6 @@ struct OTodo::OTodoData : public QShared {
notifiers = 0;
};
- ~OTodoData() {
+ ~OTodoData()
+ {
delete recur;
delete maintainer;
@@ -79,4 +82,5 @@ struct OTodo::OTodoData : public QShared {
};
+
OTodo::OTodo(const OTodo &event )
: OPimRecord( event ), data( event.data )
@@ -85,8 +89,12 @@ OTodo::OTodo(const OTodo &event )
// qWarning("ref up");
}
-OTodo::~OTodo() {
+
+
+OTodo::~OTodo()
+{
// qWarning("~OTodo " );
- if ( data->deref() ) {
+ if ( data->deref() )
+ {
// qWarning("OTodo::dereffing");
delete data;
@@ -94,4 +102,6 @@ OTodo::~OTodo() {
}
}
+
+
OTodo::OTodo(bool completed, int priority,
const QArray<int> &category,
@@ -115,4 +125,6 @@ OTodo::OTodo(bool completed, int priority,
data->desc = Qtopia::simplifyMultiLineSpace(description );
}
+
+
OTodo::OTodo(bool completed, int priority,
const QStringList &category,
@@ -136,16 +148,25 @@ OTodo::OTodo(bool completed, int priority,
data->desc = Qtopia::simplifyMultiLineSpace(description );
}
+
+
bool OTodo::match( const QRegExp &regExp )const
{
- if( QString::number( data->priority ).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 ){
+ }
+ else if ( data->hasDate && data->date.toString().find( regExp ) != -1 )
+ {
setLastHitField( HasDate );
return true;
- }else if(data->desc.find( regExp ) != -1 ){
+ }
+ 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;
@@ -153,50 +174,83 @@ bool OTodo::match( const QRegExp &regExp )const
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
{
return data->priority;
}
+
+
QString OTodo::summary() const
{
return data->sum;
}
+
+
ushort OTodo::progress() const
{
return data->prog;
}
+
+
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
{
return data->desc;
}
-bool OTodo::hasState() const{
+
+
+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;
@@ -205,23 +259,37 @@ OPimState OTodo::state()const {
return (*data->state);
}
-bool OTodo::hasRecurrence()const {
+
+
+bool OTodo::hasRecurrence() const
+{
if (!data->recur) return false;
return data->recur->doesRecur();
}
-ORecur OTodo::recurrence()const {
+
+
+ORecur OTodo::recurrence() const
+{
if (!data->recur) return ORecur();
return (*data->recur);
}
-bool OTodo::hasMaintainer()const {
+
+
+bool OTodo::hasMaintainer() const
+{
if (!data->maintainer) return false;
return (data->maintainer->mode() != OPimMaintainer::Undefined );
}
-OPimMaintainer OTodo::maintainer()const {
+
+
+OPimMaintainer OTodo::maintainer() const
+{
if (!data->maintainer) return OPimMaintainer();
return (*data->maintainer);
}
+
+
void OTodo::setCompleted( bool completed )
{
@@ -229,4 +297,6 @@ void OTodo::setCompleted( bool completed )
data->isCompleted = completed;
}
+
+
void OTodo::setHasDueDate( bool hasDate )
{
@@ -234,4 +304,6 @@ void OTodo::setHasDueDate( bool hasDate )
data->hasDate = hasDate;
}
+
+
void OTodo::setDescription(const QString &desc )
{
@@ -240,4 +312,6 @@ void OTodo::setDescription(const QString &desc )
data->desc = Qtopia::simplifyMultiLineSpace(desc );
}
+
+
void OTodo::setSummary( const QString& sum )
{
@@ -245,4 +319,6 @@ void OTodo::setSummary( const QString& sum )
data->sum = sum;
}
+
+
void OTodo::setPriority(int prio )
{
@@ -250,4 +326,6 @@ void OTodo::setPriority(int prio )
data->priority = prio;
}
+
+
void OTodo::setDueDate( const QDate& date )
{
@@ -255,13 +333,22 @@ void OTodo::setDueDate( const QDate& date )
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 )
@@ -270,5 +357,8 @@ void OTodo::setState( const OPimState& state ) {
data->state = new OPimState( state );
}
-void OTodo::setRecurrence( const ORecur& rec) {
+
+
+void OTodo::setRecurrence( const ORecur& rec )
+{
changeOrModify();
if (data->recur )
@@ -277,5 +367,8 @@ void OTodo::setRecurrence( const ORecur& rec) {
data->recur = new ORecur( rec );
}
-void OTodo::setMaintainer( const OPimMaintainer& pim ) {
+
+
+void OTodo::setMaintainer( const OPimMaintainer& pim )
+{
changeOrModify();
@@ -285,4 +378,6 @@ void OTodo::setMaintainer( const OPimMaintainer& pim ) {
data->maintainer = new OPimMaintainer( pim );
}
+
+
bool OTodo::isOverdue( )
{
@@ -291,4 +386,6 @@ bool OTodo::isOverdue( )
return false;
}
+
+
void OTodo::setProgress(ushort progress )
{
@@ -296,7 +393,12 @@ void OTodo::setProgress(ushort progress )
data->prog = progress;
}
-QString OTodo::toShortText() const {
+
+
+QString OTodo::toShortText() const
+{
return summary();
}
+
+
/*!
Returns a richt text string
@@ -309,5 +411,6 @@ QString OTodo::toRichText() const
// summary
text += "<b><h3><img src=\"todo/TodoList\"> ";
- if ( !summary().isEmpty() ) {
+ if ( !summary().isEmpty() )
+ {
text += Qtopia::escapeString(summary() ).replace(QRegExp( "[\n]"), "" );
}
@@ -315,5 +418,6 @@ QString OTodo::toRichText() const
// description
- if( !description().isEmpty() ){
+ if ( !description().isEmpty() )
+ {
text += "<b>" + QObject::tr( "Description:" ) + "</b><br>";
text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "<br>" ) + "<br>";
@@ -345,5 +449,6 @@ QString OTodo::toRichText() const
// due date
- if (hasDueDate() ){
+ if ( hasDueDate() )
+ {
QDate dd = dueDate();
int off = QDate::currentDate().daysTo( dd );
@@ -367,14 +472,23 @@ QString OTodo::toRichText() const
return text;
}
-bool OTodo::hasNotifiers()const {
+
+
+bool OTodo::hasNotifiers() const
+{
if (!data->notifiers) return false;
return !data->notifiers->isEmpty();
}
-OPimNotifyManager& OTodo::notifiers() {
+
+
+OPimNotifyManager& OTodo::notifiers()
+{
if (!data->notifiers )
data->notifiers = new OPimNotifyManager;
return (*data->notifiers);
}
-const OPimNotifyManager& OTodo::notifiers()const{
+
+
+const OPimNotifyManager& OTodo::notifiers() const
+{
if (!data->notifiers )
data->notifiers = new OPimNotifyManager;
@@ -383,11 +497,17 @@ const OPimNotifyManager& OTodo::notifiers()const{
}
-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
+ if ( hasDueDate() && toDoEvent.hasDueDate() )
+ {
+ if ( dueDate() == toDoEvent.dueDate() )
+ { // let's the priority decide
return priority() < toDoEvent.priority();
- }else{
+ }
+ else
+ {
return dueDate() < toDoEvent.dueDate();
}
@@ -395,12 +515,18 @@ bool OTodo::operator<( const OTodo &toDoEvent )const{
return false;
}
+
+
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
+ if ( hasDueDate() && toDoEvent.hasDueDate() )
+ {
+ if ( dueDate() == toDoEvent.dueDate() )
+ { // let's the priority decide
return priority() <= toDoEvent.priority();
- }else{
+ }
+ else
+ {
return dueDate() <= toDoEvent.dueDate();
}
@@ -408,12 +534,18 @@ bool OTodo::operator<=(const OTodo &toDoEvent )const
return true;
}
+
+
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
+ if ( hasDueDate() && toDoEvent.hasDueDate() )
+ {
+ if ( dueDate() == toDoEvent.dueDate() )
+ { // let's the priority decide
return priority() > toDoEvent.priority();
- }else{
+ }
+ else
+ {
return dueDate() > toDoEvent.dueDate();
}
@@ -421,12 +553,18 @@ bool OTodo::operator>(const OTodo &toDoEvent )const
return false;
}
+
+
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
+ if ( hasDueDate() && toDoEvent.hasDueDate() )
+ {
+ if ( dueDate() == toDoEvent.dueDate() )
+ { // let's the priority decide
return priority() > toDoEvent.priority();
- }else{
+ }
+ else
+ {
return dueDate() > toDoEvent.dueDate();
}
@@ -434,4 +572,6 @@ bool OTodo::operator>=(const OTodo &toDoEvent )const
return true;
}
+
+
bool OTodo::operator==(const OTodo &toDoEvent )const
{
@@ -448,8 +588,12 @@ bool OTodo::operator==(const OTodo &toDoEvent )const
return OPimRecord::operator==( toDoEvent );
}
-void OTodo::deref() {
+
+
+void OTodo::deref()
+{
// qWarning("deref in ToDoEvent");
- if ( data->deref() ) {
+ if ( data->deref() )
+ {
// qWarning("deleting");
delete data;
@@ -457,4 +601,6 @@ void OTodo::deref() {
}
}
+
+
OTodo &OTodo::operator=(const OTodo &item )
{
@@ -470,5 +616,7 @@ OTodo &OTodo::operator=(const OTodo &item )
}
-QMap<int, QString> OTodo::toMap() const {
+
+QMap<int, QString> OTodo::toMap() const
+{
QMap<int, QString> map;
@@ -493,4 +641,5 @@ QMap<int, QString> OTodo::toMap() const {
}
+
/**
* change or modify looks at the ref count and either
@@ -498,6 +647,8 @@ QMap<int, QString> OTodo::toMap() const {
* right in place
*/
-void OTodo::changeOrModify() {
- if ( data->count != 1 ) {
+void OTodo::changeOrModify()
+{
+ if ( data->count != 1 )
+ {
qWarning("changeOrModify");
data->deref();
@@ -507,4 +658,6 @@ void OTodo::changeOrModify() {
}
}
+
+
// WATCHOUT
/*
@@ -512,5 +665,6 @@ void OTodo::changeOrModify() {
* 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;
@@ -537,12 +691,20 @@ void OTodo::copy( OTodoData* src, OTodoData* dest ) {
dest->notifiers = new OPimNotifyManager( *src->notifiers );
}
-QString OTodo::type() const {
+
+
+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
@@ -27,8 +27,14 @@
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>
@@ -38,11 +44,6 @@
#include <qvaluelist.h>
-#include <qpe/recordfields.h>
-#include <qpe/palmtopuidgen.h>
-
-#include <opie2/opimrecord.h>
-
-
-namespace Opie {
+namespace Opie
+{
class OPimState;
@@ -50,5 +51,6 @@ class ORecur;
class OPimMaintainer;
class OPimNotifyManager;
-class OTodo : public OPimRecord {
+class OTodo : public OPimRecord
+{
public:
typedef QValueList<OTodo> ValueList;
@@ -307,5 +309,8 @@ public:
};
-inline bool OTodo::operator!=(const OTodo &toDoEvent )const {
+
+
+inline bool OTodo::operator!=( const OTodo &toDoEvent ) const
+{
return !(*this == toDoEvent);
}