File indexing completed on 2025-01-05 04:49:45

0001 /*
0002    SPDX-FileCopyrightText: 2014-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include <QWidget>
0010 
0011 #include <Akonadi/Collection>
0012 #include <KCalendarCore/Event>
0013 #include <KMime/Message>
0014 
0015 class QLineEdit;
0016 class QPushButton;
0017 namespace Akonadi
0018 {
0019 class CollectionComboBox;
0020 }
0021 
0022 namespace MessageViewer
0023 {
0024 class EventDateTimeWidget;
0025 class EventEdit : public QWidget
0026 {
0027     Q_OBJECT
0028 public:
0029     explicit EventEdit(QWidget *parent = nullptr);
0030     ~EventEdit() override;
0031 
0032     [[nodiscard]] Akonadi::Collection collection() const;
0033     void setCollection(const Akonadi::Collection &value);
0034 
0035     [[nodiscard]] KMime::Message::Ptr message() const;
0036     void setMessage(const KMime::Message::Ptr &value);
0037 
0038     void writeConfig();
0039     void showEventEdit();
0040 
0041 public Q_SLOTS:
0042     void slotCloseWidget();
0043 
0044 private Q_SLOTS:
0045     void slotReturnPressed();
0046     void slotCollectionChanged(int);
0047     void slotOpenEditor();
0048     void slotStartDateTimeChanged(const QDateTime &newDateTime);
0049     void slotUpdateButtons(const QString &subject);
0050 
0051     void slotEndDateTimeChanged(const QDateTime &newDateTime);
0052 Q_SIGNALS:
0053     void createEvent(const KCalendarCore::Event::Ptr &event, const Akonadi::Collection &collection);
0054     void collectionChanged(const Akonadi::Collection &col);
0055     void messageChanged(const KMime::Message::Ptr &msg);
0056 
0057 protected:
0058     bool eventFilter(QObject *object, QEvent *e) override;
0059 
0060 private:
0061     KCalendarCore::Event::Ptr createEventItem();
0062     void readConfig();
0063     void comboboxRowInserted();
0064     Akonadi::Collection mCollection;
0065     KMime::Message::Ptr mMessage;
0066     QLineEdit *const mEventEdit;
0067     Akonadi::CollectionComboBox *mCollectionCombobox = nullptr;
0068     EventDateTimeWidget *const mStartDateTimeEdit;
0069     EventDateTimeWidget *const mEndDateTimeEdit;
0070     QPushButton *const mSaveButton;
0071     QPushButton *const mOpenEditorButton;
0072 };
0073 }