File indexing completed on 2024-12-01 04:47:50
0001 /* 0002 This file is part of the kolab resource - the implementation of the 0003 Kolab storage format. See www.kolab.org for documentation on this. 0004 0005 SPDX-FileCopyrightText: 2004 Bo Thorsen <bo@sonofthor.dk> 0006 0007 SPDX-License-Identifier: LGPL-2.0-or-later 0008 */ 0009 0010 #pragma once 0011 0012 #include "incidence.h" 0013 0014 #include <KCalendarCore/Event> 0015 0016 class QDomElement; 0017 0018 namespace KolabV2 0019 { 0020 /** 0021 * This class represents an event, and knows how to load/save it 0022 * from/to XML, and from/to a KCalendarCore::Event. 0023 * The instances of this class are temporary, only used to convert 0024 * one to the other. 0025 */ 0026 class Event : public Incidence 0027 { 0028 public: 0029 /// Use this to parse an xml string to a event entry 0030 /// The caller is responsible for deleting the returned event 0031 static KCalendarCore::Event::Ptr fromXml(const QDomDocument &xmlDoc, const QString &tz); 0032 0033 /// Use this to get an xml string describing this event entry 0034 static QString eventToXML(const KCalendarCore::Event::Ptr &, const QString &tz); 0035 0036 /// Create a event object and 0037 explicit Event(const QString &tz, const KCalendarCore::Event::Ptr &event = KCalendarCore::Event::Ptr()); 0038 ~Event() override; 0039 0040 void saveTo(const KCalendarCore::Event::Ptr &event); 0041 0042 QString type() const override 0043 { 0044 return QStringLiteral("Event"); 0045 } 0046 0047 virtual void setTransparency(KCalendarCore::Event::Transparency transparency); 0048 virtual KCalendarCore::Event::Transparency transparency() const; 0049 0050 virtual void setEndDate(const QDateTime &date); 0051 virtual void setEndDate(const QDate &date); 0052 virtual void setEndDate(const QString &date); 0053 virtual QDateTime endDate() const; 0054 0055 // Load the attributes of this class 0056 bool loadAttribute(QDomElement &) override; 0057 0058 // Save the attributes of this class 0059 bool saveAttributes(QDomElement &) const override; 0060 0061 // Load this event by reading the XML file 0062 bool loadXML(const QDomDocument &xml) override; 0063 0064 // Serialize this event to an XML string 0065 QString saveXML() const override; 0066 0067 protected: 0068 // Read all known fields from this ical incidence 0069 void setFields(const KCalendarCore::Event::Ptr &); 0070 0071 KCalendarCore::Event::Transparency mShowTimeAs; 0072 QDateTime mEndDate; 0073 bool mHasEndDate; 0074 }; 0075 }