Warning, file /libraries/kproperty/src/KPropertyListData.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* This file is part of the KDE project 0002 Copyright (C) 2004 Cedric Pasteur <cedric.pasteur@free.fr> 0003 Copyright (C) 2004 Alexander Dymo <cloudtemple@mskat.net> 0004 Copyright (C) 2004-2017 Jarosław Staniek <staniek@kde.org> 0005 0006 This library is free software; you can redistribute it and/or 0007 modify it under the terms of the GNU Library General Public 0008 License as published by the Free Software Foundation; either 0009 version 2 of the License, or (at your option) any later version. 0010 0011 This library is distributed in the hope that it will be useful, 0012 but WITHOUT ANY WARRANTY; without even the implied warranty of 0013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0014 Library General Public License for more details. 0015 0016 You should have received a copy of the GNU Library General Public License 0017 along with this library; see the file COPYING.LIB. If not, write to 0018 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0019 * Boston, MA 02110-1301, USA. 0020 */ 0021 0022 #include "KPropertyListData.h" 0023 0024 class Q_DECL_HIDDEN KPropertyListData::Private 0025 { 0026 public: 0027 Private() { 0028 } 0029 Private(const Private &other) { 0030 copy(other); 0031 } 0032 #define KPropertyListDataPrivateArgs(o) std::tie(o.keys, o.names) 0033 void copy(const Private &other) { 0034 KPropertyListDataPrivateArgs((*this)) = KPropertyListDataPrivateArgs(other); 0035 } 0036 bool operator==(const Private &other) const { 0037 return KPropertyListDataPrivateArgs((*this)) == KPropertyListDataPrivateArgs(other); 0038 } 0039 QVariantList keys; 0040 QVariantList names; 0041 }; 0042 0043 KPropertyListData::KPropertyListData() 0044 : d(new Private) 0045 { 0046 } 0047 0048 KPropertyListData::KPropertyListData(const KPropertyListData &other) 0049 : d(new Private(*other.d)) 0050 { 0051 } 0052 0053 KPropertyListData::KPropertyListData(const QStringList &keys, const QStringList &names) 0054 : d(new Private) 0055 { 0056 setKeysAsStringList(keys); 0057 setNamesAsStringList(names); 0058 } 0059 0060 KPropertyListData::KPropertyListData(const QVariantList &keys, const QVariantList &names) 0061 : d(new Private) 0062 { 0063 setKeys(keys); 0064 setNames(names); 0065 } 0066 0067 KPropertyListData::KPropertyListData(const QVariantList &keys, const QStringList &names) 0068 : d(new Private) 0069 { 0070 setKeys(keys); 0071 setNamesAsStringList(names); 0072 } 0073 0074 KPropertyListData::~KPropertyListData() 0075 { 0076 delete d; 0077 } 0078 0079 KPropertyListData& KPropertyListData::operator=(const KPropertyListData &other) 0080 { 0081 if (this != &other) { 0082 d->copy(*other.d); 0083 } 0084 return *this; 0085 } 0086 0087 bool KPropertyListData::operator==(const KPropertyListData &other) const 0088 { 0089 return *d == *other.d; 0090 } 0091 0092 void KPropertyListData::setKeysAsStringList(const QStringList &keys) 0093 { 0094 d->keys.clear(); 0095 for (const QString &key : keys) { 0096 d->keys.append(key); 0097 } 0098 } 0099 0100 void KPropertyListData::setKeys(const QVariantList &keys) 0101 { 0102 d->keys = keys; 0103 } 0104 0105 QVariantList KPropertyListData::keys() const 0106 { 0107 return d->keys; 0108 } 0109 0110 QStringList KPropertyListData::keysAsStringList() const 0111 { 0112 QStringList result; 0113 for (const QVariant &key : d->keys) { 0114 result.append(key.toString()); 0115 } 0116 return result; 0117 } 0118 0119 QVariantList KPropertyListData::names() const 0120 { 0121 return d->names; 0122 } 0123 0124 QStringList KPropertyListData::namesAsStringList() const 0125 { 0126 QStringList result; 0127 for (const QVariant &name : d->names) { 0128 result.append(name.toString()); 0129 } 0130 return result; 0131 } 0132 0133 void KPropertyListData::setNamesAsStringList(const QStringList &names) 0134 { 0135 d->names.clear(); 0136 for (const QString &name : names) { 0137 d->names.append(name); 0138 } 0139 } 0140 0141 void KPropertyListData::setNames(const QVariantList &names) 0142 { 0143 d->names = names; 0144 }