File indexing completed on 2024-05-05 16:08:29

0001 /* This file is part of the KDE libraries
0002 
0003    Copyright (c) 2007 Jos van den Oever <jos@vandenoever.info>
0004 
0005    This library is free software; you can redistribute it and/or
0006    modify it under the terms of the GNU Library General Public
0007    License (LGPL) as published by the Free Software Foundation; either
0008    version 2 of the License, or (at your option) any later version.
0009 
0010    This library is distributed in the hope that it will be useful,
0011    but WITHOUT ANY WARRANTY; without even the implied warranty of
0012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0013    Library General Public License for more details.
0014 
0015    You should have received a copy of the GNU Library General Public License
0016    along with this library; see the file COPYING.LIB.  If not, write to
0017    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0018    Boston, MA 02110-1301, USA.
0019 */
0020 
0021 #include "predicateproperties.h"
0022 
0023 #include <QStringList>
0024 
0025 using namespace std;
0026 
0027 class Q_DECL_HIDDEN PredicateProperties::Private : public QSharedData
0028 {
0029 public:
0030     static const QString nullString;
0031     static const QStringList nullStringList;
0032 #ifndef KDELIBS4SUPPORT_NO_DEPRECATED
0033     static const PredicateProperties nullPP;
0034 #endif
0035     PredicateProperties parent;
0036     QString key;
0037     QString name;
0038     QVariant::Type type;
0039     uint attributes;
0040 };
0041 const QString PredicateProperties::Private::nullString;
0042 const QStringList PredicateProperties::Private::nullStringList;
0043 #ifndef KDELIBS4SUPPORT_NO_DEPRECATED
0044 const PredicateProperties PredicateProperties::Private::nullPP;
0045 #endif
0046 
0047 #ifndef KDELIBS4SUPPORT_NO_DEPRECATED
0048 PredicateProperties::PredicateProperties(const QString &predicate)
0049 {
0050     if (!predicate.isEmpty()) {
0051         d = new Private();
0052         d->key = predicate;
0053     }
0054 }
0055 #endif
0056 PredicateProperties::PredicateProperties(const PredicateProperties &pp)
0057     : d(pp.d)
0058 {
0059 }
0060 PredicateProperties::~PredicateProperties()
0061 {
0062 }
0063 const PredicateProperties &
0064 PredicateProperties::operator=(const PredicateProperties &pp)
0065 {
0066     d = pp.d;
0067     return pp;
0068 }
0069 const QString &
0070 PredicateProperties::name() const
0071 {
0072     if (d == nullptr) {
0073         return Private::nullString;
0074     }
0075     return (d->name.isEmpty()) ? d->key : d->name;
0076 }
0077 
0078 const QStringList &
0079 PredicateProperties::suggestedValues() const
0080 {
0081     return Private::nullStringList;
0082 }
0083 
0084 uint
0085 PredicateProperties::minCardinality() const
0086 {
0087     return 0;
0088 }
0089 
0090 uint
0091 PredicateProperties::maxCardinality() const
0092 {
0093     return 0;
0094 }
0095 
0096 uint
0097 PredicateProperties::attributes() const
0098 {
0099     return (d) ? d->attributes : 0;
0100 }
0101 QVariant::Type
0102 PredicateProperties::type() const
0103 {
0104     return (d) ? d->type : QVariant::Invalid;
0105 }
0106 QValidator *
0107 PredicateProperties::createValidator() const
0108 {
0109     return nullptr;
0110 }
0111 const PredicateProperties &
0112 PredicateProperties::parent() const
0113 {
0114 #ifndef KDELIBS4SUPPORT_NO_DEPRECATED
0115     return (d) ? d->parent : Private::nullPP;
0116 #else
0117     return d->parent;
0118 #endif
0119 }
0120 bool
0121 PredicateProperties::isValid() const
0122 {
0123     return d;
0124 }