summaryrefslogtreecommitdiff
path: root/library/datebookdb.cpp
Side-by-side diff
Diffstat (limited to 'library/datebookdb.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--library/datebookdb.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/library/datebookdb.cpp b/library/datebookdb.cpp
index 0fedfa8..2f33255 100644
--- a/library/datebookdb.cpp
+++ b/library/datebookdb.cpp
@@ -62,25 +62,25 @@ static QString dateBookFilename()
february or the 31st of some other months. However
these are still bounded */
bool nextOccurance(const Event &e, const QDate &from, QDateTime &next)
{
// easy checks, first are we too far in the future or too far in the past?
QDate tmpDate;
int freq = e.repeatPattern().frequency;
int diff, diff2, a;
int iday, imonth, iyear;
int dayOfWeek = 0;
int firstOfWeek = 0;
int weekOfMonth;
-
+
if (e.repeatPattern().hasEndDate && e.repeatPattern().endDate() < from)
return FALSE;
if (e.start() >= from) {
next = e.start();
return TRUE;
}
switch ( e.repeatPattern().type ) {
case Event::Weekly:
/* weekly is just daily by 7 */
@@ -452,25 +452,25 @@ QValueList<Event> DateBookDB::getEvents( const QDateTime &start )
QValueList<EffectiveEvent> DateBookDB::getEffectiveEvents( const QDate &from,
const QDate &to )
{
QValueList<EffectiveEvent> tmpList;
QValueListIterator<Event> it;
EffectiveEvent effEv;
QDateTime dtTmp,
dtEnd;
for (it = eventList.begin(); it != eventList.end(); ++it ) {
- if (!(*it).isValidUid())
+ if (!(*it).isValidUid())
(*it).assignUid(); // FIXME: Hack to restore cleared uids
dtTmp = (*it).start(TRUE);
dtEnd = (*it).end(TRUE);
if ( dtTmp.date() >= from && dtTmp.date() <= to ) {
Event tmpEv = *it;
effEv.setEvent(tmpEv);
effEv.setDate( dtTmp.date() );
effEv.setStart( dtTmp.time() );
if ( dtTmp.date() != dtEnd.date() )
effEv.setEnd( QTime(23, 59, 0) );
@@ -497,25 +497,25 @@ QValueList<EffectiveEvent> DateBookDB::getEffectiveEvents( const QDate &from,
effEv.setEnd( dtEnd.time() );
else
effEv.setEnd( QTime(23, 59, 59) );
tmpList.append( effEv );
}
dt = dt.addDays( 1 );
}
}
}
// check for repeating events...
QDateTime repeat;
for ( it = repeatEvents.begin(); it != repeatEvents.end(); ++it ) {
- if (!(*it).isValidUid())
+ if (!(*it).isValidUid())
(*it).assignUid(); // FIXME: Hack to restore cleared uids
/* create a false end date, to short circuit on hard
MonthlyDay recurences */
Event dummy_event = *it;
int duration = (*it).start().date().daysTo( (*it).end().date() );
QDate itDate = from.addDays(-duration);
Event::RepeatPattern r = dummy_event.repeatPattern();
if ( !r.hasEndDate || r.endDate() > to ) {
r.setEndDate( to );
r.hasEndDate = TRUE;
@@ -614,25 +614,25 @@ void DateBookDB::editEvent( const Event &old, Event &editedEv )
// write to the journal...
if ( oldHadRepeat ) {
if ( origRepeat( old, orig ) ) // should work always...
oldIndex = repeatEvents.findIndex( orig );
} else
oldIndex = eventList.findIndex( old );
saveJournalEntry( editedEv, ACTION_REPLACE, oldIndex, oldHadRepeat );
// Delete old event
if ( old.hasAlarm() )
delEventAlarm( old );
if ( oldHadRepeat ) {
- if ( editedEv.hasRepeat() ) { // This mean that origRepeat was run above and
+ if ( editedEv.hasRepeat() ) { // This mean that origRepeat was run above and
// orig is initialized
// assumption, when someone edits a repeating event, they
// want to change them all, maybe not perfect, but it works
// for the moment...
repeatEvents.remove( orig );
} else
removeRepeat( old );
} else {
QValueList<Event>::Iterator it = eventList.find( old );
if ( it != eventList.end() )
eventList.remove( it );
}
@@ -663,25 +663,25 @@ void DateBookDB::removeJFEvent( const Event&ev )
if ( ev.hasRepeat() ) {
removeRepeat( ev );
} else {
QValueList<Event>::Iterator it = eventList.find( ev );
if ( it != eventList.end() )
eventList.remove( it );
}
}
// also handles journaling...
void DateBookDB::loadFile( const QString &strFile )
{
-
+
QFile f( strFile );
if ( !f.open( IO_ReadOnly ) )
return;
enum Attribute {
FDescription = 0,
FLocation,
FCategories,
FUid,
FType,
FAlarm,
FSound,
@@ -714,25 +714,25 @@ void DateBookDB::loadFile( const QString &strFile )
dict.insert( "rposition", new int(FRPosition) );
dict.insert( "rfreq", new int(FRFreq) );
dict.insert( "rhasenddate", new int(FRHasEndDate) );
dict.insert( "enddt", new int(FREndDate) );
dict.insert( "start", new int(FRStart) );
dict.insert( "end", new int(FREnd) );
dict.insert( "note", new int(FNote) );
dict.insert( "created", new int(FCreated) );
dict.insert( "action", new int(FAction) );
dict.insert( "actionkey", new int(FActionKey) );
dict.insert( "actionorig", new int (FJournalOrigHadRepeat) );
-
+
QByteArray ba = f.readAll();
char* dt = ba.data();
int len = ba.size();
int currentAction,
journalKey,
origHadRepeat; // should be bool, but we need tri-state(not being used)
int i = 0;
char *point;
// hack to get rid of segfaults after reading </DATEBOOK>
while ( (dt+i != 0) && (( point = strstr( dt+i, "<event " ) ) != 0 )) {
i = point - dt;