summaryrefslogtreecommitdiffabout
path: root/libkcal
Side-by-side diff
Diffstat (limited to 'libkcal') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/recurrence.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/libkcal/recurrence.cpp b/libkcal/recurrence.cpp
index 5181eaf..8a175c9 100644
--- a/libkcal/recurrence.cpp
+++ b/libkcal/recurrence.cpp
@@ -98,211 +98,217 @@ Recurrence::~Recurrence()
bool Recurrence::operator==( const Recurrence& r2 ) const
{
// the following line is obvious
if ( recurs == rNone && r2.recurs == rNone )
return true;
// we need the above line, because two non recurring events may
// differ in the other settings, because one (or both)
// may be not initialized properly
if ( recurs != r2.recurs
|| rFreq != r2.rFreq
|| rDuration != r2.rDuration
|| !rDuration && rEndDateTime != r2.rEndDateTime
|| mRecurStart != r2.mRecurStart
|| mFloats != r2.mFloats
|| mRecurReadOnly != r2.mRecurReadOnly
|| mRecurExDatesCount != r2.mRecurExDatesCount )
return false;
// no need to compare mCompat* and mParent
// OK to compare the pointers
switch ( recurs )
{
case rWeekly:
return rDays == r2.rDays
&& rWeekStart == r2.rWeekStart;
case rMonthlyPos: {
QPtrList<rMonthPos> MonthPositions = rMonthPositions;
QPtrList<rMonthPos> MonthPositions2 = r2.rMonthPositions;
if ( !MonthPositions.count() )
return false;
if ( !MonthPositions2.count() )
return false;
return MonthPositions.first()->rPos == MonthPositions2.first()->rPos;
}
case rMonthlyDay: {
QPtrList<int> MonthDays = rMonthDays ;
QPtrList<int> MonthDays2 = r2.rMonthDays ;
if ( !MonthDays.count() )
return false;
if ( !MonthDays2.count() )
return false;
return *MonthDays.first() == *MonthDays2.first() ;
}
case rYearlyPos: {
QPtrList<int> YearNums = rYearNums;
QPtrList<int> YearNums2 = r2.rYearNums;
if ( *YearNums.first() != *YearNums2.first() )
return false;
QPtrList<rMonthPos> MonthPositions = rMonthPositions;
QPtrList<rMonthPos> MonthPositions2 = r2.rMonthPositions;
if ( !MonthPositions.count() )
return false;
if ( !MonthPositions2.count() )
return false;
return MonthPositions.first()->rPos == MonthPositions2.first()->rPos;
}
case rYearlyMonth: {
QPtrList<int> YearNums = rYearNums;
QPtrList<int> YearNums2 = r2.rYearNums;
return ( *YearNums.first() == *YearNums2.first() && mFeb29YearlyType == r2.mFeb29YearlyType);
}
case rYearlyDay: {
QPtrList<int> YearNums = rYearNums;
QPtrList<int> YearNums2 = r2.rYearNums;
return ( *YearNums.first() == *YearNums2.first() );
}
case rNone:
case rMinutely:
case rHourly:
case rDaily:
default:
return true;
}
}
/*
bool Recurrence::compareLists( const QPtrList<int> &l1 ,const QPtrList<int> &l2)
{
if ( l1.count() != l2.count() )
return false;
int count = l1.count();
int i;
for ( i = 0; i < count ; ++i ) {
// if ( l1.at(i) != l2.at(i) )
return false;
qDebug("compüare ");
}
return true;
}
*/
QString Recurrence::recurrenceText() const
{
- QString recurText = i18n("No");
+ QString recurText;
if ( recurs == Recurrence::rMinutely )
recurText = i18n("minutely");
else if ( recurs == Recurrence::rHourly )
recurText = i18n("hourly");
else if ( recurs == Recurrence::rDaily )
recurText = i18n("daily");
else if ( recurs == Recurrence::rWeekly )
recurText = i18n("weekly");
else if ( recurs == Recurrence::rMonthlyPos )
recurText = i18n("monthly");
else if ( recurs == Recurrence::rMonthlyDay )
- recurText = i18n("day-monthly");
+ recurText = i18n("monthly");
else if ( recurs == Recurrence::rYearlyMonth )
- recurText = i18n("month-yearly");
+ recurText = i18n("yearly");
else if ( recurs == Recurrence::rYearlyDay )
recurText = i18n("day-yearly");
else if ( recurs == Recurrence::rYearlyPos )
recurText = i18n("position-yearly");
+ if ( !recurText.isEmpty() ) {
+ if ( rFreq > 1 ){
+ recurText = i18n("(%1) ").arg(rFreq ) + recurText;
+ }
+ } else
+ recurText = i18n("No");
return recurText;
}
void Recurrence::setCompatVersion(int version)
{
mCompatVersion = version ? version : INT_MAX;
}
ushort Recurrence::doesRecur() const
{
return recurs;
}
bool Recurrence::recursOnPure(const QDate &qd) const
{
switch(recurs) {
case rMinutely:
return recursSecondly(qd, rFreq*60);
case rHourly:
return recursSecondly(qd, rFreq*3600);
case rDaily:
return recursDaily(qd);
case rWeekly:
return recursWeekly(qd);
case rMonthlyPos:
case rMonthlyDay:
return recursMonthly(qd);
case rYearlyMonth:
return recursYearlyByMonth(qd);
case rYearlyDay:
return recursYearlyByDay(qd);
case rYearlyPos:
return recursYearlyByPos(qd);
default:
return false;
case rNone:
return false;
} // case
return false;
}
bool Recurrence::recursAtPure(const QDateTime &dt) const
{
switch(recurs) {
case rMinutely:
return recursMinutelyAt(dt, rFreq);
case rHourly:
return recursMinutelyAt(dt, rFreq*60);
default:
if (dt.time() != mRecurStart.time())
return false;
switch(recurs) {
case rDaily:
return recursDaily(dt.date());
case rWeekly:
return recursWeekly(dt.date());
case rMonthlyPos:
case rMonthlyDay:
return recursMonthly(dt.date());
case rYearlyMonth:
return recursYearlyByMonth(dt.date());
case rYearlyDay:
return recursYearlyByDay(dt.date());
case rYearlyPos:
return recursYearlyByPos(dt.date());
default:
return false;
case rNone:
return false;
}
} // case
return false;
}
QDate Recurrence::endDate() const
{
int count = 0;
QDate end;
if (recurs != rNone) {
if (rDuration < 0)
return QDate(); // infinite recurrence
if (rDuration == 0)
return rEndDateTime.date();
// The end date is determined by the recurrence count
QDate dStart = mRecurStart.date();
switch (recurs)
{
case rMinutely:
return mRecurStart.addSecs((rDuration-1+mRecurExDatesCount)*rFreq*60).date();
case rHourly:
return mRecurStart.addSecs((rDuration-1+mRecurExDatesCount)*rFreq*3600).date();
case rDaily:
return dStart.addDays((rDuration-1+mRecurExDatesCount)*rFreq);
case rWeekly: