KPeople

emaildetailswidget.cpp
1 /*
2  SPDX-FileCopyrightText: 2013 David Edmundson <[email protected]>
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 
16 using namespace KPeople;
17 
18 QWidget *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 
33 QString EmailFieldsPlugin::label() const
34 {
35  return i18nc("E-mail field label", "E-mail");
36 }
37 
38 int EmailFieldsPlugin::sortWeight() const
39 {
40  return 50;
41 }
void setContentsMargins(int left, int top, int right, int bottom)
Allows to query the information about a given person.
Definition: persondata.h:34
void addWidget(QWidget *widget, int stretch, Qt::Alignment alignment)
QString i18nc(const char *context, const char *text, const TYPE &arg...)
bool isEmpty() const const
QStringList allEmails() const
Returns all e-mail addresses from the person.
Definition: persondata.cpp:199
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Thu Jan 27 2022 22:42:01 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.