File indexing completed on 2025-02-16 13:03:42
0001 /* 0002 This file is part of the KFileMetaData project 0003 SPDX-FileCopyrightText: 2014 Vishesh Handa <me@vhanda.in> 0004 0005 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0006 */ 0007 0008 #ifndef _KFILEMETADATA_PROPERTYINFO_H 0009 #define _KFILEMETADATA_PROPERTYINFO_H 0010 0011 #include <QString> 0012 #include <QVariant> 0013 #include "properties.h" 0014 #include "kfilemetadata_export.h" 0015 0016 namespace KFileMetaData { 0017 0018 class PropertyInfoData; 0019 /** 0020 * \class PropertyInfo propertyinfo.h <KFileMetaData/PropertyInfo> 0021 * 0022 * The PropertyInfo class can be used to obtain extra information 0023 * about any property. It is commonly used be indexers in order 0024 * to obtain a translatable name of the property along with 0025 * additional information such as if the property should be indexed. 0026 */ 0027 class KFILEMETADATA_EXPORT PropertyInfo 0028 { 0029 public: 0030 PropertyInfo(); 0031 PropertyInfo(Property::Property property); 0032 PropertyInfo(const PropertyInfo& pi); 0033 ~PropertyInfo(); 0034 0035 PropertyInfo& operator=(const PropertyInfo& rhs); 0036 bool operator==(const PropertyInfo& rhs) const; 0037 0038 /** 0039 * The enumeration which represents this property 0040 */ 0041 Property::Property property() const; 0042 0043 /** 0044 * The internal unique name used to refer to the property 0045 */ 0046 QString name() const; 0047 0048 /** 0049 * A user visible name of the property 0050 * 0051 * Note: When the displayName for a given property is used repeatedly 0052 * the returned value should be cached, as calling this method is 0053 * fairly expensive, as the returned name is localized. 0054 */ 0055 QString displayName() const; 0056 0057 /** 0058 * The type the value of this property should be. 0059 * Eg - Property::Height should be an integer 0060 */ 0061 QVariant::Type valueType() const; 0062 0063 /** 0064 * Indicates if this property requires indexing or should just be stored. 0065 * Eg - Property::Height does not need to be part of the global index. 0066 * When a user searches for 600, they should not get images with 0067 * that height 0068 * 0069 * This is just a recommendation. 0070 */ 0071 bool shouldBeIndexed() const; 0072 0073 /** 0074 * Construct a PropertyInfo from the internal property name. 0075 * The internal property name is case insensitive 0076 */ 0077 static PropertyInfo fromName(const QString& name); 0078 0079 /** 0080 * Get all supported property names 0081 * @since 6.0 0082 */ 0083 static QStringList allNames(); 0084 0085 /** 0086 * Returns the value of the property as a QString with added formatting, 0087 * added units if needed, and translated enums. 0088 * @since 5.56 0089 */ 0090 QString formatAsDisplayString(const QVariant& value) const; 0091 0092 private: 0093 const PropertyInfoData* d; 0094 }; 0095 0096 } // namespace 0097 Q_DECLARE_METATYPE(KFileMetaData::PropertyInfo) 0098 0099 0100 #endif // _KFILEMETADATA_PROPERTYINFO_H