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

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 <Akonadi/Collection>
0010 #include <KCalendarCore/Todo>
0011 #include <KMime/Message>
0012 #include <QWidget>
0013 
0014 class KMessageWidget;
0015 class QLineEdit;
0016 class QPushButton;
0017 namespace Akonadi
0018 {
0019 class CollectionComboBox;
0020 }
0021 
0022 namespace MessageViewer
0023 {
0024 class TodoEdit : public QWidget
0025 {
0026     Q_OBJECT
0027 public:
0028     explicit TodoEdit(QWidget *parent = nullptr);
0029     ~TodoEdit() override;
0030 
0031     [[nodiscard]] Akonadi::Collection collection() const;
0032     void setCollection(const Akonadi::Collection &value);
0033 
0034     [[nodiscard]] KMime::Message::Ptr message() const;
0035     void setMessage(const KMime::Message::Ptr &value);
0036 
0037     void writeConfig();
0038 
0039     void showToDoWidget();
0040     void setCurrentCollection(const Akonadi::Collection &col);
0041 public Q_SLOTS:
0042     void slotCloseWidget();
0043 
0044 Q_SIGNALS:
0045     void createTodo(const KCalendarCore::Todo::Ptr &todo, const Akonadi::Collection &collection);
0046     void collectionChanged(const Akonadi::Collection &col);
0047     void messageChanged(const KMime::Message::Ptr &msg);
0048 
0049 protected:
0050     bool eventFilter(QObject *object, QEvent *e) override;
0051 
0052 private:
0053     KCalendarCore::Todo::Ptr createTodoItem();
0054     void comboboxRowInserted();
0055     void slotReturnPressed();
0056     void slotCollectionChanged(int);
0057     void slotOpenEditor();
0058     void slotTextEdited(const QString &subject);
0059     void updateButtons(const QString &subject);
0060     void readConfig();
0061     Akonadi::Collection mCollection;
0062     Akonadi::Collection mCurrentCollection;
0063     KMime::Message::Ptr mMessage;
0064     QLineEdit *mNoteEdit = nullptr;
0065     Akonadi::CollectionComboBox *mCollectionCombobox = nullptr;
0066     KMessageWidget *const mMsgWidget;
0067     QPushButton *const mSaveButton;
0068     QPushButton *const mOpenEditorButton;
0069 };
0070 }