Baloo

kio_tags.h
1 /*
2  This file is part of the KDE Baloo Project
3  SPDX-FileCopyrightText: 2013 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 BALOO_KIO_TAGS_H_
9 #define BALOO_KIO_TAGS_H_
10 
11 #include <KFileMetaData/UserMetaData>
12 #include <KIO/ForwardingWorkerBase>
13 
14 #include "query.h"
15 
16 namespace Baloo
17 {
18 
19 class TagsProtocol : public KIO::ForwardingWorkerBase
20 {
21  Q_OBJECT
22 public:
23  TagsProtocol(const QByteArray& pool_socket, const QByteArray& app_socket);
24  ~TagsProtocol() override;
25 
26  enum UrlType {
27  InvalidUrl,
28  FileUrl,
29  TagUrl,
30  };
31  Q_ENUM(UrlType)
32 
33  /**
34  * List all files and folders tagged with the corresponding tag, along with
35  * additional tags that can be used to filter the results
36  */
37  KIO::WorkerResult listDir(const QUrl& url) override;
38 
39  /**
40  * Will be forwarded for files.
41  */
42  KIO::WorkerResult get(const QUrl& url) override;
43 
44  /**
45  * Files and folders can be copied to the virtual folders resulting
46  * is assignment of the corresponding tag.
47  */
48  KIO::WorkerResult copy(const QUrl& src, const QUrl& dest, int permissions, KIO::JobFlags flags) override;
49 
50  /**
51  * File renaming will be forwarded.
52  * Folder renaming results in renaming of the tag.
53  */
54  KIO::WorkerResult rename(const QUrl& src, const QUrl& dest, KIO::JobFlags flags) override;
55 
56  /**
57  * File deletion means remocing the tag
58  * Folder deletion will result in deletion of the tag.
59  */
60  KIO::WorkerResult del(const QUrl& url, bool isfile) override;
61 
62  /**
63  * Files will be forwarded.
64  * Tags will be created as virtual folders.
65  */
66  KIO::WorkerResult mimetype(const QUrl& url) override;
67 
68  /**
69  * Virtual folders will be created.
70  */
71  KIO::WorkerResult mkdir(const QUrl& url, int permissions) override;
72 
73  /**
74  * Files will be forwarded.
75  * Tags will be created as virtual folders.
76  */
77  KIO::WorkerResult stat(const QUrl& url) override;
78 
79 protected:
80  bool rewriteUrl(const QUrl& url, QUrl& newURL) override;
81 
82 private:
83  enum ParseFlags {
84  ChopLastSection,
85  LazyValidation,
86  };
87 
88  struct ParseResult {
89  UrlType urlType = InvalidUrl;
90  QString decodedUrl;
91  QString tag;
92  QUrl fileUrl;
93  KFileMetaData::UserMetaData metaData = KFileMetaData::UserMetaData(QString());
94  Query query;
95  KIO::UDSEntryList pathUDSResults;
96  };
97 
98  ParseResult parseUrl(const QUrl& url, const QList<ParseFlags> &flags = QList<ParseFlags>());
99  QStringList m_unassignedTags;
100 };
101 }
102 
103 #endif // BALOO_KIO_TAGS_H_
Q_OBJECTQ_OBJECT
std::optional< QSqlQuery > query(const QString &queryStatement)
Q_ENUM(...)
KIOCORE_EXPORT MimetypeJob * mimetype(const QUrl &url, JobFlags flags=DefaultFlags)
QAction * copy(const QObject *recvr, const char *slot, QObject *parent)
int mkdir(const QString &pathname, mode_t mode)
Implements storage for docIds without any associated data Instantiated for:
Definition: coding.cpp:11
KGuiItem del()
int rename(const QString &in, const QString &out)
KIOCORE_EXPORT ListJob * listDir(const QUrl &url, JobFlags flags=DefaultFlags, bool includeHidden=true)
virtual QVariant get(ScriptableExtension *callerPrincipal, quint64 objId, const QString &propName)
int stat(const QString &path, KDE_struct_stat *buf)
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Dec 11 2023 03:53:56 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.