File indexing completed on 2024-04-28 05:11:34

0001 /*
0002   SPDX-FileCopyrightText: 2010 Bertjan Broeksema <broeksema@kde.org>
0003   SPDX-FileCopyrightText: 2010 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
0004 
0005   SPDX-License-Identifier: LGPL-2.0-or-later
0006 */
0007 
0008 #pragma once
0009 
0010 #include "incidenceeditor_export.h"
0011 
0012 #include <KCalendarCore/Incidence>
0013 
0014 #include <memory>
0015 
0016 namespace IncidenceEditorNG
0017 {
0018 class IncidenceDefaultsPrivate;
0019 /**
0020  * @brief The IncidenceDefaults class
0021  */
0022 class INCIDENCEEDITOR_EXPORT IncidenceDefaults
0023 {
0024 public:
0025     explicit IncidenceDefaults(bool cleanupAttachmentTEmporaryFiles = false);
0026     IncidenceDefaults(const IncidenceDefaults &other);
0027     ~IncidenceDefaults();
0028 
0029     IncidenceDefaults &operator=(const IncidenceDefaults &other);
0030 
0031     /**
0032       Sets the attachments that are added by default to incidences.
0033     */
0034     void setAttachments(const QStringList &attachments,
0035                         const QStringList &attachmentMimetypes = QStringList(),
0036                         const QStringList &attachmentLabels = QStringList(),
0037                         bool inlineAttachment = false);
0038 
0039     /**
0040       Sets the attendees that are added by default to incidences.
0041       @param attendees Expected to be of the form "name name <email>"
0042     */
0043     void setAttendees(const QStringList &attendees);
0044 
0045     /**
0046       Sets the list of identities to be used for the user. The items in the list
0047       are expected to be of the form: "name [name] <email>".
0048 
0049       If the list is empty, it is assumed that no valid identities are configured.
0050 
0051       @param fullEmails The list of name email pairs that the user has configured as identities.
0052     */
0053     void setFullEmails(const QStringList &fullEmails);
0054 
0055     /**
0056       This is used to do a smarter guess about which identity to use for the organizer.
0057       If the groupware server is not set, the first available identity will be used.
0058       @param domain The gropuware server domain name without any protocol prefixes
0059       (e.g. demo.kolab.org).
0060     */
0061     void setGroupWareDomain(const QString &domain);
0062 
0063     /**
0064       Sets the incidence related to the incidence for which to set the defaults. For
0065       example the parent todo of a new sub todo.
0066     */
0067     void setRelatedIncidence(const KCalendarCore::Incidence::Ptr &incidence);
0068 
0069     /**
0070       Set the start date/time to use for passed incidences. This defaults to the
0071       current start date/time. The main purpose of this method is supporting
0072       defaults for new incidences that where created with a given time slot.
0073       @param startDT The start date time to set on the incidence.
0074     */
0075     void setStartDateTime(const QDateTime &startDT);
0076 
0077     /**
0078       Set the end date/time to use for passed incidences. This defaults to the
0079       current start date/time. The main purpose of this method is supporting
0080       defaults for new incidences that where created with a given time slot.
0081       @param endDT The start date time to set on the incidence.
0082     */
0083     void setEndDateTime(const QDateTime &endDT);
0084 
0085     /**
0086       Sets the default values for @param incidence. This method is merely meant for
0087       <em>new</em> incidences. However, it will clear out all fields and set them
0088       to default values.
0089       @param incidence The incidence that will get default values for all of its field.
0090     */
0091     void setDefaults(const KCalendarCore::Incidence::Ptr &incidence) const;
0092 
0093     /**
0094      * Returns minimal incidence defaults: e-mails and groupware domain.
0095      *
0096      * TODO: See if this is always called when using IncidenceDefaults.
0097      * If yes, this should be done inside ctor.
0098      */
0099     [[nodiscard]] static IncidenceDefaults minimalIncidenceDefaults(bool cleanupAttachmentTempFiles = false);
0100 
0101     // Returns the e-mail address used for the organizer when we can't find anything useful
0102     // This is something like "invalid@invalid"
0103     [[nodiscard]] static QString invalidEmailAddress();
0104 
0105 private:
0106     std::unique_ptr<IncidenceDefaultsPrivate> const d_ptr;
0107     Q_DECLARE_PRIVATE(IncidenceDefaults)
0108 };
0109 }