summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (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
@@ -51,13 +51,13 @@ Calendar::Calendar( const QString &timeZoneId )
void Calendar::init()
{
mObserver = 0;
mNewObserver = false;
mUndoIncidence = 0;
mModified = false;
-
+ mDefaultCalendar = 1;
// Setup default filter, which does nothing
mDefaultFilter = new CalFilter;
mFilter = mDefaultFilter;
mFilter->setEnabled(false);
// initialize random numbers. This is a hack, and not
@@ -109,13 +109,20 @@ void Calendar::init()
Calendar::~Calendar()
{
delete mDefaultFilter;
if ( mUndoIncidence )
delete mUndoIncidence;
}
-
+void Calendar::setDefaultCalendar( int d )
+{
+ mDefaultCalendar = d;
+}
+int Calendar::defaultCalendar()
+{
+ return mDefaultCalendar;
+}
const QString &Calendar::getOwner() const
{
return mOwner;
}
bool Calendar::undoDeleteIncidence()
@@ -345,13 +352,14 @@ void Calendar::addIncidenceBranch(Incidence *i)
}
}
bool Calendar::addIncidence(Incidence *i)
{
Incidence::AddVisitor<Calendar> v(this);
-
+ i->setCalID( mDefaultCalendar );
+ i->setCalEnabled( true );
return i->accept(v);
}
void Calendar::deleteIncidence(Incidence *in)
{
if ( in->typeID() == eventID )
deleteEvent( (Event*) in );
diff --git a/libkcal/calendar.h b/libkcal/calendar.h
index ab40970..4c6760f 100644
--- a/libkcal/calendar.h
+++ b/libkcal/calendar.h
@@ -299,13 +299,17 @@ public:
void setLoadedProductId( const QString & );
/**
Return product id taken from file that has been loaded. Returns
QString::null, if no calendar has been loaded.
*/
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();
void calendarSaved();
void calendarLoaded();
void addAlarm(const QDateTime &qdt, const QString &noti );
void removeAlarm(const QDateTime &qdt, const QString &noti );
@@ -323,26 +327,29 @@ public:
/**
Get events in a range of dates. If inclusive is set to true, only events
are returned, which are completely included in the range.
*/
virtual QPtrList<Event> rawEvents( const QDate &start, const QDate &end,
bool inclusive = false ) = 0;
+
Incidence *mNextAlarmIncidence;
Incidence *mUndoIncidence;
+ int mDefaultCalendar;
private:
void init();
QString mOwner; // who the calendar belongs to
QString mOwnerEmail; // email address of the owner
int mTimeZone; // timezone OFFSET from GMT (MINUTES)
bool mLocalTime; // use local time, not UTC or a time zone
CalFilter *mFilter;
CalFilter *mDefaultFilter;
+
QString mTimeZoneId;
Observer *mObserver;
bool mNewObserver;
bool mModified;
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp
index fe74052..c5500bf 100644
--- a/libkcal/calendarlocal.cpp
+++ b/libkcal/calendarlocal.cpp
@@ -147,12 +147,14 @@ bool CalendarLocal::addEvent( Event *event )
{
insertEvent( event );
event->registerObserver( this );
setModified( true );
+ event->setCalID( mDefaultCalendar );
+ event->setCalEnabled( true );
return true;
}
void CalendarLocal::deleteEvent( Event *event )
{
@@ -167,13 +169,13 @@ void CalendarLocal::deleteEvent( Event *event )
Event *CalendarLocal::event( const QString &uid )
{
Event *event;
for ( event = mEventList.first(); event; event = mEventList.next() ) {
- if ( event->uid() == uid ) {
+ if ( event->uid() == uid && event->calEnabled() ) {
return event;
}
}
return 0;
}
@@ -195,13 +197,14 @@ bool CalendarLocal::addTodo( Todo *todo )
todo->registerObserver( this );
// Set up subtask relations
setupRelations( todo );
setModified( true );
-
+ todo->setCalID( mDefaultCalendar );
+ todo->setCalEnabled( true );
return true;
}
void CalendarLocal::deleteTodo( Todo *todo )
{
// Handle orphaned children
@@ -213,19 +216,22 @@ void CalendarLocal::deleteTodo( Todo *todo )
setModified( true );
}
}
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 )
{
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;
}
return 0;
}
void CalendarLocal::removeSyncInfo( QString syncProfile)
{
@@ -264,22 +270,22 @@ QPtrList<Event> CalendarLocal::getExternLastSyncEvents()
}
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;
}
return 0;
}
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;
}
return 0;
}
QString CalendarLocal::nextSummary() const
{
@@ -386,12 +392,13 @@ void CalendarLocal::deRegisterAlarm()
QPtrList<Todo> CalendarLocal::todos( const QDate &date )
{
QPtrList<Todo> todos;
Todo *todo;
for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) {
+ if ( !todo->calEnabled() ) continue;
if ( todo->hasDueDate() && todo->dtDue().date() == date ) {
todos.append( todo );
}
}
filter()->apply( &todos );
@@ -418,12 +425,13 @@ QDateTime CalendarLocal::nextAlarm( int daysTo )
Event *e;
bool ok;
bool found = false;
int offset;
mNextAlarmIncidence = 0;
for( e = mEventList.first(); e; e = mEventList.next() ) {
+ if ( !e->calEnabled() ) continue;
next = e->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ;
if ( ok ) {
if ( next < nextA ) {
nextA = next;
found = true;
mNextSummary = e->summary();
@@ -431,12 +439,13 @@ QDateTime CalendarLocal::nextAlarm( int daysTo )
mNextAlarmIncidence = (Incidence *) e;
}
}
}
Todo *t;
for( t = mTodoList.first(); t; t = mTodoList.next() ) {
+ if ( !t->calEnabled() ) continue;
next = t->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ;
if ( ok ) {
if ( next < nextA ) {
nextA = next;
found = true;
mNextSummary = t->summary();
@@ -461,18 +470,20 @@ Alarm::List CalendarLocal::alarms( const QDateTime &from, const QDateTime &to )
Alarm::List alarms;
Event *e;
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 );
}
Todo *t;
for( t = mTodoList.first(); t; t = mTodoList.next() ) {
+ if ( !t->calEnabled() ) continue;
appendAlarms( alarms, t, from, to );
}
return alarms;
}
@@ -540,12 +551,13 @@ void CalendarLocal::insertEvent( Event *event )
QPtrList<Event> CalendarLocal::rawEventsForDate( const QDate &qd, bool sorted )
{
QPtrList<Event> eventList;
Event *event;
for( event = mEventList.first(); event; event = mEventList.next() ) {
+ if ( !event->calEnabled() ) continue;
if ( event->doesRecur() ) {
if ( event->isMultiDay() ) {
int extraDays = event->dtStart().date().daysTo( event->dtEnd().date() );
int i;
for ( i = 0; i <= extraDays; i++ ) {
if ( event->recursOn( qd.addDays( -i ) ) ) {
@@ -592,12 +604,13 @@ QPtrList<Event> CalendarLocal::rawEvents( const QDate &start, const QDate &end,
Event *event = 0;
QPtrList<Event> eventList;
// Get non-recurring events
for( event = mEventList.first(); event; event = mEventList.next() ) {
+ if ( !event->calEnabled() ) continue;
if ( event->doesRecur() ) {
QDate rStart = event->dtStart().date();
bool found = false;
if ( inclusive ) {
if ( rStart >= start && rStart <= end ) {
// Start date of event is in range. Now check for end date.
@@ -667,13 +680,16 @@ QPtrList<Event> CalendarLocal::rawEventsForDate( const QDateTime &qdt )
{
return rawEventsForDate( qdt.date() );
}
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;
}
bool CalendarLocal::addJournal(Journal *journal)
{
if ( journal->dtStart().isValid())
kdDebug(5800) << "Adding Journal on " << journal->dtStart().toString() << endl;
@@ -682,13 +698,14 @@ bool CalendarLocal::addJournal(Journal *journal)
mJournalList.append(journal);
journal->registerObserver( this );
setModified( true );
-
+ journal->setCalID( mDefaultCalendar );
+ journal->setCalEnabled( true );
return true;
}
void CalendarLocal::deleteJournal( Journal *journal )
{
if ( mUndoIncidence ) delete mUndoIncidence;
@@ -701,26 +718,65 @@ void CalendarLocal::deleteJournal( Journal *journal )
Journal *CalendarLocal::journal( const QDate &date )
{
// kdDebug(5800) << "CalendarLocal::journal() " << date.toString() << endl;
for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
- if ( it->dtStart().date() == date )
+ if ( it->calEnabled() && it->dtStart().date() == date )
return it;
return 0;
}
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;
return 0;
}
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
@@ -177,12 +177,15 @@ class CalendarLocal : public Calendar
QPtrList<Event> rawEvents( const QDate &start, const QDate &end,
bool inclusive = false );
Todo *todo( QString, QString );
Event *event( QString, QString );
+ void setCalendarEnabled( int id, bool enable );
+ void setAlarmEnabled( int id, bool enable );
+ void setDefaultCalendarEnabledOnly();
protected:
// Event* mNextAlarmEvent;
QString mNextSummary;
QString mNextAlarmEventDateTimeString;
diff --git a/libkcal/calfilter.cpp b/libkcal/calfilter.cpp
index 20078a7..3510c7d 100644
--- a/libkcal/calfilter.cpp
+++ b/libkcal/calfilter.cpp
@@ -75,38 +75,47 @@ void CalFilter::apply(QPtrList<Todo> *eventlist)
}
// kdDebug(5800) << "CalFilter::apply() done" << endl;
}
bool CalFilter::filterCalendarItem(Incidence *in)
{
+ if ( !in->calEnabled() )
+ return false;
if ( in->typeID() == eventID )
return filterEvent( (Event*) in );
else if ( in->typeID() == todoID )
return filterTodo( (Todo*) in);
else if ( in->typeID () == journalID )
return filterJournal( (Journal*) in );
return false;
}
bool CalFilter::filterEvent(Event *event)
{
+
+ if ( !event->calEnabled() )
+ return false;
if (mCriteria & HideEvents)
return false;
if (mCriteria & HideRecurring) {
if (event->recurrence()->doesRecur()) return false;
}
return filterIncidence(event);
}
bool CalFilter::filterJournal(Journal *j)
{
+ if ( !j->calEnabled() )
+ return false;
if (mCriteria & HideJournals)
return false;
return true;
}
bool CalFilter::filterTodo(Todo *todo)
{
+ if ( !todo->calEnabled() )
+ return false;
if (mCriteria & HideTodos)
return false;
if (mCriteria & HideCompleted) {
if (todo->isCompleted()) return false;
}
diff --git a/libkcal/calfilter.h b/libkcal/calfilter.h
index 29db441..e349770 100644
--- a/libkcal/calfilter.h
+++ b/libkcal/calfilter.h
@@ -23,12 +23,13 @@
#include <qstring.h>
#include <qptrlist.h>
#include "event.h"
#include "todo.h"
+#include "journal.h"
namespace KCal {
/**
Filter for calendar objects.
*/
diff --git a/libkcal/event.cpp b/libkcal/event.cpp
index 9b99855..7cd81fa 100644
--- a/libkcal/event.cpp
+++ b/libkcal/event.cpp
@@ -170,13 +170,15 @@ void Event::setDuration(int seconds)
{
setHasEndDate(false);
Incidence::setDuration(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 );
if ( ! yes || cancelled() ) {
*ok = false;
return QDateTime ();
}
diff --git a/libkcal/incidencebase.cpp b/libkcal/incidencebase.cpp
index b5fe2e6..2ddbb01 100644
--- a/libkcal/incidencebase.cpp
+++ b/libkcal/incidencebase.cpp
@@ -41,23 +41,30 @@ IncidenceBase::IncidenceBase() :
mHasDuration = false;
mPilotId = 0;
mExternalId = ":";
mTempSyncStat = SYNC_TEMPSTATE_INITIAL;
mSyncStatus = 0;
mAttendees.setAutoDelete( true );
+ mCalEnabled = true;
+ mAlarmEnabled = true;
+ mCalID = 0;
}
IncidenceBase::IncidenceBase(const IncidenceBase &i) :
CustomProperties( i )
{
+
mReadOnly = i.mReadOnly;
mDtStart = i.mDtStart;
mDuration = i.mDuration;
mHasDuration = i.mHasDuration;
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() ) {
mAttendees.append( new Attendee( *a ) );
}
mFloats = i.mFloats;
mLastModified = i.mLastModified;
@@ -129,12 +136,38 @@ QDateTime IncidenceBase::getEvenTime( QDateTime dt )
{
QTime t = dt.time();
dt.setTime( QTime (t.hour (), t.minute (), t.second () ) );
return 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)
{
mUid = uid;
updated();
}
diff --git a/libkcal/incidencebase.h b/libkcal/incidencebase.h
index 05209e0..dc6024a 100644
--- a/libkcal/incidencebase.h
+++ b/libkcal/incidencebase.h
@@ -138,22 +138,31 @@ class IncidenceBase : public CustomProperties
QString getCsum( const QString & );
void removeID(const QString &);
void registerObserver( Observer * );
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:
QDateTime mDtStart;
bool mReadOnly;
QDateTime getEvenTime( QDateTime );
private:
// base components
QString mOrganizer;
QString mUid;
+ int mCalID;
+ bool mCalEnabled;
+ bool mAlarmEnabled;
QDateTime mLastModified;
QPtrList<Attendee> mAttendees;
bool mFloats;
int mDuration;
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp
index c97a61e..42274ff 100644
--- a/libkcal/todo.cpp
+++ b/libkcal/todo.cpp
@@ -514,13 +514,13 @@ void Todo::setPercentComplete(int v)
if ( v != 100 )
mHasCompletedDate = false;
updated();
}
QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const
{
- if ( isCompleted() || ! hasDueDate() || cancelled() ) {
+ if ( isCompleted() || ! hasDueDate() || cancelled() || !alarmEnabled() ) {
*ok = false;
return QDateTime ();
}
QDateTime incidenceStart;
incidenceStart = dtDue();
bool enabled = false;