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, [email protected]
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>
16 using namespace ContactEditor;
17 
18 NicknameWidget::NicknameWidget(QWidget *parent)
19  : QWidget(parent)
20 {
21  auto topLayout = new QVBoxLayout(this);
22  topLayout->setContentsMargins(0, 0, 0, 0);
23  topLayout->setObjectName(QStringLiteral("mainlayout"));
24  auto nickNameLabel = new QLabel(i18n("Nickname"), this);
25  nickNameLabel->setObjectName(QStringLiteral("nicknamelabel"));
26  topLayout->addWidget(nickNameLabel);
27 
28  mNickName = new KLineEdit(this);
29  mNickName->setTrapReturnKey(true);
30  mNickName->setPlaceholderText(i18n("Add a Nickname"));
31  mNickName->setObjectName(QStringLiteral("nickname"));
32  topLayout->addWidget(mNickName);
33 }
34 
35 NicknameWidget::~NicknameWidget()
36 {
37 }
38 
39 void NicknameWidget::loadContact(const KContacts::Addressee &contact)
40 {
41  mNickName->setText(contact.nickName());
42 }
43 
44 void NicknameWidget::storeContact(KContacts::Addressee &contact) const
45 {
46  contact.setNickName(mNickName->text().trimmed());
47 }
48 
49 void NicknameWidget::setReadOnly(bool readOnly)
50 {
51  mNickName->setReadOnly(readOnly);
52 }
QString nickName() const
void setNickName(const QString &nickName)
QString i18n(const char *text, const TYPE &arg...)
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Wed Jun 23 2021 23:09:25 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.