summaryrefslogtreecommitdiffabout
path: root/libkcal
authorzautrix <zautrix>2005-06-10 20:13:31 (UTC)
committer zautrix <zautrix>2005-06-10 20:13:31 (UTC)
commitcdc55afb3d2c3ebd970843b7dce02acb1e6a189b (patch) (side-by-side diff)
tree45f3bfa69a72de4e8b53bbcb2414478ec65cd183 /libkcal
parent31fed261955dcb25d06052a8154ac4cc630b0f7d (diff)
downloadkdepimpi-cdc55afb3d2c3ebd970843b7dce02acb1e6a189b.zip
kdepimpi-cdc55afb3d2c3ebd970843b7dce02acb1e6a189b.tar.gz
kdepimpi-cdc55afb3d2c3ebd970843b7dce02acb1e6a189b.tar.bz2
many preparations for multiple calendars
Diffstat (limited to 'libkcal') (more/less context) (show whitespace changes)
-rw-r--r--libkcal/calendar.cpp14
-rw-r--r--libkcal/calendar.h9
-rw-r--r--libkcal/calendarlocal.cpp78
-rw-r--r--libkcal/calendarlocal.h3
-rw-r--r--libkcal/calfilter.cpp9
-rw-r--r--libkcal/calfilter.h1
-rw-r--r--libkcal/event.cpp4
-rw-r--r--libkcal/incidencebase.cpp33
-rw-r--r--libkcal/incidencebase.h9
-rw-r--r--libkcal/todo.cpp2
10 files changed, 145 insertions, 17 deletions
diff --git a/libkcal/calendar.cpp b/libkcal/calendar.cpp
index 7e8e2c5..f4350d9 100644
--- a/libkcal/calendar.cpp
+++ b/libkcal/calendar.cpp
@@ -55,5 +55,5 @@ void Calendar::init()
mUndoIncidence = 0;
mModified = false;
-
+ mDefaultCalendar = 1;
// Setup default filter, which does nothing
mDefaultFilter = new CalFilter;
@@ -113,5 +113,12 @@ Calendar::~Calendar()
delete mUndoIncidence;
}
-
+void Calendar::setDefaultCalendar( int d )
+{
+ mDefaultCalendar = d;
+}
+int Calendar::defaultCalendar()
+{
+ return mDefaultCalendar;
+}
const QString &Calendar::getOwner() const
{
@@ -349,5 +356,6 @@ bool Calendar::addIncidence(Incidence *i)
{
Incidence::AddVisitor<Calendar> v(this);
-
+ i->setCalID( mDefaultCalendar );
+ i->setCalEnabled( true );
return i->accept(v);
}
diff --git a/libkcal/calendar.h b/libkcal/calendar.h
index ab40970..4c6760f 100644
--- a/libkcal/calendar.h
+++ b/libkcal/calendar.h
@@ -303,5 +303,9 @@ public:
*/
QString loadedProductId();
-
+ void setDefaultCalendar( int );
+ int defaultCalendar();
+ virtual void setCalendarEnabled( int id, bool enable ) = 0;
+ virtual void setAlarmEnabled( int id, bool enable ) = 0;
+ virtual void setDefaultCalendarEnabledOnly() = 0;
signals:
void calendarChanged();
@@ -327,6 +331,8 @@ public:
virtual QPtrList<Event> rawEvents( const QDate &start, const QDate &end,
bool inclusive = false ) = 0;
+
Incidence *mNextAlarmIncidence;
Incidence *mUndoIncidence;
+ int mDefaultCalendar;
private:
@@ -341,4 +347,5 @@ private:
CalFilter *mDefaultFilter;
+
QString mTimeZoneId;
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp
index fe74052..c5500bf 100644
--- a/libkcal/calendarlocal.cpp
+++ b/libkcal/calendarlocal.cpp
@@ -151,4 +151,6 @@ bool CalendarLocal::addEvent( Event *event )
setModified( true );
+ event->setCalID( mDefaultCalendar );
+ event->setCalEnabled( true );
return true;
@@ -171,5 +173,5 @@ Event *CalendarLocal::event( const QString &uid )
for ( event = mEventList.first(); event; event = mEventList.next() ) {
- if ( event->uid() == uid ) {
+ if ( event->uid() == uid && event->calEnabled() ) {
return event;
}
@@ -199,5 +201,6 @@ bool CalendarLocal::addTodo( Todo *todo )
setModified( true );
-
+ todo->setCalID( mDefaultCalendar );
+ todo->setCalEnabled( true );
return true;
}
@@ -217,5 +220,8 @@ void CalendarLocal::deleteTodo( Todo *todo )
QPtrList<Todo> CalendarLocal::rawTodos()
{
- return mTodoList;
+ QPtrList<Todo> el;
+ for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() )
+ if ( it->calEnabled() ) el.append( it );
+ return el;
}
Todo *CalendarLocal::todo( QString syncProf, QString id )
@@ -223,5 +229,5 @@ Todo *CalendarLocal::todo( QString syncProf, QString id )
Todo *todo;
for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) {
- if ( todo->getID( syncProf ) == id ) return todo;
+ if ( todo->calEnabled() && todo->getID( syncProf ) == id ) return todo;
}
@@ -268,5 +274,5 @@ Event *CalendarLocal::event( QString syncProf, QString id )
Event *todo;
for ( todo = mEventList.first(); todo; todo = mEventList.next() ) {
- if ( todo->getID( syncProf ) == id ) return todo;
+ if ( todo->calEnabled() && todo->getID( syncProf ) == id ) return todo;
}
@@ -277,5 +283,5 @@ Todo *CalendarLocal::todo( const QString &uid )
Todo *todo;
for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) {
- if ( todo->uid() == uid ) return todo;
+ if ( todo->calEnabled() && todo->uid() == uid ) return todo;
}
@@ -390,4 +396,5 @@ QPtrList<Todo> CalendarLocal::todos( const QDate &date )
Todo *todo;
for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) {
+ if ( !todo->calEnabled() ) continue;
if ( todo->hasDueDate() && todo->dtDue().date() == date ) {
todos.append( todo );
@@ -422,4 +429,5 @@ QDateTime CalendarLocal::nextAlarm( int daysTo )
mNextAlarmIncidence = 0;
for( e = mEventList.first(); e; e = mEventList.next() ) {
+ if ( !e->calEnabled() ) continue;
next = e->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ;
if ( ok ) {
@@ -435,4 +443,5 @@ QDateTime CalendarLocal::nextAlarm( int daysTo )
Todo *t;
for( t = mTodoList.first(); t; t = mTodoList.next() ) {
+ if ( !t->calEnabled() ) continue;
next = t->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ;
if ( ok ) {
@@ -465,4 +474,5 @@ Alarm::List CalendarLocal::alarms( const QDateTime &from, const QDateTime &to )
for( e = mEventList.first(); e; e = mEventList.next() ) {
+ if ( !e->calEnabled() ) continue;
if ( e->doesRecur() ) appendRecurringAlarms( alarms, e, from, to );
else appendAlarms( alarms, e, from, to );
@@ -471,4 +481,5 @@ Alarm::List CalendarLocal::alarms( const QDateTime &from, const QDateTime &to )
Todo *t;
for( t = mTodoList.first(); t; t = mTodoList.next() ) {
+ if ( !t->calEnabled() ) continue;
appendAlarms( alarms, t, from, to );
}
@@ -544,4 +555,5 @@ QPtrList<Event> CalendarLocal::rawEventsForDate( const QDate &qd, bool sorted )
Event *event;
for( event = mEventList.first(); event; event = mEventList.next() ) {
+ if ( !event->calEnabled() ) continue;
if ( event->doesRecur() ) {
if ( event->isMultiDay() ) {
@@ -596,4 +608,5 @@ QPtrList<Event> CalendarLocal::rawEvents( const QDate &start, const QDate &end,
// Get non-recurring events
for( event = mEventList.first(); event; event = mEventList.next() ) {
+ if ( !event->calEnabled() ) continue;
if ( event->doesRecur() ) {
QDate rStart = event->dtStart().date();
@@ -671,5 +684,8 @@ QPtrList<Event> CalendarLocal::rawEventsForDate( const QDateTime &qdt )
QPtrList<Event> CalendarLocal::rawEvents()
{
- return mEventList;
+ QPtrList<Event> el;
+ for ( Event *it = mEventList.first(); it; it = mEventList.next() )
+ if ( it->calEnabled() ) el.append( it );
+ return el;
}
@@ -686,5 +702,6 @@ bool CalendarLocal::addJournal(Journal *journal)
setModified( true );
-
+ journal->setCalID( mDefaultCalendar );
+ journal->setCalEnabled( true );
return true;
}
@@ -705,5 +722,5 @@ Journal *CalendarLocal::journal( const QDate &date )
for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
- if ( it->dtStart().date() == date )
+ if ( it->calEnabled() && it->dtStart().date() == date )
return it;
@@ -714,5 +731,5 @@ Journal *CalendarLocal::journal( const QString &uid )
{
for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
- if ( it->uid() == uid )
+ if ( it->calEnabled() && it->uid() == uid )
return it;
@@ -722,5 +739,44 @@ Journal *CalendarLocal::journal( const QString &uid )
QPtrList<Journal> CalendarLocal::journals()
{
- return mJournalList;
+ QPtrList<Journal> el;
+ for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
+ if ( it->calEnabled() ) el.append( it );
+ return el;
}
+void CalendarLocal::setCalendarEnabled( int id, bool enable )
+{
+ for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
+ if ( it->calID() == id ) it->setCalEnabled( enable );
+
+ for ( Event *it = mEventList.first(); it; it = mEventList.next() )
+ if ( it->calID() == id ) it->setCalEnabled( enable );
+
+ for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() )
+ if ( it->calID() == id ) it->setCalEnabled( enable );
+
+}
+void CalendarLocal::setAlarmEnabled( int id, bool enable )
+{
+ for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
+ if ( it->calID() == id ) it->setAlarmEnabled( enable );
+
+ for ( Event *it = mEventList.first(); it; it = mEventList.next() )
+ if ( it->calID() == id ) it->setAlarmEnabled( enable );
+
+ for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() )
+ if ( it->calID() == id ) it->setAlarmEnabled( enable );
+
+}
+void CalendarLocal::setDefaultCalendarEnabledOnly()
+{
+ for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
+ it->setCalEnabled( it->calID() == mDefaultCalendar );
+
+ for ( Event *it = mEventList.first(); it; it = mEventList.next() )
+ it->setCalEnabled( it->calID() == mDefaultCalendar);
+
+ for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() )
+ it->setCalEnabled( it->calID() == mDefaultCalendar);
+
+}
diff --git a/libkcal/calendarlocal.h b/libkcal/calendarlocal.h
index 98ec710..b25fcbe 100644
--- a/libkcal/calendarlocal.h
+++ b/libkcal/calendarlocal.h
@@ -181,4 +181,7 @@ class CalendarLocal : public Calendar
+ void setCalendarEnabled( int id, bool enable );
+ void setAlarmEnabled( int id, bool enable );
+ void setDefaultCalendarEnabledOnly();
protected:
diff --git a/libkcal/calfilter.cpp b/libkcal/calfilter.cpp
index 20078a7..3510c7d 100644
--- a/libkcal/calfilter.cpp
+++ b/libkcal/calfilter.cpp
@@ -79,4 +79,6 @@ void CalFilter::apply(QPtrList<Todo> *eventlist)
bool CalFilter::filterCalendarItem(Incidence *in)
{
+ if ( !in->calEnabled() )
+ return false;
if ( in->typeID() == eventID )
return filterEvent( (Event*) in );
@@ -89,4 +91,7 @@ bool CalFilter::filterCalendarItem(Incidence *in)
bool CalFilter::filterEvent(Event *event)
{
+
+ if ( !event->calEnabled() )
+ return false;
if (mCriteria & HideEvents)
return false;
@@ -99,4 +104,6 @@ bool CalFilter::filterEvent(Event *event)
bool CalFilter::filterJournal(Journal *j)
{
+ if ( !j->calEnabled() )
+ return false;
if (mCriteria & HideJournals)
return false;
@@ -105,4 +112,6 @@ bool CalFilter::filterJournal(Journal *j)
bool CalFilter::filterTodo(Todo *todo)
{
+ if ( !todo->calEnabled() )
+ return false;
if (mCriteria & HideTodos)
return false;
diff --git a/libkcal/calfilter.h b/libkcal/calfilter.h
index 29db441..e349770 100644
--- a/libkcal/calfilter.h
+++ b/libkcal/calfilter.h
@@ -27,4 +27,5 @@
#include "event.h"
#include "todo.h"
+#include "journal.h"
namespace KCal {
diff --git a/libkcal/event.cpp b/libkcal/event.cpp
index 9b99855..7cd81fa 100644
--- a/libkcal/event.cpp
+++ b/libkcal/event.cpp
@@ -174,5 +174,7 @@ void Event::setDuration(int seconds)
QDateTime Event::getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const
{
-
+ *ok = false;
+ if ( !alarmEnabled() )
+ return QDateTime ();
bool yes;
QDateTime incidenceStart = getNextOccurence( start_dt, &yes );
diff --git a/libkcal/incidencebase.cpp b/libkcal/incidencebase.cpp
index b5fe2e6..2ddbb01 100644
--- a/libkcal/incidencebase.cpp
+++ b/libkcal/incidencebase.cpp
@@ -45,4 +45,7 @@ IncidenceBase::IncidenceBase() :
mSyncStatus = 0;
mAttendees.setAutoDelete( true );
+ mCalEnabled = true;
+ mAlarmEnabled = true;
+ mCalID = 0;
}
@@ -50,4 +53,5 @@ IncidenceBase::IncidenceBase(const IncidenceBase &i) :
CustomProperties( i )
{
+
mReadOnly = i.mReadOnly;
mDtStart = i.mDtStart;
@@ -56,4 +60,7 @@ IncidenceBase::IncidenceBase(const IncidenceBase &i) :
mOrganizer = i.mOrganizer;
mUid = i.mUid;
+ mCalEnabled = i.mCalEnabled;
+ mAlarmEnabled = i.mAlarmEnabled;
+ mCalID = i.mCalID;
QPtrList<Attendee> attendees = i.attendees();
for( Attendee *a = attendees.first(); a; a = attendees.next() ) {
@@ -133,4 +140,30 @@ QDateTime IncidenceBase::getEvenTime( QDateTime dt )
}
+void IncidenceBase::setCalID( int id )
+{
+ mCalID = id;
+}
+int IncidenceBase::calID() const
+{
+ return mCalID;
+}
+void IncidenceBase::setCalEnabled( bool b )
+{
+ mCalEnabled = b;
+}
+bool IncidenceBase::calEnabled() const
+{
+ return mCalEnabled;
+}
+
+void IncidenceBase::setAlarmEnabled( bool b )
+{
+ mAlarmEnabled = b;
+}
+bool IncidenceBase::alarmEnabled() const
+{
+ return mAlarmEnabled;
+}
+
void IncidenceBase::setUid(const QString &uid)
diff --git a/libkcal/incidencebase.h b/libkcal/incidencebase.h
index 05209e0..dc6024a 100644
--- a/libkcal/incidencebase.h
+++ b/libkcal/incidencebase.h
@@ -142,4 +142,10 @@ class IncidenceBase : public CustomProperties
void unRegisterObserver( Observer * );
void updated();
+ void setCalID( int id );
+ int calID() const;
+ void setCalEnabled( bool );
+ bool calEnabled() const;
+ void setAlarmEnabled( bool );
+ bool alarmEnabled() const;
protected:
@@ -152,4 +158,7 @@ class IncidenceBase : public CustomProperties
QString mOrganizer;
QString mUid;
+ int mCalID;
+ bool mCalEnabled;
+ bool mAlarmEnabled;
QDateTime mLastModified;
QPtrList<Attendee> mAttendees;
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp
index c97a61e..42274ff 100644
--- a/libkcal/todo.cpp
+++ b/libkcal/todo.cpp
@@ -518,5 +518,5 @@ void Todo::setPercentComplete(int v)
QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const
{
- if ( isCompleted() || ! hasDueDate() || cancelled() ) {
+ if ( isCompleted() || ! hasDueDate() || cancelled() || !alarmEnabled() ) {
*ok = false;
return QDateTime ();