Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-80601

Non-sparse model operations

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Unresolved
    • Not Evaluated
    • None
    • None
    • Core: Item Models
    • None

    Description

      Our project implements QAbstractItemModel and is plagued by QSortFilterProxyModel: inconsistent changes reported by source model errors.

      The reason is that we are trying to implement efficient sparse removal operations on a dense storage container. Right now, Qt seems to assume that if I trigger N beginRemoveItems, I will proceed to trigger N endRemoveItems, and each individual removal will leave the system exactly in the same state as if I had instead issued one at a time, back to front. This is not the case.

      Instead, our model performs a swap of each range to be removed with elements ahead that will not be removed. When the loop completes, all remaining elements from the last deleted range are swapped backward as well, leaving the deleted elements at the end of the array. We then truncate the list, deleting the unwanted rows.

      Since all deletion happens at once, QSortFilterProxyModel complains that the rest of the data isn't where it was expected to be.

      One solution would be to actively support sparse removal operations, if not by changing the behavior of beginRemoveRows (when called in succession), then by adding a new operation for it.

      If adding a sparse delete would be too specific, perhaps we could tackle the more immediate problem and support a range swap operation, instead—Using MoveRows for this only works when the swapped ranges overlap, so I would need an actual swap operation to cover this use case.

      Anyway, thanks for your time. Please let me know if I've missed something.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            dfaure_kdab David Faure
            joshdreamland Josh Ventura
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes