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 note, 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 Note : 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 xmlToJournal(const QString &xml);
0032 
0033     /// Use this to get an xml string describing this journal entry
0034     static QString journalToXML(const KCalendarCore::Journal::Ptr &);
0035 
0036     /// Create a note object and
0037     explicit Note(const KCalendarCore::Journal::Ptr &journal = KCalendarCore::Journal::Ptr());
0038     ~Note() override;
0039 
0040     void saveTo(const KCalendarCore::Journal::Ptr &journal) const;
0041 
0042     QString type() const override
0043     {
0044         return QStringLiteral("Note");
0045     }
0046 
0047     virtual void setSummary(const QString &summary);
0048     virtual QString summary() const;
0049 
0050     virtual void setBackgroundColor(const QColor &bgColor);
0051     virtual QColor backgroundColor() const;
0052 
0053     virtual void setForegroundColor(const QColor &fgColor);
0054     virtual QColor foregroundColor() const;
0055 
0056     virtual void setRichText(bool richText);
0057     virtual bool richText() const;
0058 
0059     // Load the attributes of this class
0060     bool loadAttribute(QDomElement &) override;
0061 
0062     // Save the attributes of this class
0063     bool saveAttributes(QDomElement &) const override;
0064 
0065     // Load this note by reading the XML file
0066     bool loadXML(const QDomDocument &xml) override;
0067 
0068     // Serialize this note to an XML string
0069     QString saveXML() const override;
0070 
0071 protected:
0072     // Read all known fields from this ical incidence
0073     void setFields(const KCalendarCore::Journal::Ptr &);
0074 
0075     // Save all known fields into this ical incidence
0076     void saveTo(const KCalendarCore::Incidence::Ptr &) const;
0077 
0078     QString productID() const override;
0079 
0080     QString mSummary;
0081     QColor mBackgroundColor;
0082     QColor mForegroundColor;
0083     bool mRichText = false;
0084 };
0085 }