Akonadi Contacts

nicknamewidget.cpp
1 /*
2  This file is part of Contact Editor.
3 
4  Copyright (C) 2016 eyeOS S.L.U., a Telefonica company, [email protected]
5  Copyright (C) 2016-2020 Laurent Montel <montel.org>
6 
7  This library is free software; you can redistribute it and/or modify it
8  under the terms of the GNU Library General Public License as published by
9  the Free Software Foundation; either version 2 of the License, or (at your
10  option) any later version.
11 
12  This library is distributed in the hope that it will be useful, but WITHOUT
13  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
15  License for more details.
16 
17  You should have received a copy of the GNU Library General Public License
18  along with this library; see the file COPYING.LIB. If not, write to the
19  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20  02110-1301, USA.
21 */
22 
23 #include "nicknamewidget.h"
24 #include <KLocalizedString>
25 #include <QLabel>
26 #include <QVBoxLayout>
27 #include <KLineEdit>
28 #include <KContacts/Addressee>
29 using namespace ContactEditor;
30 
31 NicknameWidget::NicknameWidget(QWidget *parent)
32  : QWidget(parent)
33 {
34  QVBoxLayout *topLayout = new QVBoxLayout(this);
35  topLayout->setContentsMargins(0, 0, 0, 0);
36  topLayout->setObjectName(QStringLiteral("mainlayout"));
37  QLabel *nickNameLabel = new QLabel(i18n("Nickname"), this);
38  nickNameLabel->setObjectName(QStringLiteral("nicknamelabel"));
39  topLayout->addWidget(nickNameLabel);
40 
41  mNickName = new KLineEdit(this);
42  mNickName->setTrapReturnKey(true);
43  mNickName->setPlaceholderText(i18n("Add a Nickname"));
44  mNickName->setObjectName(QStringLiteral("nickname"));
45  topLayout->addWidget(mNickName);
46 }
47 
48 NicknameWidget::~NicknameWidget()
49 {
50 }
51 
52 void NicknameWidget::loadContact(const KContacts::Addressee &contact)
53 {
54  mNickName->setText(contact.nickName());
55 }
56 
57 void NicknameWidget::storeContact(KContacts::Addressee &contact) const
58 {
59  contact.setNickName(mNickName->text().trimmed());
60 }
61 
62 void NicknameWidget::setReadOnly(bool readOnly)
63 {
64  mNickName->setReadOnly(readOnly);
65 }
void setContentsMargins(int left, int top, int right, int bottom)
QString nickName() const
void addWidget(QWidget *widget, int stretch, Qt::Alignment alignment)
void setObjectName(const QString &name)
void setNickName(const QString &nickName)
QString i18n(const char *text, const TYPE &arg...)
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Fri Jul 3 2020 23:07:31 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.