KProperty

KPropertyListData.cpp
1/* This file is part of the KDE project
2 Copyright (C) 2004 Cedric Pasteur <cedric.pasteur@free.fr>
3 Copyright (C) 2004 Alexander Dymo <cloudtemple@mskat.net>
4 Copyright (C) 2004-2017 Jarosław Staniek <staniek@kde.org>
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
15
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
20*/
21
22#include "KPropertyListData.h"
23
24class Q_DECL_HIDDEN KPropertyListData::Private
25{
26public:
27 Private() {
28 }
29 Private(const Private &other) {
30 copy(other);
31 }
32#define KPropertyListDataPrivateArgs(o) std::tie(o.keys, o.names)
33 void copy(const Private &other) {
34 KPropertyListDataPrivateArgs((*this)) = KPropertyListDataPrivateArgs(other);
35 }
36 bool operator==(const Private &other) const {
37 return KPropertyListDataPrivateArgs((*this)) == KPropertyListDataPrivateArgs(other);
38 }
39 QVariantList keys;
40 QVariantList names;
41};
42
43KPropertyListData::KPropertyListData()
44 : d(new Private)
45{
46}
47
48KPropertyListData::KPropertyListData(const KPropertyListData &other)
49 : d(new Private(*other.d))
50{
51}
52
53KPropertyListData::KPropertyListData(const QStringList &keys, const QStringList &names)
54 : d(new Private)
55{
56 setKeysAsStringList(keys);
57 setNamesAsStringList(names);
58}
59
60KPropertyListData::KPropertyListData(const QVariantList &keys, const QVariantList &names)
61 : d(new Private)
62{
63 setKeys(keys);
64 setNames(names);
65}
66
67KPropertyListData::KPropertyListData(const QVariantList &keys, const QStringList &names)
68 : d(new Private)
69{
70 setKeys(keys);
71 setNamesAsStringList(names);
72}
73
74KPropertyListData::~KPropertyListData()
75{
76 delete d;
77}
78
80{
81 if (this != &other) {
82 d->copy(*other.d);
83 }
84 return *this;
85}
86
88{
89 return *d == *other.d;
90}
91
93{
94 d->keys.clear();
95 for (const QString &key : keys) {
96 d->keys.append(key);
97 }
98}
99
100void KPropertyListData::setKeys(const QVariantList &keys)
101{
102 d->keys = keys;
103}
104
105QVariantList KPropertyListData::keys() const
106{
107 return d->keys;
108}
109
111{
112 QStringList result;
113 for (const QVariant &key : d->keys) {
114 result.append(key.toString());
115 }
116 return result;
117}
118
119QVariantList KPropertyListData::names() const
120{
121 return d->names;
122}
123
125{
126 QStringList result;
127 for (const QVariant &name : d->names) {
128 result.append(name.toString());
129 }
130 return result;
131}
132
134{
135 d->names.clear();
136 for (const QString &name : names) {
137 d->names.append(name);
138 }
139}
140
141void KPropertyListData::setNames(const QVariantList &names)
142{
143 d->names = names;
144}
A data container for properties of list type.
KPropertyListData & operator=(const KPropertyListData &other)
Assigns other to this KPropertyListData.
QVariantList keys() const
A list containing all possible keys for a property.
QStringList keysAsStringList() const
A list containing all possible keys for a property converted to strings.
bool operator==(const KPropertyListData &other) const
void setNames(const QVariantList &names)
Sets a list containing all possible keys for a property.
void setKeys(const QVariantList &keys)
Sets a list containing all possible keys for a property.
QStringList namesAsStringList() const
The list of user-visible translated name elements as strings.
QVariantList names() const
The list of user-visible translated name elements.
void setNamesAsStringList(const QStringList &names)
Sets a list containing all possible keys for a property as strings.
void setKeysAsStringList(const QStringList &keys)
Sets a list containing all possible keys for a property as strings.
const QList< QKeySequence > & copy()
bool operator==(const StyleDelim &l, const StyleDelim &r)
void append(QList< T > &&value)
QString toString() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:04:09 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.