• Skip to content
  • Skip to link menu
KDE API Documentation - phonedetailswidget.cpp Source File (KPeople)
  • KDE Home
  • Contact Us
 

KPeople

  • frameworks
  • kpeople
  • src
  • widgets
  • plugins
phonedetailswidget.cpp
1 /*
2  Copyright (C) 2013 David Edmundson <davidedmundson@kde.org>
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Lesser General Public
6  License as published by the Free Software Foundation; either
7  version 2.1 of the License, or (at your option) any later version.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Lesser General Public License for more details.
13 
14  You should have received a copy of the GNU Lesser General Public
15  License along with this library; if not, write to the Free Software
16  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18 
19 #include "phonedetailswidget.h"
20 #include "persondata.h"
21 
22 #include <QGridLayout>
23 #include <QVBoxLayout>
24 #include <QLabel>
25 
26 #include <KLocalizedString>
27 #include <KPluginFactory>
28 
29 K_PLUGIN_FACTORY(PhoneDetailsWidgetFactory, registerPlugin<PhoneDetailsWidget>();)
30 K_EXPORT_PLUGIN(PhoneDetailsWidgetFactory("phonedetailswidgetplugin"))
31 
32 using namespace KPeople;
33 
34 PhoneDetailsWidget::PhoneDetailsWidget(QWidget *parent, const QVariantList &args):
35  AbstractPersonDetailsWidget(parent)
36 {
37  Q_UNUSED(args);
38  setTitle(i18n("Phone"));
39  setIcon(QIcon::fromTheme("phone"));
40 
41  setLayout(new QVBoxLayout(this));
42 }
43 
44 void PhoneDetailsWidget::setPerson(PersonData *person)
45 {
46  if (person->phones().size() == 0) {
47  setActive(false);
48  } else {
49  setActive(true);
50  }
51 
52  QLayoutItem *child;
53  while ((child = layout()->takeAt(0)) != 0) {
54  delete child->widget();
55  delete child;
56  }
57 
58  Q_FOREACH (const QString &phone, person->phones()) {
59  QLabel *phoneLabel = new QLabel(phone, this);
60  phoneLabel->setTextInteractionFlags(Qt::TextSelectableByMouse);
61  layout()->addWidget(phoneLabel);
62  }
63 }
KPeople::PersonData
Allows to query the information about a given person.
Definition: persondata.h:44
KPeople
The KPeople namespace contains all the classes for Libkpeople.
This file is part of the KDE documentation.
Documentation copyright © 1996-2015 The KDE developers.
Generated on Fri Feb 13 2015 15:16:39 by doxygen 1.8.9.1 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KPeople

Skip menu "KPeople"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • File List

Class Picker

Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal