Pimcommon

collectionaclpage.cpp
1/**
2 *
3 * SPDX-FileCopyrightText: 2004 David Faure <faure@kde.org>
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 */
7
8#include "collectionaclpage.h"
9using namespace Qt::Literals::StringLiterals;
10
11#include "aclmanager.h"
12#include "collectionaclwidget.h"
13#include "imapaclattribute.h"
14#include <Akonadi/Collection>
15#include <KLocalizedString>
16#include <QHBoxLayout>
17
18using namespace PimCommon;
19
20class PimCommon::CollectionAclPagePrivate
21{
22public:
23 CollectionAclPagePrivate() = default;
24
25 CollectionAclWidget *mCollectionAclWidget = nullptr;
26};
27
28CollectionAclPage::CollectionAclPage(QWidget *parent)
29 : CollectionPropertiesPage(parent)
30 , d(new PimCommon::CollectionAclPagePrivate)
31{
32 setObjectName("PimCommon::CollectionAclPage"_L1);
33
34 setPageTitle(i18nc("@title:tab Access Control settings page.", "Access Control"));
35 init();
36}
37
38CollectionAclPage::~CollectionAclPage() = default;
39
40void CollectionAclPage::init()
41{
42 auto layout = new QHBoxLayout(this);
44 d->mCollectionAclWidget = new CollectionAclWidget(this);
45 layout->addWidget(d->mCollectionAclWidget);
46}
47
48bool CollectionAclPage::canHandle(const Akonadi::Collection &collection) const
49{
50 return collection.hasAttribute<PimCommon::ImapAclAttribute>();
51}
52
53void CollectionAclPage::load(const Akonadi::Collection &collection)
54{
55 d->mCollectionAclWidget->aclManager()->setCollection(collection);
56}
57
58void CollectionAclPage::save(Akonadi::Collection &collection)
59{
60 d->mCollectionAclWidget->aclManager()->save(d->mCollectionAclWidget->recursive());
61
62 // The collection dialog expects the changed collection to run
63 // its own ItemModifyJob, so make him happy...
64 const auto origCol = d->mCollectionAclWidget->aclManager()->collection();
65 collection.addAttribute(origCol.attribute<PimCommon::ImapAclAttribute>()->clone());
66}
67
68#include "moc_collectionaclpage.cpp"
void addAttribute(Attribute *attribute)
bool hasAttribute() const
The ImapAclAttribute class.
QString i18nc(const char *context, const char *text, const TYPE &arg...)
void init(KXmlGuiWindow *window, KGameDifficulty *difficulty=nullptr)
folderdialogacltab.h
void addWidget(QWidget *w)
void setContentsMargins(const QMargins &margins)
QLayout * layout() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:39:22 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.