KFileMetaData

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

KDE's Doxygen guidelines are available online.