refactor: use QList instead of QVector (#1812)

In Qt 6 QVector is an alias.
This commit is contained in:
Oleg Shparber
2026-04-08 15:59:36 +03:00
committed by GitHub
parent 471221fb77
commit e198747168
8 changed files with 26 additions and 26 deletions
+4 -5
View File
@@ -17,7 +17,6 @@
#include <QMenu>
#include <QMessageBox>
#include <QPushButton>
#include <QVector>
#include <QWebEngineContextMenuRequest>
#include <QWebEngineProfile>
#include <QWebEngineSettings>
@@ -58,12 +57,12 @@ void WebView::setZoomLevel(int level)
emit zoomLevelChanged();
}
const QVector<int> &WebView::availableZoomLevels()
const QList<int> &WebView::availableZoomLevels()
{
// clang-format off
static const QVector<int> zoomLevels = {30, 40, 50, 67, 80, 90, 100,
110, 120, 133, 150, 170, 200,
220, 233, 250, 270, 285, 300};
static const QList<int> zoomLevels = {30, 40, 50, 67, 80, 90, 100,
110, 120, 133, 150, 170, 200,
220, 233, 250, 270, 285, 300};
// clang-format on
return zoomLevels;
+2 -1
View File
@@ -5,6 +5,7 @@
#ifndef ZEAL_BROWSER_WEBVIEW_H
#define ZEAL_BROWSER_WEBVIEW_H
#include <QList>
#include <QWebEngineView>
namespace Zeal::Browser {
@@ -22,7 +23,7 @@ public:
bool eventFilter(QObject *watched, QEvent *event) override;
static const QVector<int> &availableZoomLevels();
static const QList<int> &availableZoomLevels();
static int defaultZoomLevel();
public slots:
+2 -2
View File
@@ -7,7 +7,7 @@
#include <QString>
#include <QUrl>
#include <QVector>
#include <QList>
namespace Zeal::Registry {
@@ -24,7 +24,7 @@ struct SearchResult
Docset *docset;
double score;
QVector<int> matchPositions;
QList<int> matchPositions;
inline bool operator<(const SearchResult &other) const
{
@@ -35,8 +35,8 @@
#include <QGuiApplication>
#include <QKeyEvent>
#include <QKeySequence>
#include <QList>
#include <QScopedPointer>
#include <QVector>
#include <QtGui/private/qtx11extras_p.h>
#include <QtGui/private/qxkbcommon_p.h>
+1 -1
View File
@@ -128,7 +128,7 @@ void SearchItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op
const QString elidedText = fm.elidedText(opt.text, Qt::ElideRight, textRect.width());
// Get pre-computed match positions from model for highlighting.
const QVector<int> matchPositions = index.data(m_textHighlightRole).value<QVector<int>>();
const auto matchPositions = index.data(m_textHighlightRole).value<QList<int>>();
painter->save();
+2 -2
View File
@@ -81,7 +81,7 @@ bool hasMatch(const QString &needle, const QString &haystack)
// High-level Qt convenience API implementation
// ============================================================================
double score(const QString &needle, const QString &haystack, QVector<int> *positions)
double score(const QString &needle, const QString &haystack, QList<int> *positions)
{
// Pre-filter: check if all needle characters exist in haystack (performance optimization)
// This avoids expensive DP computation on unmatchable strings
@@ -101,7 +101,7 @@ double score(const QString &needle, const QString &haystack, QVector<int> *posit
// Low-level API implementation
// ============================================================================
double computeScore(const QString &needle, const QString &haystack, QVector<int> *positions)
double computeScore(const QString &needle, const QString &haystack, QList<int> *positions)
{
const int needleLen = needle.length();
const int haystackLen = haystack.length();
+3 -3
View File
@@ -4,8 +4,8 @@
#ifndef ZEAL_UTIL_FUZZY_H
#define ZEAL_UTIL_FUZZY_H
#include <QList>
#include <QString>
#include <QVector> // TODO: [Qt 6] Use QList.
namespace Zeal::Util::Fuzzy {
@@ -28,7 +28,7 @@ namespace Zeal::Util::Fuzzy {
* @param positions Optional output list of matched haystack indices for highlighting
* @return Match score (higher is better, -infinity for no match)
*/
double score(const QString &needle, const QString &haystack, QVector<int> *positions = nullptr);
double score(const QString &needle, const QString &haystack, QList<int> *positions = nullptr);
/**
* @brief Computes fuzzy match score, optionally returning match positions
@@ -44,7 +44,7 @@ double score(const QString &needle, const QString &haystack, QVector<int> *posit
* @return Fuzzy match score (-infinity if no match possible, infinity if needle == haystack,
* otherwise unbounded: ~0.9 + (n-1) for a perfect length-n consecutive match)
*/
double computeScore(const QString &needle, const QString &haystack, QVector<int> *positions = nullptr);
double computeScore(const QString &needle, const QString &haystack, QList<int> *positions = nullptr);
/**
* @brief Main scoring function for use in SQLite callbacks
+11 -11
View File
@@ -110,7 +110,7 @@ void FuzzyTest::testFuzzyMatch()
void FuzzyTest::testPositionsFuzzy()
{
QVector<int> positions;
QList<int> positions;
double fuzzyScore = score(QStringLiteral("abc"), QStringLiteral("aXbXc"), &positions);
QVERIFY(fuzzyScore > 0);
@@ -122,7 +122,7 @@ void FuzzyTest::testPositionsFuzzy()
void FuzzyTest::testPositionsExact()
{
QVector<int> positions;
QList<int> positions;
double exactScore = score(QStringLiteral("test"), QStringLiteral("prefix_test"), &positions);
QVERIFY(exactScore > 0);
@@ -136,7 +136,7 @@ void FuzzyTest::testPositionsExact()
void FuzzyTest::testCamelCase()
{
// Should detect camelCase word boundaries
QVector<int> positions;
QList<int> positions;
double camelScore = score(QStringLiteral("path"), QStringLiteral("HasPermissionForPath"), &positions);
QVERIFY(camelScore > 0);
@@ -162,7 +162,7 @@ void FuzzyTest::testUnicode()
void FuzzyTest::testPubTrimIssue()
{
// Regression test: "pubtrim" should highlight Publisher + toTrim, not prototype
QVector<int> positions;
QList<int> positions;
score(QStringLiteral("pubtrim"), QStringLiteral("Publisher.prototype.toTrim"), &positions);
QCOMPARE(positions.size(), 7);
@@ -177,7 +177,7 @@ void FuzzyTest::testPubTrimIssue()
void FuzzyTest::testPubProtIssue()
{
// Regression test: "pubprot" should highlight Publisher + prototype
QVector<int> positions;
QList<int> positions;
score(QStringLiteral("pubprot"), QStringLiteral("Publisher.prototype.fieldsToTrim"), &positions);
QCOMPARE(positions.size(), 7);
@@ -252,7 +252,7 @@ void FuzzyTest::testEqualLengthNonMatching()
void FuzzyTest::testSpecialCharacters()
{
// Should handle special characters
QVector<int> positions;
QList<int> positions;
double s = score(QStringLiteral("a-b"), QStringLiteral("foo-a-bar-b"), &positions);
QVERIFY(s > 0);
QCOMPARE(positions.size(), 3);
@@ -390,7 +390,7 @@ void FuzzyTest::testManyGapsNegativeScore()
void FuzzyTest::testPositionsClearedOnNoMatch()
{
QVector<int> positions;
QList<int> positions;
positions.append(1);
positions.append(2);
positions.append(3);
@@ -404,7 +404,7 @@ void FuzzyTest::testPositionsClearedOnNoMatch()
void FuzzyTest::testPositionsForInfinityScore()
{
QVector<int> positions;
QList<int> positions;
// Equal length exact match should return infinity and fill positions sequentially
double s = score(QStringLiteral("test"), QStringLiteral("test"), &positions);
@@ -463,7 +463,7 @@ void FuzzyTest::testSpaceHandling()
// Spaces are treated as literal characters in fzy algorithm
// They must match exactly and give word boundary bonus to the next character
QVector<int> positions;
QList<int> positions;
// Space in needle matches space in haystack
double spaceMatch = score(QStringLiteral("a b"), QStringLiteral("a b"), &positions);
@@ -515,7 +515,7 @@ void FuzzyTest::testBacktrackingPrefixConflict()
// matchRequired. M[i][j] reflects the global prefix optimum (s,t,r at 0,1,2
// decaying via gaps), not the path being backtracked, so matchRequired
// incorrectly dropped to false and the algorithm fell back to j=0,1.
QVector<int> positions;
QList<int> positions;
score(QStringLiteral("string"), QStringLiteral("str::to_string"), &positions);
QCOMPARE(positions.size(), 6);
@@ -536,7 +536,7 @@ void FuzzyTest::testBacktrackingWordBoundaryWins()
// The 'S' at position 0 (slash bonus 0.9) builds up an M score that is
// higher than D at position 7 (word boundary bonus 0.8), causing the same
// matchRequired bug to drop false and fall back to j=0 for the first char.
QVector<int> positions;
QList<int> positions;
score(QStringLiteral("string"), QStringLiteral("Static String"), &positions);
QCOMPARE(positions.size(), 6);