summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/pim/ocontact.cpp41
-rw-r--r--libopie/pim/opimrecord.h4
-rw-r--r--libopie/pim/opimstate.cpp64
-rw-r--r--libopie/pim/opimstate.h44
-rw-r--r--libopie/pim/orecordlist.h2
-rw-r--r--libopie/pim/orecur.cpp9
-rw-r--r--libopie/pim/orecur.h2
-rw-r--r--libopie/pim/otodo.cpp23
-rw-r--r--libopie/pim/otodo.h27
-rw-r--r--libopie2/opiepim/core/opimrecord.h4
-rw-r--r--libopie2/opiepim/core/opimstate.cpp64
-rw-r--r--libopie2/opiepim/core/opimstate.h44
-rw-r--r--libopie2/opiepim/core/orecur.cpp9
-rw-r--r--libopie2/opiepim/core/orecur.h2
-rw-r--r--libopie2/opiepim/ocontact.cpp41
-rw-r--r--libopie2/opiepim/orecordlist.h2
-rw-r--r--libopie2/opiepim/otodo.cpp23
-rw-r--r--libopie2/opiepim/otodo.h27
18 files changed, 388 insertions, 44 deletions
diff --git a/libopie/pim/ocontact.cpp b/libopie/pim/ocontact.cpp
index acd65c4..cd238ef 100644
--- a/libopie/pim/ocontact.cpp
+++ b/libopie/pim/ocontact.cpp
@@ -1124,20 +1124,20 @@ static VObject *createVObject( const OContact &c )
safeAddPropValue( vcard, VCNoteProp, c.notes() );
// Exporting Birthday regarding RFC 2425 (5.8.4)
if ( c.birthday().isValid() ){
QString birthd_rfc2425 = QString("%1-%2-%3")
- .arg( c.birthday().year() )
+ .arg( c.birthday().year() )
.arg( c.birthday().month(), 2 )
.arg( c.birthday().day(), 2 );
// Now replace spaces with "0"...
int pos = 0;
while ( ( pos = birthd_rfc2425.find (' ') ) > 0 )
birthd_rfc2425.replace( pos, 1, "0" );
-
+
qWarning("Exporting birthday as: %s", birthd_rfc2425.latin1());
safeAddPropValue( vcard, VCBirthDateProp, birthd_rfc2425.latin1() );
}
if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) {
VObject *org = safeAddProp( vcard, VCOrgProp );
@@ -1385,17 +1385,17 @@ static OContact parseVObject( VObject *obj )
}
else if ( name == "X-Qtopia-Nickname" ) {
c.setNickname( value );
}
else if ( name == "X-Qtopia-Children" ) {
c.setChildren( value );
- }
+ }
else if ( name == VCBirthDateProp ) {
// Reading Birthdate regarding RFC 2425 (5.8.4)
c.setBirthday( convVCardDateToDate( value ) );
-
+
}
#if 0
else {
printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) );
VObjectIterator nit;
@@ -1461,13 +1461,22 @@ QValueList<OContact> OContact::readVCard( const QString &filename )
qDebug("vobject = %p", obj );
QValueList<OContact> contacts;
while ( obj ) {
- contacts.append( parseVObject( obj ) );
+ OContact con = parseVObject( obj );
+ /*
+ * if uid is 0 assign a new one
+ * this at least happens on
+ * Nokia6210
+ */
+ if ( con.uid() == 0 )
+ con.setUid( 1 );
+
+ contacts.append(con );
VObject *t = obj;
obj = nextVObjectInList(obj);
cleanVObject( t );
}
@@ -1524,23 +1533,23 @@ class QString OContact::recordField( int pos ) const
{
QStringList SLFIELDS = fields(); // ?? why this ? (se)
return SLFIELDS[pos];
}
// In future releases, we should store birthday and anniversary
-// internally as QDate instead of QString !
+// internally as QDate instead of QString !
// QString is always too complicate to interprete (DD.MM.YY, DD/MM/YY, MM/DD/YY, etc..)(se)
/*! \fn void OContact::setBirthday( const QDate& date )
Sets the birthday for the contact to \a date.
*/
void OContact::setBirthday( const QDate &v )
-{
+{
if ( ( !v.isNull() ) && ( v.isValid() ) )
replace( Qtopia::Birthday, TimeConversion::toString( v ) );
-
+
}
/*! \fn void OContact::setAnniversary( const QDate &date )
Sets the anniversary of the contact to \a date.
*/
@@ -1550,33 +1559,33 @@ void OContact::setAnniversary( const QDate &v )
replace( Qtopia::Anniversary, TimeConversion::toString( v ) );
}
/*! \fn QDate OContact::birthday() const
Returns the birthday of the contact.
*/
-QDate OContact::birthday() const
-{
+QDate OContact::birthday() const
+{
QString str = find( Qtopia::Birthday );
qWarning ("Birthday %s", str.latin1() );
if ( !str.isEmpty() )
return TimeConversion::fromString ( str );
else
return QDate();
}
/*! \fn QDate OContact::anniversary() const
Returns the anniversary of the contact.
*/
-QDate OContact::anniversary() const
-{
+QDate OContact::anniversary() const
+{
QDate empty;
QString str = find( Qtopia::Anniversary );
qWarning ("Anniversary %s", str.latin1() );
if ( !str.isEmpty() )
- return TimeConversion::fromString ( str );
+ return TimeConversion::fromString ( str );
else
return empty;
}
void OContact::insertEmail( const QString &v )
@@ -1604,13 +1613,13 @@ void OContact::insertEmail( const QString &v )
void OContact::removeEmail( const QString &v )
{
QString e = v.simplifyWhiteSpace();
QString def = defaultEmail();
QString emailsStr = find( Qtopia::Emails );
QStringList emails = emailList();
-
+
// otherwise, must first contain it
if ( !emailsStr.contains( e ) )
return;
// remove it
//qDebug(" removing email from list %s", e.latin1());
@@ -1637,15 +1646,15 @@ void OContact::setDefaultEmail( const QString &v )
{
QString e = v.simplifyWhiteSpace();
//qDebug("OContact::setDefaultEmail %s", e.latin1());
replace( Qtopia::DefaultEmail, e );
- if ( !e.isEmpty() )
+ if ( !e.isEmpty() )
insertEmail( e );
-
+
}
void OContact::insertEmails( const QStringList &v )
{
for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it )
insertEmail( *it );
diff --git a/libopie/pim/opimrecord.h b/libopie/pim/opimrecord.h
index dbb94ed..d9ccad4 100644
--- a/libopie/pim/opimrecord.h
+++ b/libopie/pim/opimrecord.h
@@ -6,13 +6,13 @@
#include <qstringlist.h>
#include <qpe/palmtoprecord.h>
/**
- * This is the base class for
+ * This is the base class for
* all PIM Records
*
*/
class OPimRecord : public Qtopia::Record {
public:
/**
@@ -107,13 +107,13 @@ public:
void addRelation( const QString& app, int id );
/**
* set the relations for an app
*/
void setRelations( const QString&, QArray<int> ids );
-
+
/**
* set the uid
*/
virtual void setUid( int uid );
protected:
diff --git a/libopie/pim/opimstate.cpp b/libopie/pim/opimstate.cpp
new file mode 100644
index 0000000..6fb2feb
--- a/dev/null
+++ b/libopie/pim/opimstate.cpp
@@ -0,0 +1,64 @@
+#include <qshared.h>
+
+#include "opimstate.h"
+
+/*
+ * for one int this does not make
+ * much sense but never the less
+ * we will do it for the future
+ */
+struct OPimState::Data : public QShared {
+ Data() : QShared(),state(Undefined) {
+ }
+ int state;
+};
+
+OPimState::OPimState( int state ) {
+ data = new Data;
+ data->state = state;
+}
+OPimState::OPimState( const OPimState& st) :
+ data( st.data ) {
+ /* ref up */
+ data->ref();
+}
+OPimState::~OPimState() {
+ if ( data->deref() ) {
+ delete data ;
+ data = 0;
+ }
+}
+bool OPimState::operator==( const OPimState& st) {
+ if ( data->state == st.data->state ) return true;
+
+ return false;
+}
+OPimState &OPimState::operator=( const OPimState& st) {
+ st.data->ref();
+ deref();
+ data = st.data;
+
+ return *this;
+}
+void OPimState::setState( int st) {
+ copyInternally();
+ data->state = st;
+}
+int OPimState::state()const {
+ return data->state;
+}
+void OPimState::deref() {
+ if ( data->deref() ) {
+ delete data;
+ data = 0l;
+ }
+}
+void OPimState::copyInternally() {
+ /* we need to change it */
+ if ( data->count != 1 ) {
+ data->deref();
+ Data* d2 = new Data;
+ d2->state = data->state;
+ data = d2;
+ }
+}
diff --git a/libopie/pim/opimstate.h b/libopie/pim/opimstate.h
new file mode 100644
index 0000000..731181e
--- a/dev/null
+++ b/libopie/pim/opimstate.h
@@ -0,0 +1,44 @@
+#ifndef OPIE_PIM_STATE_H
+#define OPIE_PIM_STATE_H
+
+#include <qstring.h>
+
+/**
+ * The State of a Task
+ * This class encapsules the state of a todo
+ * and it's shared too
+ */
+/*
+ * in c a simple struct would be enough ;)
+ * g_new_state();
+ * g_do_some_thing( state_t* );
+ * ;)
+ */
+class OPimState {
+public:
+ enum State {
+ Started = 0,
+ Postponed,
+ Finished,
+ NotStarted,
+ Undefined
+ };
+ OPimState( int state = Undefined );
+ OPimState( const OPimState& );
+ ~OPimState();
+
+ bool operator==( const OPimState& );
+ OPimState &operator=( const OPimState& );
+ void setState( int state);
+ int state()const;
+private:
+ void deref();
+ inline void copyInternally();
+ struct Data;
+ Data* data;
+ class Private;
+ Private *d;
+};
+
+
+#endif
diff --git a/libopie/pim/orecordlist.h b/libopie/pim/orecordlist.h
index 2f4a5d3..8ed41e2 100644
--- a/libopie/pim/orecordlist.h
+++ b/libopie/pim/orecordlist.h
@@ -231,13 +231,13 @@ void ORecordListIterator<T>::setCurrent( uint cur ) {
m_end = false;
m_current= cur;
}
}
template <class T>
uint ORecordListIterator<T>::count()const {
- return m_uids.count();
+ return m_uids.count();
}
template <class T>
ORecordList<T>::ORecordList( const QArray<int>& ids,
const Base* acc )
: m_ids( ids ), m_acc( acc )
{
diff --git a/libopie/pim/orecur.cpp b/libopie/pim/orecur.cpp
index 6c81f8f..257d4fd 100644
--- a/libopie/pim/orecur.cpp
+++ b/libopie/pim/orecur.cpp
@@ -18,12 +18,13 @@ struct ORecur::Data : public QShared {
ORecur::RepeatType type;
int freq;
int pos;
bool hasEnd : 1;
time_t end;
time_t create;
+ int rep;
};
ORecur::ORecur() {
data = new Data;
}
@@ -75,12 +76,15 @@ QDate ORecur::endDate()const {
time_t ORecur::endDateUTC()const {
return data->end;
}
time_t ORecur::createTime()const {
return data->create;
}
+int ORecur::repetition()const {
+ return data->rep;
+}
void ORecur::setType( const RepeatType& z) {
checkOrModify();
data->type = z;
}
void ORecur::setFrequency( int freq ) {
checkOrModify();
@@ -107,21 +111,26 @@ void ORecur::setCreateTime( time_t t) {
data->create = t;
}
void ORecur::setHasEndDate( bool b) {
checkOrModify();
data->hasEnd = b;
}
+void ORecur::setRepitition( int rep ) {
+ checkOrModify();
+ data->rep = rep;
+}
void ORecur::checkOrModify() {
if ( data->count != 1 ) {
data->deref();
Data* d2 = new Data;
d2->days = data->days;
d2->type = data->type;
d2->freq = data->freq;
d2->pos = data->pos;
d2->hasEnd = data->hasEnd;
d2->end = data->end;
d2->create = data->create;
+ d2->rep = data->rep;
data = d2;
}
}
diff --git a/libopie/pim/orecur.h b/libopie/pim/orecur.h
index 89258f8..d24d72d 100644
--- a/libopie/pim/orecur.h
+++ b/libopie/pim/orecur.h
@@ -28,21 +28,23 @@ public:
int position()const;
char days()const;
bool hasEndDate()const;
QDate endDate()const;
time_t endDateUTC()const;
time_t createTime()const;
+ int repetition()const;
void setType( const RepeatType& );
void setFrequency( int freq );
void setPosition( int pos );
void setDays( char c);
void setEndDate( const QDate& dt );
void setEndDateUTC( time_t );
void setCreateTime( time_t );
void setHasEndDate( bool b );
+ void setRepitition(int );
private:
void deref();
inline void checkOrModify();
class Data;
diff --git a/libopie/pim/otodo.cpp b/libopie/pim/otodo.cpp
index 765d5a9..0d5b1d3 100644
--- a/libopie/pim/otodo.cpp
+++ b/libopie/pim/otodo.cpp
@@ -9,13 +9,14 @@
#include <qpe/palmtoprecord.h>
#include <qpe/stringutil.h>
#include <qpe/categories.h>
#include <qpe/categoryselect.h>
-
+#include "opimstate.h"
+#include "orecur.h"
#include "otodo.h"
struct OTodo::OTodoData : public QShared {
OTodoData() : QShared() {
};
@@ -27,12 +28,14 @@ struct OTodo::OTodoData : public QShared {
QString desc;
QString sum;
QMap<QString, QString> extra;
ushort prog;
bool hasAlarmDateTime :1;
QDateTime alarmDateTime;
+ OPimState state;
+ ORecur recur;
};
OTodo::OTodo(const OTodo &event )
: OPimRecord( event ), data( event.data )
{
data->ref();
@@ -141,12 +144,18 @@ QDateTime OTodo::alarmDateTime() const
}
QString OTodo::description()const
{
return data->desc;
}
+OPimState OTodo::state()const {
+ return data->state;
+}
+ORecur OTodo::recurrence()const {
+ return data->recur;
+}
void OTodo::setCompleted( bool completed )
{
changeOrModify();
data->isCompleted = completed;
}
void OTodo::setHasDueDate( bool hasDate )
@@ -182,12 +191,20 @@ void OTodo::setDueDate( QDate date )
}
void OTodo::setAlarmDateTime( const QDateTime& alarm )
{
changeOrModify();
data->alarmDateTime = alarm;
}
+void OTodo::setState( const OPimState& state ) {
+ changeOrModify();
+ data->state = state;
+}
+void OTodo::setRecurrence( const ORecur& rec) {
+ changeOrModify();
+ data->recur = rec;
+}
bool OTodo::isOverdue( )
{
if( data->hasDate && !data->isCompleted)
return QDate::currentDate() > data->date;
return false;
}
@@ -355,13 +372,13 @@ QMap<QString, QString> OTodo::toExtraMap()const {
* change or modify looks at the ref count and either
* creates a new QShared Object or it can modify it
* right in place
*/
void OTodo::changeOrModify() {
if ( data->count != 1 ) {
-// qWarning("changeOrModify");
+ qWarning("changeOrModify");
data->deref();
OTodoData* d2 = new OTodoData();
copy(data, d2 );
data = d2;
}
}
@@ -373,12 +390,14 @@ void OTodo::copy( OTodoData* src, OTodoData* dest ) {
dest->desc = src->desc;
dest->sum = src->sum;
dest->extra = src->extra;
dest->prog = src->prog;
dest->hasAlarmDateTime = src->hasAlarmDateTime;
dest->alarmDateTime = src->alarmDateTime;
+ dest->state = src->state;
+ dest->recur = src->recur;
}
QString OTodo::type() const {
return QString::fromLatin1("OTodo");
}
QString OTodo::recordField(int id )const {
return QString::null;
diff --git a/libopie/pim/otodo.h b/libopie/pim/otodo.h
index 5bd91d6..2cdc587 100644
--- a/libopie/pim/otodo.h
+++ b/libopie/pim/otodo.h
@@ -13,12 +13,14 @@
#include <qpe/recordfields.h>
#include <qpe/palmtopuidgen.h>
#include <opie/opimrecord.h>
+class OPimState;
+class ORecur;
class OTodo : public OPimRecord {
public:
typedef QValueList<OTodo> ValueList;
enum RecordFields {
Uid = Qtopia::UID_ID,
Category = Qtopia::CATEGORY_ID,
@@ -30,13 +32,18 @@ public:
DateDay,
DateMonth,
DateYear,
Progress,
CrossReference,
HasAlarmDateTime,
- AlarmDateTime
+ AlarmDateTime,
+ State,
+ Recurrance,
+ Alarms,
+ Reminders,
+ Notifiers
};
public:
// priorities from Very low to very high
enum TaskPriority { VeryHigh=1, High, Normal, Low, VeryLow };
/* Constructs a new ToDoEvent
@@ -108,12 +115,22 @@ public:
/**
* Alarm Date and Time
*/
QDateTime alarmDateTime()const;
/**
+ * What is the state of this OTodo?
+ */
+ OPimState state()const;
+
+ /**
+ * the recurrance of this
+ */
+ ORecur recurrence()const;
+
+ /**
* The description of the todo
*/
QString description()const;
/**
* A small summary of the todo
@@ -167,19 +184,27 @@ public:
/**
* set the end date
*/
void setDueDate( QDate date );
+
+ void setRecurrence( const ORecur& );
/**
* set the alarm time
*/
void setAlarmDateTime ( const QDateTime& alarm );
void setDescription(const QString& );
void setSummary(const QString& );
+
+ /**
+ * set the state of a Todo
+ * @param state State what the todo should take
+ */
+ void setState( const OPimState& state);
bool isOverdue();
bool match( const QRegExp &r )const;
bool operator<(const OTodo &toDoEvent )const;
diff --git a/libopie2/opiepim/core/opimrecord.h b/libopie2/opiepim/core/opimrecord.h
index dbb94ed..d9ccad4 100644
--- a/libopie2/opiepim/core/opimrecord.h
+++ b/libopie2/opiepim/core/opimrecord.h
@@ -6,13 +6,13 @@
#include <qstringlist.h>
#include <qpe/palmtoprecord.h>
/**
- * This is the base class for
+ * This is the base class for
* all PIM Records
*
*/
class OPimRecord : public Qtopia::Record {
public:
/**
@@ -107,13 +107,13 @@ public:
void addRelation( const QString& app, int id );
/**
* set the relations for an app
*/
void setRelations( const QString&, QArray<int> ids );
-
+
/**
* set the uid
*/
virtual void setUid( int uid );
protected:
diff --git a/libopie2/opiepim/core/opimstate.cpp b/libopie2/opiepim/core/opimstate.cpp
new file mode 100644
index 0000000..6fb2feb
--- a/dev/null
+++ b/libopie2/opiepim/core/opimstate.cpp
@@ -0,0 +1,64 @@
+#include <qshared.h>
+
+#include "opimstate.h"
+
+/*
+ * for one int this does not make
+ * much sense but never the less
+ * we will do it for the future
+ */
+struct OPimState::Data : public QShared {
+ Data() : QShared(),state(Undefined) {
+ }
+ int state;
+};
+
+OPimState::OPimState( int state ) {
+ data = new Data;
+ data->state = state;
+}
+OPimState::OPimState( const OPimState& st) :
+ data( st.data ) {
+ /* ref up */
+ data->ref();
+}
+OPimState::~OPimState() {
+ if ( data->deref() ) {
+ delete data ;
+ data = 0;
+ }
+}
+bool OPimState::operator==( const OPimState& st) {
+ if ( data->state == st.data->state ) return true;
+
+ return false;
+}
+OPimState &OPimState::operator=( const OPimState& st) {
+ st.data->ref();
+ deref();
+ data = st.data;
+
+ return *this;
+}
+void OPimState::setState( int st) {
+ copyInternally();
+ data->state = st;
+}
+int OPimState::state()const {
+ return data->state;
+}
+void OPimState::deref() {
+ if ( data->deref() ) {
+ delete data;
+ data = 0l;
+ }
+}
+void OPimState::copyInternally() {
+ /* we need to change it */
+ if ( data->count != 1 ) {
+ data->deref();
+ Data* d2 = new Data;
+ d2->state = data->state;
+ data = d2;
+ }
+}
diff --git a/libopie2/opiepim/core/opimstate.h b/libopie2/opiepim/core/opimstate.h
new file mode 100644
index 0000000..731181e
--- a/dev/null
+++ b/libopie2/opiepim/core/opimstate.h
@@ -0,0 +1,44 @@
+#ifndef OPIE_PIM_STATE_H
+#define OPIE_PIM_STATE_H
+
+#include <qstring.h>
+
+/**
+ * The State of a Task
+ * This class encapsules the state of a todo
+ * and it's shared too
+ */
+/*
+ * in c a simple struct would be enough ;)
+ * g_new_state();
+ * g_do_some_thing( state_t* );
+ * ;)
+ */
+class OPimState {
+public:
+ enum State {
+ Started = 0,
+ Postponed,
+ Finished,
+ NotStarted,
+ Undefined
+ };
+ OPimState( int state = Undefined );
+ OPimState( const OPimState& );
+ ~OPimState();
+
+ bool operator==( const OPimState& );
+ OPimState &operator=( const OPimState& );
+ void setState( int state);
+ int state()const;
+private:
+ void deref();
+ inline void copyInternally();
+ struct Data;
+ Data* data;
+ class Private;
+ Private *d;
+};
+
+
+#endif
diff --git a/libopie2/opiepim/core/orecur.cpp b/libopie2/opiepim/core/orecur.cpp
index 6c81f8f..257d4fd 100644
--- a/libopie2/opiepim/core/orecur.cpp
+++ b/libopie2/opiepim/core/orecur.cpp
@@ -18,12 +18,13 @@ struct ORecur::Data : public QShared {
ORecur::RepeatType type;
int freq;
int pos;
bool hasEnd : 1;
time_t end;
time_t create;
+ int rep;
};
ORecur::ORecur() {
data = new Data;
}
@@ -75,12 +76,15 @@ QDate ORecur::endDate()const {
time_t ORecur::endDateUTC()const {
return data->end;
}
time_t ORecur::createTime()const {
return data->create;
}
+int ORecur::repetition()const {
+ return data->rep;
+}
void ORecur::setType( const RepeatType& z) {
checkOrModify();
data->type = z;
}
void ORecur::setFrequency( int freq ) {
checkOrModify();
@@ -107,21 +111,26 @@ void ORecur::setCreateTime( time_t t) {
data->create = t;
}
void ORecur::setHasEndDate( bool b) {
checkOrModify();
data->hasEnd = b;
}
+void ORecur::setRepitition( int rep ) {
+ checkOrModify();
+ data->rep = rep;
+}
void ORecur::checkOrModify() {
if ( data->count != 1 ) {
data->deref();
Data* d2 = new Data;
d2->days = data->days;
d2->type = data->type;
d2->freq = data->freq;
d2->pos = data->pos;
d2->hasEnd = data->hasEnd;
d2->end = data->end;
d2->create = data->create;
+ d2->rep = data->rep;
data = d2;
}
}
diff --git a/libopie2/opiepim/core/orecur.h b/libopie2/opiepim/core/orecur.h
index 89258f8..d24d72d 100644
--- a/libopie2/opiepim/core/orecur.h
+++ b/libopie2/opiepim/core/orecur.h
@@ -28,21 +28,23 @@ public:
int position()const;
char days()const;
bool hasEndDate()const;
QDate endDate()const;
time_t endDateUTC()const;
time_t createTime()const;
+ int repetition()const;
void setType( const RepeatType& );
void setFrequency( int freq );
void setPosition( int pos );
void setDays( char c);
void setEndDate( const QDate& dt );
void setEndDateUTC( time_t );
void setCreateTime( time_t );
void setHasEndDate( bool b );
+ void setRepitition(int );
private:
void deref();
inline void checkOrModify();
class Data;
diff --git a/libopie2/opiepim/ocontact.cpp b/libopie2/opiepim/ocontact.cpp
index acd65c4..cd238ef 100644
--- a/libopie2/opiepim/ocontact.cpp
+++ b/libopie2/opiepim/ocontact.cpp
@@ -1124,20 +1124,20 @@ static VObject *createVObject( const OContact &c )
safeAddPropValue( vcard, VCNoteProp, c.notes() );
// Exporting Birthday regarding RFC 2425 (5.8.4)
if ( c.birthday().isValid() ){
QString birthd_rfc2425 = QString("%1-%2-%3")
- .arg( c.birthday().year() )
+ .arg( c.birthday().year() )
.arg( c.birthday().month(), 2 )
.arg( c.birthday().day(), 2 );
// Now replace spaces with "0"...
int pos = 0;
while ( ( pos = birthd_rfc2425.find (' ') ) > 0 )
birthd_rfc2425.replace( pos, 1, "0" );
-
+
qWarning("Exporting birthday as: %s", birthd_rfc2425.latin1());
safeAddPropValue( vcard, VCBirthDateProp, birthd_rfc2425.latin1() );
}
if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) {
VObject *org = safeAddProp( vcard, VCOrgProp );
@@ -1385,17 +1385,17 @@ static OContact parseVObject( VObject *obj )
}
else if ( name == "X-Qtopia-Nickname" ) {
c.setNickname( value );
}
else if ( name == "X-Qtopia-Children" ) {
c.setChildren( value );
- }
+ }
else if ( name == VCBirthDateProp ) {
// Reading Birthdate regarding RFC 2425 (5.8.4)
c.setBirthday( convVCardDateToDate( value ) );
-
+
}
#if 0
else {
printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) );
VObjectIterator nit;
@@ -1461,13 +1461,22 @@ QValueList<OContact> OContact::readVCard( const QString &filename )
qDebug("vobject = %p", obj );
QValueList<OContact> contacts;
while ( obj ) {
- contacts.append( parseVObject( obj ) );
+ OContact con = parseVObject( obj );
+ /*
+ * if uid is 0 assign a new one
+ * this at least happens on
+ * Nokia6210
+ */
+ if ( con.uid() == 0 )
+ con.setUid( 1 );
+
+ contacts.append(con );
VObject *t = obj;
obj = nextVObjectInList(obj);
cleanVObject( t );
}
@@ -1524,23 +1533,23 @@ class QString OContact::recordField( int pos ) const
{
QStringList SLFIELDS = fields(); // ?? why this ? (se)
return SLFIELDS[pos];
}
// In future releases, we should store birthday and anniversary
-// internally as QDate instead of QString !
+// internally as QDate instead of QString !
// QString is always too complicate to interprete (DD.MM.YY, DD/MM/YY, MM/DD/YY, etc..)(se)
/*! \fn void OContact::setBirthday( const QDate& date )
Sets the birthday for the contact to \a date.
*/
void OContact::setBirthday( const QDate &v )
-{
+{
if ( ( !v.isNull() ) && ( v.isValid() ) )
replace( Qtopia::Birthday, TimeConversion::toString( v ) );
-
+
}
/*! \fn void OContact::setAnniversary( const QDate &date )
Sets the anniversary of the contact to \a date.
*/
@@ -1550,33 +1559,33 @@ void OContact::setAnniversary( const QDate &v )
replace( Qtopia::Anniversary, TimeConversion::toString( v ) );
}
/*! \fn QDate OContact::birthday() const
Returns the birthday of the contact.
*/
-QDate OContact::birthday() const
-{
+QDate OContact::birthday() const
+{
QString str = find( Qtopia::Birthday );
qWarning ("Birthday %s", str.latin1() );
if ( !str.isEmpty() )
return TimeConversion::fromString ( str );
else
return QDate();
}
/*! \fn QDate OContact::anniversary() const
Returns the anniversary of the contact.
*/
-QDate OContact::anniversary() const
-{
+QDate OContact::anniversary() const
+{
QDate empty;
QString str = find( Qtopia::Anniversary );
qWarning ("Anniversary %s", str.latin1() );
if ( !str.isEmpty() )
- return TimeConversion::fromString ( str );
+ return TimeConversion::fromString ( str );
else
return empty;
}
void OContact::insertEmail( const QString &v )
@@ -1604,13 +1613,13 @@ void OContact::insertEmail( const QString &v )
void OContact::removeEmail( const QString &v )
{
QString e = v.simplifyWhiteSpace();
QString def = defaultEmail();
QString emailsStr = find( Qtopia::Emails );
QStringList emails = emailList();
-
+
// otherwise, must first contain it
if ( !emailsStr.contains( e ) )
return;
// remove it
//qDebug(" removing email from list %s", e.latin1());
@@ -1637,15 +1646,15 @@ void OContact::setDefaultEmail( const QString &v )
{
QString e = v.simplifyWhiteSpace();
//qDebug("OContact::setDefaultEmail %s", e.latin1());
replace( Qtopia::DefaultEmail, e );
- if ( !e.isEmpty() )
+ if ( !e.isEmpty() )
insertEmail( e );
-
+
}
void OContact::insertEmails( const QStringList &v )
{
for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it )
insertEmail( *it );
diff --git a/libopie2/opiepim/orecordlist.h b/libopie2/opiepim/orecordlist.h
index 2f4a5d3..8ed41e2 100644
--- a/libopie2/opiepim/orecordlist.h
+++ b/libopie2/opiepim/orecordlist.h
@@ -231,13 +231,13 @@ void ORecordListIterator<T>::setCurrent( uint cur ) {
m_end = false;
m_current= cur;
}
}
template <class T>
uint ORecordListIterator<T>::count()const {
- return m_uids.count();
+ return m_uids.count();
}
template <class T>
ORecordList<T>::ORecordList( const QArray<int>& ids,
const Base* acc )
: m_ids( ids ), m_acc( acc )
{
diff --git a/libopie2/opiepim/otodo.cpp b/libopie2/opiepim/otodo.cpp
index 765d5a9..0d5b1d3 100644
--- a/libopie2/opiepim/otodo.cpp
+++ b/libopie2/opiepim/otodo.cpp
@@ -9,13 +9,14 @@
#include <qpe/palmtoprecord.h>
#include <qpe/stringutil.h>
#include <qpe/categories.h>
#include <qpe/categoryselect.h>
-
+#include "opimstate.h"
+#include "orecur.h"
#include "otodo.h"
struct OTodo::OTodoData : public QShared {
OTodoData() : QShared() {
};
@@ -27,12 +28,14 @@ struct OTodo::OTodoData : public QShared {
QString desc;
QString sum;
QMap<QString, QString> extra;
ushort prog;
bool hasAlarmDateTime :1;
QDateTime alarmDateTime;
+ OPimState state;
+ ORecur recur;
};
OTodo::OTodo(const OTodo &event )
: OPimRecord( event ), data( event.data )
{
data->ref();
@@ -141,12 +144,18 @@ QDateTime OTodo::alarmDateTime() const
}
QString OTodo::description()const
{
return data->desc;
}
+OPimState OTodo::state()const {
+ return data->state;
+}
+ORecur OTodo::recurrence()const {
+ return data->recur;
+}
void OTodo::setCompleted( bool completed )
{
changeOrModify();
data->isCompleted = completed;
}
void OTodo::setHasDueDate( bool hasDate )
@@ -182,12 +191,20 @@ void OTodo::setDueDate( QDate date )
}
void OTodo::setAlarmDateTime( const QDateTime& alarm )
{
changeOrModify();
data->alarmDateTime = alarm;
}
+void OTodo::setState( const OPimState& state ) {
+ changeOrModify();
+ data->state = state;
+}
+void OTodo::setRecurrence( const ORecur& rec) {
+ changeOrModify();
+ data->recur = rec;
+}
bool OTodo::isOverdue( )
{
if( data->hasDate && !data->isCompleted)
return QDate::currentDate() > data->date;
return false;
}
@@ -355,13 +372,13 @@ QMap<QString, QString> OTodo::toExtraMap()const {
* change or modify looks at the ref count and either
* creates a new QShared Object or it can modify it
* right in place
*/
void OTodo::changeOrModify() {
if ( data->count != 1 ) {
-// qWarning("changeOrModify");
+ qWarning("changeOrModify");
data->deref();
OTodoData* d2 = new OTodoData();
copy(data, d2 );
data = d2;
}
}
@@ -373,12 +390,14 @@ void OTodo::copy( OTodoData* src, OTodoData* dest ) {
dest->desc = src->desc;
dest->sum = src->sum;
dest->extra = src->extra;
dest->prog = src->prog;
dest->hasAlarmDateTime = src->hasAlarmDateTime;
dest->alarmDateTime = src->alarmDateTime;
+ dest->state = src->state;
+ dest->recur = src->recur;
}
QString OTodo::type() const {
return QString::fromLatin1("OTodo");
}
QString OTodo::recordField(int id )const {
return QString::null;
diff --git a/libopie2/opiepim/otodo.h b/libopie2/opiepim/otodo.h
index 5bd91d6..2cdc587 100644
--- a/libopie2/opiepim/otodo.h
+++ b/libopie2/opiepim/otodo.h
@@ -13,12 +13,14 @@
#include <qpe/recordfields.h>
#include <qpe/palmtopuidgen.h>
#include <opie/opimrecord.h>
+class OPimState;
+class ORecur;
class OTodo : public OPimRecord {
public:
typedef QValueList<OTodo> ValueList;
enum RecordFields {
Uid = Qtopia::UID_ID,
Category = Qtopia::CATEGORY_ID,
@@ -30,13 +32,18 @@ public:
DateDay,
DateMonth,
DateYear,
Progress,
CrossReference,
HasAlarmDateTime,
- AlarmDateTime
+ AlarmDateTime,
+ State,
+ Recurrance,
+ Alarms,
+ Reminders,
+ Notifiers
};
public:
// priorities from Very low to very high
enum TaskPriority { VeryHigh=1, High, Normal, Low, VeryLow };
/* Constructs a new ToDoEvent
@@ -108,12 +115,22 @@ public:
/**
* Alarm Date and Time
*/
QDateTime alarmDateTime()const;
/**
+ * What is the state of this OTodo?
+ */
+ OPimState state()const;
+
+ /**
+ * the recurrance of this
+ */
+ ORecur recurrence()const;
+
+ /**
* The description of the todo
*/
QString description()const;
/**
* A small summary of the todo
@@ -167,19 +184,27 @@ public:
/**
* set the end date
*/
void setDueDate( QDate date );
+
+ void setRecurrence( const ORecur& );
/**
* set the alarm time
*/
void setAlarmDateTime ( const QDateTime& alarm );
void setDescription(const QString& );
void setSummary(const QString& );
+
+ /**
+ * set the state of a Todo
+ * @param state State what the todo should take
+ */
+ void setState( const OPimState& state);
bool isOverdue();
bool match( const QRegExp &r )const;
bool operator<(const OTodo &toDoEvent )const;