File indexing completed on 2024-11-24 04:39:30

0001 /*
0002     This file is part of Contact Editor.
0003 
0004     SPDX-FileCopyrightText: 2016 eyeOS S.L.U., a Telefonica company, sales@eyeos.com
0005     SPDX-FileCopyrightText: 2016-2020 Laurent Montel <montel.org>
0006 
0007     SPDX-License-Identifier: LGPL-2.0-or-later
0008 */
0009 
0010 #include "customfieldswidget.h"
0011 #include "customfieldeditorwidget.h"
0012 #include "customfieldslistwidget.h"
0013 
0014 #include <QVBoxLayout>
0015 
0016 using namespace Akonadi;
0017 
0018 CustomFieldsWidget::CustomFieldsWidget(QWidget *parent)
0019     : QWidget(parent)
0020     , mCustomFieldEditorWidget(new Akonadi::CustomFieldEditorWidget(this))
0021     , mCustomFieldsListWidget(new Akonadi::CustomFieldsListWidget(this))
0022 {
0023     auto topLayout = new QVBoxLayout(this);
0024     topLayout->setContentsMargins({});
0025     mCustomFieldEditorWidget->setObjectName(QLatin1StringView("customfieldeditorwidget"));
0026     topLayout->addWidget(mCustomFieldEditorWidget);
0027 
0028     mCustomFieldsListWidget->setObjectName(QLatin1StringView("customfieldslistwidget"));
0029     topLayout->addWidget(mCustomFieldsListWidget);
0030 
0031     connect(mCustomFieldEditorWidget, &CustomFieldEditorWidget::addNewField, mCustomFieldsListWidget, &CustomFieldsListWidget::slotAddNewField);
0032 }
0033 
0034 CustomFieldsWidget::~CustomFieldsWidget() = default;
0035 
0036 void CustomFieldsWidget::loadContact(const KContacts::Addressee &contact)
0037 {
0038     mCustomFieldsListWidget->loadContact(contact);
0039 }
0040 
0041 void CustomFieldsWidget::storeContact(KContacts::Addressee &contact) const
0042 {
0043     mCustomFieldsListWidget->storeContact(contact);
0044 }
0045 
0046 void CustomFieldsWidget::setReadOnly(bool readOnly)
0047 {
0048     mCustomFieldEditorWidget->setReadOnly(readOnly);
0049     mCustomFieldsListWidget->setReadOnly(readOnly);
0050 }
0051 
0052 void CustomFieldsWidget::setLocalCustomFieldDescriptions(const QVariantList &descriptions)
0053 {
0054     mCustomFieldsListWidget->setLocalCustomFieldDescriptions(descriptions);
0055 }
0056 
0057 QVariantList CustomFieldsWidget::localCustomFieldDescriptions() const
0058 {
0059     return mCustomFieldsListWidget->localCustomFieldDescriptions();
0060 }
0061 
0062 #include "moc_customfieldswidget.cpp"