simplify setContents by letting Qt do more of the work

Authored by sitter on Jul 18 2017, 10:03 AM.

Description

simplify setContents by letting Qt do more of the work

Summary:
This is refactoring the code, it is doing the same as before.

QTableView already manages its own selectionModel based on the model
we give it there does not seem to be a reason why we would duplicate thise code

  • simplify the code managing the models by removing the manual selectionModel management and instead letting Qt handle its creation via QTableView::setModel
  • update the deletion comment to point out that deleting the old model will in fact also delete the associated automatically created selectionModel
  • move behavior and mode setup of the view to the constructor. a search on the QAbstractItemView suggests that neither setting is passed along nor mutated outside the setter, so we only need to set these up once

ideally I suppose instead of changing the model at all we should have a
full model and put a qsortfilterproxymodel in front of it thus making
setContents in its current form obsolete as we'd then only need to filter
as necessary. I am not quite confident enough in my understanding of
how the code presently works to make such an invasive change.

Test Plan: tests still passing

Reviewers: cfeck, davidedmundson

Reviewed By: cfeck, davidedmundson

Subscribers: davidedmundson, Frameworks

Tags: Frameworks

Differential Revision: https://phabricator.kde.org/D6767

Details

Committed
sitterAug 30 2017, 4:02 PM
Reviewer
cfeck
Differential Revision
D6767: simplify setContents by letting Qt do more of the work
Parents
R236:0f440836c548: KSqueezedTextLabel: Add isSqueezed() for convenience
Branches
Unknown
Tags
Unknown