summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/backend/otodoaccessxml.cpp34
1 files changed, 17 insertions, 17 deletions
diff --git a/libopie2/opiepim/backend/otodoaccessxml.cpp b/libopie2/opiepim/backend/otodoaccessxml.cpp
index ab50604..7a08f12 100644
--- a/libopie2/opiepim/backend/otodoaccessxml.cpp
+++ b/libopie2/opiepim/backend/otodoaccessxml.cpp
@@ -450,266 +450,266 @@ void OPimTodoAccessXML::todo( QAsciiDict<int>* dict, OPimTodo& ev,
ev.setState( val.toInt() );
break;
case OPimTodo::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
OPimAlarm al( alarm[2].toInt(), OPimDateConversion::dateTimeFromString( alarm[0] ), alarm[1].toInt() );
manager.add( al );
}
}
break;
case OPimTodo::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 OPimTodo::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( OPimRecurrence::Daily );
else if ( val == "Weekly" )
recur()->setType( OPimRecurrence::Weekly);
else if ( val == "MonthlyDay" )
recur()->setType( OPimRecurrence::MonthlyDay );
else if ( val == "MonthlyDate" )
recur()->setType( OPimRecurrence::MonthlyDate );
else if ( val == "Yearly" )
recur()->setType( OPimRecurrence::Yearly );
else
recur()->setType( OPimRecurrence::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:
ev.setCustomField( attr, val );
break;
}
}
// from PalmtopRecord... GPL ### FIXME
namespace {
QString customToXml(const QMap<QString, QString>& customMap )
{
QString buf(" ");
for ( QMap<QString, QString>::ConstIterator cit = customMap.begin();
cit != customMap.end(); ++cit) {
buf += cit.key();
buf += "=\"";
buf += Qtopia::escapeString(cit.data());
buf += "\" ";
}
return buf;
}
}
QString OPimTodoAccessXML::toString( const OPimTodo& 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 += "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() ) + "\" ";
+ 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() ) + "\" ";
+ str += " DateYear=\"" + QString::number( ev.dueDate().year() ) + "\"";
+ str += " DateMonth=\"" + QString::number( ev.dueDate().month() ) + "\"";
+ str += " DateDay=\"" + QString::number( ev.dueDate().day() ) + "\"";
}
- str += "Uid=\"" + QString::number( 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() + "\" ";
+ str += " " + extIt.key() + "=\"" + extIt.data() + "\"";
*/
// cross refernce
if ( ev.hasRecurrence() ) {
str += ev.recurrence().toString();
}
if ( ev.hasStartDate() )
- str += "StartDate=\""+ OPimDateConversion::dateToString( ev.startDate() ) +"\" ";
+ str += " StartDate=\""+ OPimDateConversion::dateToString( ev.startDate() ) +"\"";
if ( ev.hasCompletedDate() )
- str += "CompletedDate=\""+ OPimDateConversion::dateToString( ev.completedDate() ) +"\" ";
+ str += " CompletedDate=\""+ OPimDateConversion::dateToString( ev.completedDate() ) +"\"";
if ( ev.hasState() )
- str += "State=\""+QString::number( ev.state().state() )+"\" ";
+ 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 << OPimDateConversion::dateTimeToString( (*it).dateTime() )
+ ":" + QString::number( (*it).duration() )
+ ":" + QString::number( (*it).sound() )
+ ":";
}
}
// now write the list
- str += "Alarms=\""+als.join(";") +"\" ";
+ str += " Alarms=\""+als.join(";") +"\"";
}
/*
* now the same for reminders but more easy. We just save the uid of the OPimEvent.
*/
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(";") +"\" ";
+ str += " Reminders=\""+ records.join(";") +"\"";
}
}
str += customToXml( ev.toExtraMap() );
return str;
}
QString OPimTodoAccessXML::toString( const QArray<int>& ints ) const {
return Qtopia::Record::idsToString( ints );
}
QArray<int> OPimTodoAccessXML::sorted( const UIDArray& events, bool asc,
int sortOrder,int sortFilter,
const QArray<int>& categories )const {
Internal::OPimTodoSortVector vector(events.count(), asc,sortOrder );
int item = 0;
bool bCat = sortFilter & OPimTodoAccess::FilterCategory ? true : false;
bool bOnly = sortFilter & OPimTodoAccess::OnlyOverDue ? true : false;
bool comp = sortFilter & OPimTodoAccess::DoNotShowCompleted ? true : false;
bool catPassed = false;
int cat;
for ( uint i = 0; i < events.count(); ++i ) {
/* Guard against creating a new item... */
if ( !m_events.contains( events[i] ) )
continue;
OPimTodo todo = m_events[events[i]];
/* show category */
/* -1 == unfiled */
catPassed = false;
for ( uint cat_nu = 0; cat_nu < categories.count(); ++cat_nu ) {
cat = categories[cat_nu];
if ( bCat && cat == -1 ) {
if(!todo.categories().isEmpty() )
continue;
} else if ( bCat && cat != 0)
if (!todo.categories().contains( cat ) )
continue;
catPassed = true;
break;
}
/*
* If none of the Categories matched
* continue
*/
if ( !catPassed )
continue;
if ( !todo.isOverdue() && bOnly )
continue;
if (todo.isCompleted() && comp )
continue;
vector.insert(item++, todo );
}
vector.resize( item );
/* sort it now */
vector.sort();
/* now get the uids */
UIDArray array( vector.count() );
for (uint i= 0; i < vector.count(); i++ )
array[i] = vector.uidAt( i );
return array;
}
void OPimTodoAccessXML::removeAllCompleted() {
QMap<int, OPimTodo> events = m_events;
for ( QMap<int, OPimTodo>::Iterator it = m_events.begin(); it != m_events.end(); ++it ) {
if ( (*it).isCompleted() )
events.remove( it.key() );
}
m_events = events;
}
QArray<int> OPimTodoAccessXML::matchRegexp( const QRegExp &r ) const
{
QArray<int> currentQuery( m_events.count() );
uint arraycounter = 0;
QMap<int, OPimTodo>::ConstIterator it;
for (it = m_events.begin(); it != m_events.end(); ++it ) {
if ( it.data().match( r ) )
currentQuery[arraycounter++] = it.data().uid();
}
// Shrink to fit..
currentQuery.resize(arraycounter);
return currentQuery;
}