Changeset View
Changeset View
Standalone View
Standalone View
src/file/extractor/result.cpp
Show First 20 Lines • Show All 79 Lines • ▼ Show 20 Line(s) | 51 | { | |||
---|---|---|---|---|---|
80 | else if (value.type() == QVariant::Date) { | 80 | else if (value.type() == QVariant::Date) { | ||
81 | const QByteArray term = prefix + value.toDate().toString(Qt::ISODate).toUtf8(); | 81 | const QByteArray term = prefix + value.toDate().toString(Qt::ISODate).toUtf8(); | ||
82 | m_doc.addBoolTerm(term); | 82 | m_doc.addBoolTerm(term); | ||
83 | } | 83 | } | ||
84 | else if (value.type() == QVariant::DateTime) { | 84 | else if (value.type() == QVariant::DateTime) { | ||
85 | const QByteArray term = prefix + value.toDateTime().toString(Qt::ISODate).toUtf8(); | 85 | const QByteArray term = prefix + value.toDateTime().toString(Qt::ISODate).toUtf8(); | ||
86 | m_doc.addBoolTerm(term); | 86 | m_doc.addBoolTerm(term); | ||
87 | } | 87 | } | ||
88 | else if (value.type() == QVariant::StringList) { | ||||
89 | bool shouldBeIndexed = KFileMetaData::PropertyInfo(property).shouldBeIndexed(); | ||||
90 | const auto valueList = value.toStringList(); | ||||
bruns: `const auto list = value.toStringList();`, to avoid detach. | |||||
91 | for (const auto& val : valueList) | ||||
92 | { | ||||
93 | if (val.isEmpty()) | ||||
bruns: `continue;`, you don't want to drop the remaining list entries | |||||
94 | continue; | ||||
95 | m_termGen.indexText(val, prefix); | ||||
96 | if (shouldBeIndexed) | ||||
97 | m_termGen.indexText(val); | ||||
98 | | ||||
99 | } | ||||
100 | } | ||||
88 | else { | 101 | else { | ||
89 | const QString val = value.toString(); | 102 | const QString val = value.toString(); | ||
90 | if (val.isEmpty()) | 103 | if (val.isEmpty()) | ||
this check is not strictly necessary - if the list is empty, you iterate zero times in the loop. But see below [1] bruns: this check is not strictly necessary - if the list is empty, you iterate zero times in the loop. | |||||
91 | return; | 104 | return; | ||
92 | 105 | | |||
bool shouldBeIndexed = KFMD:PropertyInfo(property).shouldBeIndexed(); avoids the check on each iteration bruns: `bool shouldBeIndexed = KFMD:PropertyInfo(property).shouldBeIndexed(); `
avoids the check on… | |||||
93 | m_termGen.indexText(val, prefix); | 106 | m_termGen.indexText(val, prefix); | ||
bruns: range-based-for loop, please:
`for (const auto& val : values) { ... }` | |||||
94 | KFileMetaData::PropertyInfo pi(property); | 107 | KFileMetaData::PropertyInfo pi(property); | ||
[1] ... here you miss the check on val.at(i).empty() - the list can contain empty strings. bruns: [1] ... here you miss the check on val.at(i).empty() - the list can contain empty strings. | |||||
95 | if (pi.shouldBeIndexed()) | 108 | if (pi.shouldBeIndexed()) | ||
96 | m_termGen.indexText(val); | 109 | m_termGen.indexText(val); | ||
97 | } | 110 | } | ||
98 | } | 111 | } | ||
99 | 112 | | |||
100 | void Result::append(const QString& text) | 113 | void Result::append(const QString& text) | ||
101 | { | 114 | { | ||
102 | m_termGenForText.indexText(text); | 115 | m_termGenForText.indexText(text); | ||
Show All 39 Lines |
const auto list = value.toStringList();, to avoid detach.