File indexing completed on 2024-04-28 05:11:31
0001 /* 0002 SPDX-FileCopyrightText: 2010 Bertjan Broeksema <broeksema@kde.org> 0003 SPDX-FileCopyrightText: 2010 Klaralvdalens Datakonsult AB, a KDAB Group company <info@kdab.net> 0004 0005 SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 #pragma once 0009 0010 #include "incidenceeditor-ng.h" 0011 0012 #include <Akonadi/Item> 0013 #include <KMessageWidget> 0014 0015 namespace IncidenceEditorNG 0016 { 0017 /** 0018 * The CombinedIncidenceEditor combines optional widgets with zero or more 0019 * IncidenceEditors. The CombinedIncidenceEditor keeps track of the dirty state 0020 * of the IncidenceEditors that where combined. 0021 */ 0022 class CombinedIncidenceEditor : public IncidenceEditor 0023 { 0024 Q_OBJECT 0025 public: 0026 explicit CombinedIncidenceEditor(QWidget *parent = nullptr); 0027 /** 0028 * Deletes this editor as well as all editors which are combined into this 0029 * one. 0030 */ 0031 ~CombinedIncidenceEditor() override; 0032 0033 void combine(IncidenceEditor *other); 0034 0035 /** 0036 * Returns whether or not the current values in the editor differ from the 0037 * initial values or if one of the combined editors is dirty. 0038 */ 0039 [[nodiscard]] bool isDirty() const override; 0040 [[nodiscard]] bool isValid() const override; 0041 0042 /** 0043 * Loads all data from @param incidence into the combined editors. Note, if 0044 * you reimplement the load method in a subclass, make sure to call this 0045 * implementation too. 0046 */ 0047 void load(const KCalendarCore::Incidence::Ptr &incidence) override; 0048 void load(const Akonadi::Item &item) override; 0049 void save(const KCalendarCore::Incidence::Ptr &incidence) override; 0050 void save(Akonadi::Item &item) override; 0051 0052 Q_SIGNALS: 0053 void showMessage(const QString &reason, KMessageWidget::MessageType) const; 0054 0055 private: 0056 void handleDirtyStatusChange(bool isDirty); 0057 QList<IncidenceEditor *> mCombinedEditors; 0058 int mDirtyEditorCount = 0; 0059 }; 0060 }