mirror of
https://anongit.gentoo.org/git/repo/gentoo.git
synced 2025-12-19 00:18:26 +00:00
Take a snapshot as upstream releases seem infrequent and we'd have
to backport a few patches if using the last release, and I already did
the dep work for master.
Based on the ebuild from ::kdab-overlay [0].
[0] 640bf73ef2/dev-util/hotspot/hotspot-1.5.1.ebuild
Closes: https://bugs.gentoo.org/624062
Signed-off-by: Sam James <sam@gentoo.org>
234 lines
10 KiB
Diff
234 lines
10 KiB
Diff
--- a/src/models/disassemblymodel.cpp
|
|
+++ b/src/models/disassemblymodel.cpp
|
|
@@ -240,7 +240,7 @@ QModelIndex DisassemblyModel::indexForFileLine(const Data::FileLine& fileLine) c
|
|
return index(bestMatch, 0);
|
|
}
|
|
|
|
-void DisassemblyModel::find(const QString& search, Direction direction, int current)
|
|
+void DisassemblyModel::find(const QString& search, SearchDirection direction, int current)
|
|
{
|
|
auto searchFunc = [&search](const DisassemblyOutput::DisassemblyLine& line) {
|
|
return line.disassembly.indexOf(search, 0, Qt::CaseInsensitive) != -1;
|
|
--- a/src/models/disassemblymodel.h
|
|
+++ b/src/models/disassemblymodel.h
|
|
@@ -20,7 +20,7 @@ class Definition;
|
|
class Repository;
|
|
}
|
|
|
|
-enum class Direction;
|
|
+enum class SearchDirection;
|
|
|
|
class DisassemblyModel : public QAbstractTableModel
|
|
{
|
|
@@ -76,7 +76,7 @@ signals:
|
|
|
|
public slots:
|
|
void updateHighlighting(int line);
|
|
- void find(const QString& search, Direction direction, int offset);
|
|
+ void find(const QString& search, SearchDirection direction, int offset);
|
|
void scrollToLine(const QString& lineNumber);
|
|
|
|
private:
|
|
--- a/src/models/search.h
|
|
+++ b/src/models/search.h
|
|
@@ -10,7 +10,7 @@
|
|
#include <algorithm>
|
|
#include <iterator>
|
|
|
|
-enum class Direction
|
|
+enum class SearchDirection
|
|
{
|
|
Forward,
|
|
Backward
|
|
@@ -45,7 +45,7 @@ int search_helper(const it begin, const it end, const it current, SearchFunc sea
|
|
}
|
|
|
|
template<typename it, typename SearchFunc, typename EndReached>
|
|
-int search(const it begin, const it end, int current, Direction direction, SearchFunc searchFunc, EndReached endReached)
|
|
+int search(const it begin, const it end, int current, SearchDirection direction, SearchFunc searchFunc, EndReached endReached)
|
|
{
|
|
if (begin == end)
|
|
return -1;
|
|
@@ -54,7 +54,7 @@ int search(const it begin, const it end, int current, Direction direction, Searc
|
|
current = std::clamp(current, 0, static_cast<int>(size) - 1);
|
|
const auto currentIt = begin + current;
|
|
|
|
- if (direction == Direction::Forward) {
|
|
+ if (direction == SearchDirection::Forward) {
|
|
return search_helper(begin, end, std::next(currentIt), searchFunc, endReached);
|
|
}
|
|
|
|
--- a/src/models/sourcecodemodel.cpp
|
|
+++ b/src/models/sourcecodemodel.cpp
|
|
@@ -258,7 +258,7 @@ void SourceCodeModel::setSysroot(const QString& sysroot)
|
|
m_sysroot = sysroot;
|
|
}
|
|
|
|
-void SourceCodeModel::find(const QString& search, Direction direction, int current)
|
|
+void SourceCodeModel::find(const QString& search, SearchDirection direction, int current)
|
|
{
|
|
auto searchFunc = [&search](const QString& line) { return line.indexOf(search, 0, Qt::CaseInsensitive) != -1; };
|
|
|
|
--- a/src/models/sourcecodemodel.h
|
|
+++ b/src/models/sourcecodemodel.h
|
|
@@ -20,7 +20,7 @@ class Repository;
|
|
class Definition;
|
|
}
|
|
|
|
-enum class Direction;
|
|
+enum class SearchDirection;
|
|
|
|
Q_DECLARE_METATYPE(QTextLine)
|
|
|
|
@@ -73,7 +73,7 @@ public slots:
|
|
void updateHighlighting(int line);
|
|
void setSysroot(const QString& sysroot);
|
|
|
|
- void find(const QString& search, Direction direction, int current);
|
|
+ void find(const QString& search, SearchDirection direction, int current);
|
|
void scrollToLine(const QString& lineNumber);
|
|
|
|
private:
|
|
--- a/src/resultsdisassemblypage.cpp
|
|
+++ b/src/resultsdisassemblypage.cpp
|
|
@@ -407,12 +407,12 @@ ResultsDisassemblyPage::ResultsDisassemblyPage(CostContextMenu* costContextMenu,
|
|
|
|
auto searchNext = [model, edit, additionalRows, searchResultIndex] {
|
|
const auto offset = searchResultIndex->isValid() ? searchResultIndex->row() - additionalRows : 0;
|
|
- model->find(edit->text(), Direction::Forward, offset);
|
|
+ model->find(edit->text(), SearchDirection::Forward, offset);
|
|
};
|
|
|
|
auto searchPrev = [model, edit, additionalRows, searchResultIndex] {
|
|
const auto offset = searchResultIndex->isValid() ? searchResultIndex->row() - additionalRows : 0;
|
|
- model->find(edit->text(), Direction::Backward, offset);
|
|
+ model->find(edit->text(), SearchDirection::Backward, offset);
|
|
};
|
|
|
|
auto findNextAction = KStandardAction::findNext(this, searchNext, actions);
|
|
--- a/tests/modeltests/tst_models.cpp
|
|
+++ b/tests/modeltests/tst_models.cpp
|
|
@@ -514,7 +514,7 @@ private slots:
|
|
// check if search works in general
|
|
QSignalSpy searchSpy(&model, &SourceCodeModel::resultFound);
|
|
for (int i = 0; i < 5; i++) {
|
|
- model.find(QStringLiteral("Line 5"), Direction::Forward, i);
|
|
+ model.find(QStringLiteral("Line 5"), SearchDirection::Forward, i);
|
|
auto result = searchSpy.takeFirst();
|
|
QCOMPARE(result.at(0).value<QModelIndex>(), model.index(3, SourceCodeModel::SourceCodeColumn));
|
|
}
|
|
@@ -522,21 +522,21 @@ private slots:
|
|
// Check wrap around
|
|
for (int i = 1; i < 4; i++) {
|
|
QSignalSpy endReached(&model, &SourceCodeModel::searchEndReached);
|
|
- model.find(QStringLiteral("Line 3"), Direction::Forward, i);
|
|
+ model.find(QStringLiteral("Line 3"), SearchDirection::Forward, i);
|
|
QCOMPARE(endReached.size(), 1);
|
|
}
|
|
|
|
// check if no result found works
|
|
searchSpy.clear();
|
|
for (int i = 0; i < 5; i++) {
|
|
- model.find(QStringLiteral("Line 8"), Direction::Forward, i);
|
|
+ model.find(QStringLiteral("Line 8"), SearchDirection::Forward, i);
|
|
auto result = searchSpy.takeFirst();
|
|
QCOMPARE(result.at(0).value<QModelIndex>().isValid(), false);
|
|
}
|
|
|
|
// test backward search
|
|
for (int i = 4; i > 0; i--) {
|
|
- model.find(QStringLiteral("Line 7"), Direction::Backward, i);
|
|
+ model.find(QStringLiteral("Line 7"), SearchDirection::Backward, i);
|
|
auto result = searchSpy.takeFirst();
|
|
QCOMPARE(result.at(0).value<QModelIndex>(), model.index(5, SourceCodeModel::SourceCodeColumn));
|
|
}
|
|
@@ -544,14 +544,14 @@ private slots:
|
|
// Check wrap around
|
|
for (int i = 4; i > 0; i--) {
|
|
QSignalSpy endReached(&model, &SourceCodeModel::searchEndReached);
|
|
- model.find(QStringLiteral("Line 7"), Direction::Backward, i);
|
|
+ model.find(QStringLiteral("Line 7"), SearchDirection::Backward, i);
|
|
QCOMPARE(endReached.size(), 1);
|
|
}
|
|
|
|
// check if no result found works
|
|
searchSpy.clear();
|
|
for (int i = 0; i < 5; i++) {
|
|
- model.find(QStringLiteral("Line 8"), Direction::Backward, i);
|
|
+ model.find(QStringLiteral("Line 8"), SearchDirection::Backward, i);
|
|
auto result = searchSpy.takeFirst();
|
|
QCOMPARE(result.at(0).value<QModelIndex>().isValid(), false);
|
|
}
|
|
--- a/tests/modeltests/tst_search.cpp
|
|
+++ b/tests/modeltests/tst_search.cpp
|
|
@@ -24,9 +24,9 @@ private slots:
|
|
const std::array<int, 0> testArray = {};
|
|
|
|
QCOMPARE(
|
|
- search(testArray.cbegin(), testArray.cend(), 0, Direction::Forward, [](int) { return false; }, [] {}), -1);
|
|
+ search(testArray.cbegin(), testArray.cend(), 0, SearchDirection::Forward, [](int) { return false; }, [] {}), -1);
|
|
QCOMPARE(
|
|
- search(testArray.cbegin(), testArray.cend(), 0, Direction::Backward, [](int) { return false; }, [] {}), -1);
|
|
+ search(testArray.cbegin(), testArray.cend(), 0, SearchDirection::Backward, [](int) { return false; }, [] {}), -1);
|
|
}
|
|
void testSearch()
|
|
{
|
|
@@ -35,11 +35,11 @@ private slots:
|
|
int maxOffset = testArray.size() - 1;
|
|
for (int offset = 0; offset < maxOffset; offset++) {
|
|
QCOMPARE(search(
|
|
- testArray.cbegin(), testArray.cend(), offset, Direction::Forward,
|
|
+ testArray.cbegin(), testArray.cend(), offset, SearchDirection::Forward,
|
|
[](int num) { return num == 2; }, [] {}),
|
|
1);
|
|
QCOMPARE(search(
|
|
- testArray.cbegin(), testArray.cend(), offset, Direction::Backward,
|
|
+ testArray.cbegin(), testArray.cend(), offset, SearchDirection::Backward,
|
|
[](int num) { return num == 2; }, [] {}),
|
|
1);
|
|
}
|
|
@@ -51,7 +51,7 @@ private slots:
|
|
{
|
|
bool endReached = false;
|
|
QCOMPARE(search(
|
|
- testArray.cbegin(), testArray.cend(), 1, Direction::Forward, [](int i) { return i == 1; },
|
|
+ testArray.cbegin(), testArray.cend(), 1, SearchDirection::Forward, [](int i) { return i == 1; },
|
|
[&endReached] { endReached = true; }),
|
|
0);
|
|
QCOMPARE(endReached, true);
|
|
@@ -60,7 +60,7 @@ private slots:
|
|
{
|
|
bool endReached = false;
|
|
QCOMPARE(search(
|
|
- testArray.cbegin(), testArray.cend(), 1, Direction::Backward, [](int i) { return i == 4; },
|
|
+ testArray.cbegin(), testArray.cend(), 1, SearchDirection::Backward, [](int i) { return i == 4; },
|
|
[&endReached] { endReached = true; }),
|
|
3);
|
|
QCOMPARE(endReached, true);
|
|
@@ -73,7 +73,7 @@ private slots:
|
|
|
|
for (int i = 0; i < 2; i++) {
|
|
QCOMPARE(search(
|
|
- testArray.cbegin(), testArray.cend(), 0, Direction::Forward, [](int) { return true; }, [] {}),
|
|
+ testArray.cbegin(), testArray.cend(), 0, SearchDirection::Forward, [](int) { return true; }, [] {}),
|
|
-1);
|
|
}
|
|
}
|
|
@@ -83,7 +83,7 @@ private slots:
|
|
const std::array<int, 1> testArray = {0};
|
|
|
|
QCOMPARE(search(
|
|
- testArray.cbegin(), testArray.cend(), 1, Direction::Forward, [](int i) { return i == 0; }, [] {}),
|
|
+ testArray.cbegin(), testArray.cend(), 1, SearchDirection::Forward, [](int i) { return i == 0; }, [] {}),
|
|
0);
|
|
}
|
|
|
|
@@ -93,7 +93,7 @@ private slots:
|
|
|
|
for (std::size_t i = 0; i < testArray.size(); i++) {
|
|
QCOMPARE(search(
|
|
- testArray.cbegin() + 1, testArray.cbegin() + 3, i, Direction::Forward,
|
|
+ testArray.cbegin() + 1, testArray.cbegin() + 3, i, SearchDirection::Forward,
|
|
[](int i) { return i == 0; }, [] {}),
|
|
-1);
|
|
}
|