summaryrefslogtreecommitdiff
path: root/libopie2/opiepim
Side-by-side diff
Diffstat (limited to 'libopie2/opiepim') (more/less context) (ignore whitespace changes)
-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
9 files changed, 194 insertions, 22 deletions
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
@@ -10,5 +10,5 @@
/**
- * This is the base class for
+ * This is the base class for
* all PIM Records
*
@@ -111,5 +111,5 @@ public:
*/
void setRelations( const QString&, QArray<int> ids );
-
+
/**
* set the uid
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
@@ -22,4 +22,5 @@ struct ORecur::Data : public QShared {
time_t end;
time_t create;
+ int rep;
};
@@ -79,4 +80,7 @@ time_t ORecur::createTime()const {
return data->create;
}
+int ORecur::repetition()const {
+ return data->rep;
+}
void ORecur::setType( const RepeatType& z) {
checkOrModify();
@@ -111,4 +115,8 @@ void ORecur::setHasEndDate( bool b) {
data->hasEnd = b;
}
+void ORecur::setRepitition( int rep ) {
+ checkOrModify();
+ data->rep = rep;
+}
void ORecur::checkOrModify() {
if ( data->count != 1 ) {
@@ -122,4 +130,5 @@ void ORecur::checkOrModify() {
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
@@ -32,4 +32,5 @@ public:
time_t endDateUTC()const;
time_t createTime()const;
+ int repetition()const;
void setType( const RepeatType& );
@@ -41,4 +42,5 @@ public:
void setCreateTime( time_t );
void setHasEndDate( bool b );
+ void setRepitition(int );
private:
void deref();
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
@@ -1128,5 +1128,5 @@ static VObject *createVObject( const OContact &c )
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 );
@@ -1135,5 +1135,5 @@ static VObject *createVObject( const OContact &c )
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() );
@@ -1389,9 +1389,9 @@ static OContact parseVObject( VObject *obj )
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 ) );
-
+
}
@@ -1465,5 +1465,14 @@ QValueList<OContact> OContact::readVCard( const QString &filename )
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;
@@ -1528,5 +1537,5 @@ class QString OContact::recordField( int pos ) const
// 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)
@@ -1535,8 +1544,8 @@ class QString OContact::recordField( int pos ) const
*/
void OContact::setBirthday( const QDate &v )
-{
+{
if ( ( !v.isNull() ) && ( v.isValid() ) )
replace( Qtopia::Birthday, TimeConversion::toString( v ) );
-
+
}
@@ -1554,6 +1563,6 @@ void OContact::setAnniversary( const QDate &v )
Returns the birthday of the contact.
*/
-QDate OContact::birthday() const
-{
+QDate OContact::birthday() const
+{
QString str = find( Qtopia::Birthday );
qWarning ("Birthday %s", str.latin1() );
@@ -1568,11 +1577,11 @@ QDate OContact::birthday() 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;
@@ -1608,5 +1617,5 @@ void OContact::removeEmail( const QString &v )
QString emailsStr = find( Qtopia::Emails );
QStringList emails = emailList();
-
+
// otherwise, must first contain it
if ( !emailsStr.contains( e ) )
@@ -1641,7 +1650,7 @@ void OContact::setDefaultEmail( const QString &v )
replace( Qtopia::DefaultEmail, e );
- if ( !e.isEmpty() )
+ if ( !e.isEmpty() )
insertEmail( e );
-
+
}
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
@@ -235,5 +235,5 @@ void ORecordListIterator<T>::setCurrent( uint cur ) {
template <class T>
uint ORecordListIterator<T>::count()const {
- return m_uids.count();
+ return m_uids.count();
}
template <class T>
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
@@ -13,5 +13,6 @@
-
+#include "opimstate.h"
+#include "orecur.h"
#include "otodo.h"
@@ -31,4 +32,6 @@ struct OTodo::OTodoData : public QShared {
bool hasAlarmDateTime :1;
QDateTime alarmDateTime;
+ OPimState state;
+ ORecur recur;
};
@@ -145,4 +148,10 @@ 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 )
{
@@ -186,4 +195,12 @@ void OTodo::setAlarmDateTime( const QDateTime& alarm )
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( )
{
@@ -359,5 +376,5 @@ QMap<QString, QString> OTodo::toExtraMap()const {
void OTodo::changeOrModify() {
if ( data->count != 1 ) {
-// qWarning("changeOrModify");
+ qWarning("changeOrModify");
data->deref();
OTodoData* d2 = new OTodoData();
@@ -377,4 +394,6 @@ void OTodo::copy( OTodoData* src, OTodoData* dest ) {
dest->hasAlarmDateTime = src->hasAlarmDateTime;
dest->alarmDateTime = src->alarmDateTime;
+ dest->state = src->state;
+ dest->recur = src->recur;
}
QString OTodo::type() const {
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
@@ -17,4 +17,6 @@
+class OPimState;
+class ORecur;
class OTodo : public OPimRecord {
public:
@@ -34,5 +36,10 @@ public:
CrossReference,
HasAlarmDateTime,
- AlarmDateTime
+ AlarmDateTime,
+ State,
+ Recurrance,
+ Alarms,
+ Reminders,
+ Notifiers
};
public:
@@ -112,4 +119,14 @@ public:
/**
+ * What is the state of this OTodo?
+ */
+ OPimState state()const;
+
+ /**
+ * the recurrance of this
+ */
+ ORecur recurrence()const;
+
+ /**
* The description of the todo
*/
@@ -171,4 +188,6 @@ public:
void setDueDate( QDate date );
+
+ void setRecurrence( const ORecur& );
/**
* set the alarm time
@@ -178,4 +197,10 @@ public:
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();