KFileMetaData

usermetadata.h
1/*
2 SPDX-FileCopyrightText: 2014 Vishesh Handa <me@vhanda.in>
3
4 SPDX-License-Identifier: LGPL-2.1-or-later
5*/
6
7#ifndef KFILEMETADATA_USERMETADATA_H
8#define KFILEMETADATA_USERMETADATA_H
9
10#include "kfilemetadata_export.h"
11#include <QStringList>
12#include <QUrl>
13
14#include <memory>
15
16namespace KFileMetaData {
17
18class UserMetaDataPrivate;
19
20/**
21 * \class UserMetaData usermetadata.h <KFileMetaData/UserMetaData>
22 *
23 * \brief The UserMetaData class can be used to read and set user meta data of files.
24 */
25class KFILEMETADATA_EXPORT UserMetaData
26{
27public:
28 UserMetaData(const QString &filePath);
29 UserMetaData(const UserMetaData &rhs);
30 virtual ~UserMetaData();
31
32 enum Error {
33 /// i.e Success
34 NoError = 0,
35 /// An error that's not currently handled specifically @since 6.2
37 /// Underlying filesystem does not provide extended attributes features @since 6.2
39 /// There is insufficient space remaining to store the extended attribute. @since 6.2
41 /// Process doesn't have write permission to the file or the file is marked append-only @since 6.2
43 /// The value size exceeds the maximum size allowed per-value (64 kB for Linux VFS) @since 6.2
45 /// The attribute name is too long (255 bytes for Linux VFS) @since 6.2
47 };
48
49 /**
50 * @see Attributes
51 */
52 enum Attribute : uint32_t {
53 None = 0x0,
54 Any = None,
55 Tags = 0x1,
56 Rating = 0x2,
57 Comment = 0x4,
58 OriginUrl = 0x8,
59 OriginEmailSubject = 0x10,
60 OriginEmailSender = 0x20,
61 OriginEmailMessageId = 0x40,
62 Other = 0xffffff80,
63 All = 0xffffffff,
64 };
65 /**
66 * Stores a combination of #Attribute values.
67 */
68 Q_DECLARE_FLAGS(Attributes, Attribute)
69
70 const UserMetaData& operator =(const UserMetaData& rhs);
71
72 QString filePath() const;
73 bool isSupported() const;
74
75 Error setTags(const QStringList& tags);
76 QStringList tags() const;
77
78 int rating() const;
79 Error setRating(int rating);
80
81 QString userComment() const;
82 Error setUserComment(const QString& userComment);
83
84 QUrl originUrl() const;
85 Error setOriginUrl(const QUrl &originUrl);
86
87 QString originEmailSubject() const;
88 Error setOriginEmailSubject(const QString &originEmailSubject);
89
90 QString originEmailSender() const;
91 Error setOriginEmailSender(const QString &originEmailSender);
92
93 QString originEmailMessageId() const;
94 Error setOriginEmailMessageId(const QString &originEmailMessageId);
95
96#if KFILEMETADATA_ENABLE_DEPRECATED_SINCE(6, 2)
97 /// @deprecated since 6.2
98 QString attribute(const QString &name);
99#endif
100 /// @since 6.2
101 QString attribute(const QString &name) const;
102
103 Error setAttribute(const QString &name, const QString &value);
104
105#if KFILEMETADATA_ENABLE_DEPRECATED_SINCE(6, 2)
106 /// @deprecated since 6.2
107 bool hasAttribute(const QString &name);
108#endif
109 /// @since 6.2
110 bool hasAttribute(const QString &name) const;
111
112 /**
113 * Query list of available attributes
114 *
115 * Checks for the availability of the given \p attributes. May return
116 * a superset of the input value when the file has attributes set
117 * beyond the requested ones.
118 *
119 * If the input attribute mask is Attribute::Any, either Attribute::None
120 * (the file has no user attributes) or Attribute::All (the file has at
121 * least one attribute set) is returned.
122 *
123 * \since 5.60
124 */
125 Attributes queryAttributes(Attributes attributes = Attribute::Any) const;
126
127private:
128 const std::unique_ptr<UserMetaDataPrivate> d;
129};
130
131Q_DECLARE_OPERATORS_FOR_FLAGS(UserMetaData::Attributes)
132}
133
134#endif // KFILEMETADATA_USERMETADATA_H
The UserMetaData class can be used to read and set user meta data of files.
@ NameToolong
The attribute name is too long (255 bytes for Linux VFS)
@ NoSpace
There is insufficient space remaining to store the extended attribute.
@ UnknownError
An error that's not currently handled specifically.
@ MissingPermission
Process doesn't have write permission to the file or the file is marked append-only.
@ ValueTooBig
The value size exceeds the maximum size allowed per-value (64 kB for Linux VFS)
@ NotSupported
Underlying filesystem does not provide extended attributes features.
The KFileMetaData namespace.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 17 2024 11:49:15 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.