summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/core/orecur.cpp
Side-by-side diff
Diffstat (limited to 'libopie2/opiepim/core/orecur.cpp') (more/less context) (show whitespace changes)
-rw-r--r--libopie2/opiepim/core/orecur.cpp76
1 files changed, 71 insertions, 5 deletions
diff --git a/libopie2/opiepim/core/orecur.cpp b/libopie2/opiepim/core/orecur.cpp
index 033f264..5e2da25 100644
--- a/libopie2/opiepim/core/orecur.cpp
+++ b/libopie2/opiepim/core/orecur.cpp
@@ -26,18 +26,22 @@
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
-#include <time.h>
+#include "orecur.h"
-#include <qshared.h>
+/* OPIE */
+#include <opie2/otimezone.h>
+#include <qpe/timeconversion.h>
-#include <qtopia/timeconversion.h>
+/* QT */
+#include <qshared.h>
-#include <opie2/otimezone.h>
-#include <opie2/orecur.h>
+/* STD */
+#include <time.h>
namespace Opie {
+
struct ORecur::Data : public QShared {
Data() : QShared() {
type = ORecur::NoRepeat;
freq = -1;
@@ -76,23 +80,31 @@ ORecur::ORecur( const ORecur& rec)
: data( rec.data )
{
data->ref();
}
+
+
ORecur::~ORecur() {
if ( data->deref() ) {
delete data;
data = 0l;
}
}
+
+
void ORecur::deref() {
if ( data->deref() ) {
delete data;
data = 0l;
}
}
+
+
bool ORecur::operator==( const ORecur& )const {
return false;
}
+
+
ORecur &ORecur::operator=( const ORecur& re) {
if ( *this == re ) return *this;
re.data->ref();
@@ -100,11 +112,15 @@ ORecur &ORecur::operator=( const ORecur& re) {
data = re.data;
return *this;
}
+
+
bool ORecur::doesRecur()const {
return !( type() == NoRepeat );
}
+
+
/*
* we try to be smart here
*
*/
@@ -117,8 +133,10 @@ bool ORecur::doesRecur( const QDate& date ) {
return false;
return (recur == date);
}
+
+
// FIXME unuglify!
// GPL from Datebookdb.cpp
// FIXME exception list!
bool ORecur::nextOcurrence( const QDate& from, QDate& next ) {
@@ -128,8 +146,10 @@ bool ORecur::nextOcurrence( const QDate& from, QDate& next ) {
stillLooking = p_nextOccurrence( next.addDays(1), next );
return stillLooking;
}
+
+
bool ORecur::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;
@@ -400,81 +420,125 @@ bool ORecur::p_nextOccurrence( const QDate& from, QDate& next ) {
default:
return FALSE;
}
}
+
+
ORecur::RepeatType ORecur::type()const{
return data->type;
}
+
+
int ORecur::frequency()const {
return data->freq;
}
+
+
int ORecur::position()const {
return data->pos;
}
+
+
char ORecur::days() const{
return data->days;
}
+
+
bool ORecur::hasEndDate()const {
return data->hasEnd;
}
+
+
QDate ORecur::endDate()const {
return data->end;
}
+
+
QDate ORecur::start()const{
return data->start;
}
+
+
QDateTime ORecur::createdDateTime()const {
return data->create;
}
+
+
int ORecur::repetition()const {
return data->rep;
}
+
+
QString ORecur::service()const {
return data->app;
}
+
+
ORecur::ExceptionList& ORecur::exceptions() {
return data->list;
}
+
+
void ORecur::setType( const RepeatType& z) {
checkOrModify();
data->type = z;
}
+
+
void ORecur::setFrequency( int freq ) {
checkOrModify();
data->freq = freq;
}
+
+
void ORecur::setPosition( int pos ) {
checkOrModify();
data->pos = pos;
}
+
+
void ORecur::setDays( char c ) {
checkOrModify();
data->days = c;
}
+
+
void ORecur::setEndDate( const QDate& dt) {
checkOrModify();
data->end = dt;
}
+
+
void ORecur::setCreatedDateTime( const QDateTime& t) {
checkOrModify();
data->create = t;
}
+
+
void ORecur::setHasEndDate( bool b) {
checkOrModify();
data->hasEnd = b;
}
+
+
void ORecur::setRepitition( int rep ) {
checkOrModify();
data->rep = rep;
}
+
+
void ORecur::setService( const QString& app ) {
checkOrModify();
data->app = app;
}
+
+
void ORecur::setStart( const QDate& dt ) {
checkOrModify();
data->start = dt;
}
+
+
void ORecur::checkOrModify() {
if ( data->count != 1 ) {
data->deref();
Data* d2 = new Data;
@@ -491,8 +555,10 @@ void ORecur::checkOrModify() {
d2->start = data->start;
data = d2;
}
}
+
+
QString ORecur::toString()const {
QString buf;
QMap<int, QString> recMap = toMap();