File indexing completed on 2024-12-01 04:47:51

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 <KCalendarCore/Journal>
0013 
0014 #include "kolabbase.h"
0015 
0016 class QDomElement;
0017 
0018 namespace KolabV2
0019 {
0020 /**
0021  * This class represents a journal entry, and knows how to load/save it
0022  * from/to XML, and from/to a KCalendarCore::Journal.
0023  * The instances of this class are temporary, only used to convert
0024  * one to the other.
0025  */
0026 class Journal : public KolabBase
0027 {
0028 public:
0029     /// Use this to parse an xml string to a journal entry
0030     /// The caller is responsible for deleting the returned journal
0031     static KCalendarCore::Journal::Ptr fromXml(const QDomDocument &xmlDoc, const QString &tz);
0032 
0033     /// Use this to get an xml string describing this journal entry
0034     static QString journalToXML(const KCalendarCore::Journal::Ptr &, const QString &tz);
0035 
0036     explicit Journal(const QString &tz, const KCalendarCore::Journal::Ptr &journal = KCalendarCore::Journal::Ptr());
0037     ~Journal() override;
0038 
0039     QString type() const override
0040     {
0041         return QStringLiteral("Journal");
0042     }
0043 
0044     void saveTo(const KCalendarCore::Journal::Ptr &journal) const;
0045 
0046     virtual void setSummary(const QString &summary);
0047     virtual QString summary() const;
0048 
0049     virtual void setStartDate(const QDateTime &startDate);
0050     virtual QDateTime startDate() const;
0051 
0052     virtual void setEndDate(const QDateTime &endDate);
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 journal by reading the XML file
0062     bool loadXML(const QDomDocument &xml) override;
0063 
0064     // Serialize this journal to an XML string
0065     QString saveXML() const override;
0066 
0067 protected:
0068     // Read all known fields from this ical journal
0069     void setFields(const KCalendarCore::Journal::Ptr &);
0070 
0071     QString productID() const override;
0072 
0073     QString mSummary;
0074     QDateTime mStartDate;
0075     QDateTime mEndDate;
0076     bool mDateOnly = false;
0077 };
0078 }