summaryrefslogtreecommitdiffabout
path: root/libkcal
authorzautrix <zautrix>2005-07-28 10:38:58 (UTC)
committer zautrix <zautrix>2005-07-28 10:38:58 (UTC)
commitfee4c893fe8fd01af1b55c1ccd40213fc18a36b4 (patch) (side-by-side diff)
tree83a3018d54d60e880d441a6f91ef8fe54254aaff /libkcal
parent27ffa2e08ebb38e71f613af3a214750442418e2c (diff)
downloadkdepimpi-fee4c893fe8fd01af1b55c1ccd40213fc18a36b4.zip
kdepimpi-fee4c893fe8fd01af1b55c1ccd40213fc18a36b4.tar.gz
kdepimpi-fee4c893fe8fd01af1b55c1ccd40213fc18a36b4.tar.bz2
fixxxx
Diffstat (limited to 'libkcal') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/alarm.cpp2
-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, 52 insertions, 2 deletions
diff --git a/libkcal/alarm.cpp b/libkcal/alarm.cpp
index 79e0464..3157214 100644
--- a/libkcal/alarm.cpp
+++ b/libkcal/alarm.cpp
@@ -352,3 +352,3 @@ int Alarm::offset()
}
-QString Alarm::offsetText()
+QString Alarm::offsetText()
{
diff --git a/libkcal/event.cpp b/libkcal/event.cpp
index 0766fd9..fdf5657 100644
--- a/libkcal/event.cpp
+++ b/libkcal/event.cpp
@@ -416 +416,9 @@ QDateTime Event::getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_
}
+
+QString Event::durationText()
+{
+ int sec = mDtStart.secsTo( mDtEnd );
+ if ( doesFloat() )
+ sec += 86400;
+ return durationText4Time( sec );
+}
diff --git a/libkcal/event.h b/libkcal/event.h
index 2da9770..6a58618 100644
--- a/libkcal/event.h
+++ b/libkcal/event.h
@@ -78,2 +78,3 @@ class Event : public Incidence
bool isOverlapping ( Event*, QDateTime*, QDateTime* );
+ QString durationText();
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp
index 4643a3a..201f593 100644
--- a/libkcal/incidence.cpp
+++ b/libkcal/incidence.cpp
@@ -102,3 +102,32 @@ Incidence::~Incidence()
}
+QString Incidence::durationText()
+{
+ return "---";
+}
+QString Incidence::durationText4Time( int offset )
+{
+ int min = offset/60;
+ int hours = min /60;
+ min = min % 60;
+ int days = hours /24;
+ hours = hours % 24;
+
+ if ( doesFloat() || ( min == 0 && hours == 0 ) ) {
+ if ( days == 1 )
+ return "1" + i18n(" day");
+ else
+ return QString::number( days )+ i18n(" days");
+ }
+ QString message = QString::number ( hours ) +":";
+ if ( min < 10 ) message += "0";
+ message += QString::number ( min );
+ if ( days > 0 ) {
+ if ( days == 1 )
+ message = "1" + i18n(" day") + " "+message;
+ else
+ message = QString::number( days )+ i18n(" days") + " "+message;
+ }
+ return message;
+}
bool Incidence::isHoliday() const
diff --git a/libkcal/incidence.h b/libkcal/incidence.h
index 8519f01..88df217 100644
--- a/libkcal/incidence.h
+++ b/libkcal/incidence.h
@@ -283,3 +283,4 @@ class Incidence : public IncidenceBase
-
+ virtual QString durationText();
+ QString durationText4Time( int secs );
Recurrence *mRecurrence;
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp
index 7bf756a..e4508a0 100644
--- a/libkcal/todo.cpp
+++ b/libkcal/todo.cpp
@@ -616 +616,11 @@ void Todo::checkSetCompletedFalse()
}
+QString Todo::durationText()
+{
+ if ( mHasDueDate && hasStartDate() ) {
+ int sec = dtStart().secsTo( dtDue() );
+ if ( doesFloat() )
+ sec += 86400;
+ return durationText4Time( sec );
+ }
+ return "---";
+}
diff --git a/libkcal/todo.h b/libkcal/todo.h
index 425dfad..7feb32e 100644
--- a/libkcal/todo.h
+++ b/libkcal/todo.h
@@ -132,2 +132,3 @@ namespace KCal {
void saveParents();
+ QString durationText();
private: