File indexing completed on 2024-10-27 04:50:48

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 #include "ui_sendlaterconfigurewidget.h"
0009 
0010 #include <Akonadi/Item>
0011 
0012 #include <KConfigGroup>
0013 #include <QTreeWidgetItem>
0014 
0015 namespace MessageComposer
0016 {
0017 class SendLaterInfo;
0018 }
0019 
0020 class SendLaterItem : public QTreeWidgetItem
0021 {
0022 public:
0023     explicit SendLaterItem(QTreeWidget *parent = nullptr);
0024     ~SendLaterItem() override;
0025 
0026     void setInfo(MessageComposer::SendLaterInfo *info);
0027     [[nodiscard]] MessageComposer::SendLaterInfo *info() const;
0028 
0029 private:
0030     MessageComposer::SendLaterInfo *mInfo = nullptr;
0031 };
0032 
0033 class SendLaterWidget : public QWidget
0034 {
0035     Q_OBJECT
0036 public:
0037     explicit SendLaterWidget(QWidget *parent = nullptr);
0038     ~SendLaterWidget() override;
0039 
0040     enum SendLaterColumn {
0041         To = 0,
0042         Subject,
0043         SendAround,
0044         Recursive,
0045         MessageId,
0046     };
0047 
0048     void save();
0049     void saveTreeWidgetHeader(KConfigGroup &group);
0050     void restoreTreeWidgetHeader(const QByteArray &group);
0051     void needToReload();
0052     [[nodiscard]] QList<Akonadi::Item::Id> messagesToRemove() const;
0053 
0054 Q_SIGNALS:
0055     void sendNow(Akonadi::Item::Id);
0056 
0057 private:
0058     void slotDeleteItem();
0059     void slotModifyItem();
0060     void updateButtons();
0061     void slotCustomContextMenuRequested(QPoint);
0062     void slotSendNow();
0063     void createOrUpdateItem(MessageComposer::SendLaterInfo *info, SendLaterItem *item = nullptr);
0064     void load();
0065     QList<Akonadi::Item::Id> mListMessagesToRemove;
0066     bool mChanged = false;
0067     Ui::SendLaterConfigureWidget *mWidget = nullptr;
0068 };