KFileMetaData

propertyinfo.h
1 /*
2  This file is part of the KFileMetaData project
3  SPDX-FileCopyrightText: 2014 Vishesh Handa <[email protected]>
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 PropertyInfo propertyinfo.h <KFileMetaData/PropertyInfo>
21  *
22  * The PropertyInfo class can be used to obtain extra information
23  * about any property. It is commonly used be indexers in order
24  * to obtain a translatable name of the property along with
25  * additional information such as if the property should be indexed.
26  */
27 class KFILEMETADATA_EXPORT PropertyInfo
28 {
29 public:
30  PropertyInfo();
32  PropertyInfo(const PropertyInfo& pi);
33  ~PropertyInfo();
34 
35  PropertyInfo& operator=(const PropertyInfo& rhs);
36  bool operator==(const PropertyInfo& rhs) const;
37 
38  /**
39  * The enumeration which represents this property
40  */
41  Property::Property property() const;
42 
43  /**
44  * The internal unique name used to refer to the property
45  */
46  QString name() const;
47 
48  /**
49  * A user visible name of the property
50  *
51  * Note: When the displayName for a given property is used repeatedly
52  * the returned value should be cached, as calling this method is
53  * fairly expensive, as the returned name is localized.
54  */
55  QString displayName() const;
56 
57  /**
58  * The type the value of this property should be.
59  * Eg - Property::Height should be an integer
60  */
61  QVariant::Type valueType() const;
62 
63  /**
64  * Indicates if this property requires indexing or should just be stored.
65  * Eg - Property::Height does not need to be part of the global index.
66  * When a user searches for 600, they should not get images with
67  * that height
68  *
69  * This is just a recommendation.
70  */
71  bool shouldBeIndexed() const;
72 
73  /**
74  * Construct a PropertyInfo from the internal property name.
75  * The internal property name is case insensitive
76  */
77  static PropertyInfo fromName(const QString& name);
78 
79  /**
80  * Get all supported property names
81  * @since 6.0
82  */
83  static QStringList allNames();
84 
85  /**
86  * Returns the value of the property as a QString with added formatting,
87  * added units if needed, and translated enums.
88  * @since 5.56
89  */
90  QString formatAsDisplayString(const QVariant& value) const;
91 
92 private:
93  const PropertyInfoData* d;
94 };
95 
96 } // namespace
97 Q_DECLARE_METATYPE(KFileMetaData::PropertyInfo)
98 
99 
100 #endif // _KFILEMETADATA_PROPERTYINFO_H
Property
The Property enum contains all files property types that KFileMetaData manipulates.
Definition: properties.h:25
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sat Dec 2 2023 03:48:42 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.