summaryrefslogtreecommitdiff
path: root/core/pim/todo/smalltodo.cpp
Unidiff
Diffstat (limited to 'core/pim/todo/smalltodo.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/todo/smalltodo.cpp114
1 files changed, 114 insertions, 0 deletions
diff --git a/core/pim/todo/smalltodo.cpp b/core/pim/todo/smalltodo.cpp
new file mode 100644
index 0000000..412fe9e
--- a/dev/null
+++ b/core/pim/todo/smalltodo.cpp
@@ -0,0 +1,114 @@
1/*
2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 <zecke@handhelds.org>
4           .>+-=
5 _;:,     .>    :=|. This program is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU General Public
8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This program is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more
18++=   -.     .`     .: details.
19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = Library General Public License along with
22    --        :-=` this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA.
26
27*/
28#include <qshared.h>
29
30#include "smalltodo.h"
31
32using namespace Todo;
33
34struct SmallTodo::SmallTodoPrivate : public QShared{
35
36 SmallTodoPrivate() : QShared(), uid(-1) {};
37 QString name;
38 QStringList categories; // as real Names
39 int uid;
40 bool complete:1;
41 QDate date;
42
43
44 void deleteSelf() { delete this; };
45};
46
47SmallTodo::SmallTodo(int uid,
48 bool comp,
49 const QDate& date,
50 const QString& name,
51 const QStringList& cats) {
52 d = new SmallTodoPrivate();
53 d->name = name;
54 d->uid = uid;
55 d->categories = cats;
56 d->complete = comp;
57 d->date = date;
58}
59SmallTodo::SmallTodo( const SmallTodo& s ) : d(s.d) {
60 d->ref();
61}
62SmallTodo::~SmallTodo() {
63 /* deref and if last one delete */
64 if ( d->deref() ) {
65 d->deleteSelf();
66 }
67}
68bool SmallTodo::operator==( const SmallTodo& todo ) {
69 if ( d->complete != todo.d->complete ) return false;
70 if ( d->name != todo.d->name ) return false;
71 if ( d->uid != todo.d->uid ) return false;
72 if ( d->categories != todo.d->categories ) return false;
73 if ( d->date != todo.d->date ) return false;
74
75 return true;
76}
77bool SmallTodo::operator==( const SmallTodo& todo ) const{
78 if ( d->complete != todo.d->complete ) return false;
79 if ( d->uid != todo.d->uid ) return false;
80 if ( d->name != todo.d->name ) return false;
81 if ( d->categories != todo.d->categories ) return false;
82 if ( d->date != todo.d->date ) return false;
83
84 return true;
85}
86SmallTodo &SmallTodo::operator=( const SmallTodo& todo ) {
87 todo.d->ref();
88 deref();
89
90 d = todo.d;
91
92 return *this;
93}
94void SmallTodo::deref() {
95 if ( d->deref() ) {
96 delete d;
97 d = 0;
98 }
99}
100QString SmallTodo::name() const {
101 return d->name;
102}
103QStringList SmallTodo::categories()const {
104 return d->categories;
105}
106int SmallTodo::uid()const {
107 return d->uid;
108}
109bool SmallTodo::isCompleted()const {
110 return d->complete;
111}
112QDate SmallTodo::date()const {
113 return d->date;
114}