• Skip to content
  • Skip to link menu
Brand

API Documentation

  1. KDE API Reference
  2. The KDE Frameworks
  3. KContacts
  • KDE Home
  • Contact Us

Quick Links

Skip menu "KContacts"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • File List
  • Dependencies
  • Related Pages

Class Picker

About

Address book API for KDE

Maintainer
Laurent Montel
Supported platforms
Android, FreeBSD, iOS, Linux, MacOSX, Windows
Community
IRC: #kde-devel on Freenode
Mailing list: kde-frameworks-devel
Use with CMake
find_package(KF5Contacts)
target_link_libraries(yourapp KF5::Contacts)
Use with QMake
QT += KContacts 
Clone
git clone git://anongit.kde.org/kcontacts.git
Browse source
KContacts on cgit.kde.org

KContacts

  • frameworks
  • frameworks
  • kcontacts
  • src
title.cpp
1 /*
2  This file is part of the KContacts framework.
3  Copyright (C) 2016-2019 Laurent Montel <[email protected]>
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Library General Public
7  License as published by the Free Software Foundation; either
8  version 2 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Library General Public License for more details.
14 
15  You should have received a copy of the GNU Library General Public License
16  along with this library; see the file COPYING.LIB. If not, write to
17  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  Boston, MA 02110-1301, USA.
19 */
20 
21 #include "title.h"
22 #include <QMap>
23 #include <QStringList>
24 #include <QDataStream>
25 
26 using namespace KContacts;
27 
28 class Q_DECL_HIDDEN Title::Private : public QSharedData
29 {
30 public:
31  Private()
32  {
33  }
34 
35  Private(const Private &other)
36  : QSharedData(other)
37  {
38  parameters = other.parameters;
39  title = other.title;
40  }
41 
42  QMap<QString, QStringList> parameters;
43  QString title;
44 };
45 
46 Title::Title()
47  : d(new Private)
48 {
49 }
50 
51 Title::Title(const Title &other)
52  : d(other.d)
53 {
54 }
55 
56 Title::Title(const QString &title)
57  : d(new Private)
58 {
59  d->title = title;
60 }
61 
62 Title::~Title()
63 {
64 }
65 
66 void Title::setTitle(const QString &title)
67 {
68  d->title = title;
69 }
70 
71 QString Title::title() const
72 {
73  return d->title;
74 }
75 
76 bool Title::isValid() const
77 {
78  return !d->title.isEmpty();
79 }
80 
81 void Title::setParameters(const QMap<QString, QStringList> &params)
82 {
83  d->parameters = params;
84 }
85 
86 QMap<QString, QStringList> Title::parameters() const
87 {
88  return d->parameters;
89 }
90 
91 bool Title::operator==(const Title &other) const
92 {
93  return (d->parameters == other.parameters()) && (d->title == other.title());
94 }
95 
96 bool Title::operator!=(const Title &other) const
97 {
98  return !(other == *this);
99 }
100 
101 Title &Title::operator=(const Title &other)
102 {
103  if (this != &other) {
104  d = other.d;
105  }
106 
107  return *this;
108 }
109 
110 QString Title::toString() const
111 {
112  QString str = QLatin1String("Title {\n");
113  str += QStringLiteral(" title: %1\n").arg(d->title);
114  if (!d->parameters.isEmpty()) {
115  QString param;
116  QMap<QString, QStringList>::const_iterator it = d->parameters.constBegin();
117  const QMap<QString, QStringList>::const_iterator end = d->parameters.constEnd();
118  while (it != end) {
119  param += QStringLiteral("%1 %2").arg(it.key(), it.value().join(QLatin1Char(',')));
120  ++it;
121  }
122  str += QStringLiteral(" parameters: %1\n").arg(param);
123  }
124  str += QLatin1String("}\n");
125  return str;
126 }
127 
128 QDataStream &KContacts::operator<<(QDataStream &s, const Title &title)
129 {
130  return s << title.d->parameters << title.d->title;
131 }
132 
133 QDataStream &KContacts::operator>>(QDataStream &s, Title &title)
134 {
135  s >> title.d->parameters >> title.d->title;
136  return s;
137 }
QDataStream
QMap< QString, QStringList >
QSharedData
QString
QLatin1Char
QMap::key
const Key key(const T &value, const Key &defaultKey) const
KStandardShortcut::end
const QList< QKeySequence > & end()
KContacts
Definition: address.h:32
QLatin1String
KContacts::Title
Class that holds a Title for a contact.
Definition: title.h:33
QString::arg
QString arg(qlonglong a, int fieldWidth, int base, QChar fillChar) const
QMap::value
const T value(const Key &key, const T &defaultValue) const
This file is part of the KDE documentation.
Documentation copyright © 1996-2019 The KDE developers.
Generated on Thu Dec 5 2019 03:57:42 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

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