File indexing completed on 2025-01-19 04:46:43

0001 /*
0002    SPDX-FileCopyrightText: 2016-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include "confirmaddressconfiguretab.h"
0008 
0009 #include "confirmaddressconfiguretabwidget.h"
0010 #include <KIdentityManagementCore/Identity>
0011 #include <KIdentityManagementCore/IdentityManager>
0012 #include <QTabWidget>
0013 #include <QVBoxLayout>
0014 
0015 ConfirmAddressConfigureTab::ConfirmAddressConfigureTab(QWidget *parent)
0016     : QWidget(parent)
0017     , mTabWidget(new QTabWidget(this))
0018 {
0019     auto mainLayout = new QVBoxLayout(this);
0020     mainLayout->setObjectName(QLatin1StringView("mainlayout"));
0021     mainLayout->setContentsMargins({});
0022 
0023     mTabWidget->setObjectName(QLatin1StringView("tabwidget"));
0024     mainLayout->addWidget(mTabWidget);
0025 
0026     initTab(KIdentityManagementCore::IdentityManager::self());
0027 }
0028 
0029 ConfirmAddressConfigureTab::~ConfirmAddressConfigureTab() = default;
0030 
0031 void ConfirmAddressConfigureTab::loadSettings(const KConfigGroup &grp)
0032 {
0033     for (ConfirmAddressConfigureTabWidget *w : std::as_const(mListTabWidget)) {
0034         w->loadSettings(grp);
0035     }
0036 }
0037 
0038 void ConfirmAddressConfigureTab::saveSettings(KConfigGroup &grp)
0039 {
0040     for (ConfirmAddressConfigureTabWidget *w : std::as_const(mListTabWidget)) {
0041         w->saveSettings(grp);
0042     }
0043 }
0044 
0045 void ConfirmAddressConfigureTab::resetSettings()
0046 {
0047     for (ConfirmAddressConfigureTabWidget *w : std::as_const(mListTabWidget)) {
0048         w->resetSettings();
0049     }
0050 }
0051 
0052 void ConfirmAddressConfigureTab::initTab(KIdentityManagementCore::IdentityManager *identityManager)
0053 {
0054     KIdentityManagementCore::IdentityManager::ConstIterator end = identityManager->end();
0055     for (KIdentityManagementCore::IdentityManager::ConstIterator it = identityManager->begin(); it != end; ++it) {
0056         auto w = new ConfirmAddressConfigureTabWidget(this);
0057         connect(w, &ConfirmAddressConfigureTabWidget::configureChanged, this, &ConfirmAddressConfigureTab::configureChanged);
0058         mTabWidget->addTab(w, QStringLiteral("%1 (%2)").arg((*it).identityName(), (*it).primaryEmailAddress()));
0059         w->setIdentity((*it).uoid());
0060         mListTabWidget.append(w);
0061     }
0062 }
0063 
0064 #include "moc_confirmaddressconfiguretab.cpp"