diff options
author | Evgeniy A. Dushistov <dushistov@mail.ru> | 2021-04-13 18:20:14 +0300 |
---|---|---|
committer | Evgeniy A. Dushistov <dushistov@mail.ru> | 2021-04-14 12:43:11 +0300 |
commit | 572d127c64b0a407d3765b21ee8b3f52068e05ed (patch) | |
tree | dfde173bb8f8ccef9a82c696b993d567911a090a | |
parent | ccc71d05d7226064dc98c92f993f7bc15670c091 (diff) |
Fix part of clazy warnings: ineffective loops and missed overrides
Change-Id: If9fcde221d5de7302e62b314be34e5311bd3efae
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
-rw-r--r-- | src/qquicktreemodeladaptor.cpp | 2 | ||||
-rw-r--r-- | src/qquicktreemodeladaptor_p.h | 16 | ||||
-rw-r--r-- | src/qquicktreeview.cpp | 12 |
3 files changed, 21 insertions, 9 deletions
diff --git a/src/qquicktreemodeladaptor.cpp b/src/qquicktreemodeladaptor.cpp index 220ce41..9c6fba2 100644 --- a/src/qquicktreemodeladaptor.cpp +++ b/src/qquicktreemodeladaptor.cpp @@ -998,7 +998,7 @@ void QQuickTreeModelAdaptor::emitQueuedSignals() * We don't merge adjacent updates, because they are typically filed with a * different role (a parent row is next to its children). */ - for (const DataChangedParams &dataChange : m_queuedDataChanged) { + for (const DataChangedParams &dataChange : qAsConst(m_queuedDataChanged)) { int startRow = dataChange.topLeft.row(); int endRow = dataChange.bottomRight.row(); bool merged = false; diff --git a/src/qquicktreemodeladaptor_p.h b/src/qquicktreemodeladaptor_p.h index 19c2d24..88c2d72 100644 --- a/src/qquicktreemodeladaptor_p.h +++ b/src/qquicktreemodeladaptor_p.h @@ -69,11 +69,11 @@ public: void setRootIndex(const QModelIndex &idx); void resetRootIndex(); - QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const; - QModelIndex parent(const QModelIndex &child) const; + QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override; + QModelIndex parent(const QModelIndex &child) const override; - int rowCount(const QModelIndex &parent = QModelIndex()) const; - int columnCount(const QModelIndex &parent = QModelIndex()) const; + int rowCount(const QModelIndex &parent = QModelIndex()) const override; + int columnCount(const QModelIndex &parent = QModelIndex()) const override; enum { DepthRole = Qt::UserRole - 5, @@ -83,10 +83,10 @@ public: ModelIndexRole }; - QHash<int, QByteArray> roleNames() const; - QVariant data(const QModelIndex &, int role) const; - bool setData(const QModelIndex &index, const QVariant &value, int role); - QVariant headerData(int section, Qt::Orientation orientation, int role) const; + QHash<int, QByteArray> roleNames() const override; + QVariant data(const QModelIndex &, int role) const override; + bool setData(const QModelIndex &index, const QVariant &value, int role) override; + QVariant headerData(int section, Qt::Orientation orientation, int role) const override; void clearModelData(); diff --git a/src/qquicktreeview.cpp b/src/qquicktreeview.cpp index a604571..f61a8df 100644 --- a/src/qquicktreeview.cpp +++ b/src/qquicktreeview.cpp @@ -727,7 +727,13 @@ int QQuickTreeView::rowAtY(int y, bool includeSpacing) qreal currentRowEnd = d->loadedTableOuterRect.y() - contentY(); int foundRow = -1; +// in Qt 6.x QQuickTableview uses `QFlatMap` which keys() doesn't allocate +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) for (auto const row : qAsConst(d->loadedRows).keys()) { +#else + for (auto it = d->loadedRows.keyBegin(), end = d->loadedRows.keyEnd(); it != end; ++it) { + const auto row = *it; +#endif currentRowEnd += d->effectiveRowHeight(row); if (y < currentRowEnd) { foundRow = row; @@ -759,7 +765,13 @@ int QQuickTreeView::columnAtX(int x, bool includeSpacing) qreal currentColumnEnd = d->loadedTableOuterRect.x() - contentX(); int foundColumn = -1; +// in Qt 6.x QQuickTableview uses `QFlatMap` which keys() doesn't allocate +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) for (auto const column : qAsConst(d->loadedColumns).keys()) { +#else + for (auto it = d->loadedColumns.keyBegin(), end = d->loadedColumns.keyEnd(); it != end; ++it) { + const auto column = *it; +#endif currentColumnEnd += d->effectiveColumnWidth(column); if (x < currentColumnEnd) { foundColumn = column; |