File indexing completed on 2024-04-28 05:11:35
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 "editoritemmanager.h" 0011 #include "incidenceeditor_export.h" 0012 0013 #include <QDate> 0014 #include <QDialog> 0015 0016 #include <memory> 0017 0018 class QAbstractButton; 0019 0020 namespace Akonadi 0021 { 0022 class IncidenceChanger; 0023 } 0024 0025 namespace IncidenceEditorNG 0026 { 0027 class IncidenceDialogPrivate; 0028 /** 0029 * @brief The IncidenceDialog class 0030 */ 0031 class INCIDENCEEDITOR_EXPORT IncidenceDialog : public QDialog 0032 { 0033 Q_OBJECT 0034 public: 0035 explicit IncidenceDialog(Akonadi::IncidenceChanger *changer = nullptr, QWidget *parent = nullptr, Qt::WindowFlags flags = {}); 0036 ~IncidenceDialog() override; 0037 0038 /** 0039 * Loads the @param item into the dialog. 0040 * 0041 * To create a new Incidence pass an invalid item with either an 0042 * KCalendarCore::Event:Ptr or a KCalendarCore::Todo:Ptr set as payload. Note: When the 0043 * item is invalid, i.e. it has an invalid id, a valid payload <em>must</em> 0044 * be set. 0045 * 0046 * When the item has is valid this method will fetch the payload when this is 0047 * not already set. 0048 */ 0049 virtual void load(const Akonadi::Item &item, const QDate &activeDate = QDate()); 0050 0051 /** 0052 * Sets the Collection combobox to @param collection. 0053 */ 0054 virtual void selectCollection(const Akonadi::Collection &collection); 0055 0056 virtual void setIsCounterProposal(bool isCounterProposal); 0057 0058 /** 0059 Returns the object that will receive all key events. 0060 */ 0061 QObject *typeAheadReceiver() const; 0062 0063 /** 0064 By default, if you load an incidence into the editor ( load(item) ), then press [OK] 0065 without changing anything, the dialog is dismissed, and the incidence isn't saved 0066 to akonadi. 0067 0068 Call this method with @p initiallyDirty = true if you want the incidence to be saved, 0069 It's useful if you're creating a dialog with an already crafted content, like in kmail's 0070 "Create Todo/Reminder Feature". 0071 */ 0072 void setInitiallyDirty(bool initiallyDirty); 0073 0074 [[nodiscard]] Akonadi::Item item() const; 0075 0076 Q_SIGNALS: 0077 /** 0078 * This signal is emitted when an incidence is created. 0079 * @param collection The collection where it was created. 0080 */ 0081 void incidenceCreated(const Akonadi::Item &); 0082 void invalidCollection() const; 0083 0084 protected: 0085 void closeEvent(QCloseEvent *event) override; 0086 0087 protected Q_SLOTS: 0088 void slotButtonClicked(QAbstractButton *button); 0089 void handleSelectedCollectionChange(const Akonadi::Collection &collection); 0090 void reject() override; 0091 0092 private: 0093 std::unique_ptr<IncidenceDialogPrivate> const d_ptr; 0094 Q_DECLARE_PRIVATE(IncidenceDialog) 0095 Q_DISABLE_COPY(IncidenceDialog) 0096 0097 INCIDENCEEDITOR_NO_EXPORT void writeConfig(); 0098 INCIDENCEEDITOR_NO_EXPORT void readConfig(); 0099 }; 0100 }