summaryrefslogtreecommitdiff
path: root/libopie/pim
Side-by-side diff
Diffstat (limited to 'libopie/pim') (more/less context) (show whitespace changes)
-rw-r--r--libopie/pim/opimmaintainer.cpp37
-rw-r--r--libopie/pim/opimmaintainer.h36
-rw-r--r--libopie/pim/opimxrefmanager.cpp2
-rw-r--r--libopie/pim/otodo.cpp20
-rw-r--r--libopie/pim/otodo.h12
5 files changed, 106 insertions, 1 deletions
diff --git a/libopie/pim/opimmaintainer.cpp b/libopie/pim/opimmaintainer.cpp
new file mode 100644
index 0000000..e34f035
--- a/dev/null
+++ b/libopie/pim/opimmaintainer.cpp
@@ -0,0 +1,37 @@
+#include "opimmaintainer.h"
+
+OPimMaintainer::OPimMaintainer( enum Mode mode, int uid )
+ : m_mode(mode), m_uid(uid )
+{}
+OPimMaintainer::~OPimMaintainer() {
+}
+OPimMaintainer::OPimMaintainer( const OPimMaintainer& main ) {
+ *this = main;
+}
+OPimMaintainer &OPimMaintainer::operator=( const OPimMaintainer& main ) {
+ m_mode = main.m_mode;
+ m_uid = main.m_uid;
+
+ return *this;
+}
+bool OPimMaintainer::operator==( const OPimMaintainer& main ) {
+ if (m_mode != main.m_mode ) return false;
+ if (m_uid != main.m_uid ) return false;
+
+ return true;
+}
+bool OPimMaintainer::operator!=( const OPimMaintainer& main ) {
+ return !(*this == main );
+}
+OPimMaintainer::Mode OPimMaintainer::mode()const {
+ return m_mode;
+}
+int OPimMaintainer::uid()const {
+ return m_uid;
+}
+void OPimMaintainer::setMode( enum Mode mo) {
+ m_mode = mo;
+}
+void OPimMaintainer::setUid( int uid ) {
+ m_uid = uid;
+}
diff --git a/libopie/pim/opimmaintainer.h b/libopie/pim/opimmaintainer.h
new file mode 100644
index 0000000..310e15a
--- a/dev/null
+++ b/libopie/pim/opimmaintainer.h
@@ -0,0 +1,36 @@
+#ifndef OPIE_PIM_MAINTAINER_H
+#define OPIE_PIM_MAINTAINER_H
+
+#include <qstring.h>
+
+/**
+ * Who maintains what?
+ */
+class OPimMaintainer {
+public:
+ enum Mode { Undefined = -1,
+ Responsible = 0,
+ DoneBy,
+ Coordinating };
+ OPimMaintainer( enum Mode mode = Undefined, int uid = 0);
+ OPimMaintainer( const OPimMaintainer& );
+ ~OPimMaintainer();
+
+ OPimMaintainer &operator=( const OPimMaintainer& );
+ bool operator==( const OPimMaintainer& );
+ bool operator!=( const OPimMaintainer& );
+
+
+ Mode mode()const;
+ int uid()const;
+
+ void setMode( enum Mode );
+ void setUid( int uid );
+
+private:
+ Mode m_mode;
+ int m_uid;
+
+};
+
+#endif
diff --git a/libopie/pim/opimxrefmanager.cpp b/libopie/pim/opimxrefmanager.cpp
index d49f5f5..965f542 100644
--- a/libopie/pim/opimxrefmanager.cpp
+++ b/libopie/pim/opimxrefmanager.cpp
@@ -1,32 +1,34 @@
#include "opimxrefmanager.h"
OPimXRefManager::OPimXRefManager() {
}
OPimXRefManager::OPimXRefManager( const OPimXRefManager& ref) {
m_list = ref.m_list;
}
+OPimXRefManager::~OPimXRefManager() {
+}
OPimXRefManager &OPimXRefManager::operator=( const OPimXRefManager& ref) {
m_list = ref.m_list;
return *this;
}
bool OPimXRefManager::operator==( const OPimXRefManager& /*ref*/) {
// if ( m_list == ref.m_list ) return true;
return false;
}
void OPimXRefManager::add( const OPimXRef& ref) {
m_list.append( ref );
}
void OPimXRefManager::remove( const OPimXRef& ref) {
m_list.remove( ref );
}
void OPimXRefManager::replace( const OPimXRef& ref) {
m_list.remove( ref );
m_list.append( ref );
}
void OPimXRefManager::clear() {
m_list.clear();
}
QStringList OPimXRefManager::apps()const {
OPimXRef::ValueList::ConstIterator it;
diff --git a/libopie/pim/otodo.cpp b/libopie/pim/otodo.cpp
index 4d5cb79..6fcf9f6 100644
--- a/libopie/pim/otodo.cpp
+++ b/libopie/pim/otodo.cpp
@@ -1,59 +1,62 @@
#include <qobject.h>
#include <qshared.h>
#include <qpe/palmtopuidgen.h>
#include <qpe/stringutil.h>
#include <qpe/palmtoprecord.h>
#include <qpe/stringutil.h>
#include <qpe/categories.h>
#include <qpe/categoryselect.h>
#include "opimstate.h"
#include "orecur.h"
+#include "opimmaintainer.h"
+
#include "otodo.h"
struct OTodo::OTodoData : public QShared {
OTodoData() : QShared() {
};
QDate date;
bool isCompleted:1;
bool hasDate:1;
int priority;
QString desc;
QString sum;
QMap<QString, QString> extra;
ushort prog;
bool hasAlarmDateTime :1;
QDateTime alarmDateTime;
OPimState state;
ORecur recur;
+ OPimMaintainer maintainer;
};
OTodo::OTodo(const OTodo &event )
: OPimRecord( event ), data( event.data )
{
data->ref();
// qWarning("ref up");
}
OTodo::~OTodo() {
// qWarning("~OTodo " );
if ( data->deref() ) {
// qWarning("OTodo::dereffing");
delete data;
data = 0l;
}
}
OTodo::OTodo(bool completed, int priority,
const QArray<int> &category,
const QString& summary,
const QString &description,
ushort progress,
bool hasDate, QDate date, int uid )
: OPimRecord( uid )
@@ -132,48 +135,51 @@ QString OTodo::summary() const
ushort OTodo::progress() const
{
return data->prog;
}
QDate OTodo::dueDate()const
{
return data->date;
}
QDateTime OTodo::alarmDateTime() const
{
return data->alarmDateTime;
}
QString OTodo::description()const
{
return data->desc;
}
OPimState OTodo::state()const {
return data->state;
}
ORecur OTodo::recurrence()const {
return data->recur;
}
+OPimMaintainer OTodo::maintainer()const {
+ return data->maintainer;
+}
void OTodo::setCompleted( bool completed )
{
changeOrModify();
data->isCompleted = completed;
}
void OTodo::setHasDueDate( bool hasDate )
{
changeOrModify();
data->hasDate = hasDate;
}
void OTodo::setHasAlarmDateTime( bool hasAlarmDateTime )
{
changeOrModify();
data->hasAlarmDateTime = hasAlarmDateTime;
}
void OTodo::setDescription(const QString &desc )
{
// qWarning( "desc " + desc );
changeOrModify();
data->desc = Qtopia::simplifyMultiLineSpace(desc );
}
void OTodo::setSummary( const QString& sum )
{
changeOrModify();
@@ -181,48 +187,52 @@ void OTodo::setSummary( const QString& sum )
}
void OTodo::setPriority(int prio )
{
changeOrModify();
data->priority = prio;
}
void OTodo::setDueDate( QDate date )
{
changeOrModify();
data->date = 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;
}
+void OTodo::setMaintainer( const OPimMaintainer& pim ) {
+ changeOrModify();
+ data->maintainer = 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 {
return summary();
}
/*!
Returns a richt text string
*/
QString OTodo::toRichText() const
{
QString text;
QStringList catlist;
// Description of the todo
if ( !summary().isEmpty() ) {
@@ -300,106 +310,114 @@ bool OTodo::operator>=(const OTodo &toDoEvent )const
if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true;
if( !hasDueDate() && toDoEvent.hasDueDate() ) return false;
if( hasDueDate() && toDoEvent.hasDueDate() ){
if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide
return priority() > toDoEvent.priority();
}else{
return dueDate() > toDoEvent.dueDate();
}
}
return true;
}
bool OTodo::operator==(const OTodo &toDoEvent )const
{
if ( data->priority != toDoEvent.data->priority ) return false;
if ( data->priority != toDoEvent.data->prog ) return false;
if ( data->isCompleted != toDoEvent.data->isCompleted ) return false;
if ( data->hasDate != toDoEvent.data->hasDate ) return false;
if ( data->date != toDoEvent.data->date ) return false;
if ( data->sum != toDoEvent.data->sum ) return false;
if ( data->desc != toDoEvent.data->desc ) return false;
if ( data->hasAlarmDateTime != toDoEvent.data->hasAlarmDateTime )
return false;
if ( data->alarmDateTime != toDoEvent.data->alarmDateTime )
return false;
+ if ( data->maintainer != toDoEvent.data->maintainer )
+ return false;
return OPimRecord::operator==( toDoEvent );
}
void OTodo::deref() {
// qWarning("deref in ToDoEvent");
if ( data->deref() ) {
// qWarning("deleting");
delete data;
data= 0;
}
}
OTodo &OTodo::operator=(const OTodo &item )
{
OPimRecord::operator=( item );
//qWarning("operator= ref ");
item.data->ref();
deref();
data = item.data;
return *this;
}
QMap<int, QString> OTodo::toMap() const {
QMap<int, QString> map;
map.insert( Uid, QString::number( uid() ) );
map.insert( Category, idsToString( categories() ) );
map.insert( HasDate, QString::number( data->hasDate ) );
map.insert( Completed, QString::number( data->isCompleted ) );
map.insert( Description, data->desc );
map.insert( Summary, data->sum );
map.insert( Priority, QString::number( data->priority ) );
map.insert( DateDay, QString::number( data->date.day() ) );
map.insert( DateMonth, QString::number( data->date.month() ) );
map.insert( DateYear, QString::number( data->date.year() ) );
map.insert( Progress, QString::number( data->prog ) );
- map.insert( CrossReference, crossToString() );
+// map.insert( CrossReference, crossToString() );
map.insert( HasAlarmDateTime, QString::number( data->hasAlarmDateTime ) );
map.insert( AlarmDateTime, data->alarmDateTime.toString() );
return map;
}
QMap<QString, QString> OTodo::toExtraMap()const {
return data->extra;
}
/**
* 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");
data->deref();
OTodoData* d2 = new OTodoData();
copy(data, d2 );
data = d2;
}
}
+// WATCHOUT
+/*
+ * if you add something to the Data struct
+ * be sure to copy it here
+ */
void OTodo::copy( OTodoData* src, OTodoData* dest ) {
dest->date = src->date;
dest->isCompleted = src->isCompleted;
dest->hasDate = src->hasDate;
dest->priority = src->priority;
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;
+ dest->maintainer = src->maintainer;
}
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 2cdc587..70b0253 100644
--- a/libopie/pim/otodo.h
+++ b/libopie/pim/otodo.h
@@ -1,44 +1,45 @@
#ifndef OPIE_TODO_EVENT_H
#define OPIE_TODO_EVENT_H
#include <qarray.h>
#include <qmap.h>
#include <qregexp.h>
#include <qstringlist.h>
#include <qdatetime.h>
#include <qvaluelist.h>
#include <qpe/recordfields.h>
#include <qpe/palmtopuidgen.h>
#include <opie/opimrecord.h>
class OPimState;
class ORecur;
+class OPimMaintainer;
class OTodo : public OPimRecord {
public:
typedef QValueList<OTodo> ValueList;
enum RecordFields {
Uid = Qtopia::UID_ID,
Category = Qtopia::CATEGORY_ID,
HasDate,
Completed,
Description,
Summary,
Priority,
DateDay,
DateMonth,
DateYear,
Progress,
CrossReference,
HasAlarmDateTime,
AlarmDateTime,
State,
Recurrance,
Alarms,
Reminders,
Notifiers
};
@@ -107,48 +108,53 @@ public:
*/
ushort progress() const;
/**
* The due Date
*/
QDate dueDate()const;
/**
* 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 Maintainer of this OTodo
+ */
+ OPimMaintainer maintainer()const;
+
+ /**
* The description of the todo
*/
QString description()const;
/**
* A small summary of the todo
*/
QString summary() const;
/**
* @reimplemented
* Return this todoevent in a RichText formatted QString
*/
QString toRichText() const;
/**
* reimplementation
*/
QString type()const;
QString toShortText()const;
QMap<QString, QString> toExtraMap()const;
QString recordField(int id )const;
/**
@@ -181,48 +187,54 @@ public:
* Set the progress.
*/
void setProgress( ushort progress );
/**
* 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);
+
+ /**
+ * set the Maintainer Mode
+ */
+ void setMaintainer( const OPimMaintainer& );
+
bool isOverdue();
bool match( const QRegExp &r )const;
bool operator<(const OTodo &toDoEvent )const;
bool operator<=(const OTodo &toDoEvent )const;
bool operator!=(const OTodo &toDoEvent )const;
bool operator>(const OTodo &toDoEvent )const;
bool operator>=(const OTodo &toDoEvent)const;
bool operator==(const OTodo &toDoEvent )const;
OTodo &operator=(const OTodo &toDoEvent );
private:
class OTodoPrivate;
struct OTodoData;
void deref();
inline void changeOrModify();
void copy( OTodoData* src, OTodoData* dest );
OTodoPrivate *d;
OTodoData *data;
};