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

0001 /*
0002     This file is part of Contact Editor.
0003 
0004     SPDX-FileCopyrightText: 2018-2020 Laurent Montel <montel.org>
0005 
0006     SPDX-License-Identifier: LGPL-2.0-or-later
0007 */
0008 
0009 #include "blogfeedwidget.h"
0010 #include <KContacts/Addressee>
0011 #include <KLineEdit>
0012 #include <KLocalizedString>
0013 #include <QLabel>
0014 #include <QVBoxLayout>
0015 using namespace Akonadi;
0016 
0017 BlogfeedWidget::BlogfeedWidget(QWidget *parent)
0018     : QWidget(parent)
0019     , mBlogFeed(new KLineEdit(this))
0020 {
0021     auto topLayout = new QVBoxLayout(this);
0022     topLayout->setContentsMargins({});
0023     topLayout->setObjectName(QLatin1StringView("mainlayout"));
0024     auto blogFeedLabel = new QLabel(i18n("Blog Feed"), this);
0025     blogFeedLabel->setObjectName(QLatin1StringView("blogFeedLabel"));
0026     topLayout->addWidget(blogFeedLabel);
0027 
0028     mBlogFeed->setTrapReturnKey(true);
0029     mBlogFeed->setPlaceholderText(i18n("Add a Blog Feed"));
0030     mBlogFeed->setObjectName(QLatin1StringView("blogfeed"));
0031     topLayout->addWidget(mBlogFeed);
0032 }
0033 
0034 BlogfeedWidget::~BlogfeedWidget() = default;
0035 
0036 void BlogfeedWidget::loadContact(const KContacts::Addressee &contact)
0037 {
0038     mBlogFeed->setText(contact.blogFeed().url());
0039 }
0040 
0041 void BlogfeedWidget::storeContact(KContacts::Addressee &contact) const
0042 {
0043     contact.setBlogFeed(QUrl(mBlogFeed->text().trimmed()));
0044 }
0045 
0046 void BlogfeedWidget::setReadOnly(bool readOnly)
0047 {
0048     mBlogFeed->setReadOnly(readOnly);
0049 }
0050 
0051 #include "moc_blogfeedwidget.cpp"