summaryrefslogtreecommitdiff
authorzecke <zecke>2003-05-12 13:20:21 (UTC)
committer zecke <zecke>2003-05-12 13:20:21 (UTC)
commita4c8b8912c9e87a2fd76103193e6b4f91c2a2c5d (patch) (side-by-side diff)
treeaee89fa76cc9e71a67d8ae9462b567e3f91f284f
parentc2602b4c290a14f4655d7e07eea20b55c1f38c8e (diff)
downloadopie-a4c8b8912c9e87a2fd76103193e6b4f91c2a2c5d.zip
opie-a4c8b8912c9e87a2fd76103193e6b4f91c2a2c5d.tar.gz
opie-a4c8b8912c9e87a2fd76103193e6b4f91c2a2c5d.tar.bz2
Hospital Hacking Session
kill warnings implement storing of reminders and alarms... Nach viel Eiter und Gestank...
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/pim/otodoaccessxml.cpp71
-rw-r--r--libopie2/opiepim/backend/otodoaccessxml.cpp71
2 files changed, 130 insertions, 12 deletions
diff --git a/libopie/pim/otodoaccessxml.cpp b/libopie/pim/otodoaccessxml.cpp
index 69b7ab4..2b62f0d 100644
--- a/libopie/pim/otodoaccessxml.cpp
+++ b/libopie/pim/otodoaccessxml.cpp
@@ -1,68 +1,69 @@
#include <errno.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <qfile.h>
#include <qvector.h>
#include <qpe/global.h>
#include <qpe/stringutil.h>
#include <qpe/timeconversion.h>
#include "oconversion.h"
#include "opimstate.h"
#include "otimezone.h"
+#include "opimnotifymanager.h"
#include "orecur.h"
#include "otodoaccessxml.h"
namespace {
time_t rp_end;
ORecur* rec;
ORecur *recur() {
if (!rec ) rec = new ORecur;
return rec;
}
int snd;
enum MoreAttributes {
FRType = OTodo::CompletedDate + 2,
FRWeekdays,
FRPosition,
FRFreq,
FRHasEndDate,
FREndDate,
FRStart,
FREnd
};
// FROM TT again
char *strstrlen(const char *haystack, int hLen, const char* needle, int nLen)
{
char needleChar;
char haystackChar;
if (!needle || !haystack || !hLen || !nLen)
return 0;
const char* hsearch = haystack;
if ((needleChar = *needle++) != 0) {
nLen--; //(to make up for needle++)
do {
do {
if ((haystackChar = *hsearch++) == 0)
return (0);
if (hsearch >= haystack + hLen)
return (0);
} while (haystackChar != needleChar);
} while (strncmp(hsearch, needle, QMIN(hLen - (hsearch - haystack), nLen)) != 0);
hsearch--;
}
return ((char *)hsearch);
}
}
@@ -381,192 +382,251 @@ void OTodoAccessXML::todo( QAsciiDict<int>* dict, OTodo& ev,
// qWarning("Unknown option" + it.key() );
ev.setCustomField( attr, val );
return;
}
switch( *find ) {
case OTodo::Uid:
ev.setUid( val.toInt() );
break;
case OTodo::Category:
ev.setCategories( ev.idsFromString( val ) );
break;
case OTodo::HasDate:
ev.setHasDueDate( val.toInt() );
break;
case OTodo::Completed:
ev.setCompleted( val.toInt() );
break;
case OTodo::Description:
ev.setDescription( val );
break;
case OTodo::Summary:
ev.setSummary( val );
break;
case OTodo::Priority:
ev.setPriority( val.toInt() );
break;
case OTodo::DateDay:
m_day = val.toInt();
break;
case OTodo::DateMonth:
m_month = val.toInt();
break;
case OTodo::DateYear:
m_year = val.toInt();
break;
case OTodo::Progress:
ev.setProgress( val.toInt() );
break;
case OTodo::CompletedDate:
ev.setCompletedDate( OConversion::dateFromString( val ) );
break;
case OTodo::StartDate:
ev.setStartDate( OConversion::dateFromString( val ) );
break;
case OTodo::State:
ev.setState( val.toInt() );
break;
+ case OTodo::Alarms:{
+ OPimNotifyManager &manager = ev.notifiers();
+ QStringList als = QStringList::split(";", val );
+ for (QStringList::Iterator it = als.begin(); it != als.end(); ++it ) {
+ QStringList alarm = QStringList::split(":", (*it), TRUE ); // allow empty
+ qWarning("alarm: %s", alarm.join("___").latin1() );
+ qWarning("alarm[0]: %s %s", alarm[0].latin1(), OConversion::dateTimeFromString( alarm[0] ).toString().latin1() );
+ OPimAlarm al( alarm[2].toInt(), OConversion::dateTimeFromString( alarm[0] ), alarm[1].toInt() );
+ manager.add( al );
+ }
+ }
+ break;
+ case OTodo::Reminders:{
+ OPimNotifyManager &manager = ev.notifiers();
+ QStringList rems = QStringList::split(";", val );
+ for (QStringList::Iterator it = rems.begin(); it != rems.end(); ++it ) {
+ OPimReminder rem( (*it).toInt() );
+ manager.add( rem );
+ }
+ }
+ break;
case OTodo::CrossReference:
{
/*
* A cross refernce looks like
* appname,id;appname,id
* we need to split it up
*/
QStringList refs = QStringList::split(';', val );
QStringList::Iterator strIt;
for (strIt = refs.begin(); strIt != refs.end(); ++strIt ) {
int pos = (*strIt).find(',');
if ( pos > -1 )
; // ev.addRelation( (*strIt).left(pos), (*strIt).mid(pos+1).toInt() );
}
break;
}
/* Recurrence stuff below + post processing later */
case FRType:
if ( val == "Daily" )
recur()->setType( ORecur::Daily );
else if ( val == "Weekly" )
recur()->setType( ORecur::Weekly);
else if ( val == "MonthlyDay" )
recur()->setType( ORecur::MonthlyDay );
else if ( val == "MonthlyDate" )
recur()->setType( ORecur::MonthlyDate );
else if ( val == "Yearly" )
recur()->setType( ORecur::Yearly );
else
recur()->setType( ORecur::NoRepeat );
break;
case FRWeekdays:
recur()->setDays( val.toInt() );
break;
case FRPosition:
recur()->setPosition( val.toInt() );
break;
case FRFreq:
recur()->setFrequency( val.toInt() );
break;
case FRHasEndDate:
recur()->setHasEndDate( val.toInt() );
break;
case FREndDate: {
rp_end = (time_t) val.toLong();
break;
}
default:
break;
}
}
QString OTodoAccessXML::toString( const OTodo& ev )const {
QString str;
str += "Completed=\"" + QString::number( ev.isCompleted() ) + "\" ";
str += "HasDate=\"" + QString::number( ev.hasDueDate() ) + "\" ";
str += "Priority=\"" + QString::number( ev.priority() ) + "\" ";
str += "Progress=\"" + QString::number(ev.progress() ) + "\" ";
str += "Categories=\"" + toString( ev.categories() ) + "\" ";
str += "Description=\"" + Qtopia::escapeString( ev.description() ) + "\" ";
str += "Summary=\"" + Qtopia::escapeString( ev.summary() ) + "\" ";
if ( ev.hasDueDate() ) {
str += "DateYear=\"" + QString::number( ev.dueDate().year() ) + "\" ";
str += "DateMonth=\"" + QString::number( ev.dueDate().month() ) + "\" ";
str += "DateDay=\"" + QString::number( ev.dueDate().day() ) + "\" ";
}
// qWarning( "Uid %d", ev.uid() );
str += "Uid=\"" + QString::number( ev.uid() ) + "\" ";
// append the extra options
/* FIXME Qtopia::Record this is currently not
* possible you can set custom fields
* but don' iterate over the list
* I may do #define private protected
* for this case - cough --zecke
*/
/*
QMap<QString, QString> extras = ev.extras();
QMap<QString, QString>::Iterator extIt;
for (extIt = extras.begin(); extIt != extras.end(); ++extIt )
str += extIt.key() + "=\"" + extIt.data() + "\" ";
*/
// cross refernce
if ( ev.hasRecurrence() ) {
str += ev.recurrence().toString();
}
if ( ev.hasStartDate() )
str += "StartDate=\""+ OConversion::dateToString( ev.startDate() ) +"\" ";
if ( ev.hasCompletedDate() )
str += "CompletedDate=\""+ OConversion::dateToString( ev.completedDate() ) +"\" ";
if ( ev.hasState() )
str += "State=\""+QString::number( ev.state().state() )+"\" ";
+ /*
+ * save reminders and notifiers!
+ * DATE_TIME:DURATION:SOUND:NOT_USED_YET;OTHER_DATE_TIME:OTHER:DURATION:SOUND:....
+ */
+ if ( ev.hasNotifiers() ) {
+ OPimNotifyManager manager = ev.notifiers();
+ OPimNotifyManager::Alarms alarms = manager.alarms();
+ if (!alarms.isEmpty() ) {
+ QStringList als;
+ OPimNotifyManager::Alarms::Iterator it = alarms.begin();
+ for ( ; it != alarms.end(); ++it ) {
+ /* only if time is valid */
+ if ( (*it).dateTime().isValid() ) {
+ als << OConversion::dateTimeToString( (*it).dateTime() )
+ + ":" + QString::number( (*it).duration() )
+ + ":" + QString::number( (*it).sound() )
+ + ":";
+ }
+ }
+ // now write the list
+ qWarning("als: %s", als.join("____________").latin1() );
+ str += "Alarms=\""+als.join(";") +"\" ";
+ }
+
+ /*
+ * now the same for reminders but more easy. We just save the uid of the OEvent.
+ */
+ OPimNotifyManager::Reminders reminders = manager.reminders();
+ if (!reminders.isEmpty() ) {
+ OPimNotifyManager::Reminders::Iterator it = reminders.begin();
+ QStringList records;
+ for ( ; it != reminders.end(); ++it ) {
+ records << QString::number( (*it).recordUid() );
+ }
+ str += "Reminders=\""+ records.join(";") +"\" ";
+ }
+ }
+
return str;
}
QString OTodoAccessXML::toString( const QArray<int>& ints ) const {
return Qtopia::Record::idsToString( ints );
}
/* internal class for sorting
*
* Inspired by todoxmlio.cpp from TT
*/
struct OTodoXMLContainer {
OTodo todo;
};
namespace {
inline QString string( const OTodo& todo) {
return todo.summary().isEmpty() ?
todo.description().left(20 ) :
todo.summary();
}
inline int completed( const OTodo& todo1, const OTodo& todo2) {
int ret = 0;
if ( todo1.isCompleted() ) ret++;
if ( todo2.isCompleted() ) ret--;
return ret;
}
inline int priority( const OTodo& t1, const OTodo& t2) {
return ( t1.priority() - t2.priority() );
}
inline int description( const OTodo& t1, const OTodo& t2) {
return QString::compare( string(t1), string(t2) );
}
inline int deadline( const OTodo& t1, const OTodo& t2) {
int ret = 0;
if ( t1.hasDueDate() &&
t2.hasDueDate() )
ret = t2.dueDate().daysTo( t1.dueDate() );
else if ( t1.hasDueDate() )
ret = -1;
else if ( t2.hasDueDate() )
ret = 1;
else
ret = 0;
return ret;
}
@@ -659,134 +719,133 @@ public:
if ( ret )
return ret;
// default did not gave difference let's try it other way around
/*
* General try if already checked if not test
* and return
* 1.Completed
* 2.Priority
* 3.Description
* 4.DueDate
*/
if (!seComp ) {
if ( (ret = completed( con1->todo, con2->todo ) ) ) {
if (!m_asc ) ret *= -1;
return ret;
}
}
if (!sePrio ) {
if ( (ret = priority( con1->todo, con2->todo ) ) ) {
if (!m_asc ) ret *= -1;
return ret;
}
}
if (!seDesc ) {
if ( (ret = description(con1->todo, con2->todo ) ) ) {
if (!m_asc) ret *= -1;
return ret;
}
}
if (!seDeadline) {
if ( (ret = deadline( con1->todo, con2->todo ) ) ) {
if (!m_asc) ret *= -1;
return ret;
}
}
return 0;
}
private:
bool m_asc;
int m_sort;
};
QArray<int> OTodoAccessXML::sorted( bool asc, int sortOrder,
int sortFilter, int cat ) {
- qWarning("sorted! %d cat", cat);
OTodoXMLVector vector(m_events.count(), asc,sortOrder );
QMap<int, OTodo>::Iterator it;
int item = 0;
bool bCat = sortFilter & 1 ? true : false;
bool bOnly = sortFilter & 2 ? true : false;
bool comp = sortFilter & 4 ? true : false;
for ( it = m_events.begin(); it != m_events.end(); ++it ) {
/* show category */
- if ( bCat && cat != 0)
+ /* -1 == unfiled */
+ if ( bCat && cat == -1 ) {
+ if(!(*it).categories().isEmpty() )
+ continue;
+ }else if ( bCat && cat != 0)
if (!(*it).categories().contains( cat ) ) {
- qWarning("category mis match");
continue;
}
/* isOverdue but we should not show overdue - why?*/
/* if ( (*it).isOverdue() && !bOnly ) {
qWarning("item is overdue but !bOnly");
continue;
}
*/
if ( !(*it).isOverdue() && bOnly ) {
- qWarning("item is not overdue but bOnly checked");
continue;
}
if ((*it).isCompleted() && comp ) {
- qWarning("completed continue!");
continue;
}
OTodoXMLContainer* con = new OTodoXMLContainer();
con->todo = (*it);
vector.insert(item, con );
item++;
}
- qWarning("XXX %d Items added", item);
vector.resize( item );
/* sort it now */
vector.sort();
/* now get the uids */
QArray<int> array( vector.count() );
for (uint i= 0; i < vector.count(); i++ ) {
array[i] = ( vector.at(i) )->todo.uid();
}
return array;
};
void OTodoAccessXML::removeAllCompleted() {
for ( QMap<int, OTodo>::Iterator it = m_events.begin(); it != m_events.end(); ++it ) {
if ( (*it).isCompleted() )
m_events.remove( it );
}
}
QBitArray OTodoAccessXML::supports()const {
static QBitArray ar = sup();
return ar;
}
QBitArray OTodoAccessXML::sup() {
QBitArray ar( OTodo::CompletedDate +1 );
ar.fill( true );
ar[OTodo::CrossReference] = false;
ar[OTodo::State ] = false;
ar[OTodo::Reminders] = false;
ar[OTodo::Notifiers] = false;
ar[OTodo::Maintainer] = false;
return ar;
}
QArray<int> OTodoAccessXML::matchRegexp( const QRegExp &r ) const
{
QArray<int> m_currentQuery( m_events.count() );
uint arraycounter = 0;
QMap<int, OTodo>::ConstIterator it;
for (it = m_events.begin(); it != m_events.end(); ++it ) {
if ( it.data().match( r ) )
m_currentQuery[arraycounter++] = it.data().uid();
}
// Shrink to fit..
m_currentQuery.resize(arraycounter);
return m_currentQuery;
}
diff --git a/libopie2/opiepim/backend/otodoaccessxml.cpp b/libopie2/opiepim/backend/otodoaccessxml.cpp
index 69b7ab4..2b62f0d 100644
--- a/libopie2/opiepim/backend/otodoaccessxml.cpp
+++ b/libopie2/opiepim/backend/otodoaccessxml.cpp
@@ -1,68 +1,69 @@
#include <errno.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <qfile.h>
#include <qvector.h>
#include <qpe/global.h>
#include <qpe/stringutil.h>
#include <qpe/timeconversion.h>
#include "oconversion.h"
#include "opimstate.h"
#include "otimezone.h"
+#include "opimnotifymanager.h"
#include "orecur.h"
#include "otodoaccessxml.h"
namespace {
time_t rp_end;
ORecur* rec;
ORecur *recur() {
if (!rec ) rec = new ORecur;
return rec;
}
int snd;
enum MoreAttributes {
FRType = OTodo::CompletedDate + 2,
FRWeekdays,
FRPosition,
FRFreq,
FRHasEndDate,
FREndDate,
FRStart,
FREnd
};
// FROM TT again
char *strstrlen(const char *haystack, int hLen, const char* needle, int nLen)
{
char needleChar;
char haystackChar;
if (!needle || !haystack || !hLen || !nLen)
return 0;
const char* hsearch = haystack;
if ((needleChar = *needle++) != 0) {
nLen--; //(to make up for needle++)
do {
do {
if ((haystackChar = *hsearch++) == 0)
return (0);
if (hsearch >= haystack + hLen)
return (0);
} while (haystackChar != needleChar);
} while (strncmp(hsearch, needle, QMIN(hLen - (hsearch - haystack), nLen)) != 0);
hsearch--;
}
return ((char *)hsearch);
}
}
@@ -381,192 +382,251 @@ void OTodoAccessXML::todo( QAsciiDict<int>* dict, OTodo& ev,
// qWarning("Unknown option" + it.key() );
ev.setCustomField( attr, val );
return;
}
switch( *find ) {
case OTodo::Uid:
ev.setUid( val.toInt() );
break;
case OTodo::Category:
ev.setCategories( ev.idsFromString( val ) );
break;
case OTodo::HasDate:
ev.setHasDueDate( val.toInt() );
break;
case OTodo::Completed:
ev.setCompleted( val.toInt() );
break;
case OTodo::Description:
ev.setDescription( val );
break;
case OTodo::Summary:
ev.setSummary( val );
break;
case OTodo::Priority:
ev.setPriority( val.toInt() );
break;
case OTodo::DateDay:
m_day = val.toInt();
break;
case OTodo::DateMonth:
m_month = val.toInt();
break;
case OTodo::DateYear:
m_year = val.toInt();
break;
case OTodo::Progress:
ev.setProgress( val.toInt() );
break;
case OTodo::CompletedDate:
ev.setCompletedDate( OConversion::dateFromString( val ) );
break;
case OTodo::StartDate:
ev.setStartDate( OConversion::dateFromString( val ) );
break;
case OTodo::State:
ev.setState( val.toInt() );
break;
+ case OTodo::Alarms:{
+ OPimNotifyManager &manager = ev.notifiers();
+ QStringList als = QStringList::split(";", val );
+ for (QStringList::Iterator it = als.begin(); it != als.end(); ++it ) {
+ QStringList alarm = QStringList::split(":", (*it), TRUE ); // allow empty
+ qWarning("alarm: %s", alarm.join("___").latin1() );
+ qWarning("alarm[0]: %s %s", alarm[0].latin1(), OConversion::dateTimeFromString( alarm[0] ).toString().latin1() );
+ OPimAlarm al( alarm[2].toInt(), OConversion::dateTimeFromString( alarm[0] ), alarm[1].toInt() );
+ manager.add( al );
+ }
+ }
+ break;
+ case OTodo::Reminders:{
+ OPimNotifyManager &manager = ev.notifiers();
+ QStringList rems = QStringList::split(";", val );
+ for (QStringList::Iterator it = rems.begin(); it != rems.end(); ++it ) {
+ OPimReminder rem( (*it).toInt() );
+ manager.add( rem );
+ }
+ }
+ break;
case OTodo::CrossReference:
{
/*
* A cross refernce looks like
* appname,id;appname,id
* we need to split it up
*/
QStringList refs = QStringList::split(';', val );
QStringList::Iterator strIt;
for (strIt = refs.begin(); strIt != refs.end(); ++strIt ) {
int pos = (*strIt).find(',');
if ( pos > -1 )
; // ev.addRelation( (*strIt).left(pos), (*strIt).mid(pos+1).toInt() );
}
break;
}
/* Recurrence stuff below + post processing later */
case FRType:
if ( val == "Daily" )
recur()->setType( ORecur::Daily );
else if ( val == "Weekly" )
recur()->setType( ORecur::Weekly);
else if ( val == "MonthlyDay" )
recur()->setType( ORecur::MonthlyDay );
else if ( val == "MonthlyDate" )
recur()->setType( ORecur::MonthlyDate );
else if ( val == "Yearly" )
recur()->setType( ORecur::Yearly );
else
recur()->setType( ORecur::NoRepeat );
break;
case FRWeekdays:
recur()->setDays( val.toInt() );
break;
case FRPosition:
recur()->setPosition( val.toInt() );
break;
case FRFreq:
recur()->setFrequency( val.toInt() );
break;
case FRHasEndDate:
recur()->setHasEndDate( val.toInt() );
break;
case FREndDate: {
rp_end = (time_t) val.toLong();
break;
}
default:
break;
}
}
QString OTodoAccessXML::toString( const OTodo& ev )const {
QString str;
str += "Completed=\"" + QString::number( ev.isCompleted() ) + "\" ";
str += "HasDate=\"" + QString::number( ev.hasDueDate() ) + "\" ";
str += "Priority=\"" + QString::number( ev.priority() ) + "\" ";
str += "Progress=\"" + QString::number(ev.progress() ) + "\" ";
str += "Categories=\"" + toString( ev.categories() ) + "\" ";
str += "Description=\"" + Qtopia::escapeString( ev.description() ) + "\" ";
str += "Summary=\"" + Qtopia::escapeString( ev.summary() ) + "\" ";
if ( ev.hasDueDate() ) {
str += "DateYear=\"" + QString::number( ev.dueDate().year() ) + "\" ";
str += "DateMonth=\"" + QString::number( ev.dueDate().month() ) + "\" ";
str += "DateDay=\"" + QString::number( ev.dueDate().day() ) + "\" ";
}
// qWarning( "Uid %d", ev.uid() );
str += "Uid=\"" + QString::number( ev.uid() ) + "\" ";
// append the extra options
/* FIXME Qtopia::Record this is currently not
* possible you can set custom fields
* but don' iterate over the list
* I may do #define private protected
* for this case - cough --zecke
*/
/*
QMap<QString, QString> extras = ev.extras();
QMap<QString, QString>::Iterator extIt;
for (extIt = extras.begin(); extIt != extras.end(); ++extIt )
str += extIt.key() + "=\"" + extIt.data() + "\" ";
*/
// cross refernce
if ( ev.hasRecurrence() ) {
str += ev.recurrence().toString();
}
if ( ev.hasStartDate() )
str += "StartDate=\""+ OConversion::dateToString( ev.startDate() ) +"\" ";
if ( ev.hasCompletedDate() )
str += "CompletedDate=\""+ OConversion::dateToString( ev.completedDate() ) +"\" ";
if ( ev.hasState() )
str += "State=\""+QString::number( ev.state().state() )+"\" ";
+ /*
+ * save reminders and notifiers!
+ * DATE_TIME:DURATION:SOUND:NOT_USED_YET;OTHER_DATE_TIME:OTHER:DURATION:SOUND:....
+ */
+ if ( ev.hasNotifiers() ) {
+ OPimNotifyManager manager = ev.notifiers();
+ OPimNotifyManager::Alarms alarms = manager.alarms();
+ if (!alarms.isEmpty() ) {
+ QStringList als;
+ OPimNotifyManager::Alarms::Iterator it = alarms.begin();
+ for ( ; it != alarms.end(); ++it ) {
+ /* only if time is valid */
+ if ( (*it).dateTime().isValid() ) {
+ als << OConversion::dateTimeToString( (*it).dateTime() )
+ + ":" + QString::number( (*it).duration() )
+ + ":" + QString::number( (*it).sound() )
+ + ":";
+ }
+ }
+ // now write the list
+ qWarning("als: %s", als.join("____________").latin1() );
+ str += "Alarms=\""+als.join(";") +"\" ";
+ }
+
+ /*
+ * now the same for reminders but more easy. We just save the uid of the OEvent.
+ */
+ OPimNotifyManager::Reminders reminders = manager.reminders();
+ if (!reminders.isEmpty() ) {
+ OPimNotifyManager::Reminders::Iterator it = reminders.begin();
+ QStringList records;
+ for ( ; it != reminders.end(); ++it ) {
+ records << QString::number( (*it).recordUid() );
+ }
+ str += "Reminders=\""+ records.join(";") +"\" ";
+ }
+ }
+
return str;
}
QString OTodoAccessXML::toString( const QArray<int>& ints ) const {
return Qtopia::Record::idsToString( ints );
}
/* internal class for sorting
*
* Inspired by todoxmlio.cpp from TT
*/
struct OTodoXMLContainer {
OTodo todo;
};
namespace {
inline QString string( const OTodo& todo) {
return todo.summary().isEmpty() ?
todo.description().left(20 ) :
todo.summary();
}
inline int completed( const OTodo& todo1, const OTodo& todo2) {
int ret = 0;
if ( todo1.isCompleted() ) ret++;
if ( todo2.isCompleted() ) ret--;
return ret;
}
inline int priority( const OTodo& t1, const OTodo& t2) {
return ( t1.priority() - t2.priority() );
}
inline int description( const OTodo& t1, const OTodo& t2) {
return QString::compare( string(t1), string(t2) );
}
inline int deadline( const OTodo& t1, const OTodo& t2) {
int ret = 0;
if ( t1.hasDueDate() &&
t2.hasDueDate() )
ret = t2.dueDate().daysTo( t1.dueDate() );
else if ( t1.hasDueDate() )
ret = -1;
else if ( t2.hasDueDate() )
ret = 1;
else
ret = 0;
return ret;
}
@@ -659,134 +719,133 @@ public:
if ( ret )
return ret;
// default did not gave difference let's try it other way around
/*
* General try if already checked if not test
* and return
* 1.Completed
* 2.Priority
* 3.Description
* 4.DueDate
*/
if (!seComp ) {
if ( (ret = completed( con1->todo, con2->todo ) ) ) {
if (!m_asc ) ret *= -1;
return ret;
}
}
if (!sePrio ) {
if ( (ret = priority( con1->todo, con2->todo ) ) ) {
if (!m_asc ) ret *= -1;
return ret;
}
}
if (!seDesc ) {
if ( (ret = description(con1->todo, con2->todo ) ) ) {
if (!m_asc) ret *= -1;
return ret;
}
}
if (!seDeadline) {
if ( (ret = deadline( con1->todo, con2->todo ) ) ) {
if (!m_asc) ret *= -1;
return ret;
}
}
return 0;
}
private:
bool m_asc;
int m_sort;
};
QArray<int> OTodoAccessXML::sorted( bool asc, int sortOrder,
int sortFilter, int cat ) {
- qWarning("sorted! %d cat", cat);
OTodoXMLVector vector(m_events.count(), asc,sortOrder );
QMap<int, OTodo>::Iterator it;
int item = 0;
bool bCat = sortFilter & 1 ? true : false;
bool bOnly = sortFilter & 2 ? true : false;
bool comp = sortFilter & 4 ? true : false;
for ( it = m_events.begin(); it != m_events.end(); ++it ) {
/* show category */
- if ( bCat && cat != 0)
+ /* -1 == unfiled */
+ if ( bCat && cat == -1 ) {
+ if(!(*it).categories().isEmpty() )
+ continue;
+ }else if ( bCat && cat != 0)
if (!(*it).categories().contains( cat ) ) {
- qWarning("category mis match");
continue;
}
/* isOverdue but we should not show overdue - why?*/
/* if ( (*it).isOverdue() && !bOnly ) {
qWarning("item is overdue but !bOnly");
continue;
}
*/
if ( !(*it).isOverdue() && bOnly ) {
- qWarning("item is not overdue but bOnly checked");
continue;
}
if ((*it).isCompleted() && comp ) {
- qWarning("completed continue!");
continue;
}
OTodoXMLContainer* con = new OTodoXMLContainer();
con->todo = (*it);
vector.insert(item, con );
item++;
}
- qWarning("XXX %d Items added", item);
vector.resize( item );
/* sort it now */
vector.sort();
/* now get the uids */
QArray<int> array( vector.count() );
for (uint i= 0; i < vector.count(); i++ ) {
array[i] = ( vector.at(i) )->todo.uid();
}
return array;
};
void OTodoAccessXML::removeAllCompleted() {
for ( QMap<int, OTodo>::Iterator it = m_events.begin(); it != m_events.end(); ++it ) {
if ( (*it).isCompleted() )
m_events.remove( it );
}
}
QBitArray OTodoAccessXML::supports()const {
static QBitArray ar = sup();
return ar;
}
QBitArray OTodoAccessXML::sup() {
QBitArray ar( OTodo::CompletedDate +1 );
ar.fill( true );
ar[OTodo::CrossReference] = false;
ar[OTodo::State ] = false;
ar[OTodo::Reminders] = false;
ar[OTodo::Notifiers] = false;
ar[OTodo::Maintainer] = false;
return ar;
}
QArray<int> OTodoAccessXML::matchRegexp( const QRegExp &r ) const
{
QArray<int> m_currentQuery( m_events.count() );
uint arraycounter = 0;
QMap<int, OTodo>::ConstIterator it;
for (it = m_events.begin(); it != m_events.end(); ++it ) {
if ( it.data().match( r ) )
m_currentQuery[arraycounter++] = it.data().uid();
}
// Shrink to fit..
m_currentQuery.resize(arraycounter);
return m_currentQuery;
}