From 87f1fc0187c1dfd1d7eee289c35667061ed595f9 Mon Sep 17 00:00:00 2001 From: Jan Wester Date: Sat, 10 Jul 2021 01:22:02 +0200 Subject: [PATCH] Bugfix for filtering on POV characters If a project only had one character, and it was marked as a POV character, then that could lead to the accessing of a non-existent second character. (Yes. That code was very broken.) Fixes issues 843, 875, 896. --- manuskript/models/characterPOVModel.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/manuskript/models/characterPOVModel.py b/manuskript/models/characterPOVModel.py index fbbe419e..03309a71 100644 --- a/manuskript/models/characterPOVModel.py +++ b/manuskript/models/characterPOVModel.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # --!-- coding: utf8 --!-- from PyQt5.QtCore import QModelIndex, QSortFilterProxyModel - +from manuskript.enums import Character as C class characterPOVModel(QSortFilterProxyModel): @@ -14,7 +14,11 @@ class characterPOVModel(QSortFilterProxyModel): sourceModel.dataChanged.connect(self.sourceDataChanged) def filterAcceptsRow(self, sourceRow, sourceParent): - return self.sourceModel().pov(sourceRow) + # Although I would prefer to reuse the existing characterModel.pov() method, + # this is simpler to do, actually works and also more ideomatic Qt code. + index = self.sourceModel().index(sourceRow, C.pov.value, sourceParent) + value = self.sourceModel().data(index) + return bool(value) def rowToSource(self, row): index = self.index(row, 0)