Akonadi Contacts

nicknamewidget.cpp
1/*
2 This file is part of Contact Editor.
3
4 SPDX-FileCopyrightText: 2016 eyeOS S.L.U., a Telefonica company, sales@eyeos.com
5 SPDX-FileCopyrightText: 2016-2020 Laurent Montel <montel.org>
6
7 SPDX-License-Identifier: LGPL-2.0-or-later
8*/
9
10#include "nicknamewidget.h"
11#include <KContacts/Addressee>
12#include <KLineEdit>
13#include <KLocalizedString>
14#include <QLabel>
15#include <QVBoxLayout>
16using namespace Akonadi;
17
18NicknameWidget::NicknameWidget(QWidget *parent)
19 : QWidget(parent)
20 , mNickName(new KLineEdit(this))
21{
22 auto topLayout = new QVBoxLayout(this);
23 topLayout->setContentsMargins({});
24 topLayout->setObjectName(QLatin1StringView("mainlayout"));
25 auto nickNameLabel = new QLabel(i18nc("@label:textbox", "Nickname"), this);
26 nickNameLabel->setObjectName(QLatin1StringView("nicknamelabel"));
27 topLayout->addWidget(nickNameLabel);
28
29 mNickName->setTrapReturnKey(true);
30 mNickName->setPlaceholderText(i18nc("@info:placeholder", "Add a Nickname"));
31 mNickName->setObjectName(QLatin1StringView("nickname"));
32 topLayout->addWidget(mNickName);
33}
34
35NicknameWidget::~NicknameWidget() = default;
36
37void NicknameWidget::loadContact(const KContacts::Addressee &contact)
38{
39 mNickName->setText(contact.nickName());
40}
41
42void NicknameWidget::storeContact(KContacts::Addressee &contact) const
43{
44 contact.setNickName(mNickName->text().trimmed());
45}
46
47void NicknameWidget::setReadOnly(bool readOnly)
48{
49 mNickName->setReadOnly(readOnly);
50}
51
52#include "moc_nicknamewidget.cpp"
QString nickName() const
void setNickName(const QString &nickName)
virtual void setReadOnly(bool)
virtual void setText(const QString &)
QString i18nc(const char *context, const char *text, const TYPE &arg...)
A widget for editing the display name of a contact.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:05:47 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.