00001 /* 00002 This file is part of the Opie Project 00003 00004 Copyright (C) Opie Team <opie-devel@handhelds.org> 00005 =. 00006 .=l. 00007 .>+-= 00008 _;:, .> :=|. This program is free software; you can 00009 .> <`_, > . <= redistribute it and/or modify it under 00010 :`=1 )Y*s>-.-- : the terms of the GNU Library General Public 00011 .="- .-=="i, .._ License as published by the Free Software 00012 - . .-<_> .<> Foundation; either version 2 of the License, 00013 ._= =} : or (at your option) any later version. 00014 .%`+i> _;_. 00015 .i_,=:_. -<s. This program is distributed in the hope that 00016 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 00017 : .. .:, . . . without even the implied warranty of 00018 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 00019 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 00020 ..}^=.= = ; Library General Public License for more 00021 ++= -. .` .: details. 00022 : = ...= . :.=- 00023 -. .:....=;==+<; You should have received a copy of the GNU 00024 -_. . . )=. = Library General Public License along with 00025 -- :-=` this library; see the file COPYING.LIB. 00026 If not, write to the Free Software Foundation, 00027 Inc., 59 Temple Place - Suite 330, 00028 Boston, MA 02111-1307, USA. 00029 */ 00030 00031 #include "smalltodo.h" 00032 00033 using namespace Todo; 00034 00035 struct SmallTodo::SmallTodoPrivate : public QShared{ 00036 00037 SmallTodoPrivate() : QShared(), uid(-1) {}; 00038 QString name; 00039 QStringList categories; // as real Names 00040 int uid; 00041 bool complete:1; 00042 QDate date; 00043 00044 00045 void deleteSelf() { delete this; }; 00046 }; 00047 00048 SmallTodo::SmallTodo(int uid, 00049 bool comp, 00050 const QDate& date, 00051 const QString& name, 00052 const QStringList& cats) { 00053 d = new SmallTodoPrivate(); 00054 d->name = name; 00055 d->uid = uid; 00056 d->categories = cats; 00057 d->complete = comp; 00058 d->date = date; 00059 } 00060 SmallTodo::SmallTodo( const SmallTodo& s ) : d(s.d) { 00061 d->ref(); 00062 } 00063 SmallTodo::~SmallTodo() { 00064 /* deref and if last one delete */ 00065 if ( d->deref() ) { 00066 d->deleteSelf(); 00067 } 00068 } 00069 bool SmallTodo::operator==( const SmallTodo& todo ) { 00070 if ( d->complete != todo.d->complete ) return false; 00071 if ( d->name != todo.d->name ) return false; 00072 if ( d->uid != todo.d->uid ) return false; 00073 if ( d->categories != todo.d->categories ) return false; 00074 if ( d->date != todo.d->date ) return false; 00075 00076 return true; 00077 } 00078 bool SmallTodo::operator==( const SmallTodo& todo ) const{ 00079 if ( d->complete != todo.d->complete ) return false; 00080 if ( d->uid != todo.d->uid ) return false; 00081 if ( d->name != todo.d->name ) return false; 00082 if ( d->categories != todo.d->categories ) return false; 00083 if ( d->date != todo.d->date ) return false; 00084 00085 return true; 00086 } 00087 SmallTodo &SmallTodo::operator=( const SmallTodo& todo ) { 00088 todo.d->ref(); 00089 deref(); 00090 00091 d = todo.d; 00092 00093 return *this; 00094 } 00095 void SmallTodo::deref() { 00096 if ( d->deref() ) { 00097 delete d; 00098 d = 0; 00099 } 00100 } 00101 QString SmallTodo::name() const { 00102 return d->name; 00103 } 00104 QStringList SmallTodo::categories()const { 00105 return d->categories; 00106 } 00107 int SmallTodo::uid()const { 00108 return d->uid; 00109 } 00110 bool SmallTodo::isCompleted()const { 00111 return d->complete; 00112 } 00113 QDate SmallTodo::date()const { 00114 return d->date; 00115 }
1.4.2