summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/otodo.cpp
Side-by-side diff
Diffstat (limited to 'libopie2/opiepim/otodo.cpp') (more/less context) (show whitespace changes)
-rw-r--r--libopie2/opiepim/otodo.cpp294
1 files changed, 228 insertions, 66 deletions
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
@@ -28,7 +28,11 @@
*/
-#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>
@@ -40,15 +44,13 @@
+/* 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;
@@ -58,3 +60,4 @@ struct OTodo::OTodoData : public QShared {
};
- ~OTodoData() {
+ ~OTodoData()
+ {
delete recur;
@@ -80,2 +83,3 @@ struct OTodo::OTodoData : public QShared {
+
OTodo::OTodo(const OTodo &event )
@@ -86,6 +90,10 @@ OTodo::OTodo(const OTodo &event )
}
-OTodo::~OTodo() {
+
+
+OTodo::~OTodo()
+{
// qWarning("~OTodo " );
- if ( data->deref() ) {
+ if ( data->deref() )
+ {
// qWarning("OTodo::dereffing");
@@ -95,2 +103,4 @@ OTodo::~OTodo() {
}
+
+
OTodo::OTodo(bool completed, int priority,
@@ -116,2 +126,4 @@ OTodo::OTodo(bool completed, int priority,
}
+
+
OTodo::OTodo(bool completed, int priority,
@@ -137,14 +149,23 @@ OTodo::OTodo(bool completed, int priority,
}
+
+
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 );
@@ -154,2 +175,4 @@ bool OTodo::match( const QRegExp &regExp )const
}
+
+
bool OTodo::isCompleted() const
@@ -158,2 +181,4 @@ bool OTodo::isCompleted() const
}
+
+
bool OTodo::hasDueDate() const
@@ -162,8 +187,16 @@ bool OTodo::hasDueDate() const
}
-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
@@ -172,2 +205,4 @@ int OTodo::priority()const
}
+
+
QString OTodo::summary() const
@@ -176,2 +211,4 @@ QString OTodo::summary() const
}
+
+
ushort OTodo::progress() const
@@ -180,2 +217,4 @@ ushort OTodo::progress() const
}
+
+
QDate OTodo::dueDate()const
@@ -184,8 +223,16 @@ QDate OTodo::dueDate()const
}
-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
@@ -194,3 +241,6 @@ QString OTodo::description()const
}
-bool OTodo::hasState() const{
+
+
+bool OTodo::hasState() const
+{
if (!data->state ) return false;
@@ -198,4 +248,8 @@ bool OTodo::hasState() const{
}
-OPimState OTodo::state()const {
- if (!data->state ) {
+
+
+OPimState OTodo::state() const
+{
+ if ( !data->state )
+ {
OPimState state;
@@ -206,3 +260,6 @@ OPimState OTodo::state()const {
}
-bool OTodo::hasRecurrence()const {
+
+
+bool OTodo::hasRecurrence() const
+{
if (!data->recur) return false;
@@ -210,3 +267,6 @@ bool OTodo::hasRecurrence()const {
}
-ORecur OTodo::recurrence()const {
+
+
+ORecur OTodo::recurrence() const
+{
if (!data->recur) return ORecur();
@@ -215,3 +275,6 @@ ORecur OTodo::recurrence()const {
}
-bool OTodo::hasMaintainer()const {
+
+
+bool OTodo::hasMaintainer() const
+{
if (!data->maintainer) return false;
@@ -220,3 +283,6 @@ bool OTodo::hasMaintainer()const {
}
-OPimMaintainer OTodo::maintainer()const {
+
+
+OPimMaintainer OTodo::maintainer() const
+{
if (!data->maintainer) return OPimMaintainer();
@@ -225,2 +291,4 @@ OPimMaintainer OTodo::maintainer()const {
}
+
+
void OTodo::setCompleted( bool completed )
@@ -230,2 +298,4 @@ void OTodo::setCompleted( bool completed )
}
+
+
void OTodo::setHasDueDate( bool hasDate )
@@ -235,2 +305,4 @@ void OTodo::setHasDueDate( bool hasDate )
}
+
+
void OTodo::setDescription(const QString &desc )
@@ -241,2 +313,4 @@ void OTodo::setDescription(const QString &desc )
}
+
+
void OTodo::setSummary( const QString& sum )
@@ -246,2 +320,4 @@ void OTodo::setSummary( const QString& sum )
}
+
+
void OTodo::setPriority(int prio )
@@ -251,2 +327,4 @@ void OTodo::setPriority(int prio )
}
+
+
void OTodo::setDueDate( const QDate& date )
@@ -256,3 +334,6 @@ void OTodo::setDueDate( const QDate& date )
}
-void OTodo::setStartDate( const QDate& date ) {
+
+
+void OTodo::setStartDate( const QDate& date )
+{
changeOrModify();
@@ -260,3 +341,6 @@ void OTodo::setStartDate( const QDate& date ) {
}
-void OTodo::setCompletedDate( const QDate& date ) {
+
+
+void OTodo::setCompletedDate( const QDate& date )
+{
changeOrModify();
@@ -264,3 +348,6 @@ void OTodo::setCompletedDate( const QDate& date ) {
}
-void OTodo::setState( const OPimState& state ) {
+
+
+void OTodo::setState( const OPimState& state )
+{
changeOrModify();
@@ -271,3 +358,6 @@ void OTodo::setState( const OPimState& state ) {
}
-void OTodo::setRecurrence( const ORecur& rec) {
+
+
+void OTodo::setRecurrence( const ORecur& rec )
+{
changeOrModify();
@@ -278,3 +368,6 @@ void OTodo::setRecurrence( const ORecur& rec) {
}
-void OTodo::setMaintainer( const OPimMaintainer& pim ) {
+
+
+void OTodo::setMaintainer( const OPimMaintainer& pim )
+{
changeOrModify();
@@ -286,2 +379,4 @@ void OTodo::setMaintainer( const OPimMaintainer& pim ) {
}
+
+
bool OTodo::isOverdue( )
@@ -292,2 +387,4 @@ bool OTodo::isOverdue( )
}
+
+
void OTodo::setProgress(ushort progress )
@@ -297,5 +394,10 @@ void OTodo::setProgress(ushort progress )
}
-QString OTodo::toShortText() const {
+
+
+QString OTodo::toShortText() const
+{
return summary();
}
+
+
/*!
@@ -310,3 +412,4 @@ QString OTodo::toRichText() const
text += "<b><h3><img src=\"todo/TodoList\"> ";
- if ( !summary().isEmpty() ) {
+ if ( !summary().isEmpty() )
+ {
text += Qtopia::escapeString(summary() ).replace(QRegExp( "[\n]"), "" );
@@ -316,3 +419,4 @@ QString OTodo::toRichText() const
// description
- if( !description().isEmpty() ){
+ if ( !description().isEmpty() )
+ {
text += "<b>" + QObject::tr( "Description:" ) + "</b><br>";
@@ -346,3 +450,4 @@ QString OTodo::toRichText() const
// due date
- if (hasDueDate() ){
+ if ( hasDueDate() )
+ {
QDate dd = dueDate();
@@ -368,3 +473,6 @@ QString OTodo::toRichText() const
}
-bool OTodo::hasNotifiers()const {
+
+
+bool OTodo::hasNotifiers() const
+{
if (!data->notifiers) return false;
@@ -372,3 +480,6 @@ bool OTodo::hasNotifiers()const {
}
-OPimNotifyManager& OTodo::notifiers() {
+
+
+OPimNotifyManager& OTodo::notifiers()
+{
if (!data->notifiers )
@@ -377,3 +488,6 @@ OPimNotifyManager& OTodo::notifiers() {
}
-const OPimNotifyManager& OTodo::notifiers()const{
+
+
+const OPimNotifyManager& OTodo::notifiers() const
+{
if (!data->notifiers )
@@ -384,9 +498,15 @@ const OPimNotifyManager& OTodo::notifiers()const{
-bool OTodo::operator<( const OTodo &toDoEvent )const{
+
+bool OTodo::operator<( const OTodo &toDoEvent ) const
+{
if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true;
if( !hasDueDate() && toDoEvent.hasDueDate() ) return false;
- if( hasDueDate() && toDoEvent.hasDueDate() ){
- if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide
+ if ( hasDueDate() && toDoEvent.hasDueDate() )
+ {
+ if ( dueDate() == toDoEvent.dueDate() )
+ { // let's the priority decide
return priority() < toDoEvent.priority();
- }else{
+ }
+ else
+ {
return dueDate() < toDoEvent.dueDate();
@@ -396,2 +516,4 @@ bool OTodo::operator<( const OTodo &toDoEvent )const{
}
+
+
bool OTodo::operator<=(const OTodo &toDoEvent )const
@@ -400,6 +522,10 @@ bool OTodo::operator<=(const OTodo &toDoEvent )const
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();
@@ -409,2 +535,4 @@ bool OTodo::operator<=(const OTodo &toDoEvent )const
}
+
+
bool OTodo::operator>(const OTodo &toDoEvent )const
@@ -413,6 +541,10 @@ bool OTodo::operator>(const OTodo &toDoEvent )const
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();
@@ -422,2 +554,4 @@ bool OTodo::operator>(const OTodo &toDoEvent )const
}
+
+
bool OTodo::operator>=(const OTodo &toDoEvent )const
@@ -426,6 +560,10 @@ bool OTodo::operator>=(const OTodo &toDoEvent )const
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();
@@ -435,2 +573,4 @@ bool OTodo::operator>=(const OTodo &toDoEvent )const
}
+
+
bool OTodo::operator==(const OTodo &toDoEvent )const
@@ -449,6 +589,10 @@ bool OTodo::operator==(const OTodo &toDoEvent )const
}
-void OTodo::deref() {
+
+
+void OTodo::deref()
+{
// qWarning("deref in ToDoEvent");
- if ( data->deref() ) {
+ if ( data->deref() )
+ {
// qWarning("deleting");
@@ -458,2 +602,4 @@ void OTodo::deref() {
}
+
+
OTodo &OTodo::operator=(const OTodo &item )
@@ -471,3 +617,5 @@ OTodo &OTodo::operator=(const OTodo &item )
-QMap<int, QString> OTodo::toMap() const {
+
+QMap<int, QString> OTodo::toMap() const
+{
QMap<int, QString> map;
@@ -494,2 +642,3 @@ QMap<int, QString> OTodo::toMap() const {
+
/**
@@ -499,4 +648,6 @@ QMap<int, QString> OTodo::toMap() const {
*/
-void OTodo::changeOrModify() {
- if ( data->count != 1 ) {
+void OTodo::changeOrModify()
+{
+ if ( data->count != 1 )
+ {
qWarning("changeOrModify");
@@ -508,2 +659,4 @@ void OTodo::changeOrModify() {
}
+
+
// WATCHOUT
@@ -513,3 +666,4 @@ void OTodo::changeOrModify() {
*/
-void OTodo::copy( OTodoData* src, OTodoData* dest ) {
+void OTodo::copy( OTodoData* src, OTodoData* dest )
+{
dest->date = src->date;
@@ -538,6 +692,12 @@ void OTodo::copy( OTodoData* src, OTodoData* dest ) {
}
-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;
@@ -545,3 +705,5 @@ QString OTodo::recordField(int /*id*/ )const {
-int OTodo::rtti(){
+
+int OTodo::rtti()
+{
return OPimResolver::TodoList;