mirror of
https://github.com/olivierkes/manuskript.git
synced 2024-05-17 11:22:28 +12:00
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.
This commit is contained in:
parent
0ea4c0d174
commit
87f1fc0187
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue