summaryrefslogtreecommitdiffabout
path: root/libkcal
Unidiff
Diffstat (limited to 'libkcal') (more/less context) (show whitespace changes)
-rw-r--r--libkcal/alarm.cpp0
-rw-r--r--libkcal/event.cpp8
-rw-r--r--libkcal/event.h1
-rw-r--r--libkcal/incidence.cpp29
-rw-r--r--libkcal/incidence.h3
-rw-r--r--libkcal/todo.cpp10
-rw-r--r--libkcal/todo.h1
7 files changed, 51 insertions, 1 deletions
diff --git a/libkcal/alarm.cpp b/libkcal/alarm.cpp
index 79e0464..3157214 100644
--- a/libkcal/alarm.cpp
+++ b/libkcal/alarm.cpp
diff --git a/libkcal/event.cpp b/libkcal/event.cpp
index 0766fd9..fdf5657 100644
--- a/libkcal/event.cpp
+++ b/libkcal/event.cpp
@@ -393,24 +393,32 @@ QDateTime Event::getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_
393 off = alarmStart.secsTo( incidenceStart ); 393 off = alarmStart.secsTo( incidenceStart );
394 } 394 }
395 395
396 } else { 396 } else {
397 int secs = alarm->startOffset().asSeconds(); 397 int secs = alarm->startOffset().asSeconds();
398 if ( incidenceStart.addSecs( secs ) < alarmStart ) { 398 if ( incidenceStart.addSecs( secs ) < alarmStart ) {
399 alarmStart = incidenceStart.addSecs( secs ); 399 alarmStart = incidenceStart.addSecs( secs );
400 enabled = true; 400 enabled = true;
401 off = -secs; 401 off = -secs;
402 } 402 }
403 } 403 }
404 } 404 }
405 } 405 }
406 if ( enabled ) { 406 if ( enabled ) {
407 if ( alarmStart > start_dt ) { 407 if ( alarmStart > start_dt ) {
408 *ok = true; 408 *ok = true;
409 * offset = off; 409 * offset = off;
410 return alarmStart; 410 return alarmStart;
411 } 411 }
412 } 412 }
413 *ok = false; 413 *ok = false;
414 return QDateTime (); 414 return QDateTime ();
415 415
416} 416}
417
418QString Event::durationText()
419{
420 int sec = mDtStart.secsTo( mDtEnd );
421 if ( doesFloat() )
422 sec += 86400;
423 return durationText4Time( sec );
424}
diff --git a/libkcal/event.h b/libkcal/event.h
index 2da9770..6a58618 100644
--- a/libkcal/event.h
+++ b/libkcal/event.h
@@ -55,40 +55,41 @@ class Event : public Incidence
55 QString dtEndTimeStr() const; 55 QString dtEndTimeStr() const;
56 /** returns an event's end date as a string formatted according to the 56 /** returns an event's end date as a string formatted according to the
57 users locale settings */ 57 users locale settings */
58 QString dtEndDateStr(bool shortfmt=true) const; 58 QString dtEndDateStr(bool shortfmt=true) const;
59 /** returns an event's end date and time as a string formatted according 59 /** returns an event's end date and time as a string formatted according
60 to the users locale settings */ 60 to the users locale settings */
61 QString dtEndStr(bool shortfmt=true) const; 61 QString dtEndStr(bool shortfmt=true) const;
62 void setHasEndDate(bool); 62 void setHasEndDate(bool);
63 /** Return whether the event has an end date/time. */ 63 /** Return whether the event has an end date/time. */
64 bool hasEndDate() const; 64 bool hasEndDate() const;
65 65
66 /** Return true if the event spans multiple days, otherwise return false. */ 66 /** Return true if the event spans multiple days, otherwise return false. */
67 bool isMultiDay() const; 67 bool isMultiDay() const;
68 68
69 /** set the event's time transparency level. */ 69 /** set the event's time transparency level. */
70 void setTransparency(Transparency transparency); 70 void setTransparency(Transparency transparency);
71 /** get the event's time transparency level. */ 71 /** get the event's time transparency level. */
72 Transparency transparency() const; 72 Transparency transparency() const;
73 73
74 void setDuration(int seconds); 74 void setDuration(int seconds);
75 75
76 bool contains ( Event*); 76 bool contains ( Event*);
77 77
78 bool isOverlapping ( Event*, QDateTime*, QDateTime* ); 78 bool isOverlapping ( Event*, QDateTime*, QDateTime* );
79 QString durationText();
79 80
80 private: 81 private:
81 bool accept(Visitor &v) { return v.visit(this); } 82 bool accept(Visitor &v) { return v.visit(this); }
82 83
83 QDateTime mDtEnd; 84 QDateTime mDtEnd;
84 bool mHasEndDate; 85 bool mHasEndDate;
85 Transparency mTransparency; 86 Transparency mTransparency;
86}; 87};
87 88
88bool operator==( const Event&, const Event& ); 89bool operator==( const Event&, const Event& );
89 90
90 91
91} 92}
92 93
93 94
94#endif 95#endif
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp
index 4643a3a..201f593 100644
--- a/libkcal/incidence.cpp
+++ b/libkcal/incidence.cpp
@@ -79,49 +79,78 @@ Incidence::Incidence( const Incidence &i ) : IncidenceBase( i )
79 mHasRecurrenceID = i.mHasRecurrenceID; 79 mHasRecurrenceID = i.mHasRecurrenceID;
80 mRecurrenceID = i.mRecurrenceID; 80 mRecurrenceID = i.mRecurrenceID;
81 if ( i.mRecurrence ) 81 if ( i.mRecurrence )
82 mRecurrence = new Recurrence( *(i.mRecurrence), this ); 82 mRecurrence = new Recurrence( *(i.mRecurrence), this );
83 else 83 else
84 mRecurrence = 0; 84 mRecurrence = 0;
85 mHoliday = i.mHoliday ; 85 mHoliday = i.mHoliday ;
86 mBirthday = i.mBirthday; 86 mBirthday = i.mBirthday;
87 mAnniversary = i.mAnniversary; 87 mAnniversary = i.mAnniversary;
88} 88}
89 89
90Incidence::~Incidence() 90Incidence::~Incidence()
91{ 91{
92 92
93 Incidence *ev; 93 Incidence *ev;
94 QPtrList<Incidence> Relations = relations(); 94 QPtrList<Incidence> Relations = relations();
95 for (ev=Relations.first();ev;ev=Relations.next()) { 95 for (ev=Relations.first();ev;ev=Relations.next()) {
96 if (ev->relatedTo() == this) ev->setRelatedTo(0); 96 if (ev->relatedTo() == this) ev->setRelatedTo(0);
97 } 97 }
98 if (relatedTo()) relatedTo()->removeRelation(this); 98 if (relatedTo()) relatedTo()->removeRelation(this);
99 if ( mRecurrence ) 99 if ( mRecurrence )
100 delete mRecurrence; 100 delete mRecurrence;
101 101
102} 102}
103QString Incidence::durationText()
104{
105 return "---";
106}
107QString Incidence::durationText4Time( int offset )
108{
109 int min = offset/60;
110 int hours = min /60;
111 min = min % 60;
112 int days = hours /24;
113 hours = hours % 24;
114
115 if ( doesFloat() || ( min == 0 && hours == 0 ) ) {
116 if ( days == 1 )
117 return "1" + i18n(" day");
118 else
119 return QString::number( days )+ i18n(" days");
103 120
121 }
122 QString message = QString::number ( hours ) +":";
123 if ( min < 10 ) message += "0";
124 message += QString::number ( min );
125 if ( days > 0 ) {
126 if ( days == 1 )
127 message = "1" + i18n(" day") + " "+message;
128 else
129 message = QString::number( days )+ i18n(" days") + " "+message;
130 }
131 return message;
132}
104bool Incidence::isHoliday() const 133bool Incidence::isHoliday() const
105{ 134{
106 return mHoliday; 135 return mHoliday;
107} 136}
108bool Incidence::isBirthday() const 137bool Incidence::isBirthday() const
109{ 138{
110 139
111 return mBirthday ; 140 return mBirthday ;
112} 141}
113bool Incidence::isAnniversary() const 142bool Incidence::isAnniversary() const
114{ 143{
115 return mAnniversary ; 144 return mAnniversary ;
116 145
117} 146}
118 147
119bool Incidence::hasRecurrenceID() const 148bool Incidence::hasRecurrenceID() const
120{ 149{
121 return mHasRecurrenceID; 150 return mHasRecurrenceID;
122} 151}
123 152
124void Incidence::setHasRecurrenceID( bool b ) 153void Incidence::setHasRecurrenceID( bool b )
125{ 154{
126 mHasRecurrenceID = b; 155 mHasRecurrenceID = b;
127} 156}
diff --git a/libkcal/incidence.h b/libkcal/incidence.h
index 8519f01..88df217 100644
--- a/libkcal/incidence.h
+++ b/libkcal/incidence.h
@@ -260,49 +260,50 @@ class Incidence : public IncidenceBase
260 void setLocation(const QString &location); 260 void setLocation(const QString &location);
261 /** return the event's/todo's location. Do _not_ use it with journal */ 261 /** return the event's/todo's location. Do _not_ use it with journal */
262 QString location() const; 262 QString location() const;
263 /** returns TRUE or FALSE depending on whether the todo has a start date */ 263 /** returns TRUE or FALSE depending on whether the todo has a start date */
264 bool hasStartDate() const; 264 bool hasStartDate() const;
265 /** sets the event's hasStartDate value. */ 265 /** sets the event's hasStartDate value. */
266 void setHasStartDate(bool f); 266 void setHasStartDate(bool f);
267 QDateTime getNextOccurence( const QDateTime& dt, bool* yes ) const; 267 QDateTime getNextOccurence( const QDateTime& dt, bool* yes ) const;
268 bool cancelled() const; 268 bool cancelled() const;
269 void setCancelled( bool b ); 269 void setCancelled( bool b );
270 270
271 bool hasRecurrenceID() const; 271 bool hasRecurrenceID() const;
272 void setHasRecurrenceID( bool b ); 272 void setHasRecurrenceID( bool b );
273 273
274 void setRecurrenceID(QDateTime); 274 void setRecurrenceID(QDateTime);
275 QDateTime recurrenceID () const; 275 QDateTime recurrenceID () const;
276 QDateTime dtStart() const; 276 QDateTime dtStart() const;
277 bool isHoliday() const; 277 bool isHoliday() const;
278 bool isBirthday() const; 278 bool isBirthday() const;
279 bool isAnniversary() const; 279 bool isAnniversary() const;
280 QDateTime lastModifiedSub(); 280 QDateTime lastModifiedSub();
281 QString recurrenceText() const; 281 QString recurrenceText() const;
282 void setLastModifiedSubInvalid(); 282 void setLastModifiedSubInvalid();
283 283
284 284 virtual QString durationText();
285 QString durationText4Time( int secs );
285 Recurrence *mRecurrence; 286 Recurrence *mRecurrence;
286protected: 287protected:
287 QPtrList<Alarm> mAlarms; 288 QPtrList<Alarm> mAlarms;
288 QPtrList<Incidence> mRelations; 289 QPtrList<Incidence> mRelations;
289 QDateTime mRecurrenceID; 290 QDateTime mRecurrenceID;
290 bool mHasRecurrenceID; 291 bool mHasRecurrenceID;
291 private: 292 private:
292 void checkCategories(); 293 void checkCategories();
293 bool mHoliday, mBirthday, mAnniversary; 294 bool mHoliday, mBirthday, mAnniversary;
294 int mRevision; 295 int mRevision;
295 bool mCancelled; 296 bool mCancelled;
296 297
297 // base components of jounal, event and todo 298 // base components of jounal, event and todo
298 QDateTime mCreated; 299 QDateTime mCreated;
299 QDateTime mLastModifiedSub; 300 QDateTime mLastModifiedSub;
300 QString mDescription; 301 QString mDescription;
301 QString mSummary; 302 QString mSummary;
302 QStringList mCategories; 303 QStringList mCategories;
303 Incidence *mRelatedTo; 304 Incidence *mRelatedTo;
304 QString mRelatedToUid; 305 QString mRelatedToUid;
305 DateList mExDates; 306 DateList mExDates;
306 QPtrList<Attachment> mAttachments; 307 QPtrList<Attachment> mAttachments;
307 QStringList mResources; 308 QStringList mResources;
308 bool mHasStartDate; // if todo has associated start date 309 bool mHasStartDate; // if todo has associated start date
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp
index 7bf756a..e4508a0 100644
--- a/libkcal/todo.cpp
+++ b/libkcal/todo.cpp
@@ -593,24 +593,34 @@ QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_d
593 } 593 }
594 } 594 }
595 *ok = false; 595 *ok = false;
596 return QDateTime (); 596 return QDateTime ();
597 597
598} 598}
599 599
600void Todo::checkSetCompletedFalse() 600void Todo::checkSetCompletedFalse()
601{ 601{
602 if ( !mHasRecurrenceID ) { 602 if ( !mHasRecurrenceID ) {
603 qDebug("ERROR 1 in Todo::checkSetCompletedFalse"); 603 qDebug("ERROR 1 in Todo::checkSetCompletedFalse");
604 return; 604 return;
605 } 605 }
606 // qDebug("Todo::checkSetCompletedFalse()"); 606 // qDebug("Todo::checkSetCompletedFalse()");
607 //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); 607 //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() );
608 if ( mPercentComplete == 100 ) { 608 if ( mPercentComplete == 100 ) {
609 QDateTime dt = QDateTime::currentDateTime(); 609 QDateTime dt = QDateTime::currentDateTime();
610 if ( dt > mDtStart && dt > mRecurrenceID ) { 610 if ( dt > mDtStart && dt > mRecurrenceID ) {
611 qDebug("start: %s --due: %s --recID: %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); 611 qDebug("start: %s --due: %s --recID: %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() );
612 setCompleted( false ); 612 setCompleted( false );
613 qDebug("Todo::checkSetCompletedFalse "); 613 qDebug("Todo::checkSetCompletedFalse ");
614 } 614 }
615 } 615 }
616} 616}
617QString Todo::durationText()
618{
619 if ( mHasDueDate && hasStartDate() ) {
620 int sec = dtStart().secsTo( dtDue() );
621 if ( doesFloat() )
622 sec += 86400;
623 return durationText4Time( sec );
624 }
625 return "---";
626}
diff --git a/libkcal/todo.h b/libkcal/todo.h
index 425dfad..7feb32e 100644
--- a/libkcal/todo.h
+++ b/libkcal/todo.h
@@ -109,47 +109,48 @@ namespace KCal {
109 109
110 /** return date and time when todo was completed */ 110 /** return date and time when todo was completed */
111 QDateTime completed() const; 111 QDateTime completed() const;
112 QString completedStr(bool shortF = true) const; 112 QString completedStr(bool shortF = true) const;
113 /** set date and time of completion */ 113 /** set date and time of completion */
114 void setCompleted(const QDateTime &completed); 114 void setCompleted(const QDateTime &completed);
115 115
116 /** Return true, if todo has a date associated with completion */ 116 /** Return true, if todo has a date associated with completion */
117 bool hasCompletedDate() const; 117 bool hasCompletedDate() const;
118 bool contains ( Todo*); 118 bool contains ( Todo*);
119 void checkSetCompletedFalse(); 119 void checkSetCompletedFalse();
120 bool setRecurDates(); 120 bool setRecurDates();
121 bool isRunning() {return mRunning;} 121 bool isRunning() {return mRunning;}
122 bool hasRunningSub(); 122 bool hasRunningSub();
123 void setRunning( bool ); 123 void setRunning( bool );
124 void setRunningFalse( QString ); 124 void setRunningFalse( QString );
125 void stopRunning(); 125 void stopRunning();
126 int runTime(); 126 int runTime();
127 QDateTime runStart () const { return mRunStart;} 127 QDateTime runStart () const { return mRunStart;}
128 void saveRunningInfo( QString comment, QDateTime start, QDateTime end ); 128 void saveRunningInfo( QString comment, QDateTime start, QDateTime end );
129 public slots: 129 public slots:
130 void saveRunningInfoToFile( QString st ); 130 void saveRunningInfoToFile( QString st );
131 void saveRunningInfoToFile( ); 131 void saveRunningInfoToFile( );
132 void saveParents(); 132 void saveParents();
133 QString durationText();
133 private: 134 private:
134 bool mRunning; 135 bool mRunning;
135 QTimer * mRunSaveTimer; 136 QTimer * mRunSaveTimer;
136 QDateTime mRunStart; 137 QDateTime mRunStart;
137 QDateTime mRunEnd; 138 QDateTime mRunEnd;
138 bool accept(Visitor &v) { return v.visit(this); } 139 bool accept(Visitor &v) { return v.visit(this); }
139 140
140 QDateTime mDtDue; // due date of todo 141 QDateTime mDtDue; // due date of todo
141 142
142 bool mHasDueDate; // if todo has associated due date 143 bool mHasDueDate; // if todo has associated due date
143 144
144// int mStatus; // confirmed/delegated/tentative/etc 145// int mStatus; // confirmed/delegated/tentative/etc
145 146
146 QDateTime mCompleted; 147 QDateTime mCompleted;
147 bool mHasCompletedDate; 148 bool mHasCompletedDate;
148 149
149 int mPercentComplete; 150 int mPercentComplete;
150}; 151};
151 152
152 bool operator==( const Todo&, const Todo& ); 153 bool operator==( const Todo&, const Todo& );
153} 154}
154 155
155#endif 156#endif