KPeople

emaildetailswidget.cpp
1/*
2 SPDX-FileCopyrightText: 2013 David Edmundson <davidedmundson@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.1-or-later
5*/
6
7#include "emaildetailswidget.h"
8
9#include <QLabel>
10#include <QVBoxLayout>
11
12#include <KLocalizedString>
13#include <KPeople/PersonData>
14#include <KPluginFactory>
15
16using namespace KPeople;
17
18QWidget *EmailFieldsPlugin::createDetailsWidget(const PersonData &person, QWidget *parent) const
19{
20 if (person.allEmails().isEmpty()) {
21 return nullptr;
22 }
23 QWidget *widget = new QWidget(parent);
24 QVBoxLayout *layout = new QVBoxLayout(widget);
25 layout->setContentsMargins(0, 0, 0, 0);
26 const auto lstEmails = person.allEmails();
27 for (const QString &email : lstEmails) {
28 layout->addWidget(new QLabel(email));
29 }
30 return widget;
31}
32
33QString EmailFieldsPlugin::label() const
34{
35 return i18nc("E-mail field label", "E-mail");
36}
37
38int EmailFieldsPlugin::sortWeight() const
39{
40 return 50;
41}
Allows to query the information about a given person.
Definition persondata.h:35
QStringList allEmails() const
Returns all e-mail addresses from the person.
QString i18nc(const char *context, const char *text, const TYPE &arg...)
void addWidget(QWidget *widget, int stretch, Qt::Alignment alignment)
void setContentsMargins(const QMargins &margins)
bool isEmpty() const const
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:15:03 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.