KIO
13 #include "../utils_p.h"
15 #include <QDataStream>
30 void reserve(
int size);
33 void insert(uint udsField,
long long value);
34 void replace(uint udsField,
long long value);
36 QString stringValue(uint udsField)
const;
37 long long numberValue(uint udsField,
long long defaultValue = -1)
const;
38 #if KIOCORE_BUILD_DEPRECATED_SINCE(5, 8)
42 bool contains(uint udsField)
const;
46 void debugUDSEntry(
QDebug &stream)
const;
51 static QString nameOfUdsField(uint field);
58 inline Field(
const uint index,
const QString &value)
63 inline Field(
const uint index,
long long value = 0)
70 long long m_long = LLONG_MIN;
73 std::vector<Field> storage;
76 void UDSEntryPrivate::reserve(
int size)
81 void UDSEntryPrivate::insert(uint udsField,
const QString &value)
84 Q_ASSERT(std::find_if(storage.cbegin(),
86 [udsField](
const Field &entry) {
87 return entry.m_index == udsField;
90 storage.emplace_back(udsField, value);
93 void UDSEntryPrivate::replace(uint udsField,
const QString &value)
96 auto it = std::find_if(storage.begin(), storage.end(), [udsField](
const Field &entry) {
97 return entry.m_index == udsField;
99 if (it != storage.end()) {
103 storage.emplace_back(udsField, value);
106 void UDSEntryPrivate::insert(uint udsField,
long long value)
109 Q_ASSERT(std::find_if(storage.cbegin(),
111 [udsField](
const Field &entry) {
112 return entry.m_index == udsField;
115 storage.emplace_back(udsField, value);
118 void UDSEntryPrivate::replace(uint udsField,
long long value)
121 auto it = std::find_if(storage.begin(), storage.end(), [udsField](
const Field &entry) {
122 return entry.m_index == udsField;
124 if (it != storage.end()) {
128 storage.emplace_back(udsField, value);
131 int UDSEntryPrivate::count()
const
133 return storage.size();
136 QString UDSEntryPrivate::stringValue(uint udsField)
const
138 auto it = std::find_if(storage.cbegin(), storage.cend(), [udsField](
const Field &entry) {
139 return entry.m_index == udsField;
141 if (it != storage.cend()) {
147 long long UDSEntryPrivate::numberValue(uint udsField,
long long defaultValue)
const
149 auto it = std::find_if(storage.cbegin(), storage.cend(), [udsField](
const Field &entry) {
150 return entry.m_index == udsField;
152 if (it != storage.cend()) {
158 #if KIOCORE_BUILD_DEPRECATED_SINCE(5, 8)
163 for (
const Field &field : storage) {
164 res.
append(field.m_index);
174 for (
const Field &field : storage) {
175 res.
append(field.m_index);
180 bool UDSEntryPrivate::contains(uint udsField)
const
182 auto it = std::find_if(storage.cbegin(), storage.cend(), [udsField](
const Field &entry) {
183 return entry.m_index == udsField;
185 return (it != storage.cend());
188 void UDSEntryPrivate::clear()
195 s << static_cast<quint32>(storage.size());
197 for (
const Field &field : storage) {
198 uint uds = field.m_index;
206 Q_ASSERT_X(
false,
"KIO::UDSEntry",
"Found a field with an invalid type");
223 if (quint32(cachedStrings.size()) < size) {
224 cachedStrings.
resize(size);
227 for (quint32 i = 0; i < size; ++i) {
238 if (buffer != cachedStrings.at(i)) {
239 cachedStrings[i] = buffer;
242 insert(uds, cachedStrings.at(i));
248 Q_ASSERT_X(
false,
"KIO::UDSEntry",
"Found a field with an invalid type");
253 QString UDSEntryPrivate::nameOfUdsField(uint field)
257 return QStringLiteral(
"UDS_SIZE");
259 return QStringLiteral(
"UDS_SIZE_LARGE");
261 return QStringLiteral(
"UDS_USER");
263 return QStringLiteral(
"UDS_ICON_NAME");
265 return QStringLiteral(
"UDS_GROUP");
267 return QStringLiteral(
"UDS_NAME");
269 return QStringLiteral(
"UDS_LOCAL_PATH");
271 return QStringLiteral(
"UDS_HIDDEN");
273 return QStringLiteral(
"UDS_ACCESS");
275 return QStringLiteral(
"UDS_MODIFICATION_TIME");
277 return QStringLiteral(
"UDS_ACCESS_TIME");
279 return QStringLiteral(
"UDS_CREATION_TIME");
281 return QStringLiteral(
"UDS_FILE_TYPE");
283 return QStringLiteral(
"UDS_LINK_DEST");
285 return QStringLiteral(
"UDS_URL");
287 return QStringLiteral(
"UDS_MIME_TYPE");
289 return QStringLiteral(
"UDS_GUESSED_MIME_TYPE");
291 return QStringLiteral(
"UDS_XML_PROPERTIES");
293 return QStringLiteral(
"UDS_EXTENDED_ACL");
295 return QStringLiteral(
"UDS_ACL_STRING");
297 return QStringLiteral(
"UDS_DEFAULT_ACL_STRING");
299 return QStringLiteral(
"UDS_DISPLAY_NAME");
301 return QStringLiteral(
"UDS_TARGET_URL");
303 return QStringLiteral(
"UDS_DISPLAY_TYPE");
305 return QStringLiteral(
"UDS_ICON_OVERLAY_NAMES");
307 return QStringLiteral(
"UDS_COMMENT");
309 return QStringLiteral(
"UDS_DEVICE_ID");
311 return QStringLiteral(
"UDS_INODE");
313 return QStringLiteral(
"UDS_EXTRA");
315 return QStringLiteral(
"UDS_EXTRA_END");
317 return QStringLiteral(
"Unknown uds field %1").arg(field);
321 void UDSEntryPrivate::debugUDSEntry(
QDebug &stream)
const
325 for (
const Field &field : storage) {
326 stream <<
" " << nameOfUdsField(field.m_index) <<
"=";
328 stream << field.m_str;
330 stream << field.m_long;
332 Q_ASSERT_X(
false,
"KIO::UDSEntry",
"Found a field with an invalid type");
343 : d(new UDSEntryPrivate())
348 UDSEntry::UDSEntry(
const QT_STATBUF &buff,
const QString &name)
349 : d(new UDSEntryPrivate())
370 UDSEntry::UDSEntry(
const UDSEntry &) =
default;
372 UDSEntry::UDSEntry(
UDSEntry &&) =
default;
378 return d->stringValue(field);
383 return d->numberValue(field, defaultValue);
403 d->insert(field, value);
408 d->insert(field, value);
411 #if KIOCORE_BUILD_DEPRECATED_SINCE(5, 48)
414 d->replace(field, value);
418 #if KIOCORE_BUILD_DEPRECATED_SINCE(5, 48)
421 d->replace(field, value);
427 d->replace(field, value);
432 d->replace(field, value);
435 #if KIOCORE_BUILD_DEPRECATED_SINCE(5, 8)
438 return d->listFields();
454 return d->contains(field);
465 entry.d->debugUDSEntry(stream);
488 for (uint field : fields) {
509 return !(entry == other);
void append(const T &value)
int count() const
count fields
@ UDS_DEFAULT_ACL_STRING
The default access control list serialized into a single string.
KCALENDARCORE_EXPORT QDataStream & operator<<(QDataStream &out, const KCalendarCore::Alarm::Ptr &)
@ UDS_ICON_OVERLAY_NAMES
25 was used by the now removed UDS_NEPOMUK_URI
@ UDS_ACCESS_TIME
The last time the file was opened. Required time format: seconds since UNIX epoch.
@ UDS_HIDDEN
Treat the file as a hidden file (if set to 1) or as a normal file (if set to 0).
@ UDS_USER
User ID of the file owner.
void append(const T &value)
@ UDS_GUESSED_MIME_TYPE
A MIME type to be used for displaying only.
@ UDS_TARGET_URL
This file is a shortcut or mount, pointing to an URL in a different hierarchy.
QVector< uint > fields() const
A vector of fields being present for the current entry.
KCALENDARCORE_EXPORT QDataStream & operator>>(QDataStream &in, const KCalendarCore::Alarm::Ptr &)
@ UDS_LINK_DEST
Name of the file where the link points to Allows to check for a symlink (don't use S_ISLNK !...
QAction * load(const QObject *recvr, const char *slot, QObject *parent)
bool insert(Part *part, qint64 *insertId=nullptr)
@ UDS_FILE_TYPE
File type, part of the mode returned by stat (for a link, this returns the file type of the pointed i...
@ UDS_NAME
Filename - as displayed in directory listings etc.
QString stringValue(uint field) const
void insert(uint field, const QString &value)
insert field with string value
@ UDS_INODE
Inode number for this file, used to detect hardlinks.
@ UDS_ICON_NAME
Name of the icon, that should be used for displaying.
QList< uint > listFields() const
List all fields.
bool operator==(const Qt3DRender::QGraphicsApiFilter &reference, const Qt3DRender::QGraphicsApiFilter &sample)
@ UDS_URL
An alternative URL (If different from the caption).
bool isEmpty() const const
bool operator!=(const Qt3DRender::QGraphicsApiFilter &reference, const Qt3DRender::QGraphicsApiFilter &sample)
@ UDS_SIZE
Size of the file.
QAction * replace(const QObject *recvr, const char *slot, QObject *parent)
void reserve(int size)
Calling this function before inserting items into an empty UDSEntry may save time and memory.
@ UDS_EXTRA
Extra data (used only if you specified Columns/ColumnsTypes) NB: you cannot repeat this entry; use UD...
QString loginName() const
void clear()
remove all fields
@ UDS_GROUP
Group ID of the file owner.
QAction * clear(const QObject *recvr, const char *slot, QObject *parent)
void fastInsert(uint field, const QString &value)
insert field with string value, it will assert if the field is already inserted.
long long numberValue(uint field, long long defaultValue=0) const
@ UDS_LOCAL_PATH
A local file path if the KIO worker display files sitting on the local filesystem (but in another hie...
@ UDS_MODIFICATION_TIME
The last time the file was modified. Required time format: seconds since UNIX epoch.
void replace(uint field, const QString &value)
Replace or insert field with string value.
@ UDS_EXTENDED_ACL
Indicates that the entry has extended ACL entries.
@ UDS_DISPLAY_TYPE
User-readable type of file (if not specified, the MIME type's description is used)
A namespace for KIO globals.
@ UDS_ACL_STRING
The access control list serialized into a single string.
@ UDS_STRING
Indicates that the field is a QString.
@ UDS_ACCESS
Access permissions (part of the mode returned by stat)
@ UDS_DISPLAY_NAME
If set, contains the label to display instead of the 'real name' in UDS_NAME.
@ UDS_DEVICE_ID
Device number for this file, used to detect hardlinks.
UDSEntry & operator=(const UDSEntry &)
Copy assignment.
@ UDS_NUMBER
Indicates that the field is a number (long long)
@ UDS_MIME_TYPE
A MIME type; the KIO worker should set it if it's known.
bool contains(uint field) const
check existence of a field
@ UDS_EXTRA_END
Extra data (used only if you specified Columns/ColumnsTypes) NB: you cannot repeat this entry; use UD...
@ UDS_XML_PROPERTIES
XML properties, e.g. for WebDAV.
@ UDS_COMMENT
27 was used by the now removed UDS_NEPOMUK_QUERY
QAction * save(const QObject *recvr, const char *slot, QObject *parent)
@ UDS_CREATION_TIME
The time the file was created. Required time format: seconds since UNIX epoch.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Thu Mar 23 2023 03:59:43 by
doxygen 1.8.17 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.