diff options
-rw-r--r-- | src/qgraphicstableview.cpp | 19 | ||||
-rw-r--r-- | src/qgraphicstableview_p.h | 1 |
2 files changed, 20 insertions, 0 deletions
diff --git a/src/qgraphicstableview.cpp b/src/qgraphicstableview.cpp index 4c0557c..8933156 100644 --- a/src/qgraphicstableview.cpp +++ b/src/qgraphicstableview.cpp @@ -276,6 +276,7 @@ void QtGraphicsTableViewPrivate::_q_rowsInserted(int row, int count) if (verticalHeader) verticalHeader->setSectionCount(model ? model->rowCount() : 0); checkCache(row, -1, -1, -1); + checkItems(row, -1, -1, -1); } void QtGraphicsTableViewPrivate::_q_rowsRemoved(int row, int count) @@ -290,6 +291,7 @@ void QtGraphicsTableViewPrivate::_q_rowsMoved(int from, int to, int count) { // ### update checkCache(qMin(from ,to), -1, qMax(from, to) + count, -1); + checkItems(qMin(from ,to), -1, qMax(from, to) + count, -1); } void QtGraphicsTableViewPrivate::_q_columnsInserted(int column, int count) @@ -298,6 +300,7 @@ void QtGraphicsTableViewPrivate::_q_columnsInserted(int column, int count) if (horizontalHeader) horizontalHeader->setSectionCount(model ? model->columnCount() : 0); checkCache(-1, column, -1, -1); + checkItems(-1, column, -1, -1); } void QtGraphicsTableViewPrivate::_q_columnsRemoved(int column, int count) @@ -306,12 +309,14 @@ void QtGraphicsTableViewPrivate::_q_columnsRemoved(int column, int count) if (horizontalHeader) horizontalHeader->setSectionCount(model ? model->rowCount() : 0); checkCache(-1, column, -1, -1); + checkItems(-1, column, -1, -1); } void QtGraphicsTableViewPrivate::_q_columnsMoved(int from, int to, int count) { // ### update checkCache(-1, qMin(from ,to), -1, qMax(from, to) + count); + checkItems(-1, qMin(from ,to), -1, qMax(from, to) + count); } bool QtGraphicsTableViewPrivate::isSelected(int row, int column) const @@ -328,6 +333,20 @@ bool QtGraphicsTableViewPrivate::isCurrent(int row, int column) const return false; } +void QtGraphicsTableViewPrivate::checkItems(int firstRow, int firstColumn, int rowCount, int columnCount) +{ + Q_UNUSED(firstRow); + Q_UNUSED(firstColumn); + Q_UNUSED(rowCount); + Q_UNUSED(columnCount); + QHash<int, QtGraphicsTableViewItem*>::iterator it = items.begin(); + while (it != items.end()) { + creator->recycle(it.value()); + ++it; + } + items.clear(); +} + void QtGraphicsTableViewPrivate::checkCache(int firstRow, int firstColumn, int rowCount, int columnCount) { Q_UNUSED(firstRow); diff --git a/src/qgraphicstableview_p.h b/src/qgraphicstableview_p.h index 800f2c7..63a45bd 100644 --- a/src/qgraphicstableview_p.h +++ b/src/qgraphicstableview_p.h @@ -89,6 +89,7 @@ public: bool isSelected(int row, int column) const; bool isCurrent(int row, int column) const; + void checkItems(int firstRow, int firstColumn, int rowCount, int columnCount); void checkCache(int firstRow, int firstColumn, int rowCount, int columnCount); QVariant cachedData(int row, int column, int role) const; |