File indexing completed on 2024-12-22 05:01:00

0001 /*
0002    SPDX-FileCopyrightText: 2009-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include "collectiontemplatespage.h"
0008 #include <MailCommon/CollectionTemplatesWidget>
0009 
0010 #include <Akonadi/Collection>
0011 #include <MailCommon/FolderSettings>
0012 #include <MailCommon/MailKernel>
0013 #include <TemplateParser/TemplatesConfiguration>
0014 #include <templateparser/templatesconfiguration_kfg.h>
0015 
0016 #include <KLocalizedString>
0017 
0018 using namespace Akonadi;
0019 using namespace MailCommon;
0020 
0021 CollectionTemplatesPage::CollectionTemplatesPage(QWidget *parent)
0022     : CollectionPropertiesPage(parent)
0023     , mCollectionTemplateWidget(new MailCommon::CollectionTemplatesWidget(this))
0024 {
0025     setObjectName(QLatin1StringView("KMail::CollectionTemplatesPage"));
0026     setPageTitle(i18n("Templates"));
0027     init();
0028 }
0029 
0030 CollectionTemplatesPage::~CollectionTemplatesPage() = default;
0031 
0032 bool CollectionTemplatesPage::canHandle(const Collection &collection) const
0033 {
0034     return !CommonKernel->isSystemFolderCollection(collection) || CommonKernel->isMainFolderCollection(collection);
0035 }
0036 
0037 void CollectionTemplatesPage::init()
0038 {
0039     auto topLayout = new QVBoxLayout(this);
0040     topLayout->setContentsMargins({});
0041     topLayout->addWidget(mCollectionTemplateWidget);
0042 }
0043 
0044 void CollectionTemplatesPage::load(const Collection &col)
0045 {
0046     mCollectionTemplateWidget->load(col);
0047 }
0048 
0049 void CollectionTemplatesPage::save(Collection &col)
0050 {
0051     mCollectionTemplateWidget->save(col);
0052 }
0053 
0054 #include "moc_collectiontemplatespage.cpp"