summaryrefslogtreecommitdiffabout
path: root/libkcal
Side-by-side diff
Diffstat (limited to 'libkcal') (more/less context) (show whitespace changes)
-rw-r--r--libkcal/calendar.h2
-rw-r--r--libkcal/calendarlocal.cpp26
-rw-r--r--libkcal/calendarlocal.h1
3 files changed, 28 insertions, 1 deletions
diff --git a/libkcal/calendar.h b/libkcal/calendar.h
index 3f6895d..4b8b3ff 100644
--- a/libkcal/calendar.h
+++ b/libkcal/calendar.h
@@ -274,96 +274,98 @@ public:
/**
Set calendar filter, which filters events for the events() functions.
The Filter object is owned by the caller.
*/
void setFilter( CalFilter * );
/**
Return calendar filter.
*/
CalFilter *filter();
virtual QDateTime nextAlarm( int daysTo ) = 0;
virtual QString nextSummary( ) const = 0;
virtual void reInitAlarmSettings() = 0;
virtual QDateTime nextAlarmEventDateTime() const = 0;
virtual void checkAlarmForIncidence( Incidence *, bool ) = 0;
/**
Return all alarms, which ocur in the given time interval.
*/
virtual Alarm::List alarms( const QDateTime &from,
const QDateTime &to ) = 0;
class Observer {
public:
virtual void calendarModified( bool, Calendar * ) = 0;
};
void registerObserver( Observer * );
void setModified( bool );
/**
Set product id returned by loadedProductId(). This function is only
useful for the calendar loading code.
*/
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();
int defaultCalendar();
void setDontDeleteIncidencesOnClose ();
public slots:
void setDefaultCalendar( int );
virtual void setCalendarEnabled( int id, bool enable ) = 0;
virtual void setAlarmEnabled( int id, bool enable ) = 0;
virtual void setReadOnly( int id, bool enable ) = 0;
virtual void setDefaultCalendarEnabledOnly() = 0;
virtual void setCalendarRemove( int id ) = 0;
+ virtual void getIncidenceCount( int calId, int& events, int & todos, int & journals) = 0;
+
signals:
void calendarChanged();
void calendarSaved();
void calendarLoaded();
void addAlarm(const QDateTime &qdt, const QString &noti );
void removeAlarm(const QDateTime &qdt, const QString &noti );
protected:
/**
Get unfiltered events, which occur on the given date.
*/
virtual QPtrList<Event> rawEventsForDate( const QDateTime &qdt ) = 0;
/**
Get unfiltered events, which occur on the given date.
*/
virtual QPtrList<Event> rawEventsForDate( const QDate &date,
bool sorted = false ) = 0;
/**
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;
bool mDeleteIncidencesOnClose;
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 1a1c6be..0ddfeca 100644
--- a/libkcal/calendarlocal.cpp
+++ b/libkcal/calendarlocal.cpp
@@ -407,111 +407,135 @@ Todo *CalendarLocal::todo( QString syncProf, QString id )
}
void CalendarLocal::removeSyncInfo( QString syncProfile)
{
QPtrList<Incidence> all = rawIncidences() ;
Incidence *inc;
for ( inc = all.first(); inc; inc = all.next() ) {
inc->removeID( syncProfile );
}
if ( syncProfile.isEmpty() ) {
QPtrList<Event> el;
Event *todo;
for ( todo = mEventList.first(); todo; todo = mEventList.next() ) {
if ( todo->uid().left( 15 ) == QString("last-syncEvent-") )
el.append( todo );
}
for ( todo = el.first(); todo; todo = el.next() ) {
deleteIncidence ( todo );
}
} else {
Event *lse = event( "last-syncEvent-"+ syncProfile);
if ( lse )
deleteIncidence ( lse );
}
}
QPtrList<Event> CalendarLocal::getExternLastSyncEvents()
{
QPtrList<Event> el;
Event *todo;
for ( todo = mEventList.first(); todo; todo = mEventList.next() ) {
if ( todo->uid().left( 15 ) == QString("last-syncEvent-") )
if ( todo->summary().left(3) == "E: " )
el.append( todo );
}
return el;
}
Event *CalendarLocal::event( QString syncProf, QString id )
{
Event *todo;
for ( todo = mEventList.first(); todo; todo = mEventList.next() ) {
if ( todo->calEnabled() && todo->getID( syncProf ) == id ) return todo;
}
return 0;
}
Todo *CalendarLocal::todo( const QString &uid )
{
- Todo *todo;;
+ Todo *todo;
Todo *retVal = 0;
for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) {
if ( todo->calEnabled() && todo->uid() == uid ) {
if ( retVal ) {
if ( retVal->calID() > todo->calID() ) {
retVal = todo;
}
} else {
retVal = todo;
}
}
}
return retVal;
}
+void CalendarLocal::getIncidenceCount( int calId, int& events, int & todos, int & journals)
+{
+ events = 0;
+ todos = 0;
+ journals = 0;
+ {
+ Todo *todo;
+ for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) {
+ if ( todo->calID() == calId )
+ ++todos;
+ }
+ }
+ {
+ Event *todo;
+ for ( todo = mEventList.first(); todo; todo = mEventList.next() ) {
+ if ( todo->calID() == calId )
+ ++events;
+
+ }
+ }
+ for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
+ if ( it->calID() == calId ) ++journals;
+
+}
QString CalendarLocal::nextSummary() const
{
return mNextSummary;
}
QDateTime CalendarLocal::nextAlarmEventDateTime() const
{
return mNextAlarmEventDateTime;
}
void CalendarLocal::checkAlarmForIncidence( Incidence * incidence, bool deleted)
{
//mNextAlarmIncidence
//mNextAlarmDateTime
//return mNextSummary;
//return mNextAlarmEventDateTime;
bool newNextAlarm = false;
bool computeNextAlarm = false;
bool ok;
int offset;
QDateTime nextA;
// QString nextSum;
//QDateTime nextEvent;
if ( mNextAlarmIncidence == 0 || incidence == 0 ) {
computeNextAlarm = true;
} else {
if ( ! deleted ) {
nextA = incidence->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ;
if ( ok ) {
if ( nextA < mNextAlarmDateTime ) {
deRegisterAlarm();
mNextAlarmDateTime = nextA;
mNextSummary = incidence->summary();
mNextAlarmEventDateTime = nextA.addSecs(offset ) ;
mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime);
newNextAlarm = true;
mNextAlarmIncidence = incidence;
} else {
if ( incidence == mNextAlarmIncidence ) {
computeNextAlarm = true;
}
}
} else {
if ( mNextAlarmIncidence == incidence ) {
computeNextAlarm = true;
}
}
} else { // deleted
if ( incidence == mNextAlarmIncidence ) {
computeNextAlarm = true;
diff --git a/libkcal/calendarlocal.h b/libkcal/calendarlocal.h
index a7a85c8..ca0bd98 100644
--- a/libkcal/calendarlocal.h
+++ b/libkcal/calendarlocal.h
@@ -140,91 +140,92 @@ class CalendarLocal : public Calendar
*/
Journal *journal( const QString &uid );
/**
Return list of all Journals stored in calendar.
*/
QPtrList<Journal> journals();
/**
Return all alarms, which ocur in the given time interval.
*/
Alarm::List alarms( const QDateTime &from, const QDateTime &to );
/**
Return all alarms, which ocur before given date.
*/
Alarm::List alarmsTo( const QDateTime &to );
QDateTime nextAlarm( int daysTo ) ;
QDateTime nextAlarmEventDateTime() const;
void checkAlarmForIncidence( Incidence *, bool deleted ) ;
void registerAlarm();
void deRegisterAlarm();
QString getAlarmNotification();
QString nextSummary() const ;
/**
This method should be called whenever a Event is modified directly
via it's pointer. It makes sure that the calendar is internally
consistent.
*/
void update( IncidenceBase *incidence );
/**
Builds and then returns a list of all events that match for the
date specified. useful for dayView, etc. etc.
*/
QPtrList<Event> rawEventsForDate( const QDate &date, bool sorted = false );
/**
Get unfiltered events for date \a qdt.
*/
QPtrList<Event> rawEventsForDate( const QDateTime &qdt );
/**
Get unfiltered events in a range of dates. If inclusive is set to true,
only events are returned, which are completely included in the range.
*/
QPtrList<Event> rawEvents( const QDate &start, const QDate &end,
bool inclusive = false );
Todo *todo( QString, QString );
Event *event( QString, QString );
+ void getIncidenceCount( int calId, int& events, int & todos, int & journals);
public slots:
void setCalendarEnabled( int id, bool enable );
void setAlarmEnabled( int id, bool enable );
void setReadOnly( int id, bool enable );
void setDefaultCalendarEnabledOnly();
void setCalendarRemove( int id );
protected:
// Event* mNextAlarmEvent;
QString mNextSummary;
QString mNextAlarmEventDateTimeString;
QString mLastAlarmNotificationString;
QDateTime mNextAlarmEventDateTime;
QDateTime mNextAlarmDateTime;
void reInitAlarmSettings();
/** Notification function of IncidenceBase::Observer. */
void incidenceUpdated( IncidenceBase *i ) { update( i ); }
/** inserts an event into its "proper place" in the calendar. */
void insertEvent( Event *event );
/** Append alarms of incidence in interval to list of alarms. */
void appendAlarms( Alarm::List &alarms, Incidence *incidence,
const QDateTime &from, const QDateTime &to );
/** Append alarms of recurring events in interval to list of alarms. */
void appendRecurringAlarms( Alarm::List &alarms, Incidence *incidence,
const QDateTime &from, const QDateTime &to );
private:
void init();
QPtrList<Event> mEventList;
QPtrList<Todo> mTodoList;
QPtrList<Journal> mJournalList;
};
}
#endif