diff options
-rw-r--r-- | src/quick/items/qquicktableview.cpp | 10 | ||||
-rw-r--r-- | src/quick/items/qquicktableview_p_p.h | 17 |
2 files changed, 14 insertions, 13 deletions
diff --git a/src/quick/items/qquicktableview.cpp b/src/quick/items/qquicktableview.cpp index 2e7e07f705..fd511bc2ee 100644 --- a/src/quick/items/qquicktableview.cpp +++ b/src/quick/items/qquicktableview.cpp @@ -520,10 +520,10 @@ int QQuickTableViewPrivate::nextVisibleEdgeIndexAroundLoadedTable(Qt::Edge edge) // visible, and should be loaded next if the content item moves. int startIndex = -1; switch (edge) { - case Qt::LeftEdge: startIndex = loadedColumns.firstKey() - 1; break; - case Qt::RightEdge: startIndex = loadedColumns.lastKey() + 1; break; - case Qt::TopEdge: startIndex = loadedRows.firstKey() - 1; break; - case Qt::BottomEdge: startIndex = loadedRows.lastKey() + 1; break; + case Qt::LeftEdge: startIndex = leftColumn() - 1; break; + case Qt::RightEdge: startIndex = rightColumn() + 1; break; + case Qt::TopEdge: startIndex = topRow() - 1; break; + case Qt::BottomEdge: startIndex = bottomRow() + 1; break; } return nextVisibleEdgeIndex(edge, startIndex); @@ -1913,7 +1913,7 @@ void QQuickTableViewPrivate::loadEdge(Qt::Edge edge, QQmlIncubator::IncubationMo const int edgeIndex = nextVisibleEdgeIndexAroundLoadedTable(edge); qCDebug(lcTableViewDelegateLifecycle) << edge << edgeIndex; - const QList<int> visibleCells = edge & (Qt::LeftEdge | Qt::RightEdge) + const auto visibleCells = edge & (Qt::LeftEdge | Qt::RightEdge) ? loadedRows.keys() : loadedColumns.keys(); loadRequest.begin(edge, edgeIndex, visibleCells, incubationMode); processLoadRequest(); diff --git a/src/quick/items/qquicktableview_p_p.h b/src/quick/items/qquicktableview_p_p.h index ec043f5e7e..7c81882d44 100644 --- a/src/quick/items/qquicktableview_p_p.h +++ b/src/quick/items/qquicktableview_p_p.h @@ -54,6 +54,7 @@ #include "qquicktableview_p.h" #include <QtCore/qtimer.h> +#include <QtCore/private/qflatmap_p.h> #include <QtQmlModels/private/qqmltableinstancemodel_p.h> #include <QtQml/private/qqmlincubator_p.h> #include <QtQmlModels/private/qqmlchangeset_p.h> @@ -119,7 +120,7 @@ public: qCDebug(lcTableViewDelegateLifecycle()) << "begin top-left:" << toString(); } - void begin(Qt::Edge edgeToLoad, int edgeIndex, const QList<int> visibleCellsInEdge, QQmlIncubator::IncubationMode incubationMode) + void begin(Qt::Edge edgeToLoad, int edgeIndex, const QVector<int> visibleCellsInEdge, QQmlIncubator::IncubationMode incubationMode) { Q_ASSERT(!m_active); m_active = true; @@ -169,7 +170,7 @@ public: private: Qt::Edge m_edge = Qt::Edge(0); - QList<int> m_visibleCellsInEdge; + QVector<int> m_visibleCellsInEdge; int m_edgeIndex = 0; int m_currentIndex = 0; bool m_active = false; @@ -246,8 +247,8 @@ public: // we need to fill up with more rows/columns. loadedTableInnerRect describes the pixels // that the loaded table covers if you remove one row/column on each side of the table, and // is used to determine rows/columns that are no longer visible and can be unloaded. - QMap<int, int> loadedColumns; - QMap<int, int> loadedRows; + QFlatMap<int, int> loadedColumns; + QFlatMap<int, int> loadedRows; QRectF loadedTableOuterRect; QRectF loadedTableInnerRect; @@ -333,10 +334,10 @@ public: qreal getColumnWidth(int column); qreal getRowHeight(int row); - inline int topRow() const { return loadedRows.firstKey(); } - inline int bottomRow() const { return loadedRows.lastKey(); } - inline int leftColumn() const { return loadedColumns.firstKey(); } - inline int rightColumn() const { return loadedColumns.lastKey(); } + inline int topRow() const { return loadedRows.cbegin().key(); } + inline int bottomRow() const { return (--loadedRows.cend()).key(); } + inline int leftColumn() const { return loadedColumns.cbegin().key(); } + inline int rightColumn() const { return (--loadedColumns.cend()).key(); } QQuickTableView *rootSyncView() const; |