author | drw <drw> | 2005-02-16 19:45:54 (UTC) |
---|---|---|
committer | drw <drw> | 2005-02-16 19:45:54 (UTC) |
commit | 28feca2d605de0bd5a1ccf2217dfef2a17466307 (patch) (side-by-side diff) | |
tree | 0badbaa8bbbecfbe0541f1686572e12c2b8f383a | |
parent | 5ad21664e5db417a18682903a660f4651c68ff12 (diff) | |
download | opie-28feca2d605de0bd5a1ccf2217dfef2a17466307.zip opie-28feca2d605de0bd5a1ccf2217dfef2a17466307.tar.gz opie-28feca2d605de0bd5a1ccf2217dfef2a17466307.tar.bz2 |
Fix for bug #1542 - todo crashes when priority < 1 or > 5
-rw-r--r-- | libopie2/opiepim/core/opimtodo.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/libopie2/opiepim/core/opimtodo.cpp b/libopie2/opiepim/core/opimtodo.cpp index 16ca987..5bdc648 100644 --- a/libopie2/opiepim/core/opimtodo.cpp +++ b/libopie2/opiepim/core/opimtodo.cpp @@ -72,118 +72,126 @@ struct OPimTodo::OPimTodoData : public QShared 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(); } OPimTodo::~OPimTodo() { if ( data->deref() ) { 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 ) { setCategories( category ); data = new OPimTodoData; data->date = date; data->isCompleted = completed; data->hasDate = hasDate; + if ( priority < 1 ) + priority = 1; + else if ( priority > 5 ) + priority = 5; 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 ) { setCategories( idsFromString( category.join( ";" ) ) ); data = new OPimTodoData; data->date = date; data->isCompleted = completed; data->hasDate = hasDate; + if ( priority < 1 ) + priority = 1; + else if ( priority > 5 ) + priority = 5; data->priority = priority; data->sum = summary; data->prog = progress; data->desc = Qtopia::simplifyMultiLineSpace( description ); } bool OPimTodo::match( const QRegExp ®Exp ) 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 ); return true; } else if ( data->desc.find( regExp ) != -1 ) { setLastHitField( Description ); return true; } else if ( data->sum.find( regExp ) != -1 ) { setLastHitField( Summary ); return true; } return false; } bool OPimTodo::isCompleted() const { return data->isCompleted; } bool OPimTodo::hasDueDate() const { return data->hasDate; } /** * \brief Does this Todo have a start date * * Does this Todo have a start date. The decision @@ -294,96 +302,100 @@ OPimRecurrence OPimTodo::recurrence() const bool OPimTodo::hasMaintainer() const { if ( !data->maintainer ) return false; return ( data->maintainer->mode() != OPimMaintainer::Undefined ); } 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 ) { changeOrModify(); data->desc = Qtopia::simplifyMultiLineSpace( desc ); } void OPimTodo::setSummary( const QString& sum ) { changeOrModify(); data->sum = sum; } void OPimTodo::setPriority( int prio ) { changeOrModify(); + if ( prio < 1 ) + prio = 1; + else if ( prio > 5 ) + prio = 5; data->priority = prio; } void OPimTodo::setDueDate( const QDate& date ) { changeOrModify(); data->date = date; } void OPimTodo::setStartDate( const QDate& date ) { changeOrModify(); data->start = date; } void OPimTodo::setCompletedDate( const QDate& date ) { changeOrModify(); data->completed = date; } void OPimTodo::setState( const OPimState& state ) { changeOrModify(); if ( data->state ) ( *data->state ) = state; else data->state = new OPimState( state ); } void OPimTodo::setRecurrence( const OPimRecurrence& rec ) { changeOrModify(); if ( data->recur ) ( *data->recur ) = rec; else data->recur = new OPimRecurrence( rec ); } void OPimTodo::setMaintainer( const OPimMaintainer& pim ) { changeOrModify(); |