summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/core/opimtodo.cpp
Side-by-side diff
Diffstat (limited to 'libopie2/opiepim/core/opimtodo.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/core/opimtodo.cpp22
1 files changed, 12 insertions, 10 deletions
diff --git a/libopie2/opiepim/core/opimtodo.cpp b/libopie2/opiepim/core/opimtodo.cpp
index 47433e0..27b36a6 100644
--- a/libopie2/opiepim/core/opimtodo.cpp
+++ b/libopie2/opiepim/core/opimtodo.cpp
@@ -14,48 +14,50 @@
.i_,=:_. -<s. This program is distributed in the hope that
+ . -:. = it will be useful, but WITHOUT ANY WARRANTY;
: .. .:, . . . without even the implied warranty of
=_ + =;=|` MERCHANTABILITY or FITNESS FOR A
_.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.= = ; Library General Public License for more
++= -. .` .: details.
: = ...= . :.=-
-. .:....=;==+<; You should have received a copy of the GNU
-_. . . )=. = Library General Public License along with
-- :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include "opimtodo.h"
/* OPIE */
#include <opie2/opimstate.h>
#include <opie2/opimrecurrence.h>
#include <opie2/opimmaintainer.h>
#include <opie2/opimnotifymanager.h>
#include <opie2/opimresolver.h>
+#include <opie2/odebug.h>
+
#include <qpe/palmtopuidgen.h>
#include <qpe/palmtoprecord.h>
#include <qpe/categories.h>
#include <qpe/categoryselect.h>
#include <qpe/stringutil.h>
/* QT */
#include <qobject.h>
#include <qshared.h>
namespace Opie
{
struct OPimTodo::OPimTodoData : public QShared
{
OPimTodoData() : QShared()
{
recur = 0;
state = 0;
maintainer = 0;
notifiers = 0;
};
~OPimTodoData()
{
@@ -64,97 +66,97 @@ struct OPimTodo::OPimTodoData : public QShared
delete notifiers;
}
QDate date;
bool isCompleted: 1;
bool hasDate: 1;
int priority;
QString desc;
QString sum;
QMap<QString, QString> extra;
ushort prog;
OPimState *state;
OPimRecurrence *recur;
OPimMaintainer *maintainer;
QDate start;
QDate completed;
OPimNotifyManager *notifiers;
};
OPimTodo::OPimTodo( const OPimTodo &event )
: OPimRecord( event ), data( event.data )
{
data->ref();
- // qWarning("ref up");
+ // owarn << "ref up" << oendl;
}
OPimTodo::~OPimTodo()
{
- // qWarning("~OPimTodo " );
+ // owarn << "~OPimTodo " << oendl;
if ( data->deref() )
{
- // qWarning("OPimTodo::dereffing");
+ // owarn << "OPimTodo::dereffing" << oendl;
delete data;
data = 0l;
}
}
OPimTodo::OPimTodo( bool completed, int priority,
const QArray<int> &category,
const QString& summary,
const QString &description,
ushort progress,
bool hasDate, QDate date, int uid )
: OPimRecord( uid )
{
- // qWarning("OPimTodoData " + summary);
+ // owarn << "OPimTodoData " + summary << oendl;
setCategories( category );
data = new OPimTodoData;
data->date = date;
data->isCompleted = completed;
data->hasDate = hasDate;
data->priority = priority;
data->sum = summary;
data->prog = progress;
data->desc = Qtopia::simplifyMultiLineSpace( description );
}
OPimTodo::OPimTodo( bool completed, int priority,
const QStringList &category,
const QString& summary,
const QString &description,
ushort progress,
bool hasDate, QDate date, int uid )
: OPimRecord( uid )
{
- // qWarning("OPimTodoData" + summary);
+ // owarn << "OPimTodoData" + summary << oendl;
setCategories( idsFromString( category.join( ";" ) ) );
data = new OPimTodoData;
data->date = date;
data->isCompleted = completed;
data->hasDate = hasDate;
data->priority = priority;
data->sum = summary;
data->prog = progress;
data->desc = Qtopia::simplifyMultiLineSpace( description );
}
bool OPimTodo::match( const QRegExp &regExp ) const
{
if ( QString::number( data->priority ).find( regExp ) != -1 )
{
setLastHitField( Priority );
return true;
}
else if ( data->hasDate && data->date.toString().find( regExp ) != -1 )
{
setLastHitField( HasDate );
@@ -285,49 +287,49 @@ bool OPimTodo::hasMaintainer() const
OPimMaintainer OPimTodo::maintainer() const
{
if ( !data->maintainer ) return OPimMaintainer();
return ( *data->maintainer );
}
void OPimTodo::setCompleted( bool completed )
{
changeOrModify();
data->isCompleted = completed;
}
void OPimTodo::setHasDueDate( bool hasDate )
{
changeOrModify();
data->hasDate = hasDate;
}
void OPimTodo::setDescription( const QString &desc )
{
- // qWarning( "desc " + desc );
+ // owarn << "desc " + desc << oendl;
changeOrModify();
data->desc = Qtopia::simplifyMultiLineSpace( desc );
}
void OPimTodo::setSummary( const QString& sum )
{
changeOrModify();
data->sum = sum;
}
void OPimTodo::setPriority( int prio )
{
changeOrModify();
data->priority = prio;
}
void OPimTodo::setDueDate( const QDate& date )
{
changeOrModify();
data->date = date;
}
@@ -570,107 +572,107 @@ bool OPimTodo::operator>=( const OPimTodo &toDoEvent ) const
}
return true;
}
bool OPimTodo::operator==( const OPimTodo &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->maintainer != toDoEvent.data->maintainer )
return false;
return OPimRecord::operator==( toDoEvent );
}
void OPimTodo::deref()
{
- // qWarning("deref in ToDoEvent");
+ // owarn << "deref in ToDoEvent" << oendl;
if ( data->deref() )
{
- // qWarning("deleting");
+ // owarn << "deleting" << oendl;
delete data;
data = 0;
}
}
OPimTodo &OPimTodo::operator=( const OPimTodo &item )
{
if ( this == &item ) return * this;
OPimRecord::operator=( item );
- //qWarning("operator= ref ");
+ //owarn << "operator= ref " << oendl;
item.data->ref();
deref();
data = item.data;
return *this;
}
QMap<int, QString> OPimTodo::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() );
/* FIXME!!! map.insert( State, );
map.insert( Recurrence, );
map.insert( Reminders, );
map.
*/
return map;
}
/**
* change or modify looks at the ref count and either
* creates a new QShared Object or it can modify it
* right in place
*/
void OPimTodo::changeOrModify()
{
if ( data->count != 1 )
{
- qWarning( "changeOrModify" );
+ owarn << "changeOrModify" << oendl;
data->deref();
OPimTodoData* d2 = new OPimTodoData();
copy( data, d2 );
data = d2;
}
}
// WATCHOUT
/*
* if you add something to the Data struct
* be sure to copy it here
*/
void OPimTodo::copy( OPimTodoData* src, OPimTodoData* 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;