summaryrefslogtreecommitdiff
path: root/library/backend/event.h
Side-by-side diff
Diffstat (limited to 'library/backend/event.h') (more/less context) (ignore whitespace changes)
-rw-r--r--library/backend/event.h173
1 files changed, 157 insertions, 16 deletions
diff --git a/library/backend/event.h b/library/backend/event.h
index 277aadd..7fe41a5 100644
--- a/library/backend/event.h
+++ b/library/backend/event.h
@@ -1,7 +1,7 @@
/**********************************************************************
-** Copyright (C) 2001 Trolltech AS. All rights reserved.
+** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
**
-** This file is part of Qtopia Environment.
+** This file is part of the Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
@@ -23,22 +23,31 @@
#include <qdatetime.h>
#include <qvaluelist.h>
+#include <qcolor.h>
#ifdef PALMTOPCENTER
#include <qpc/qsorter.h>
#endif
-#include <qpe/palmtoprecord.h>
+#include <qtopia/private/palmtoprecord.h>
#include <qpe/timeconversion.h>
+static const QColor colorNormal = QColor(255, 0 , 0 );
+static const QColor colorRepeat = QColor(0 , 0 , 255);
+static const QColor colorNormalLight = QColor(255, 220, 220);
+static const QColor colorRepeatLight = QColor(200, 200, 255);
+
class EventPrivate;
class QPC_EXPORT Event : public Qtopia::Record
{
public:
enum RepeatType { NoRepeat = -1, Daily, Weekly, MonthlyDay,
MonthlyDate, Yearly };
+
+ // Don't use this.
enum Days { MON = 0x01, TUE = 0x02, WED = 0x04, THU = 0x08,
FRI = 0x10, SAT = 0x20, SUN = 0x40 };
+ // Don't use this.
struct QPC_EXPORT RepeatPattern
{
RepeatPattern() {
@@ -70,6 +79,7 @@ public:
enum Type { Normal, AllDay };
enum SoundTypeChoice { Silent, Loud };
+ // Don't use these, there are essentially meaningless.
bool operator<( const Event &e1) const { return start() < e1.start(); };
bool operator<=( const Event &e1 ) const { return start() <= e1.start(); };
bool operator!=( const Event &e1 ) const { return !( *this == e1 ); };
@@ -83,34 +93,63 @@ public:
void setLocation( const QString &s );
const QString &location() const;
- void setType( Type t );
- Type type() const;
+ void setNotes( const QString &n );
+ const QString &notes() const;
+
+ void setType( Type t ); // Don't use me.
+ Type type() const; // Don't use me.
+
+ void setAllDay(bool);
+ bool isAllDay() const;
+
void setStart( const QDateTime &d );
- void setStart( time_t time );
- QDateTime start( bool actual = FALSE ) const;
- time_t startTime() const { return startUTC; }
+ void setStart( time_t time ); // don't use me.
+ QDateTime start( ) const;
+ QDateTime start( bool actual ) const; // don't use me.
+ time_t startTime() const { return startUTC; } // don't use me.
void setEnd( const QDateTime &e );
- void setEnd( time_t time );
- QDateTime end( bool actual = FALSE ) const;
- time_t endTime() const { return endUTC; }
+ void setEnd( time_t time ); // don't use me
+ QDateTime end( ) const;
+ QDateTime end( bool actual ) const; // don't use me.
+ time_t endTime() const { return endUTC; } // don't use me.
void setTimeZone( const QString & );
const QString &timeZone() const;
- void setAlarm( bool b, int minutes, SoundTypeChoice );
+ void setAlarm( int minutes, SoundTypeChoice );
+ void clearAlarm();
+ void setAlarm( bool b, int minutes, SoundTypeChoice ); // Don't use me.
bool hasAlarm() const;
- int alarmTime() const;
+ int alarmDelay() const;
+ int alarmTime() const; // Don't use me.
SoundTypeChoice alarmSound() const;
+
+ RepeatType repeatType() const;
+ int frequency() const;
+ int weekOffset() const;
+ QDate repeatTill() const;
+ bool repeatForever() const;
+ bool repeatOnWeekDay(int day) const;
+
+ void setRepeatType(RepeatType);
+ void setFrequency(int);
+ void setRepeatTill(const QDate &);
+ void setRepeatForever(bool);
+ void setRepeatOnWeekDay(int day, bool enable);
+
+ // Don't use any of these.
void setRepeat( bool b, const RepeatPattern &p );
void setRepeat( const RepeatPattern &p );
bool hasRepeat() const;
const RepeatPattern &repeatPattern() const;
RepeatPattern &repeatPattern();
- void setNotes( const QString &n );
- const QString &notes() const;
bool doRepeat() const { return pattern.type != NoRepeat; }
void save( QString& buf );
//void load( Node *n );
+ bool match( const QRegExp &r ) const;
+
+ // Don't use these either. Functionality will be moved elsewhere.
+
// helper function to calculate the week of the given date
static int week( const QDate& date );
// calculates the number of occurrences of the week day of
@@ -123,7 +162,6 @@ public:
static int dayOfWeek( char day );
// returns the difference of months from first to second.
static int monthDiff( const QDate& first, const QDate& second );
- bool match( const QRegExp &r ) const;
private:
Qtopia::UidGen &uidGen() { return sUidGen; }
@@ -211,6 +249,109 @@ private:
};
+inline void Event::setAlarm( int minutes, SoundTypeChoice s )
+{
+ setAlarm(TRUE, minutes, s);
+}
+
+inline void Event::clearAlarm()
+{
+ setAlarm(FALSE, 0, Silent);
+}
+
+inline int Event::alarmDelay() const
+{
+ return alarmTime();
+}
+
+inline void Event::setAllDay(bool enable)
+{
+ if (enable)
+ setType(AllDay);
+ else
+ setType(Normal);
+};
+
+inline bool Event::isAllDay() const
+{
+ return type() == AllDay;
+}
+
+inline Event::RepeatType Event::repeatType() const
+{
+ return repeatPattern().type;
+}
+
+inline int Event::frequency() const
+{
+ return repeatPattern().frequency;
+}
+
+inline int Event::weekOffset() const
+{
+ if (start().date().day() == 1)
+ return 1;
+ return (start().date().day() - 1) / 7 + 1;
+}
+
+inline QDate Event::repeatTill() const
+{
+ return repeatPattern().endDate();
+}
+
+inline bool Event::repeatForever() const
+{
+ return !repeatPattern().hasEndDate;
+}
+
+inline void Event::setRepeatType(RepeatType t)
+{
+ pattern.type = t;
+}
+
+inline void Event::setFrequency(int f)
+{
+ pattern.frequency = f;
+}
+
+inline void Event::setRepeatTill(const QDate &d)
+{
+ pattern.setEndDate(d);
+ pattern.hasEndDate = TRUE;
+}
+
+inline void Event::setRepeatForever(bool b)
+{
+ if (!b == pattern.hasEndDate)
+ return;
+ if (!b && !pattern.hasEndDate)
+ pattern.setEndDate(end().date());
+ pattern.hasEndDate = !b;
+}
+
+inline bool Event::repeatOnWeekDay(int day) const
+{
+ if (pattern.type != Weekly)
+ return FALSE;
+ return ( (1 << (day - 1)) & pattern.days ) != 0;
+}
+
+inline void Event::setRepeatOnWeekDay(int day, bool enable)
+{
+ if ( repeatOnWeekDay( day ) != enable )
+ pattern.days ^= 1 << (day - 1);
+}
+
+inline QDateTime Event::start( ) const
+{
+ return start(FALSE);
+}
+
+inline QDateTime Event::end( ) const
+{
+ return end(FALSE);
+}
+
#ifdef PALMTOPCENTER
class QPC_EXPORT EffectiveEventSizeSorter : public QSorter<EffectiveEvent>
{