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 * 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 */
27class KFILEMETADATA_EXPORT PropertyInfo
28{
29public:
32 PropertyInfo(const PropertyInfo& pi);
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 QMetaType::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 the names of all valid, supported properties
81 *
82 * Note: Property::Empty is not considered a valid property.
83 *
84 * @since 6.0
85 * @since 5.107
86 */
87 static QStringList allNames();
88
89 /**
90 * Returns the value of the property as a QString with added formatting,
91 * added units if needed, and translated enums.
92 * @since 5.56
93 */
94 QString formatAsDisplayString(const QVariant& value) const;
95
96private:
97 const PropertyInfoData* d;
98};
99
100} // namespace
101Q_DECLARE_METATYPE(KFileMetaData::PropertyInfo)
102
103
104#endif // _KFILEMETADATA_PROPERTYINFO_H
The PropertyInfo class can be used to obtain extra information about any property.
<KFileMetaData/Properties>
Property
The Property enum contains all files property types that KFileMetaData manipulates.
Definition properties.h:23
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:17:54 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.