summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--libopie2/opiepim/core/opimrecurrence.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/libopie2/opiepim/core/opimrecurrence.cpp b/libopie2/opiepim/core/opimrecurrence.cpp
index 98bd647..4b1d886 100644
--- a/libopie2/opiepim/core/opimrecurrence.cpp
+++ b/libopie2/opiepim/core/opimrecurrence.cpp
@@ -1,170 +1,170 @@
/*
This file is part of the Opie Project
Copyright (C) The Main Author <main-author@whereever.org>
=. Copyright (C) The Opie Team <opie-devel@handhelds.org>
.=l.
.>+-=
_;:, .> :=|. This program is free software; you can
.> <`_, > . <= redistribute it and/or modify it under
:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
.="- .-=="i, .._ License as published by the Free Software
- . .-<_> .<> Foundation; either version 2 of the License,
._= =} : or (at your option) any later version.
.%`+i> _;_.
.i_,=:_. -<s. This program is distributed in the hope that
+ . -:. = it will be useful, but WITHOUT ANY WARRANTY;
: .. .:, . . . without even the implied warranty of
=_ + =;=|` MERCHANTABILITY or FITNESS FOR A
_.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.= = ; Library General Public License for more
++= -. .` .: details.
: = ...= . :.=-
-. .:....=;==+<; You should have received a copy of the GNU
-_. . . )=. = Library General Public License along with
-- :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include "opimrecurrence.h"
/* OPIE */
#include <opie2/opimtimezone.h>
#include <qpe/timeconversion.h>
/* QT */
#include <qshared.h>
/* STD */
#include <time.h>
namespace Opie {
struct OPimRecurrence::Data : public QShared {
Data() : QShared() {
type = OPimRecurrence::NoRepeat;
freq = -1;
days = 0;
pos = 0;
create = QDateTime::currentDateTime();
hasEnd = FALSE;
end = QDate::currentDate();
}
char days; // Q_UINT8 for 8 seven days;)
OPimRecurrence::RepeatType type;
int freq;
int pos;
bool hasEnd : 1;
QDate end;
QDateTime create;
int rep;
QString app;
ExceptionList list;
QDate start;
};
OPimRecurrence::OPimRecurrence() {
data = new Data;
}
OPimRecurrence::OPimRecurrence( const QMap<int, QString>& map )
{
- OPimRecurrence();
+ data = new Data;
fromMap( map );
}
OPimRecurrence::OPimRecurrence( const OPimRecurrence& rec)
: data( rec.data )
{
data->ref();
}
OPimRecurrence::~OPimRecurrence() {
if ( data->deref() ) {
delete data;
data = 0l;
}
}
void OPimRecurrence::deref() {
if ( data->deref() ) {
delete data;
data = 0l;
}
}
bool OPimRecurrence::operator==( const OPimRecurrence& )const {
return false;
}
OPimRecurrence &OPimRecurrence::operator=( const OPimRecurrence& re) {
if ( *this == re ) return *this;
re.data->ref();
deref();
data = re.data;
return *this;
}
bool OPimRecurrence::doesRecur()const {
return !( type() == NoRepeat );
}
/*
* we try to be smart here
*
*/
bool OPimRecurrence::doesRecur( const QDate& date ) {
/* the day before the recurrance */
QDate da = date.addDays(-1);
QDate recur;
if (!nextOcurrence( da, recur ) )
return false;
return (recur == date);
}
// FIXME unuglify!
// GPL from Datebookdb.cpp
// FIXME exception list!
bool OPimRecurrence::nextOcurrence( const QDate& from, QDate& next ) {
bool stillLooking;
stillLooking = p_nextOccurrence( from, next );
while ( stillLooking && data->list.contains(next) )
stillLooking = p_nextOccurrence( next.addDays(1), next );
return stillLooking;
}
bool OPimRecurrence::p_nextOccurrence( const QDate& from, QDate& next ) {
// easy checks, first are we too far in the future or too far in the past?
QDate tmpDate;
int freq = frequency();
int diff, diff2, a;
int iday, imonth, iyear;
int dayOfWeek = 0;
int firstOfWeek = 0;
int weekOfMonth;
if (hasEndDate() && endDate() < from)
return FALSE;
if (start() >= from ) {
next = start();
return TRUE;
}