Changeset View
Changeset View
Standalone View
Standalone View
src/file/basicindexingjob.cpp
Show All 35 Lines | |||||
36 | BasicIndexingJob::BasicIndexingJob(const QString& filePath, const QString& mimetype, | 36 | BasicIndexingJob::BasicIndexingJob(const QString& filePath, const QString& mimetype, | ||
37 | IndexingLevel level) | 37 | IndexingLevel level) | ||
38 | : m_filePath(filePath) | 38 | : m_filePath(filePath) | ||
39 | , m_mimetype(mimetype) | 39 | , m_mimetype(mimetype) | ||
40 | , m_indexingLevel(level) | 40 | , m_indexingLevel(level) | ||
41 | { | 41 | { | ||
42 | } | 42 | } | ||
43 | 43 | | |||
44 | namespace { | ||||
45 | | ||||
46 | void indexXAttr(const QString& url, Document& doc) | ||||
47 | { | ||||
48 | KFileMetaData::UserMetaData userMetaData(url); | ||||
49 | TermGenerator tg(doc); | ||||
50 | | ||||
51 | QStringList tags = userMetaData.tags(); | ||||
52 | for (const QString& tag : tags) { | ||||
53 | tg.indexXattrText(tag, QByteArray("TA")); | ||||
54 | doc.addXattrTerm(QByteArray("TAG-") + tag.toUtf8()); | ||||
55 | } | ||||
56 | | ||||
57 | int rating = userMetaData.rating(); | ||||
58 | if (rating) { | ||||
59 | doc.addXattrTerm(QByteArray("R") + QByteArray::number(rating)); | ||||
60 | } | ||||
61 | | ||||
62 | QString comment = userMetaData.userComment(); | ||||
63 | if (!comment.isEmpty()) { | ||||
64 | tg.indexXattrText(comment, QByteArray("C")); | ||||
65 | } | ||||
66 | } | ||||
67 | } // namespace | ||||
68 | | ||||
44 | BasicIndexingJob::~BasicIndexingJob() | 69 | BasicIndexingJob::~BasicIndexingJob() | ||
45 | { | 70 | { | ||
46 | } | 71 | } | ||
47 | 72 | | |||
48 | bool BasicIndexingJob::index() | 73 | bool BasicIndexingJob::index() | ||
49 | { | 74 | { | ||
50 | const QByteArray url = QFile::encodeName(m_filePath); | 75 | const QByteArray url = QFile::encodeName(m_filePath); | ||
51 | 76 | | |||
Show All 34 Lines | |||||
86 | } | 111 | } | ||
87 | 112 | | |||
88 | indexXAttr(m_filePath, doc); | 113 | indexXAttr(m_filePath, doc); | ||
89 | 114 | | |||
90 | m_doc = doc; | 115 | m_doc = doc; | ||
91 | return true; | 116 | return true; | ||
92 | } | 117 | } | ||
93 | 118 | | |||
94 | bool BasicIndexingJob::indexXAttr(const QString& url, Document& doc) | | |||
95 | { | | |||
96 | KFileMetaData::UserMetaData userMetaData(url); | | |||
97 | TermGenerator tg(doc); | | |||
98 | | ||||
99 | QStringList tags = userMetaData.tags(); | | |||
100 | for (const QString& tag : tags) { | | |||
101 | tg.indexXattrText(tag, QByteArray("TA")); | | |||
102 | doc.addXattrTerm(QByteArray("TAG-") + tag.toUtf8()); | | |||
103 | } | | |||
104 | | ||||
105 | int rating = userMetaData.rating(); | | |||
106 | if (rating) { | | |||
107 | doc.addXattrTerm(QByteArray("R") + QByteArray::number(rating)); | | |||
108 | } | | |||
109 | | ||||
110 | QString comment = userMetaData.userComment(); | | |||
111 | if (!comment.isEmpty()) { | | |||
112 | tg.indexXattrText(comment, QByteArray("C")); | | |||
113 | } | | |||
114 | | ||||
115 | return (!tags.isEmpty() || rating || !comment.isEmpty()); | | |||
116 | } | | |||
117 | 119 | | |||
118 | QVector<KFileMetaData::Type::Type> BasicIndexingJob::typesForMimeType(const QString& mimeType) | 120 | QVector<KFileMetaData::Type::Type> BasicIndexingJob::typesForMimeType(const QString& mimeType) | ||
119 | { | 121 | { | ||
120 | using namespace KFileMetaData; | 122 | using namespace KFileMetaData; | ||
121 | QVector<Type::Type> types; | 123 | QVector<Type::Type> types; | ||
122 | 124 | | |||
123 | // Basic types | 125 | // Basic types | ||
124 | if (mimeType.startsWith(QLatin1String("audio/"))) | 126 | if (mimeType.startsWith(QLatin1String("audio/"))) | ||
▲ Show 20 Lines • Show All 95 Lines • Show Last 20 Lines |