summaryrefslogtreecommitdiffabout
path: root/libkcal
Side-by-side diff
Diffstat (limited to 'libkcal') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/calendarlocal.cpp55
-rw-r--r--libkcal/calfilter.cpp12
-rw-r--r--libkcal/incidence.cpp5
-rw-r--r--libkcal/incidence.h1
4 files changed, 49 insertions, 24 deletions
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp
index 749d9f6..336c3e8 100644
--- a/libkcal/calendarlocal.cpp
+++ b/libkcal/calendarlocal.cpp
@@ -204,58 +204,62 @@ 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 )
{
if ( mUndoIncidence ) delete mUndoIncidence;
mUndoIncidence = event->clone();
if ( mEventList.removeRef( event ) ) {
setModified( true );
}
}
Event *CalendarLocal::event( const QString &uid )
{
-
- Event *event;
-
- for ( event = mEventList.first(); event; event = mEventList.next() ) {
- if ( event->uid() == uid && event->calEnabled() ) {
- return event;
+ Event *event;
+ Event *retVal = 0;
+ for ( event = mEventList.first(); event; event = mEventList.next() ) {
+ if ( event->calEnabled() && event->uid() == uid ) {
+ if ( retVal ) {
+ if ( retVal->calID() > event->calID() ) {
+ retVal = event;
+ }
+ } else {
+ retVal = event;
+ }
+ }
}
- }
-
- return 0;
+ return retVal;
}
bool CalendarLocal::addTodoNoDup( Todo *todo )
{
Todo * eve;
for ( eve = mTodoList.first(); eve ; eve = mTodoList.next() ) {
if ( *eve == *todo ) {
//qDebug("duplicate todo found! not inserted! ");
return false;
}
}
return addTodo( todo );
}
bool CalendarLocal::addTodo( Todo *todo )
{
mTodoList.append( todo );
todo->registerObserver( this );
// Set up subtask relations
setupRelations( todo );
setModified( true );
todo->setCalID( mDefaultCalendar );
todo->setCalEnabled( true );
@@ -316,54 +320,62 @@ void CalendarLocal::removeSyncInfo( QString syncProfile)
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 ) return todo;
+ if ( todo->calEnabled() && todo->uid() == uid ) {
+ if ( retVal ) {
+ if ( retVal->calID() > todo->calID() ) {
+ retVal = todo;
+ }
+ } else {
+ retVal = todo;
+ }
+ }
}
-
- return 0;
+ return retVal;
}
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;
@@ -765,53 +777,60 @@ bool CalendarLocal::addJournal(Journal *journal)
void CalendarLocal::deleteJournal( Journal *journal )
{
if ( mUndoIncidence ) delete mUndoIncidence;
mUndoIncidence = journal->clone();
mUndoIncidence->setSummary( mUndoIncidence->description().left(25));
if ( mJournalList.removeRef(journal) ) {
setModified( true );
}
}
Journal *CalendarLocal::journal( const QDate &date )
{
// kdDebug(5800) << "CalendarLocal::journal() " << date.toString() << endl;
for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
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->calEnabled() && it->uid() == uid )
- return it;
-
- return 0;
+ Journal * retVal = 0;
+ for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
+ if ( it->calEnabled() && it->uid() == uid ) {
+ if ( retVal ) {
+ if ( retVal->calID() > it->calID() ) {
+ retVal = it;
+ }
+ } else {
+ retVal = it;
+ }
+ }
+ return retVal;
}
QPtrList<Journal> CalendarLocal::journals()
{
QPtrList<Journal> el;
for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
if ( it->calEnabled() ) el.append( it );
return el;
}
void CalendarLocal::setCalendarRemove( int id )
{
{
QPtrList<Event> EventList = mEventList;
Event * ev = EventList.first();
while ( ev ) {
if ( ev->calID() == id )
deleteEvent( ev );
ev = EventList.next();
}
}
{
QPtrList<Todo> TodoList = mTodoList;
diff --git a/libkcal/calfilter.cpp b/libkcal/calfilter.cpp
index 3510c7d..72f70c2 100644
--- a/libkcal/calfilter.cpp
+++ b/libkcal/calfilter.cpp
@@ -141,63 +141,63 @@ bool CalFilter::filterIncidence(Incidence *incidence)
switch (incidence->secrecy()) {
case Incidence::SecrecyPublic:
if (! (mCriteria & ShowPublic ))
return false;
break;
case Incidence::SecrecyPrivate:
if (! (mCriteria & ShowPrivate ))
return false;
break;
case Incidence::SecrecyConfidential:
if (! (mCriteria & ShowConfidential ))
return false;
break;
default:
return false;
break;
}
}
// kdDebug(5800) << "CalFilter::filterEvent(): " << event->getSummary() << endl;
if (mCriteria & ShowCategories) {
for (QStringList::Iterator it = mCategoryList.begin();
it != mCategoryList.end(); ++it ) {
- QStringList incidenceCategories = incidence->categories();
- for (QStringList::Iterator it2 = incidenceCategories.begin();
- it2 != incidenceCategories.end(); ++it2 ) {
+ //QStringList incidenceCategories = incidence->categories();
+ for (QStringList::Iterator it2 = incidence->categoriesP()->begin();
+ it2 != incidence->categoriesP()->end(); ++it2 ) {
if ((*it) == (*it2)) {
return true;
}
}
}
return false;
} else {
for (QStringList::Iterator it = mCategoryList.begin();
it != mCategoryList.end(); ++it ) {
- QStringList incidenceCategories = incidence->categories();
- for (QStringList::Iterator it2 = incidenceCategories.begin();
- it2 != incidenceCategories.end(); ++it2 ) {
+ //QStringList incidenceCategories = incidence->categories();
+ for (QStringList::Iterator it2 = incidence->categoriesP()->begin();
+ it2 != incidence->categoriesP()->end(); ++it2 ) {
if ((*it) == (*it2)) {
return false;
}
}
}
return true;
}
// kdDebug(5800) << "CalFilter::filterEvent(): passed" << endl;
return true;
}
void CalFilter::setEnabled(bool enabled)
{
mEnabled = enabled;
}
bool CalFilter::isEnabled()
{
return mEnabled;
}
void CalFilter::setCriteria(int criteria)
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp
index 4382416..11f7ecc 100644
--- a/libkcal/incidence.cpp
+++ b/libkcal/incidence.cpp
@@ -375,48 +375,53 @@ void Incidence::setCategories(const QStringList &categories, bool setForRelation
QPtrList<Incidence> Relations = relations();
for (inc=Relations.first();inc;inc=Relations.next()) {
inc->setCategories( categories, true );
}
}
}
// TODO: remove setCategories(QString) function
void Incidence::setCategories(const QString &catStr)
{
if (mReadOnly) return;
mCategories.clear();
if (catStr.isEmpty()) return;
mCategories = QStringList::split(",",catStr);
QStringList::Iterator it;
for(it = mCategories.begin();it != mCategories.end(); ++it) {
*it = (*it).stripWhiteSpace();
}
checkCategories();
updated();
}
+// using this makes filtering 3 times faster
+QStringList* Incidence::categoriesP()
+{
+ return &mCategories;
+}
QStringList Incidence::categories() const
{
return mCategories;
}
QString Incidence::categoriesStr()
{
return mCategories.join(",");
}
QString Incidence::categoriesStrWithSpace()
{
return mCategories.join(", ");
}
void Incidence::setRelatedToUid(const QString &relatedToUid)
{
if (mReadOnly) return;
mRelatedToUid = relatedToUid;
}
QString Incidence::relatedToUid() const
{
return mRelatedToUid;
diff --git a/libkcal/incidence.h b/libkcal/incidence.h
index fc97ce9..c88ba2f 100644
--- a/libkcal/incidence.h
+++ b/libkcal/incidence.h
@@ -136,48 +136,49 @@ class Incidence : public IncidenceBase
int revision() const;
/** Set starting date/time. */
virtual void setDtStart(const QDateTime &dtStart);
/** Return the incidence's ending date/time as a QDateTime. */
virtual QDateTime dtEnd() const { return QDateTime(); }
/** sets the event's lengthy description. */
void setDescription(const QString &description);
/** returns a reference to the event's description. */
QString description() const;
/** sets the event's short summary. */
void setSummary(const QString &summary);
/** returns a reference to the event's summary. */
QString summary() const;
/** set event's applicable categories */
void setCategories(const QStringList &categories, bool setForRelations = false);
void addCategories(const QStringList &categories, bool addToRelations = false);
/** set event's categories based on a comma delimited string */
void setCategories(const QString &catStr);
/** return categories in a list */
QStringList categories() const;
+ QStringList* categoriesP();
/** return categories as a comma separated string */
QString categoriesStr();
QString categoriesStrWithSpace();
/** point at some other event to which the event relates. This function should
* only be used when constructing a calendar before the related Event
* exists. */
void setRelatedToUid(const QString &);
/** what event does this one relate to? This function should
* only be used when constructing a calendar before the related Event
* exists. */
QString relatedToUid() const;
/** point at some other event to which the event relates */
void setRelatedTo(Incidence *relatedTo);
/** what event does this one relate to? */
Incidence *relatedTo() const;
/** All events that are related to this event */
QPtrList<Incidence> relations() const;
/** Add an event which is related to this event */
void addRelation(Incidence *);
/** Remove event that is related to this event */
void removeRelation(Incidence *);
/** returns the list of dates which are exceptions to the recurrence rule */