8#include "basicindexingjob.h"
9#include "termgenerator.h"
15#include <KFileMetaData/Types>
16#include <KFileMetaData/UserMetaData>
20BasicIndexingJob::BasicIndexingJob(
const QString& filePath,
const QString& mimetype,
22 : m_filePath(filePath)
24 , m_indexingLevel(
level)
38 auto attributes = userMetaData.queryAttributes(Attribute::Tags |
39 Attribute::Rating | Attribute::Comment);
40 if (attributes == Attribute::None) {
44 TermGenerator tg(doc);
47 for (
const QString& tag : tags) {
49 doc.addXattrTerm(
QByteArray(
"TAG-") + tag.toUtf8());
52 int rating = userMetaData.rating();
57 QString comment = userMetaData.userComment();
83 types << Type::Document;
87 types << Type::Presentation;
88 types << Type::Document;
91 types << Type::Spreadsheet;
92 types << Type::Document;
97 types << Type::Archive;
101 {QStringLiteral(
"text/plain"), Type::Document},
103 {QStringLiteral(
"application/msword"), Type::Document},
104 {QStringLiteral(
"application/x-scribus"), Type::Document},
116 {QStringLiteral(
"application/vnd.openxmlformats-officedocument.presentationml.presentation"), Type::Presentation},
117 {QStringLiteral(
"application/vnd.openxmlformats-officedocument.presentationml.slideshow"), Type::Presentation},
118 {QStringLiteral(
"application/vnd.openxmlformats-officedocument.presentationml.template"), Type::Presentation},
119 {QStringLiteral(
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"), Type::Spreadsheet},
121 {QStringLiteral(
"application/vnd.oasis.opendocument.presentation"), Type::Presentation},
122 {QStringLiteral(
"application/vnd.oasis.opendocument.spreadsheet"), Type::Spreadsheet},
123 {QStringLiteral(
"application/pdf"), Type::Document},
124 {QStringLiteral(
"application/postscript"), Type::Document},
125 {QStringLiteral(
"application/x-dvi"), Type::Document},
126 {QStringLiteral(
"application/rtf"), Type::Document},
128 {QStringLiteral(
"application/epub+zip"), Type::Document},
129 {QStringLiteral(
"application/vnd.amazon.mobi8-ebook"), Type::Document},
130 {QStringLiteral(
"application/x-mobipocket-ebook"), Type::Document},
132 {QStringLiteral(
"application/vnd.comicbook-rar"), Type::Document},
133 {QStringLiteral(
"application/vnd.comicbook+zip"), Type::Document},
134 {QStringLiteral(
"application/x-cb7"), Type::Document},
135 {QStringLiteral(
"application/x-cbt"), Type::Document},
137 {QStringLiteral(
"application/gzip"), Type::Archive},
138 {QStringLiteral(
"application/x-tar"), Type::Archive},
139 {QStringLiteral(
"application/x-tarz"), Type::Archive},
140 {QStringLiteral(
"application/x-arc"), Type::Archive},
141 {QStringLiteral(
"application/x-archive"), Type::Archive},
142 {QStringLiteral(
"application/x-bzip"), Type::Archive},
143 {QStringLiteral(
"application/x-cpio"), Type::Archive},
144 {QStringLiteral(
"application/x-lha"), Type::Archive},
145 {QStringLiteral(
"application/x-lhz"), Type::Archive},
146 {QStringLiteral(
"application/x-lrzip"), Type::Archive},
147 {QStringLiteral(
"application/x-lz4"), Type::Archive},
148 {QStringLiteral(
"application/x-lzip"), Type::Archive},
149 {QStringLiteral(
"application/x-lzma"), Type::Archive},
150 {QStringLiteral(
"application/x-lzop"), Type::Archive},
151 {QStringLiteral(
"application/x-7z-compressed"), Type::Archive},
152 {QStringLiteral(
"application/x-ace"), Type::Archive},
153 {QStringLiteral(
"application/x-astrotite-afa"), Type::Archive},
154 {QStringLiteral(
"application/x-alz"), Type::Archive},
155 {QStringLiteral(
"application/vnd.android.package-archive"), Type::Archive},
156 {QStringLiteral(
"application/x-arj"), Type::Archive},
157 {QStringLiteral(
"application/vnd.ms-cab-compressed"), Type::Archive},
158 {QStringLiteral(
"application/x-cfs-compressed"), Type::Archive},
159 {QStringLiteral(
"application/x-dar"), Type::Archive},
160 {QStringLiteral(
"application/x-lzh"), Type::Archive},
161 {QStringLiteral(
"application/x-lzx"), Type::Archive},
162 {QStringLiteral(
"application/vnd.rar"), Type::Archive},
163 {QStringLiteral(
"application/x-stuffit"), Type::Archive},
164 {QStringLiteral(
"application/x-stuffitx"), Type::Archive},
165 {QStringLiteral(
"application/x-tzo"), Type::Archive},
166 {QStringLiteral(
"application/x-ustar"), Type::Archive},
167 {QStringLiteral(
"application/x-xar"), Type::Archive},
168 {QStringLiteral(
"application/x-xz"), Type::Archive},
169 {QStringLiteral(
"application/x-zoo"), Type::Archive},
170 {QStringLiteral(
"application/zip"), Type::Archive},
171 {QStringLiteral(
"application/zlib"), Type::Archive},
172 {QStringLiteral(
"application/zstd"), Type::Archive},
174 {QStringLiteral(
"application/wps-office.doc"), Type::Document},
175 {QStringLiteral(
"application/wps-office.xls"), Type::Document},
176 {QStringLiteral(
"application/wps-office.xls"), Type::Spreadsheet},
177 {QStringLiteral(
"application/wps-office.pot"), Type::Document},
178 {QStringLiteral(
"application/wps-office.pot"), Type::Presentation},
179 {QStringLiteral(
"application/wps-office.wps"), Type::Document},
180 {QStringLiteral(
"application/wps-office.docx"), Type::Document},
181 {QStringLiteral(
"application/wps-office.xlsx"), Type::Document},
182 {QStringLiteral(
"application/wps-office.xlsx"), Type::Spreadsheet},
183 {QStringLiteral(
"application/wps-office.pptx"), Type::Document},
184 {QStringLiteral(
"application/wps-office.pptx"), Type::Presentation},
186 {QStringLiteral(
"text/markdown"), Type::Document},
187 {QStringLiteral(
"image/vnd.djvu+multipage"), Type::Document},
188 {QStringLiteral(
"application/x-lyx"), Type::Document}
191 auto hashIt = typeMapper.
find(mimeType);
192 while (hashIt != typeMapper.end() && hashIt.key() == mimeType) {
193 types.
append(hashIt.value());
201BasicIndexingJob::~BasicIndexingJob()
205bool BasicIndexingJob::index()
214 if (filePathToStat(filePath, statBuf) != 0) {
221 if (filePathToStat(url, statBuf) != 0) {
227 TermGenerator tg(doc);
229 if (statBuf.st_size == 0) {
230 tg.indexText(QStringLiteral(
"application/x-zerosize"),
QByteArray(
"M"));
236 doc.setMTime(statBuf.st_mtime);
237 doc.setCTime(statBuf.st_ctime);
239 if (S_ISDIR(statBuf.st_mode)) {
244 }
else if (statBuf.st_size > 0) {
245 if (m_indexingLevel == MarkForContentIndexing) {
246 doc.setContentIndexing(
true);
256 indexXAttr(m_filePath, doc);
Type type(const QSqlDatabase &db)
Implements storage for docIds without any associated data Instantiated for:
quint64 statBufToId(const QT_STATBUF &stBuf)
Convert the QT_STATBUF into a 64 bit unique identifier for the file.
KCALUTILS_EXPORT QString mimeType()
KIOCORE_EXPORT MimetypeJob * mimetype(const QUrl &url, JobFlags flags=DefaultFlags)
QStringView level(QStringView ifopt)
qsizetype lastIndexOf(QByteArrayView bv) const const
QByteArray left(qsizetype len) const const
QByteArray mid(qsizetype pos, qsizetype len) const const
QByteArray number(double n, char format, int precision)
QString decodeName(const QByteArray &localFileName)
QByteArray encodeName(const QString &fileName)
void append(QList< T > &&value)
void reserve(qsizetype size)
iterator find(const Key &key, const T &value)
bool contains(QChar ch, Qt::CaseSensitivity cs) const const
bool endsWith(QChar c, Qt::CaseSensitivity cs) const const
bool isEmpty() const const
bool startsWith(QChar c, Qt::CaseSensitivity cs) const const