1 /**************************************************************************** 2 ** 3 ** Copyright (C) 2016 The Qt Company Ltd. 4 ** Contact: https://www.qt.io/licensing/ 5 ** 6 ** This file is part of Qbs. 7 ** 8 ** $QT_BEGIN_LICENSE:LGPL$ 9 ** Commercial License Usage 10 ** Licensees holding valid commercial Qt licenses may use this file in 11 ** accordance with the commercial license agreement provided with the 12 ** Software or, alternatively, in accordance with the terms contained in 13 ** a written agreement between you and The Qt Company. For licensing terms 14 ** and conditions see https://www.qt.io/terms-conditions. For further 15 ** information use the contact form at https://www.qt.io/contact-us. 16 ** 17 ** GNU Lesser General Public License Usage 18 ** Alternatively, this file may be used under the terms of the GNU Lesser 19 ** General Public License version 3 as published by the Free Software 20 ** Foundation and appearing in the file LICENSE.LGPL3 included in the 21 ** packaging of this file. Please review the following information to 22 ** ensure the GNU Lesser General Public License version 3 requirements 23 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. 24 ** 25 ** GNU General Public License Usage 26 ** Alternatively, this file may be used under the terms of the GNU 27 ** General Public License version 2.0 or (at your option) the GNU General 28 ** Public license version 3 or any later version approved by the KDE Free 29 ** Qt Foundation. The licenses are as published by the Free Software 30 ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 31 ** included in the packaging of this file. Please review the following 32 ** information to ensure the GNU General Public License requirements will 33 ** be met: https://www.gnu.org/licenses/gpl-2.0.html and 34 ** https://www.gnu.org/licenses/gpl-3.0.html. 35 ** 36 ** $QT_END_LICENSE$ 37 ** 38 ****************************************************************************/ 39 40 #ifndef QBS_PROPERTYDECLARATION_H 41 #define QBS_PROPERTYDECLARATION_H 42 43 #include <QtCore/qshareddata.h> 44 #include <QtCore/qstring.h> 45 46 QT_BEGIN_NAMESPACE 47 class QVariant; 48 QT_END_NAMESPACE 49 50 namespace qbs { 51 namespace Internal { 52 class DeprecationInfo; 53 class PropertyDeclarationData; 54 55 class PropertyDeclaration 56 { 57 public: 58 enum Type 59 { 60 UnknownType, 61 Boolean, 62 Integer, 63 Path, 64 PathList, 65 String, 66 StringList, 67 Variant, 68 VariantList, 69 }; 70 71 enum Flag 72 { 73 DefaultFlags = 0, 74 ReadOnlyFlag = 0x1, 75 PropertyNotAvailableInConfig = 0x2 // Is this property part of a project, product or file configuration? 76 }; 77 Q_DECLARE_FLAGS(Flags, Flag) 78 79 PropertyDeclaration(); 80 PropertyDeclaration(const QString &name, Type type, const QString &initialValue = QString(), 81 Flags flags = DefaultFlags); 82 PropertyDeclaration(const PropertyDeclaration &other); 83 ~PropertyDeclaration(); 84 85 PropertyDeclaration &operator=(const PropertyDeclaration &other); 86 87 bool isValid() const; 88 bool isScalar() const; 89 90 static Type propertyTypeFromString(const QString &typeName); 91 QString typeString() const; 92 static QString typeString(Type t); 93 94 const QString &name() const; 95 void setName(const QString &name); 96 97 Type type() const; 98 void setType(Type t); 99 100 Flags flags() const; 101 void setFlags(Flags f); 102 103 const QStringList &allowedValues() const; 104 void setAllowedValues(const QStringList &v); 105 106 const QString &description() const; 107 void setDescription(const QString &str); 108 109 const QString &initialValueSource() const; 110 void setInitialValueSource(const QString &str); 111 112 const QStringList &functionArgumentNames() const; 113 void setFunctionArgumentNames(const QStringList &lst); 114 115 bool isDeprecated() const; 116 bool isExpired() const; 117 const DeprecationInfo &deprecationInfo() const; 118 void setDeprecationInfo(const DeprecationInfo &deprecationInfo); 119 120 static QVariant convertToPropertyType( 121 const QVariant &v, Type t, const QStringList &namePrefix, const QString &key); 122 123 private: 124 QSharedDataPointer<PropertyDeclarationData> d; 125 }; 126 127 } // namespace Internal 128 } // namespace qbs 129 130 #endif // QBS_PROPERTYDECLARATION_H 131