summaryrefslogtreecommitdiffabout
path: root/libkcal/freebusy.cpp
Unidiff
Diffstat (limited to 'libkcal/freebusy.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/freebusy.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/libkcal/freebusy.cpp b/libkcal/freebusy.cpp
index ba15d6d..e4e9ec9 100644
--- a/libkcal/freebusy.cpp
+++ b/libkcal/freebusy.cpp
@@ -12,47 +12,50 @@
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21#include <kdebug.h> 21#include <kdebug.h>
22 22
23#include "freebusy.h" 23#include "freebusy.h"
24//Added by qt3to4:
25#include <Q3ValueList>
26#include <Q3PtrList>
24 27
25using namespace KCal; 28using namespace KCal;
26 29
27FreeBusy::FreeBusy() 30FreeBusy::FreeBusy()
28{ 31{
29} 32}
30 33
31FreeBusy::FreeBusy(const QDateTime &start, const QDateTime &end) 34FreeBusy::FreeBusy(const QDateTime &start, const QDateTime &end)
32{ 35{
33 setDtStart(start); 36 setDtStart(start);
34 setDtEnd(end); 37 setDtEnd(end);
35} 38}
36 39
37FreeBusy::FreeBusy( Calendar *calendar, const QDateTime &start, const QDateTime &end ) 40FreeBusy::FreeBusy( Calendar *calendar, const QDateTime &start, const QDateTime &end )
38{ 41{
39 kdDebug() << "FreeBusy::FreeBusy" << endl; 42 kdDebug() << "FreeBusy::FreeBusy" << endl;
40 mCalendar = calendar; 43 mCalendar = calendar;
41 44
42 setDtStart(start); 45 setDtStart(start);
43 setDtEnd(end); 46 setDtEnd(end);
44 47
45 //Gets all the events in the calendar 48 //Gets all the events in the calendar
46 QPtrList<Event> eventList = mCalendar->events(); 49 Q3PtrList<Event> eventList = mCalendar->events();
47 Event *event; 50 Event *event;
48 51
49 int extraDays, i, x, duration; 52 int extraDays, i, x, duration;
50 duration = start.daysTo(end); 53 duration = start.daysTo(end);
51 QDate day; 54 QDate day;
52 QDateTime tmpStart; 55 QDateTime tmpStart;
53 QDateTime tmpEnd; 56 QDateTime tmpEnd;
54 //Loops through every event in the calendar 57 //Loops through every event in the calendar
55 for( event = eventList.first(); event; event = eventList.next() ) { 58 for( event = eventList.first(); event; event = eventList.next() ) {
56 //This whole for loop is for recurring events, it loops through 59 //This whole for loop is for recurring events, it loops through
57 //each of the days of the freebusy request 60 //each of the days of the freebusy request
58 61
@@ -104,25 +107,25 @@ FreeBusy::~FreeBusy()
104 107
105bool FreeBusy::setDtEnd( const QDateTime &end ) 108bool FreeBusy::setDtEnd( const QDateTime &end )
106{ 109{
107 mDtEnd = end; 110 mDtEnd = end;
108 return true; 111 return true;
109} 112}
110 113
111QDateTime FreeBusy::dtEnd() const 114QDateTime FreeBusy::dtEnd() const
112{ 115{
113 return mDtEnd; 116 return mDtEnd;
114} 117}
115 118
116QValueList<Period> FreeBusy::busyPeriods() const 119Q3ValueList<Period> FreeBusy::busyPeriods() const
117{ 120{
118 return mBusyPeriods; 121 return mBusyPeriods;
119} 122}
120 123
121bool FreeBusy::addLocalPeriod(const QDateTime &eventStart, const QDateTime &eventEnd ) { 124bool FreeBusy::addLocalPeriod(const QDateTime &eventStart, const QDateTime &eventEnd ) {
122 QDateTime tmpStart; 125 QDateTime tmpStart;
123 QDateTime tmpEnd; 126 QDateTime tmpEnd;
124 127
125 //Check to see if the start *or* end of the event is 128 //Check to see if the start *or* end of the event is
126 //between the start and end of the freebusy dates. 129 //between the start and end of the freebusy dates.
127 if (!((((this->dtStart()).secsTo(eventStart)>=0)&&(eventStart.secsTo(this->dtEnd())>=0)) 130 if (!((((this->dtStart()).secsTo(eventStart)>=0)&&(eventStart.secsTo(this->dtEnd())>=0))
128 ||(((this->dtStart()).secsTo(eventEnd) >= 0)&&(eventEnd.secsTo(this->dtEnd()) >= 0)))) 131 ||(((this->dtStart()).secsTo(eventEnd) >= 0)&&(eventEnd.secsTo(this->dtEnd()) >= 0))))
@@ -137,32 +140,32 @@ bool FreeBusy::addLocalPeriod(const QDateTime &eventStart, const QDateTime &even
137 if ( eventEnd.secsTo(this->dtEnd())<=0 ) { 140 if ( eventEnd.secsTo(this->dtEnd())<=0 ) {
138 tmpEnd = this->dtEnd(); 141 tmpEnd = this->dtEnd();
139 } else { 142 } else {
140 tmpEnd = eventEnd; 143 tmpEnd = eventEnd;
141 } 144 }
142 145
143 Period p(tmpStart, tmpEnd); 146 Period p(tmpStart, tmpEnd);
144 mBusyPeriods.append( p ); 147 mBusyPeriods.append( p );
145 148
146 return true; 149 return true;
147} 150}
148 151
149FreeBusy::FreeBusy(QValueList<Period> busyPeriods) 152FreeBusy::FreeBusy(Q3ValueList<Period> busyPeriods)
150{ 153{
151 mBusyPeriods = busyPeriods; 154 mBusyPeriods = busyPeriods;
152} 155}
153 156
154void FreeBusy::sortList() 157void FreeBusy::sortList()
155{ 158{
156 typedef QValueList<Period> PeriodList; 159 typedef Q3ValueList<Period> PeriodList;
157 160
158 PeriodList::Iterator tmpPeriod, earlyPeriod; 161 PeriodList::Iterator tmpPeriod, earlyPeriod;
159 PeriodList sortedList; 162 PeriodList sortedList;
160 QDateTime earlyTime; 163 QDateTime earlyTime;
161 164
162 while( mBusyPeriods.count() > 0 ) { 165 while( mBusyPeriods.count() > 0 ) {
163 earlyTime=(*mBusyPeriods.begin()).start(); 166 earlyTime=(*mBusyPeriods.begin()).start();
164 for (tmpPeriod=mBusyPeriods.begin(); tmpPeriod!=mBusyPeriods.end(); tmpPeriod++) { 167 for (tmpPeriod=mBusyPeriods.begin(); tmpPeriod!=mBusyPeriods.end(); tmpPeriod++) {
165 if (earlyTime.secsTo((*tmpPeriod).start()) <= 0) { 168 if (earlyTime.secsTo((*tmpPeriod).start()) <= 0) {
166 earlyTime=(*tmpPeriod).start(); 169 earlyTime=(*tmpPeriod).start();
167 earlyPeriod=tmpPeriod; 170 earlyPeriod=tmpPeriod;
168 } 171 }