| 1 | /* |
| 2 | This file is part of the KFileMetaData project |
| 3 | SPDX-FileCopyrightText: 2014 Vishesh Handa <me@vhanda.in> |
| 4 | |
| 5 | SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL |
| 6 | */ |
| 7 | |
| 8 | #ifndef _KFILEMETADATA_PROPERTYINFO_H |
| 9 | #define _KFILEMETADATA_PROPERTYINFO_H |
| 10 | |
| 11 | #include <QString> |
| 12 | #include <QVariant> |
| 13 | #include "properties.h" |
| 14 | #include "kfilemetadata_export.h" |
| 15 | |
| 16 | namespace KFileMetaData { |
| 17 | |
| 18 | class PropertyInfoData; |
| 19 | /*! |
| 20 | * \class KFileMetaData::PropertyInfo |
| 21 | * \inheaderfile KFileMetaData/PropertyInfo |
| 22 | * \inmodule KFileMetaData |
| 23 | * |
| 24 | * \brief The PropertyInfo class can be used to obtain extra information |
| 25 | * about any property. |
| 26 | * |
| 27 | * It is commonly used be indexers in order |
| 28 | * to obtain a translatable name of the property along with |
| 29 | * additional information such as if the property should be indexed. |
| 30 | */ |
| 31 | class KFILEMETADATA_EXPORT PropertyInfo |
| 32 | { |
| 33 | public: |
| 34 | /*! |
| 35 | * |
| 36 | */ |
| 37 | PropertyInfo(); |
| 38 | |
| 39 | /*! |
| 40 | * |
| 41 | */ |
| 42 | PropertyInfo(Property::Property property); |
| 43 | PropertyInfo(const PropertyInfo& pi); |
| 44 | ~PropertyInfo(); |
| 45 | |
| 46 | PropertyInfo& operator=(const PropertyInfo& rhs); |
| 47 | |
| 48 | /*! |
| 49 | * |
| 50 | */ |
| 51 | bool operator==(const PropertyInfo& rhs) const; |
| 52 | |
| 53 | /*! |
| 54 | * The enumeration which represents this property |
| 55 | */ |
| 56 | Property::Property property() const; |
| 57 | |
| 58 | /*! |
| 59 | * The internal unique name used to refer to the property |
| 60 | */ |
| 61 | QString name() const; |
| 62 | |
| 63 | /*! |
| 64 | * A user visible name of the property |
| 65 | * |
| 66 | * Note: When the displayName for a given property is used repeatedly |
| 67 | * the returned value should be cached, as calling this method is |
| 68 | * fairly expensive, as the returned name is localized. |
| 69 | */ |
| 70 | QString displayName() const; |
| 71 | |
| 72 | /*! |
| 73 | * The type the value of this property should be. |
| 74 | * Eg - Property::Height should be an integer |
| 75 | */ |
| 76 | QMetaType::Type valueType() const; |
| 77 | |
| 78 | /*! |
| 79 | * Indicates if this property requires indexing or should just be stored. |
| 80 | * Eg - Property::Height does not need to be part of the global index. |
| 81 | * When a user searches for 600, they should not get images with |
| 82 | * that height |
| 83 | * |
| 84 | * This is just a recommendation. |
| 85 | */ |
| 86 | bool shouldBeIndexed() const; |
| 87 | |
| 88 | /*! |
| 89 | * Construct a PropertyInfo from the internal property name. |
| 90 | * The internal property name is case insensitive |
| 91 | */ |
| 92 | static PropertyInfo fromName(const QString& name); |
| 93 | |
| 94 | /*! |
| 95 | * Get the names of all valid, supported properties |
| 96 | * |
| 97 | * Note: Property::Empty is not considered a valid property. |
| 98 | * |
| 99 | * \since 5.107 |
| 100 | */ |
| 101 | static QStringList allNames(); |
| 102 | |
| 103 | /*! |
| 104 | * Returns the value of the property as a QString with added formatting, |
| 105 | * added units if needed, and translated enums. |
| 106 | * \since 5.56 |
| 107 | */ |
| 108 | QString formatAsDisplayString(const QVariant& value) const; |
| 109 | |
| 110 | private: |
| 111 | const PropertyInfoData* d; |
| 112 | }; |
| 113 | |
| 114 | } // namespace |
| 115 | Q_DECLARE_METATYPE(KFileMetaData::PropertyInfo) |
| 116 | |
| 117 | |
| 118 | #endif // _KFILEMETADATA_PROPERTYINFO_H |
| 119 | |