File indexing completed on 2024-12-22 05:00:51
0001 /* 0002 SPDX-FileCopyrightText: 2015-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include "archivemailinfo.h" 0010 #include "ui_archivemailwidget.h" 0011 #include <QTreeWidgetItem> 0012 0013 #include <Akonadi/AgentConfigurationBase> 0014 0015 class ArchiveMailItem : public QTreeWidgetItem 0016 { 0017 public: 0018 explicit ArchiveMailItem(QTreeWidget *parent = nullptr); 0019 ~ArchiveMailItem() override; 0020 0021 void setInfo(ArchiveMailInfo *info); 0022 ArchiveMailInfo *info() const; 0023 0024 private: 0025 ArchiveMailInfo *mInfo = nullptr; 0026 }; 0027 0028 class ArchiveMailWidget : public Akonadi::AgentConfigurationBase 0029 { 0030 Q_OBJECT 0031 public: 0032 explicit ArchiveMailWidget(const KSharedConfigPtr &config, QWidget *parentWidget, const QVariantList &args); 0033 ~ArchiveMailWidget() override; 0034 0035 enum ArchiveMailColumn { 0036 Name = 0, 0037 LastArchiveDate, 0038 NextArchive, 0039 StorageDirectory, 0040 }; 0041 0042 [[nodiscard]] bool save() const override; 0043 void load() override; 0044 0045 void needReloadConfig(); 0046 0047 QSize restoreDialogSize() const override; 0048 void saveDialogSize(const QSize &size) override; 0049 0050 private: 0051 void createOrUpdateItem(ArchiveMailInfo *info, ArchiveMailItem *item = nullptr); 0052 [[nodiscard]] bool verifyExistingArchive(ArchiveMailInfo *info) const; 0053 void updateDiffDate(ArchiveMailItem *item, ArchiveMailInfo *info); 0054 0055 void slotDeleteItem(); 0056 void slotModifyItem(); 0057 void slotAddItem(); 0058 void updateButtons(); 0059 void slotOpenFolder(); 0060 void slotCustomContextMenuRequested(const QPoint &); 0061 void slotItemChanged(QTreeWidgetItem *item, int); 0062 0063 bool mChanged = false; 0064 Ui::ArchiveMailWidget mWidget; 0065 }; 0066 0067 AKONADI_AGENTCONFIG_FACTORY(ArchiveMailAgentConfigFactory, "archivemailagentconfig.json", ArchiveMailWidget)