File indexing completed on 2024-12-22 04:55:36
0001 /* 0002 * collectionattribute.h - Akonadi attribute holding Collection characteristics 0003 * Program: kalarm 0004 * SPDX-FileCopyrightText: 2010-2022 David Jarvie <djarvie@kde.org> 0005 * 0006 * SPDX-License-Identifier: LGPL-2.0-or-later 0007 */ 0008 0009 #pragma once 0010 0011 #include "kalarmcalendar/kacalendar.h" 0012 0013 #include <Akonadi/Attribute> 0014 0015 #include <QColor> 0016 0017 /** 0018 * @short An Attribute for a KAlarm Collection containing various status information. 0019 * 0020 * This class represents an Akonadi attribute of a legacy KAlarm Collection. It 0021 * contains information on the enabled status, the alarm types allowed in the 0022 * resource, which alarm types the resource is the standard Collection for, etc. 0023 * 0024 * This class is only used for migrating from legacy KAlarm Akonadi collections. 0025 * 0026 * @author David Jarvie <djarvie@kde.org> 0027 */ 0028 0029 class CollectionAttribute : public Akonadi::Attribute 0030 { 0031 public: 0032 CollectionAttribute(); 0033 0034 /** Copy constructor. */ 0035 CollectionAttribute(const CollectionAttribute& other); 0036 0037 /** Assignment operator. */ 0038 CollectionAttribute& operator=(const CollectionAttribute& other); 0039 0040 ~CollectionAttribute() override; 0041 0042 /** Comparison operator. */ 0043 bool operator==(const CollectionAttribute& other) const; 0044 bool operator!=(const CollectionAttribute& other) const { return !operator==(other); } 0045 0046 /** Return whether the collection is enabled for a specified alarm type 0047 * (active, archived, template or displaying). 0048 * @param type alarm type to check for. 0049 */ 0050 bool isEnabled(KAlarmCal::CalEvent::Type type) const; 0051 0052 /** Return which alarm types (active, archived or template) the 0053 * collection is enabled for. */ 0054 KAlarmCal::CalEvent::Types enabled() const; 0055 0056 /** Set the enabled/disabled state of the collection and its alarms, 0057 * for a specified alarm type (active, archived or template). The 0058 * enabled/disabled state for other alarm types is not affected. 0059 * The alarms of that type in a disabled collection are ignored, and 0060 * not displayed in the alarm list. The standard status for that type 0061 * for a disabled collection is automatically cleared. 0062 * @param type alarm type 0063 * @param enabled true to set enabled, false to set disabled. 0064 */ 0065 void setEnabled(KAlarmCal::CalEvent::Type type, bool enabled); 0066 0067 /** Set which alarm types (active, archived or template) the collection 0068 * is enabled for. 0069 * @param types alarm types 0070 */ 0071 void setEnabled(KAlarmCal::CalEvent::Types types); 0072 0073 /** Return whether the collection is the standard collection for a specified 0074 * alarm type (active, archived or template). 0075 * @param type alarm type 0076 */ 0077 bool isStandard(KAlarmCal::CalEvent::Type type) const; 0078 0079 /** Set or clear the collection as the standard collection for a specified 0080 * alarm type (active, archived or template). 0081 * @param type alarm type 0082 * @param standard true to set as standard, false to clear standard status. 0083 */ 0084 void setStandard(KAlarmCal::CalEvent::Type, bool standard); 0085 0086 /** Return which alarm types (active, archived or template) the 0087 * collection is standard for. 0088 * @return alarm types. 0089 */ 0090 KAlarmCal::CalEvent::Types standard() const; 0091 0092 /** Set which alarm types (active, archived or template) the 0093 * collection is the standard collection for. 0094 * @param types alarm types. 0095 */ 0096 void setStandard(KAlarmCal::CalEvent::Types types); 0097 0098 /** Return the background color to display this collection and its alarms, 0099 * or invalid color if none is set. 0100 */ 0101 QColor backgroundColor() const; 0102 0103 /** Set the background color for this collection and its alarms. 0104 * @param c background color 0105 */ 0106 void setBackgroundColor(const QColor& c); 0107 0108 /** Return whether the user has chosen to keep the old calendar storage 0109 * format, i.e. not update to current KAlarm format. 0110 */ 0111 bool keepFormat() const; 0112 0113 /** Set whether to keep the old calendar storage format unchanged. 0114 * @param keep true to keep format unchanged, false to allow changes. 0115 */ 0116 void setKeepFormat(bool keep); 0117 0118 // Reimplemented from Attribute 0119 QByteArray type() const override; 0120 // Reimplemented from Attribute 0121 CollectionAttribute* clone() const override; 0122 // Reimplemented from Attribute 0123 QByteArray serialized() const override; 0124 // Reimplemented from Attribute 0125 void deserialize(const QByteArray& data) override; 0126 0127 /** Return the attribute name. */ 0128 static QByteArray name(); 0129 0130 private: 0131 //@cond PRIVATE 0132 class Private; 0133 Private* const d; 0134 //@endcond 0135 }; 0136 0137 // vim: et sw=4: