summaryrefslogtreecommitdiffstats
path: root/libkcal/calendar.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-09-01 00:37:02 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-09-01 00:37:02 +0000
commitcc29364f06178f8f6b457384f2ec37a042bd9d43 (patch)
tree7c77a3184c698bbf9d98cef09fb1ba8124daceba /libkcal/calendar.cpp
parent4f6c584bacc8c3c694228f36ada3de77a76614a6 (diff)
downloadtdepim-cc29364f06178f8f6b457384f2ec37a042bd9d43.tar.gz
tdepim-cc29364f06178f8f6b457384f2ec37a042bd9d43.zip
* Massive set of changes to bring in all fixes and enhancements from the Enterprise PIM branch
* Ensured that the Trinity changes were applied on top of those enhancements, and any redundancy removed * Added journal read support to the CalDAV resource * Fixed CalDAV resource to use events URL for tasks and journals when separate URL checkbox unchecked git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdepim@1170461 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'libkcal/calendar.cpp')
-rw-r--r--libkcal/calendar.cpp185
1 files changed, 184 insertions, 1 deletions
diff --git a/libkcal/calendar.cpp b/libkcal/calendar.cpp
index c3c3a9e65..711cdc12a 100644
--- a/libkcal/calendar.cpp
+++ b/libkcal/calendar.cpp
@@ -50,6 +50,7 @@ Calendar::Calendar( const TQString &timeZoneId )
void Calendar::init()
{
+ mException = 0;
mNewObserver = false;
mObserversEnabled = true;
@@ -66,9 +67,27 @@ void Calendar::init()
Calendar::~Calendar()
{
+ clearException();
delete mDefaultFilter;
}
+void Calendar::clearException()
+{
+ delete mException;
+ mException = 0;
+}
+
+ErrorFormat *Calendar::exception() const
+{
+ return mException;
+}
+
+void Calendar::setException( ErrorFormat *e )
+{
+ delete mException;
+ mException = e;
+}
+
const Person &Calendar::getOwner() const
{
return mOwner;
@@ -122,6 +141,16 @@ CalFilter *Calendar::filter()
return mFilter;
}
+void Calendar::beginBatchAdding()
+{
+ emit batchAddingBegins();
+}
+
+void Calendar::endBatchAdding()
+{
+ emit batchAddingEnds();
+}
+
TQStringList Calendar::categories()
{
Incidence::List rawInc( rawIncidences() );
@@ -161,7 +190,7 @@ Event::List Calendar::sortEvents( Event::List *eventList,
SortDirection sortDirection )
{
Event::List eventListSorted;
- Event::List tempList, t;
+ Event::List tempList;
Event::List alphaList;
Event::List::Iterator sortIt;
Event::List::Iterator eit;
@@ -177,6 +206,10 @@ Event::List Calendar::sortEvents( Event::List *eventList,
case EventSortStartDate:
alphaList = sortEvents( eventList, EventSortSummary, sortDirection );
for ( eit = alphaList.begin(); eit != alphaList.end(); ++eit ) {
+ if ( (*eit)->doesFloat() ) {
+ tempList.append( *eit );
+ continue;
+ }
sortIt = eventListSorted.begin();
if ( sortDirection == SortDirectionAscending ) {
while ( sortIt != eventListSorted.end() &&
@@ -191,6 +224,14 @@ Event::List Calendar::sortEvents( Event::List *eventList,
}
eventListSorted.insert( sortIt, *eit );
}
+ if ( sortDirection == SortDirectionAscending ) {
+ // Prepend the list of all-day Events
+ tempList += eventListSorted;
+ eventListSorted = tempList;
+ } else {
+ // Append the list of all-day Events
+ eventListSorted += tempList;
+ }
break;
case EventSortEndDate:
@@ -245,7 +286,149 @@ Event::List Calendar::sortEvents( Event::List *eventList,
}
return eventListSorted;
+}
+
+Event::List Calendar::sortEventsForDate( Event::List *eventList,
+ const TQDate &date,
+ EventSortField sortField,
+ SortDirection sortDirection )
+{
+ Event::List eventListSorted;
+ Event::List tempList;
+ Event::List alphaList;
+ Event::List::Iterator sortIt;
+ Event::List::Iterator eit;
+
+ switch( sortField ) {
+ case EventSortStartDate:
+ alphaList = sortEvents( eventList, EventSortSummary, sortDirection );
+ for ( eit = alphaList.begin(); eit != alphaList.end(); ++eit ) {
+ if ( (*eit)->doesFloat() ) {
+ tempList.append( *eit );
+ continue;
+ }
+ sortIt = eventListSorted.begin();
+ if ( sortDirection == SortDirectionAscending ) {
+ while ( sortIt != eventListSorted.end() ) {
+ if ( !(*eit)->doesRecur() ) {
+ if ( (*eit)->dtStart().time() >= (*sortIt)->dtStart().time() ) {
+ ++sortIt;
+ } else {
+ break;
+ }
+ } else {
+ if ( (*eit)->recursOn( date ) ) {
+ if ( (*eit)->dtStart().time() >= (*sortIt)->dtStart().time() ) {
+ ++sortIt;
+ } else {
+ break;
+ }
+ } else {
+ ++sortIt;
+ }
+ }
+ }
+ } else { // descending
+ while ( sortIt != eventListSorted.end() ) {
+ if ( !(*eit)->doesRecur() ) {
+ if ( (*eit)->dtStart().time() < (*sortIt)->dtStart().time() ) {
+ ++sortIt;
+ } else {
+ break;
+ }
+ } else {
+ if ( (*eit)->recursOn( date ) ) {
+ if ( (*eit)->dtStart().time() < (*sortIt)->dtStart().time() ) {
+ ++sortIt;
+ } else {
+ break;
+ }
+ } else {
+ ++sortIt;
+ }
+ }
+ }
+ }
+ eventListSorted.insert( sortIt, *eit );
+ }
+ if ( sortDirection == SortDirectionAscending ) {
+ // Prepend the list of all-day Events
+ tempList += eventListSorted;
+ eventListSorted = tempList;
+ } else {
+ // Append the list of all-day Events
+ eventListSorted += tempList;
+ }
+ break;
+ case EventSortEndDate:
+ alphaList = sortEvents( eventList, EventSortSummary, sortDirection );
+ for ( eit = alphaList.begin(); eit != alphaList.end(); ++eit ) {
+ if ( (*eit)->hasEndDate() ) {
+ sortIt = eventListSorted.begin();
+ if ( sortDirection == SortDirectionAscending ) {
+ while ( sortIt != eventListSorted.end() ) {
+ if ( !(*eit)->doesRecur() ) {
+ if ( (*eit)->dtEnd().time() >= (*sortIt)->dtEnd().time() ) {
+ ++sortIt;
+ } else {
+ break;
+ }
+ } else {
+ if ( (*eit)->recursOn( date ) ) {
+ if ( (*eit)->dtEnd().time() >= (*sortIt)->dtEnd().time() ) {
+ ++sortIt;
+ } else {
+ break;
+ }
+ } else {
+ ++sortIt;
+ }
+ }
+ }
+ } else { // descending
+ while ( sortIt != eventListSorted.end() ) {
+ if ( !(*eit)->doesRecur() ) {
+ if ( (*eit)->dtEnd().time() < (*sortIt)->dtEnd().time() ) {
+ ++sortIt;
+ } else {
+ break;
+ }
+ } else {
+ if ( (*eit)->recursOn( date ) ) {
+ if ( (*eit)->dtEnd().time() < (*sortIt)->dtEnd().time() ) {
+ ++sortIt;
+ } else {
+ break;
+ }
+ } else {
+ ++sortIt;
+ }
+ }
+ }
+ }
+ } else {
+ // Keep a list of the Events without End DateTimes
+ tempList.append( *eit );
+ }
+ eventListSorted.insert( sortIt, *eit );
+ }
+ if ( sortDirection == SortDirectionAscending ) {
+ // Prepend the list of Events without End DateTimes
+ tempList += eventListSorted;
+ eventListSorted = tempList;
+ } else {
+ // Append the list of Events without End DateTimes
+ eventListSorted += tempList;
+ }
+ break;
+
+ default:
+ eventListSorted = sortEvents( eventList, sortField, sortDirection );
+ break;
+ }
+
+ return eventListSorted;
}
Event::List Calendar::events( const TQDate &date,