Changeset View
Changeset View
Standalone View
Standalone View
src/KPropertySet.cpp
1 | /* This file is part of the KDE project | 1 | /* This file is part of the KDE project | ||
---|---|---|---|---|---|
2 | Copyright (C) 2004 Cedric Pasteur <cedric.pasteur@free.fr> | 2 | Copyright (C) 2004 Cedric Pasteur <cedric.pasteur@free.fr> | ||
3 | Copyright (C) 2004 Alexander Dymo <cloudtemple@mskat.net> | 3 | Copyright (C) 2004 Alexander Dymo <cloudtemple@mskat.net> | ||
4 | Copyright (C) 2004-2009 Jarosław Staniek <staniek@kde.org> | 4 | Copyright (C) 2004-2017 Jarosław Staniek <staniek@kde.org> | ||
5 | 5 | | |||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or | ||
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public | ||
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either | ||
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. | ||
10 | 10 | | |||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, | ||
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
▲ Show 20 Lines • Show All 165 Lines • ▼ Show 20 Line(s) | 173 | if (propertiesOfGroup->isEmpty()) { | |||
178 | if (i != -1) { | 178 | if (i != -1) { | ||
179 | groupNames.removeAt(i); | 179 | groupNames.removeAt(i); | ||
180 | } | 180 | } | ||
181 | } | 181 | } | ||
182 | } | 182 | } | ||
183 | removePropertyFromGroup(property); | 183 | removePropertyFromGroup(property); | ||
184 | } | 184 | } | ||
185 | 185 | | |||
186 | bool KPropertySetPrivate::hasGroups() const | ||||
187 | { | ||||
188 | return groupNames.count() > 1 || (groupNames.count() == 1 && groupNames.first() != "common"); | ||||
189 | } | ||||
190 | | ||||
186 | void KPropertySetPrivate::informAboutClearing(bool* cleared) | 191 | void KPropertySetPrivate::informAboutClearing(bool* cleared) | ||
187 | { | 192 | { | ||
188 | Q_ASSERT(cleared); | 193 | Q_ASSERT(cleared); | ||
189 | *cleared = false; | 194 | *cleared = false; | ||
190 | m_informAboutClearing = cleared; | 195 | m_informAboutClearing = cleared; | ||
191 | } | 196 | } | ||
192 | 197 | | |||
193 | void KPropertySetPrivate::addRelatedProperty(KProperty *p1, KProperty *p2) const | 198 | void KPropertySetPrivate::addRelatedProperty(KProperty *p1, KProperty *p2) const | ||
194 | { | 199 | { | ||
195 | p1->d->addRelatedProperty(p2); | 200 | p1->d->addRelatedProperty(p2); | ||
196 | } | 201 | } | ||
197 | 202 | | |||
203 | int KPropertySetPrivate::indexOfProperty(const KProperty *property) const | ||||
204 | { | ||||
205 | KProperty *parentProperty = property->parent(); | ||||
206 | if (parentProperty) { | ||||
207 | const QList<KProperty*>* children = parentProperty->children(); | ||||
208 | Q_ASSERT(children); | ||||
209 | const int index = children->indexOf(parentProperty); | ||||
210 | Q_ASSERT(index != -1); | ||||
211 | return index; | ||||
212 | } | ||||
213 | return indexOfPropertyInGroup(property); | ||||
214 | } | ||||
215 | | ||||
216 | int KPropertySetPrivate::indexOfPropertyInGroup(const KProperty *property) const | ||||
217 | { | ||||
218 | const QByteArray group(groupForProperties.value(const_cast<KProperty *>(property))); | ||||
219 | QList<QByteArray>* propertiesOfGroup = this->propertiesOfGroup.value(group); | ||||
220 | if (!propertiesOfGroup) { | ||||
221 | return -1; | ||||
222 | } | ||||
223 | return propertiesOfGroup->indexOf(property->name()); | ||||
224 | } | ||||
225 | | ||||
198 | ////////////////////////////////////////////// | 226 | ////////////////////////////////////////////// | ||
199 | 227 | | |||
200 | KPropertySelector::KPropertySelector() | 228 | KPropertySelector::KPropertySelector() | ||
201 | { | 229 | { | ||
202 | } | 230 | } | ||
203 | 231 | | |||
204 | KPropertySelector::~KPropertySelector() | 232 | KPropertySelector::~KPropertySelector() | ||
205 | { | 233 | { | ||
▲ Show 20 Lines • Show All 261 Lines • ▼ Show 20 Line(s) | |||||
467 | } | 495 | } | ||
468 | 496 | | |||
469 | KProperty& | 497 | KProperty& | ||
470 | KPropertySet::property(const QByteArray &name) const | 498 | KPropertySet::property(const QByteArray &name) const | ||
471 | { | 499 | { | ||
472 | return d->propertyOrNull(name); | 500 | return d->propertyOrNull(name); | ||
473 | } | 501 | } | ||
474 | 502 | | |||
503 | void KPropertySet::changePropertyIfExists(const QByteArray &property, const QVariant &value) | ||||
504 | { | ||||
505 | if (contains(property)) { | ||||
506 | changeProperty(property, value); | ||||
507 | } | ||||
508 | } | ||||
509 | | ||||
475 | KProperty& | 510 | KProperty& | ||
476 | KPropertySet::operator[](const QByteArray &name) const | 511 | KPropertySet::operator[](const QByteArray &name) const | ||
477 | { | 512 | { | ||
478 | return d->propertyOrNull(name); | 513 | return d->propertyOrNull(name); | ||
479 | } | 514 | } | ||
480 | 515 | | |||
481 | KPropertySet& | 516 | KPropertySet& | ||
482 | KPropertySet::operator= (const KPropertySet & set) | 517 | KPropertySet::operator= (const KPropertySet & set) | ||
▲ Show 20 Lines • Show All 162 Lines • Show Last 20 Lines |