summaryrefslogtreecommitdiff
path: root/libopie2/opiepim
Side-by-side diff
Diffstat (limited to 'libopie2/opiepim') (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
@@ -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 )
{
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,39 +92,70 @@ 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;
dat->start = data->start;
@@ -118,38 +165,55 @@ void OPimNotify::copyIntern() {
data = dat;
}
}
-void OPimNotify::deref() {
- if ( data->deref() ) {
+
+
+void OPimNotify::deref()
+{
+ if ( data->deref() )
+ {
delete data;
data = 0;
}
}
+
/***********************************************************/
-struct OPimAlarm::Data : public QShared {
- Data() : QShared() {
+struct OPimAlarm::Data : public QShared
+{
+ Data() : QShared()
+ {
sound = 1;
}
int sound;
QString file;
};
+
+
OPimAlarm::OPimAlarm( int sound, const QDateTime& start, int duration, int parent )
: OPimNotify( start, duration, parent )
{
data = new Data;
data->sound = sound;
}
+
+
OPimAlarm::OPimAlarm( const OPimAlarm& al)
: OPimNotify(al), data( al.data )
{
data->ref();
}
-OPimAlarm::~OPimAlarm() {
- if ( data->deref() ) {
+
+
+OPimAlarm::~OPimAlarm()
+{
+ if ( data->deref() )
+ {
delete data;
data = 0l;
}
}
+
+
OPimAlarm &OPimAlarm::operator=( const OPimAlarm& al)
{
OPimNotify::operator=( al );
@@ -161,38 +225,64 @@ 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 {
+
+
+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;
@@ -200,25 +290,35 @@ void OPimAlarm::copyIntern() {
data = newDat;
}
}
+
+
/************************/
-struct OPimReminder::Data : public QShared {
- Data() : QShared(), record( 0) {
- }
+struct OPimReminder::Data : public QShared
+{
+ Data() : QShared(), record( 0 )
+ {}
int record;
};
+
+
OPimReminder::OPimReminder( int uid, const QDateTime& start, int dur, int parent )
: OPimNotify( start, dur, parent )
{
data = new Data;
data->record = uid;
}
+
+
OPimReminder::OPimReminder( const OPimReminder& rem )
: OPimNotify( rem ), data( rem.data )
{
data->ref();
}
-OPimReminder& OPimReminder::operator=( const OPimReminder& rem) {
+
+
+OPimReminder& OPimReminder::operator=( const OPimReminder& rem )
+{
OPimNotify::operator=(rem );
deref();
@@ -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 {
+
+
+QString OPimReminder::type() const
+{
return QString::fromLatin1("OPimReminder");
}
-int OPimReminder::recordUid()const {
+
+
+int OPimReminder::recordUid() const
+{
return data->record;
}
-void OPimReminder::setRecordUid( int uid ) {
+
+
+void OPimReminder::setRecordUid( int uid )
+{
copyIntern();
data->record = uid;
}
-void OPimReminder::deref() {
- if ( data->deref() ) {
+
+
+void OPimReminder::deref()
+{
+ if ( data->deref() )
+ {
delete data;
data = 0l;
}
}
-void OPimReminder::copyIntern() {
- if ( data->count != 1 ) {
+
+
+void OPimReminder::copyIntern()
+{
+ if ( data->count != 1 )
+ {
Data* da = new Data;
da->record = data->record;
data = da;
}
}
+
}
diff --git a/libopie2/opiepim/core/opimnotify.h b/libopie2/opiepim/core/opimnotify.h
index fed3970..d0e40ca 100644
--- a/libopie2/opiepim/core/opimnotify.h
+++ b/libopie2/opiepim/core/opimnotify.h
@@ -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,7 +49,9 @@ namespace Opie {
* given on the Due/Start Date? -zecke
* discuss: do we need a uid for the notify? -zecke
*/
-class OPimNotify {
+class OPimNotify
+{
+
public:
typedef QValueList<OPimNotify> ValueList;
OPimNotify( const QDateTime& start = QDateTime(), int duration = 0, int parent = 0 );
@@ -100,7 +104,8 @@ private:
* at a given time to inform about
* an Event
*/
-class OPimAlarm : public OPimNotify {
+class OPimAlarm : public OPimNotify
+{
public:
enum Sound{Loud=1, Silent=0, Custom=2 };
OPimAlarm( int sound = Silent, const QDateTime& start = QDateTime(), int duration = 0, int parent = 0 );
@@ -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 {
+class OPimReminder : public OPimNotify
+{
public:
-
/**
* c'tor of a reminder
* @param uid The uid of the Record inside the Datebook
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,60 +26,94 @@
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
-#include <opie2/opimnotifymanager.h>
+#include "opimnotifymanager.h"
+
+/* OPIE */
#include <opie2/oconversion.h>
+/* QT */
#include <qstringlist.h>
-namespace Opie {
+namespace Opie
+{
OPimNotifyManager::OPimNotifyManager( const Reminders& rem, const Alarms& al)
: m_rem( rem ), m_al( al )
{}
-OPimNotifyManager::~OPimNotifyManager() {
-}
+
+
+OPimNotifyManager::~OPimNotifyManager()
+{}
+
+
/* use static_cast and type instead of dynamic... */
-void OPimNotifyManager::add( const OPimNotify& noti) {
- if ( noti.type() == QString::fromLatin1("OPimReminder") ) {
+void OPimNotifyManager::add( const OPimNotify& noti )
+{
+ if ( noti.type() == QString::fromLatin1( "OPimReminder" ) )
+ {
const OPimReminder& rem = static_cast<const OPimReminder&>(noti);
m_rem.append( rem );
- }else if ( noti.type() == QString::fromLatin1("OPimAlarm") ) {
+ }
+ else if ( noti.type() == QString::fromLatin1( "OPimAlarm" ) )
+ {
const OPimAlarm& al = static_cast<const OPimAlarm&>(noti);
m_al.append( al );
}
}
-void OPimNotifyManager::remove( const OPimNotify& noti) {
- if ( noti.type() == QString::fromLatin1("OPimReminder") ) {
+
+
+void OPimNotifyManager::remove( const OPimNotify& noti )
+{
+ if ( noti.type() == QString::fromLatin1( "OPimReminder" ) )
+ {
const OPimReminder& rem = static_cast<const OPimReminder&>(noti);
m_rem.remove( rem );
- }else if ( noti.type() == QString::fromLatin1("OPimAlarm") ) {
+ }
+ else if ( noti.type() == QString::fromLatin1( "OPimAlarm" ) )
+ {
const OPimAlarm& al = static_cast<const OPimAlarm&>(noti);
m_al.remove( al );
}
}
-void OPimNotifyManager::replace( const OPimNotify& noti) {
- if ( noti.type() == QString::fromLatin1("OPimReminder") ) {
+
+
+void OPimNotifyManager::replace( const OPimNotify& noti )
+{
+ if ( noti.type() == QString::fromLatin1( "OPimReminder" ) )
+ {
const OPimReminder& rem = static_cast<const OPimReminder&>(noti);
m_rem.remove( rem );
m_rem.append( rem );
- }else if ( noti.type() == QString::fromLatin1("OPimAlarm") ) {
+ }
+ else if ( noti.type() == QString::fromLatin1( "OPimAlarm" ) )
+ {
const OPimAlarm& al = static_cast<const OPimAlarm&>(noti);
m_al.remove( al );
m_al.append( al );
}
}
-OPimNotifyManager::Reminders OPimNotifyManager::reminders()const {
+
+
+OPimNotifyManager::Reminders OPimNotifyManager::reminders() const
+{
return m_rem;
}
-OPimNotifyManager::Alarms OPimNotifyManager::alarms()const {
+
+
+OPimNotifyManager::Alarms OPimNotifyManager::alarms() const
+{
return m_al;
}
-OPimAlarm OPimNotifyManager::alarmAtDateTime( const QDateTime& when, bool& found ) const {
+
+
+OPimAlarm OPimNotifyManager::alarmAtDateTime( const QDateTime& when, bool& found ) const
+{
Alarms::ConstIterator it;
found = true;
- for ( it = m_al.begin(); it != m_al.end(); ++it ){
+ for ( it = m_al.begin(); it != m_al.end(); ++it )
+ {
if ( (*it).dateTime() == when )
return (*it);
}
@@ -91,12 +125,18 @@ 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!!! */
/**
* The idea is to check if the provider for our service
@@ -105,37 +145,45 @@ 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 {
+
+bool OPimNotifyManager::isEmpty() const
+{
qWarning("is Empty called on OPimNotifyManager %d %d", m_rem.count(), m_al.count() );
if ( m_rem.isEmpty() && m_al.isEmpty() ) return true;
else return false;
}
-// Taken from otodoaccessxml..
+
+// Taken from otodoaccessxml.. code duplication bad. any alternative?
QString OPimNotifyManager::alarmsToString() const
{
QString str;
OPimNotifyManager::Alarms alarms = m_al;
- if ( !alarms.isEmpty() ) {
+ if ( !alarms.isEmpty() )
+ {
QStringList als;
OPimNotifyManager::Alarms::Iterator it = alarms.begin();
- for ( ; it != alarms.end(); ++it ) {
+ for ( ; it != alarms.end(); ++it )
+ {
/* only if time is valid */
- if ( (*it).dateTime().isValid() ) {
+ if ( ( *it ).dateTime().isValid() )
+ {
als << OConversion::dateTimeToString( (*it).dateTime() )
+ ":" + QString::number( (*it).duration() )
+ ":" + QString::number( (*it).sound() )
@@ -149,15 +197,19 @@ QString OPimNotifyManager::alarmsToString() const
return str;
}
+
+
QString OPimNotifyManager::remindersToString() const
{
QString str;
OPimNotifyManager::Reminders reminders = m_rem;
- if (!reminders.isEmpty() ) {
+ if ( !reminders.isEmpty() )
+ {
OPimNotifyManager::Reminders::Iterator it = reminders.begin();
QStringList records;
- for ( ; it != reminders.end(); ++it ) {
+ for ( ; it != reminders.end(); ++it )
+ {
records << QString::number( (*it).recordUid() );
}
str = records.join(";");
@@ -166,10 +218,12 @@ QString OPimNotifyManager::remindersToString() const
return str;
}
+
void OPimNotifyManager::alarmsFromString( const QString& str )
{
QStringList als = QStringList::split(";", str );
- for (QStringList::Iterator it = als.begin(); it != als.end(); ++it ) {
+ for ( QStringList::Iterator it = als.begin(); it != als.end(); ++it )
+ {
QStringList alarm = QStringList::split(":", (*it), TRUE ); // allow empty
qWarning("alarm: %s", alarm.join("___").latin1() );
qWarning("alarm[0]: %s %s", alarm[0].latin1(),
@@ -180,11 +234,13 @@ 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
@@ -26,18 +26,22 @@
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
-#ifndef OPIE_PIM_NOTIFY_MANAGER_H
-#define OPIE_PIM_NOTIFY_MANAGER_H
-
-#include <qvaluelist.h>
+#ifndef OPIMNOTIFYMANAGER_H
+#define OPIMNOTIFYMANAGER_H
+/* OPIE */
#include <opie2/opimnotify.h>
-namespace Opie {
+/* QT */
+#include <qvaluelist.h>
+
+namespace Opie
+{
/**
* The notify manager keeps track of the Notifiers....
*/
-class OPimNotifyManager {
+class OPimNotifyManager
+{
public:
typedef QValueList<OPimReminder> Reminders;
typedef QValueList<OPimAlarm> Alarms;
@@ -106,8 +110,6 @@ public:
*/
void remindersFromString( const QString& str );
-
-
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,32 +26,43 @@
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
-#include <qarray.h>
+#include "opimrecord.h"
+
+/* OPIE */
#include <qpe/categories.h>
#include <qpe/categoryselect.h>
-#include <opie2/opimrecord.h>
+/* QT */
+#include <qarray.h>
-namespace Opie {
+namespace Opie
+{
Qtopia::UidGen OPimRecord::m_uidGen( Qtopia::UidGen::Qtopia );
OPimRecord::OPimRecord( int uid )
- : Qtopia::Record() {
+ : Qtopia::Record()
+{
m_lastHit = -1;
setUid( uid );
}
-OPimRecord::~OPimRecord() {
-}
+
+
+OPimRecord::~OPimRecord()
+{}
+
+
OPimRecord::OPimRecord( const OPimRecord& rec )
: Qtopia::Record( rec )
{
(*this) = rec;
}
-OPimRecord &OPimRecord::operator=( const OPimRecord& rec) {
+
+OPimRecord &OPimRecord::operator=( const OPimRecord& rec )
+{
if ( this == &rec ) return *this;
Qtopia::Record::operator=( rec );
@@ -60,33 +71,47 @@ 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();
Categories catDB;
catDB.load( categoryFileName() );
- for (uint i = 0; i < cats.count(); i++ ) {
+ for ( uint i = 0; i < cats.count(); i++ )
+ {
list << catDB.label( appname, cats[i] );
}
return list;
}
-void OPimRecord::setCategoryNames( const QStringList& ) {
+
+void OPimRecord::setCategoryNames( const QStringList& )
+{
}
-void OPimRecord::addCategoryName( const QString& ) {
+
+
+void OPimRecord::addCategoryName( const QString& )
+{
Categories catDB;
catDB.load( categoryFileName() );
}
-bool OPimRecord::isEmpty()const {
+
+
+bool OPimRecord::isEmpty() const
+{
return ( uid() == 0 );
}
+
+
/*QString OPimRecord::crossToString()const {
QString str;
QMap<QString, QArray<int> >::ConstIterator it;
@@ -102,19 +127,29 @@ bool OPimRecord::isEmpty()const {
return str;
}*/
/* if uid = 1 assign a new one */
-void OPimRecord::setUid( int uid ) {
+void OPimRecord::setUid( int uid )
+{
if ( uid == 1)
uid = uidGen().generate();
Qtopia::Record::setUid( uid );
};
-Qtopia::UidGen &OPimRecord::uidGen() {
+
+
+Qtopia::UidGen &OPimRecord::uidGen()
+{
return m_uidGen;
}
-OPimXRefManager &OPimRecord::xrefmanager() {
+
+
+OPimXRefManager &OPimRecord::xrefmanager()
+{
return m_xrefman;
}
-int OPimRecord::rtti(){
+
+
+int OPimRecord::rtti()
+{
return 0;
}
@@ -126,7 +161,8 @@ int OPimRecord::rtti(){
* Categories
* XRef
*/
-bool OPimRecord::loadFromStream( QDataStream& stream ) {
+bool OPimRecord::loadFromStream( QDataStream& stream )
+{
int Int;
uint UInt;
stream >> Int;
@@ -135,7 +171,8 @@ bool OPimRecord::loadFromStream( QDataStream& stream ) {
/** Categories */
stream >> UInt;
QArray<int> array(UInt);
- for (uint i = 0; i < UInt; i++ ) {
+ for ( uint i = 0; i < UInt; i++ )
+ {
stream >> array[i];
}
setCategories( array );
@@ -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,14 +191,18 @@ 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++ ) {
+ 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 ) {
+ 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,15 +39,21 @@
#include <qpe/palmtoprecord.h>
#undef private
-#include <opie2/opimxrefmanager.h>
+/* QT */
+#include <qdatastream.h>
+#include <qmap.h>
+#include <qstring.h>
+#include <qstringlist.h>
-namespace Opie {
+namespace Opie
+{
/**
* This is the base class for
* all PIM Records
*
*/
-class OPimRecord : public Qtopia::Record {
+class OPimRecord : public Qtopia::Record
+{
public:
/**
* c'tor
@@ -110,8 +114,10 @@ public:
* 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
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,22 +60,20 @@
*/
-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() )
@@ -99,10 +81,12 @@ 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() );
// if ( !uidStr.isEmpty() )
@@ -113,8 +97,7 @@ OContact::OContact( const QMap<int, QString> &fromMap ) :
Destroys a contact.
*/
OContact::~OContact()
-{
-}
+{}
/*! \fn void OContact::setTitle( const QString &str )
Sets the title of the contact to \a str.
@@ -481,17 +464,20 @@ QString OContact::toRichText() const
text += Qtopia::escapeString(value) + " ";
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>";
// 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);
marker = true;
@@ -499,49 +485,62 @@ 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() )
text += "<br>";
text += Qtopia::escapeString(value);
if ( state )
text += ", " + Qtopia::escapeString(state);
- } else if ( !state.isEmpty() ){
+ }
+ else if ( !state.isEmpty() )
+ {
text += "<br>" + Qtopia::escapeString(state);
marker = true;
}
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;
}
@@ -549,44 +548,51 @@ QString OContact::toRichText() const
}
}
- if ( !(value = businessCountry()).isEmpty() ){
+ if ( !( value = businessCountry() ).isEmpty() )
+ {
text += "<br>" + Qtopia::escapeString(value);
marker = true;
}
// rest of Business data
str = office();
- if ( !str.isEmpty() ){
+ if ( !str.isEmpty() )
+ {
text += "<br><b>" + QObject::tr("Office: ") + "</b>"
+ Qtopia::escapeString(str);
marker = true;
}
str = businessWebpage();
- if ( !str.isEmpty() ){
+ 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() ){
+ 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() ){
+ 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() ){
+ 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() ){
+ if ( !str.isEmpty() )
+ {
text += "<br><b>" + QObject::tr("Business Pager: ") + "</b>"
+ Qtopia::escapeString(str);
marker = true;
@@ -596,48 +602,61 @@ 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() )
text += "<br>";
text += Qtopia::escapeString(value);
if ( !state.isEmpty() )
text += ", " + Qtopia::escapeString(state);
- } else if (!state.isEmpty()) {
+ }
+ else if ( !state.isEmpty() )
+ {
text += "<br>" + Qtopia::escapeString(state);
marker = true;
}
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;
}
@@ -645,32 +664,37 @@ QString OContact::toRichText() const
}
}
- if ( !(value = homeCountry()).isEmpty() ){
+ if ( !( value = homeCountry() ).isEmpty() )
+ {
text += "<br>" + Qtopia::escapeString(value);
marker = true;
}
// 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);
marker = true;
}
str = homePhone();
- if ( !str.isEmpty() ){
+ 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() ){
+ 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() ){
+ if ( !str.isEmpty() )
+ {
text += "<br><b><img src=\"addressbook/mobilehome\"> " + QObject::tr("Home Mobile: ") + "</b>"
+ Qtopia::escapeString(str);
marker = true;
@@ -697,7 +721,8 @@ QString OContact::toRichText() const
text += "<br><b>" + QObject::tr("Manager: ") + "</b>"
+ Qtopia::escapeString(str);
str = gender();
- if ( !str.isEmpty() && str.toInt() != 0 ) {
+ if ( !str.isEmpty() && str.toInt() != 0 )
+ {
text += "<br>";
if ( str.toInt() == 1 )
str = QObject::tr( "Male" );
@@ -709,12 +734,14 @@ QString OContact::toRichText() const
if ( !str.isEmpty() )
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>"
+ Qtopia::escapeString(str);
@@ -730,13 +757,15 @@ QString OContact::toRichText() const
+ Qtopia::escapeString(str);
// categories
- if ( categoryNames("Contacts").count() ){
+ if ( categoryNames( "Contacts" ).count() )
+ {
text += "<br><b>" + QObject::tr( "Category:") + "</b> ";
text += categoryNames("Contacts").join(", ");
}
// notes last
- if ( !(value = notes()).isEmpty() ) {
+ if ( !( value = notes() ).isEmpty() )
+ {
text += "<br><hr><b>" + QObject::tr( "Notes:") + "</b> ";
QRegExp reg("\n");
@@ -837,22 +866,26 @@ QString OContact::fullName() const
QString suffix = find( Qtopia::Suffix );
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 += " ";
name += suffix;
@@ -900,7 +933,8 @@ QStringList OContact::emailList() const
QString emailStr = emails();
QStringList r;
- if ( !emailStr.isEmpty() ) {
+ if ( !emailStr.isEmpty() )
+ {
qDebug(" emailstr ");
QStringList l = QStringList::split( emailSeparator(), emailStr );
for ( QStringList::ConstIterator it = l.begin();it != l.end();++it )
@@ -946,10 +980,12 @@ 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 ) {
+ 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;
@@ -1061,8 +1097,10 @@ 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;
@@ -1076,13 +1114,14 @@ QString OContact::toShortText() const
{
return ( fullName() );
}
+
+
QString OContact::type() const
{
return QString::fromLatin1( "OContact" );
}
-
class QString OContact::recordField( int pos ) const
{
QStringList SLFIELDS = fields(); // ?? why this ? (se)
@@ -1099,7 +1138,8 @@ 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 );
return;
@@ -1117,7 +1157,8 @@ 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 );
return;
@@ -1127,6 +1168,7 @@ void OContact::setAnniversary( const QDate &v )
replace( Qtopia::Anniversary, OConversion::dateToString( v ) );
}
+
/*! \fn QDate OContact::birthday() const
Returns the birthday of the contact.
*/
@@ -1163,7 +1205,8 @@ 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() ) {
+ if ( def.isEmpty() )
+ {
setDefaultEmail( e ); // will insert into the list for us
return;
}
@@ -1178,6 +1221,7 @@ void OContact::insertEmail( const QString &v )
replace( Qtopia::Emails, emailsStr );
}
+
void OContact::removeEmail( const QString &v )
{
QString e = v.simplifyWhiteSpace();
@@ -1197,7 +1241,8 @@ void OContact::removeEmail( const QString &v )
replace( Qtopia::Emails, emailsStr );
// 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() )
clearEmails();
@@ -1205,11 +1250,15 @@ void OContact::removeEmail( const QString &v )
setDefaultEmail( emails.first() );
}
}
+
+
void OContact::clearEmails()
{
mMap.remove( Qtopia::DefaultEmail );
mMap.remove( Qtopia::Emails );
}
+
+
void OContact::setDefaultEmail( const QString &v )
{
QString e = v.simplifyWhiteSpace();
@@ -1222,14 +1271,20 @@ void OContact::setDefaultEmail( const QString &v )
}
+
void OContact::insertEmails( const QStringList &v )
{
for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it )
insertEmail( *it );
}
-int OContact::rtti() {
+
+
+int OContact::rtti()
+{
return OPimResolver::AddressBook;
}
+
+
void OContact::setUid( int i )
{
OPimRecord::setUid(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,6 +58,7 @@ class OContactPrivate;
class QPC_EXPORT OContact : public OPimRecord
{
friend class DataSet;
+
public:
OContact();
OContact( const QMap<int, QString> &fromMap );
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.
@@ -423,11 +426,13 @@ OContactFields::OContactFields():
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 ){
+ if ( changedFieldOrder )
+ {
Config cfg ( "AddressBook" );
cfg.setGroup( "ContactFieldOrder" );
cfg.writeEntry( "General", globalFieldOrder );
@@ -436,7 +441,8 @@ OContactFields::~OContactFields(){
-void OContactFields::saveToRecord( OContact &cnt ){
+void OContactFields::saveToRecord( OContact &cnt )
+{
qDebug("ocontactfields saveToRecord: >%s<",fieldOrder.latin1());
@@ -448,7 +454,8 @@ 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());
@@ -459,7 +466,8 @@ void OContactFields::loadFromRecord( const OContact &cnt ){
qDebug("fieldOrder from contact>%s<",fieldOrder.latin1());
- if (fieldOrder.isEmpty()){
+ if ( fieldOrder.isEmpty() )
+ {
fieldOrder = globalFieldOrder;
}
@@ -467,7 +475,8 @@ void OContactFields::loadFromRecord( const OContact &cnt ){
qDebug("effective fieldOrder in loadFromRecord >%s<",fieldOrder.latin1());
}
-void OContactFields::setFieldOrder( int num, int index ){
+void OContactFields::setFieldOrder( int num, int index )
+{
qDebug("qcontactfields setfieldorder pos %i -> %i",num,index);
fieldOrder[num] = QString::number( index, 16 )[0];
@@ -480,7 +489,8 @@ void OContactFields::setFieldOrder( int num, int index ){
qDebug("fieldOrder >%s<",fieldOrder.latin1());
}
-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
@@ -26,20 +26,26 @@
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{
+namespace Opie
+{
+class OContactFields
+{
public:
OContactFields();
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();
}
-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;
}
@@ -98,16 +116,21 @@ struct OEvent::Data : public QShared {
int parent;
};
+
OEvent::OEvent( int uid )
- : OPimRecord( uid ) {
+ : OPimRecord( uid )
+{
data = new Data;
}
+
+
OEvent::OEvent( const OEvent& ev)
: OPimRecord( ev ), data( ev.data )
{
data->ref();
}
+
OEvent::OEvent( const QMap<int, QString> map )
: OPimRecord( 0 )
{
@@ -116,13 +139,19 @@ OEvent::OEvent( const QMap<int, QString> map )
fromMap( 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;
OPimRecord::operator=( ev );
@@ -133,21 +162,36 @@ 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
@@ -156,7 +200,10 @@ OPimNotifyManager &OEvent::notifiers()const {
return *data->manager;
}
-bool OEvent::hasNotifiers()const {
+
+
+bool OEvent::hasNotifiers() const
+{
if (!data->manager )
return false;
if (data->manager->reminders().isEmpty() &&
@@ -165,54 +212,87 @@ bool OEvent::hasNotifiers()const {
return true;
}
-ORecur OEvent::recurrence()const {
+
+
+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;
else
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();
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
@@ -221,94 +301,133 @@ QDateTime OEvent::endDateTime()const {
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();
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;
}
-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;
}
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]"), "" );
}
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>";
}
// 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() ).
replace(QRegExp( "[\n]"), "<br>" ) + "<br>";
}
// end time
- if ( endDateTime().isValid() ) {
+ if ( endDateTime().isValid() )
+ {
text += "<b>" + QObject::tr( "End:") + "</b> ";
text += Qtopia::escapeString(endDateTime().toString() ).
replace(QRegExp( "[\n]"), "<br>" ) + "<br>";
@@ -316,14 +435,16 @@ QString OEvent::toRichText()const {
}
// categories
- if ( categoryNames("Calendar").count() ){
+ if ( categoryNames( "Calendar" ).count() )
+ {
text += "<b>" + QObject::tr( "Category:") + "</b> ";
text += categoryNames("Calendar").join(", ");
text += "<br>";
}
//notes
- if ( !note().isEmpty() ) {
+ if ( !note().isEmpty() )
+ {
text += "<b>" + QObject::tr( "Note:") + "</b><br>";
text += note();
// text += Qtopia::escapeString(note() ).
@@ -331,7 +452,10 @@ QString OEvent::toRichText()const {
}
return text;
}
-QString OEvent::toShortText()const {
+
+
+QString OEvent::toShortText() const
+{
QString text;
text += QString::number( startDateTime().date().day() );
text += ".";
@@ -346,23 +470,42 @@ QString OEvent::toShortText()const {
text += description();
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;
d2->description = data->description;
@@ -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,7 +549,8 @@ 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() ) );
@@ -420,10 +569,12 @@ QMap<int, QString> OEvent::toMap()const {
retMap.insert( OEvent::FTimeZone, timeZone().isEmpty() ? QString( "None" ) : timeZone() );
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] );
}
@@ -431,7 +582,8 @@ QMap<int, QString> OEvent::toMap()const {
}
// Add recurrence stuff
- if( hasRecurrence() ){
+ if ( hasRecurrence() )
+ {
ORecur recur = recurrence();
QMap<int, QString> recFields = recur.toMap();
retMap.insert( OEvent::FRType, recFields[ORecur::RType] );
@@ -442,7 +594,9 @@ QMap<int, QString> OEvent::toMap()const {
retMap.insert( OEvent::FREndDate, recFields[ORecur::EndDate] );
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();
retMap.insert( OEvent::FRType, recFields[ORecur::RType] );
@@ -451,6 +605,7 @@ QMap<int, QString> OEvent::toMap()const {
return retMap;
}
+
void OEvent::fromMap( const QMap<int, QString>& map )
{
@@ -472,12 +627,14 @@ void OEvent::fromMap( const QMap<int, QString>& map )
alarmTime = map[OEvent::FAlarm].toInt();
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] );
}
@@ -485,12 +642,15 @@ void OEvent::fromMap( const QMap<int, QString>& map )
time_t end = (time_t) map[OEvent::FEnd].toLong();
/* 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 );
OTimeZone zone( timeZone().isEmpty() ? OTimeZone::current() : timeZone() );
@@ -505,15 +665,18 @@ void OEvent::fromMap( const QMap<int, QString>& map )
if ( !map[OEvent::FRecParent].isEmpty() )
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() );
}
}
// 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] );
recFields.insert( ORecur::RWeekdays, map[OEvent::FRWeekdays] );
@@ -530,53 +693,77 @@ 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;
data->child = new 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 );
(*data->child)[count] = uid;
}
}
-void OEvent::removeChild( int uid ) {
+
+
+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 ) {
+ for ( uint i = 0; i < count; i++ )
+ {
+ if ( ( *data->child ) [ i ] != uid )
+ {
newAr[j] = (*data->child)[i];
j++;
}
}
(*data->child) = newAr;
}
-struct OEffectiveEvent::Data : public QShared {
- Data() : QShared() {
- }
+
+
+struct OEffectiveEvent::Data : public QShared
+{
+ Data() : QShared()
+ {}
OEvent event;
QDate date;
QTime start, end;
@@ -584,14 +771,19 @@ struct OEffectiveEvent::Data : public QShared {
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,17 +799,27 @@ 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;
ev.data->ref();
@@ -627,25 +829,40 @@ 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;
}
@@ -653,37 +870,67 @@ void OEffectiveEvent::setEffectiveDates( const QDate& from,
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 {
+
+
+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;
else if ( data->event.hasRecurrence() ) // single day, since multi-day should have a d pointer
@@ -691,7 +938,10 @@ QDate OEffectiveEvent::startDate()const {
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,7 +977,10 @@ 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;
if ( data->date == e.date() )
@@ -727,22 +988,37 @@ bool OEffectiveEvent::operator<( const OEffectiveEvent &e ) const{
else
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()
&& endTime()== e.endTime()
&& 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,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,7 +68,8 @@ class ORecur;
* available information for a single Event
* @short container for events.
*/
-class OEvent : public OPimRecord {
+class OEvent : public OPimRecord
+{
public:
typedef QValueList<OEvent> ValueList;
/**
@@ -191,6 +195,7 @@ public:
bool operator>( const OEvent& );
bool operator>=(const OEvent& );
*/
+
private:
inline void changeOrModify();
void deref();
@@ -204,7 +209,9 @@ private:
/**
* AN Event can span through multiple days. We split up a multiday eve
*/
-class OEffectiveEvent {
+class OEffectiveEvent
+{
+
public:
typedef QValueList<OEffectiveEvent> ValueList;
enum Position { MidWay, Start, End, StartEnd };
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,8 +50,10 @@ class ORecordListIteratorPrivate;
*/
template <class T> class ORecordList;
template <class T = OPimRecord>
-class ORecordListIterator {
+class ORecordListIterator
+{
friend class ORecordList<T>;
+
public:
typedef OTemplateBase<T> Base;
@@ -105,13 +110,15 @@ private:
ORecordListIteratorPrivate *d;
};
+
class ORecordListPrivate;
/**
* The recordlist used as a return type
* from OPimAccessTemplate
*/
template <class T = OPimRecord >
-class ORecordList {
+class ORecordList
+{
public:
typedef OTemplateBase<T> Base;
typedef ORecordListIterator<T> Iterator;
@@ -119,8 +126,8 @@ public:
/**
* c'tor
*/
- ORecordList () {
- }
+ ORecordList ()
+ {}
ORecordList( const QArray<int>& ids,
const Base* );
~ORecordList();
@@ -158,9 +165,11 @@ private:
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,13 +177,18 @@ ORecordListIterator<T>::ORecordListIterator() {
/* forward */
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;
m_current = it.m_current;
@@ -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,8 +211,10 @@ ORecordListIterator<T> &ORecordListIterator<T>::operator=( const ORecordListIter
return *this;
}
+
template <class T>
-T ORecordListIterator<T>::operator*() {
+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,
@@ -208,31 +226,42 @@ T ORecordListIterator<T>::operator*() {
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,10 +272,15 @@ 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,
const Base* t )
@@ -257,71 +291,103 @@ ORecordListIterator<T>::ORecordListIterator( const QArray<int> uids,
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() ) {
+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 )
-{
-}
+{}
+
+
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;
it.m_current = m_ids.count();
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();
/* forward */
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
@@ -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,25 +42,24 @@
#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;
@@ -78,21 +81,28 @@ struct OTodo::OTodoData : public QShared {
OPimNotifyManager *notifiers;
};
+
OTodo::OTodo(const OTodo &event )
: OPimRecord( event ), data( event.data )
{
data->ref();
// qWarning("ref up");
}
-OTodo::~OTodo() {
+
+
+OTodo::~OTodo()
+{
// qWarning("~OTodo " );
- if ( data->deref() ) {
+ if ( data->deref() )
+ {
// qWarning("OTodo::dereffing");
delete data;
data = 0l;
}
}
+
+
OTodo::OTodo(bool completed, int priority,
const QArray<int> &category,
const QString& summary,
@@ -114,6 +124,8 @@ OTodo::OTodo(bool completed, int priority,
data->prog = progress;
data->desc = Qtopia::simplifyMultiLineSpace(description );
}
+
+
OTodo::OTodo(bool completed, int priority,
const QStringList &category,
const QString& summary,
@@ -135,148 +147,229 @@ OTodo::OTodo(bool completed, int priority,
data->prog = progress;
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;
}
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;
}
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 )
{
changeOrModify();
data->isCompleted = completed;
}
+
+
void OTodo::setHasDueDate( bool hasDate )
{
changeOrModify();
data->hasDate = hasDate;
}
+
+
void OTodo::setDescription(const QString &desc )
{
// qWarning( "desc " + desc );
changeOrModify();
data->desc = Qtopia::simplifyMultiLineSpace(desc );
}
+
+
void OTodo::setSummary( const QString& sum )
{
changeOrModify();
data->sum = sum;
}
+
+
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;
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;
else
data->recur = new ORecur( rec );
}
-void OTodo::setMaintainer( const OPimMaintainer& pim ) {
+
+
+void OTodo::setMaintainer( const OPimMaintainer& pim )
+{
changeOrModify();
if (data->maintainer )
@@ -284,20 +377,29 @@ void OTodo::setMaintainer( const OPimMaintainer& pim ) {
else
data->maintainer = new OPimMaintainer( pim );
}
+
+
bool OTodo::isOverdue( )
{
if( data->hasDate && !data->isCompleted)
return QDate::currentDate() > data->date;
return false;
}
+
+
void OTodo::setProgress(ushort progress )
{
changeOrModify();
data->prog = progress;
}
-QString OTodo::toShortText() const {
+
+
+QString OTodo::toShortText() const
+{
return summary();
}
+
+
/*!
Returns a richt text string
*/
@@ -308,13 +410,15 @@ 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]"), "" );
}
text += "</h3></b><br><hr><br>";
// description
- if( !description().isEmpty() ){
+ if ( !description().isEmpty() )
+ {
text += "<b>" + QObject::tr( "Description:" ) + "</b><br>";
text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "<br>" ) + "<br>";
}
@@ -344,7 +448,8 @@ QString OTodo::toRichText() const
+ QString::number( progress() ) + " %<br>";
// due date
- if (hasDueDate() ){
+ if ( hasDueDate() )
+ {
QDate dd = dueDate();
int off = QDate::currentDate().daysTo( dd );
@@ -366,73 +471,108 @@ 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;
return (*data->notifiers);
}
-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();
}
}
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();
}
}
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();
}
}
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();
}
}
return true;
}
+
+
bool OTodo::operator==(const OTodo &toDoEvent )const
{
if ( data->priority != toDoEvent.data->priority ) return false;
@@ -447,15 +587,21 @@ 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;
data= 0;
}
}
+
+
OTodo &OTodo::operator=(const OTodo &item )
{
if ( this == &item ) return *this;
@@ -469,7 +615,9 @@ 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() ) );
@@ -492,13 +640,16 @@ 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 ) {
+void OTodo::changeOrModify()
+{
+ if ( data->count != 1 )
+ {
qWarning("changeOrModify");
data->deref();
OTodoData* d2 = new OTodoData();
@@ -506,12 +657,15 @@ void OTodo::changeOrModify() {
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;
@@ -536,14 +690,22 @@ void OTodo::copy( OTodoData* src, OTodoData* dest ) {
if (src->notifiers )
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
@@ -26,10 +26,16 @@
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,19 +43,15 @@
#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 {
+class OTodo : public OPimRecord
+{
public:
typedef QValueList<OTodo> ValueList;
enum RecordFields {
@@ -306,7 +308,10 @@ public:
OTodoData *data;
};
-inline bool OTodo::operator!=(const OTodo &toDoEvent )const {
+
+
+inline bool OTodo::operator!=( const OTodo &toDoEvent ) const
+{
return !(*this == toDoEvent);
}