mirror of
https://github.com/olivierkes/manuskript.git
synced 2024-05-21 05:12:27 +12:00
Merge pull request #121 from gedakc/ensure-same-add-character-importance-values
Fixes: add character button does not set importance slider to default…
This commit is contained in:
commit
e971d7e167
|
@ -156,7 +156,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|||
"""
|
||||
c = self.lstCharacters.currentCharacter()
|
||||
if not c:
|
||||
self.tabPlot.setEnabled(False)
|
||||
self.tabPersos.setEnabled(False)
|
||||
return
|
||||
|
||||
self.tabPersos.setEnabled(True)
|
||||
|
@ -179,6 +179,9 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|||
# Button color
|
||||
self.updateCharacterColor(c.ID())
|
||||
|
||||
# Slider importance
|
||||
self.updateCharacterImportance(c.ID())
|
||||
|
||||
# Character Infos
|
||||
self.tblPersoInfos.setRootIndex(index)
|
||||
|
||||
|
@ -195,6 +198,10 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|||
color = c.color().name()
|
||||
self.btnPersoColor.setStyleSheet("background:{};".format(color))
|
||||
|
||||
def updateCharacterImportance(self, ID):
|
||||
c = self.mdlCharacter.getCharacterByID(ID)
|
||||
self.sldPersoImportance.setValue(int(c.importance()))
|
||||
|
||||
###############################################################################
|
||||
# PLOTS
|
||||
###############################################################################
|
||||
|
@ -213,6 +220,10 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|||
self.sldPlotImportance.setCurrentModelIndex(index)
|
||||
self.lstPlotPerso.setRootIndex(index.sibling(index.row(),
|
||||
Plot.characters.value))
|
||||
|
||||
# Slider importance
|
||||
self.updatePlotImportance(index.row())
|
||||
|
||||
subplotindex = index.sibling(index.row(), Plot.steps.value)
|
||||
self.lstSubPlots.setRootIndex(subplotindex)
|
||||
if self.mdlPlots.rowCount(subplotindex):
|
||||
|
@ -238,6 +249,10 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|||
PlotStep.meta.value, QHeaderView.ResizeToContents)
|
||||
self.lstSubPlots.verticalHeader().hide()
|
||||
|
||||
def updatePlotImportance(self, ID):
|
||||
imp = self.mdlPlots.getPlotImportanceByID(ID)
|
||||
self.sldPlotImportance.setValue(int(imp))
|
||||
|
||||
def changeCurrentSubPlot(self, index):
|
||||
# Got segfaults when using textEditView model system, so ad hoc stuff.
|
||||
index = index.sibling(index.row(), PlotStep.summary.value)
|
||||
|
|
|
@ -55,6 +55,14 @@ class plotModel(QStandardItemModel):
|
|||
return name
|
||||
return None
|
||||
|
||||
def getPlotImportanceByID(self, ID):
|
||||
for i in range(self.rowCount()):
|
||||
_ID = self.item(i, Plot.ID.value).text()
|
||||
if _ID == ID or toInt(_ID) == ID:
|
||||
importance = self.item(i, Plot.importance.value).text()
|
||||
return importance
|
||||
return "0" # Default to "Minor"
|
||||
|
||||
def getSubPlotTextsByID(self, plotID, subplotRaw):
|
||||
"""Returns a tuple (name, summary) for the suplot whose raw in the model
|
||||
is ``subplotRaw``, of plot whose ID is ``plotID``.
|
||||
|
|
Loading…
Reference in a new issue