summaryrefslogtreecommitdiff
path: root/kolabformatV2/incidence.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <mollekopf@kolabsys.com>2013-09-23 14:07:38 (GMT)
committerChristian Mollekopf <mollekopf@kolabsys.com>2013-09-23 14:07:38 (GMT)
commit518d3d901352f8000846ac262870a8c3097ac27a (patch)
treec84d4ad3a3c36694d468c8ff24146224956106dd /kolabformatV2/incidence.cpp
parent6f5997417a8c2eed2886a8cc8869374ac4c70c46 (diff)
downloadlibkolab-518d3d901352f8000846ac262870a8c3097ac27a.tar.gz
Implemented KEP:8 in kolabv2 format (priorities).
Diffstat (limited to 'kolabformatV2/incidence.cpp')
-rw-r--r--kolabformatV2/incidence.cpp41
1 files changed, 37 insertions, 4 deletions
diff --git a/kolabformatV2/incidence.cpp b/kolabformatV2/incidence.cpp
index f627334..9f0e381 100644
--- a/kolabformatV2/incidence.cpp
+++ b/kolabformatV2/incidence.cpp
@@ -44,9 +44,8 @@
using namespace KolabV2;
-
Incidence::Incidence( const QString& tz, const KCalCore::Incidence::Ptr &incidence )
- : KolabBase( tz ), mFloatingStatus( Unset ), mHasAlarm( false )
+ : KolabBase( tz ), mFloatingStatus( Unset ), mHasAlarm( false ), mPriority( 0 )
{
Q_UNUSED( incidence );
}
@@ -55,6 +54,16 @@ Incidence::~Incidence()
{
}
+void Incidence::setPriority( int priority )
+{
+ mPriority = priority;
+}
+
+int Incidence::priority() const
+{
+ return mPriority;
+}
+
void Incidence::setSummary( const QString& summary )
{
mSummary = summary;
@@ -472,7 +481,25 @@ bool Incidence::loadAttribute( QDomElement& element )
{
QString tagName = element.tagName();
- if ( tagName == "summary" )
+ if ( tagName == "priority" ) {
+ bool ok;
+ int p = element.text().toInt( &ok );
+ if ( !ok || p < 1 || p > 9 ) {
+ kWarning() << "Invalid \"priority\" value:" << element.text();
+ } else {
+ setPriority( p );
+ }
+ } else if ( tagName == "x-kcal-priority" ) { //for backwards compat
+ bool ok;
+ int p = element.text().toInt( &ok );
+ if ( !ok || p < 0 || p > 9 ) {
+ kWarning() << "Invalid \"x-kcal-priority\" value:" << element.text();
+ } else {
+ if ( priority() == 0 ) {
+ setPriority(p);
+ }
+ }
+ } else if ( tagName == "summary" )
setSummary( element.text() );
else if ( tagName == "location" )
setLocation( element.text() );
@@ -527,6 +554,10 @@ bool Incidence::saveAttributes( QDomElement& element ) const
// Save the base class elements
KolabBase::saveAttributes( element );
+ if (priority() != 0) {
+ writeString( element, "priority", QString::number( priority() ) );
+ }
+
if ( mFloatingStatus == HasTime )
writeString( element, "start-date", dateTimeToString( startDate() ) );
else
@@ -747,6 +778,7 @@ void Incidence::setFields( const KCalCore::Incidence::Ptr &incidence )
{
KolabBase::setFields( incidence );
+ setPriority( incidence->priority() );
if ( incidence->allDay() ) {
// This is a all-day event. Don't timezone move this one
mFloatingStatus = AllDay;
@@ -857,6 +889,7 @@ void Incidence::saveTo( const KCalCore::Incidence::Ptr &incidence )
{
KolabBase::saveTo( incidence );
+ incidence->setPriority( priority() );
if ( mFloatingStatus == AllDay ) {
// This is an all-day event. Don't timezone move this one
incidence->setDtStart( startDate() );
@@ -972,6 +1005,6 @@ QString Incidence::productID() const
}
// Unhandled KCalCore::Incidence fields:
-// revision, status (unused), priority (done in tasks), attendee.uid,
+// revision, status (unused), attendee.uid,
// mComments, mReadOnly