Changes every Enum to IntEnum

This commit is contained in:
Olivier Keshavjee 2017-11-15 21:05:48 +01:00
parent 9e95196cc5
commit cf4c1c83bf
15 changed files with 107 additions and 107 deletions

View file

@ -140,7 +140,7 @@ class mindMapImporter(abstractImporter):
item.setData(Outline.type, 'md') item.setData(Outline.type, 'md')
# Move notes to text # Move notes to text
if item.data(Outline.notes): if item.data(Outline.notes):
item.setData(Outline.text.value, item.data(Outline.notes)) item.setData(Outline.text, item.data(Outline.notes))
item.setData(Outline.notes, "") item.setData(Outline.notes, "")
return items return items

View file

@ -473,7 +473,7 @@ def addPlotItem(root, mdl, parent=QModelIndex()):
outline.attrib[w.name] = val outline.attrib[w.name] = val
# List characters as attrib # List characters as attrib
if y == Plot.characters.value: if y == Plot.characters:
if mdl.hasChildren(index): if mdl.hasChildren(index):
characters = [] characters = []
for cX in range(mdl.rowCount(index)): for cX in range(mdl.rowCount(index)):
@ -486,7 +486,7 @@ def addPlotItem(root, mdl, parent=QModelIndex()):
outline.attrib.pop(Plot.characters.name) outline.attrib.pop(Plot.characters.name)
# List resolution steps as sub items # List resolution steps as sub items
elif y == Plot.steps.value: elif y == Plot.steps:
if mdl.hasChildren(index): if mdl.hasChildren(index):
for cX in range(mdl.rowCount(index)): for cX in range(mdl.rowCount(index)):
step = ET.SubElement(outline, "step") step = ET.SubElement(outline, "step")
@ -762,16 +762,16 @@ def loadProject(project, zip=None):
log("* Add plot: ", row[0].text()) log("* Add plot: ", row[0].text())
# Characters # Characters
if row[Plot.characters.value].text(): if row[Plot.characters].text():
IDs = row[Plot.characters.value].text().split(",") IDs = row[Plot.characters].text().split(",")
item = QStandardItem() item = QStandardItem()
for ID in IDs: for ID in IDs:
item.appendRow(QStandardItem(ID.strip())) item.appendRow(QStandardItem(ID.strip()))
row[Plot.characters.value] = item row[Plot.characters] = item
# Subplots # Subplots
for step in plot: for step in plot:
row[Plot.steps.value].appendRow( row[Plot.steps].appendRow(
getStandardItemRowFromXMLEnum(step, PlotStep) getStandardItemRowFromXMLEnum(step, PlotStep)
) )

View file

@ -326,12 +326,12 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.txtPlotResult.setCurrentModelIndex(index) self.txtPlotResult.setCurrentModelIndex(index)
self.sldPlotImportance.setCurrentModelIndex(index) self.sldPlotImportance.setCurrentModelIndex(index)
self.lstPlotPerso.setRootIndex(index.sibling(index.row(), self.lstPlotPerso.setRootIndex(index.sibling(index.row(),
Plot.characters.value)) Plot.characters))
# Slider importance # Slider importance
self.updatePlotImportance(index.row()) self.updatePlotImportance(index.row())
subplotindex = index.sibling(index.row(), Plot.steps.value) subplotindex = index.sibling(index.row(), Plot.steps)
self.lstSubPlots.setRootIndex(subplotindex) self.lstSubPlots.setRootIndex(subplotindex)
if self.mdlPlots.rowCount(subplotindex): if self.mdlPlots.rowCount(subplotindex):
self.updateSubPlotView() self.updateSubPlotView()
@ -351,22 +351,22 @@ class MainWindow(QMainWindow, Ui_MainWindow):
# So instead we set their width to 0. # So instead we set their width to 0.
#for i in range(self.mdlPlots.columnCount()): #for i in range(self.mdlPlots.columnCount()):
#self.lstSubPlots.hideColumn(i) #self.lstSubPlots.hideColumn(i)
#self.lstSubPlots.showColumn(PlotStep.name.value) #self.lstSubPlots.showColumn(PlotStep.name)
#self.lstSubPlots.showColumn(PlotStep.meta.value) #self.lstSubPlots.showColumn(PlotStep.meta)
self.lstSubPlots.horizontalHeader().setSectionResizeMode( self.lstSubPlots.horizontalHeader().setSectionResizeMode(
PlotStep.ID.value, QHeaderView.Fixed) PlotStep.ID, QHeaderView.Fixed)
self.lstSubPlots.horizontalHeader().setSectionResizeMode( self.lstSubPlots.horizontalHeader().setSectionResizeMode(
PlotStep.summary.value, QHeaderView.Fixed) PlotStep.summary, QHeaderView.Fixed)
self.lstSubPlots.horizontalHeader().resizeSection( self.lstSubPlots.horizontalHeader().resizeSection(
PlotStep.ID.value, 0) PlotStep.ID, 0)
self.lstSubPlots.horizontalHeader().resizeSection( self.lstSubPlots.horizontalHeader().resizeSection(
PlotStep.summary.value, 0) PlotStep.summary, 0)
self.lstSubPlots.horizontalHeader().setSectionResizeMode( self.lstSubPlots.horizontalHeader().setSectionResizeMode(
PlotStep.name.value, QHeaderView.Stretch) PlotStep.name, QHeaderView.Stretch)
self.lstSubPlots.horizontalHeader().setSectionResizeMode( self.lstSubPlots.horizontalHeader().setSectionResizeMode(
PlotStep.meta.value, QHeaderView.ResizeToContents) PlotStep.meta, QHeaderView.ResizeToContents)
self.lstSubPlots.verticalHeader().hide() self.lstSubPlots.verticalHeader().hide()
def updatePlotImportance(self, ID): def updatePlotImportance(self, ID):
@ -375,7 +375,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
def changeCurrentSubPlot(self, index): def changeCurrentSubPlot(self, index):
# Got segfaults when using textEditView model system, so ad hoc stuff. # Got segfaults when using textEditView model system, so ad hoc stuff.
index = index.sibling(index.row(), PlotStep.summary.value) index = index.sibling(index.row(), PlotStep.summary)
item = self.mdlPlots.itemFromIndex(index) item = self.mdlPlots.itemFromIndex(index)
if not item: if not item:
self.txtSubPlotSummary.setEnabled(False) self.txtSubPlotSummary.setEnabled(False)
@ -393,7 +393,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
index = self.lstSubPlots.currentIndex() index = self.lstSubPlots.currentIndex()
if not index.isValid(): if not index.isValid():
return return
index = index.sibling(index.row(), PlotStep.summary.value) index = index.sibling(index.row(), PlotStep.summary)
item = self.mdlPlots.itemFromIndex(index) item = self.mdlPlots.itemFromIndex(index)
self._updatingSubPlot = True self._updatingSubPlot = True
@ -814,16 +814,16 @@ class MainWindow(QMainWindow, Ui_MainWindow):
pass pass
for w, c in [ for w, c in [
(self.txtPersoName, Character.name.value), (self.txtPersoName, Character.name),
(self.sldPersoImportance, Character.importance.value), (self.sldPersoImportance, Character.importance),
(self.txtPersoMotivation, Character.motivation.value), (self.txtPersoMotivation, Character.motivation),
(self.txtPersoGoal, Character.goal.value), (self.txtPersoGoal, Character.goal),
(self.txtPersoConflict, Character.conflict.value), (self.txtPersoConflict, Character.conflict),
(self.txtPersoEpiphany, Character.epiphany.value), (self.txtPersoEpiphany, Character.epiphany),
(self.txtPersoSummarySentence, Character.summarySentence.value), (self.txtPersoSummarySentence, Character.summarySentence),
(self.txtPersoSummaryPara, Character.summaryPara.value), (self.txtPersoSummaryPara, Character.summaryPara),
(self.txtPersoSummaryFull, Character.summaryFull.value), (self.txtPersoSummaryFull, Character.summaryFull),
(self.txtPersoNotes, Character.notes.value) (self.txtPersoNotes, Character.notes)
]: ]:
w.setModel(self.mdlCharacter) w.setModel(self.mdlCharacter)
w.setColumn(c) w.setColumn(c)
@ -845,10 +845,10 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.lstSubPlots.selectionModel().currentRowChanged.connect(self.changeCurrentSubPlot, AUC) self.lstSubPlots.selectionModel().currentRowChanged.connect(self.changeCurrentSubPlot, AUC)
for w, c in [ for w, c in [
(self.txtPlotName, Plot.name.value), (self.txtPlotName, Plot.name),
(self.txtPlotDescription, Plot.description.value), (self.txtPlotDescription, Plot.description),
(self.txtPlotResult, Plot.result.value), (self.txtPlotResult, Plot.result),
(self.sldPlotImportance, Plot.importance.value), (self.sldPlotImportance, Plot.importance),
]: ]:
w.setModel(self.mdlPlots) w.setModel(self.mdlPlots)
w.setColumn(c) w.setColumn(c)
@ -861,7 +861,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.plotCharacterDelegate = outlineCharacterDelegate(self.mdlCharacter, self) self.plotCharacterDelegate = outlineCharacterDelegate(self.mdlCharacter, self)
self.lstPlotPerso.setItemDelegate(self.plotCharacterDelegate) self.lstPlotPerso.setItemDelegate(self.plotCharacterDelegate)
self.plotDelegate = plotDelegate(self) self.plotDelegate = plotDelegate(self)
self.lstSubPlots.setItemDelegateForColumn(PlotStep.meta.value, self.plotDelegate) self.lstSubPlots.setItemDelegateForColumn(PlotStep.meta, self.plotDelegate)
# World # World
self.treeWorld.setModel(self.mdlWorld) self.treeWorld.setModel(self.mdlWorld)
@ -873,10 +873,10 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.btnAddWorld.clicked.connect(self.mdlWorld.addItem, AUC) self.btnAddWorld.clicked.connect(self.mdlWorld.addItem, AUC)
self.btnRmWorld.clicked.connect(self.mdlWorld.removeItem, AUC) self.btnRmWorld.clicked.connect(self.mdlWorld.removeItem, AUC)
for w, c in [ for w, c in [
(self.txtWorldName, World.name.value), (self.txtWorldName, World.name),
(self.txtWorldDescription, World.description.value), (self.txtWorldDescription, World.description),
(self.txtWorldPassion, World.passion.value), (self.txtWorldPassion, World.passion),
(self.txtWorldConflict, World.conflict.value), (self.txtWorldConflict, World.conflict),
]: ]:
w.setModel(self.mdlWorld) w.setModel(self.mdlWorld)
w.setColumn(c) w.setColumn(c)
@ -918,7 +918,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.tblDebugPersos.selectionModel().currentChanged.connect( self.tblDebugPersos.selectionModel().currentChanged.connect(
lambda: self.tblDebugPersosInfos.setRootIndex(self.mdlCharacter.index( lambda: self.tblDebugPersosInfos.setRootIndex(self.mdlCharacter.index(
self.tblDebugPersos.selectionModel().currentIndex().row(), self.tblDebugPersos.selectionModel().currentIndex().row(),
Character.name.value)), AUC) Character.name)), AUC)
self.tblDebugPlots.setModel(self.mdlPlots) self.tblDebugPlots.setModel(self.mdlPlots)
self.tblDebugPlotsPersos.setModel(self.mdlPlots) self.tblDebugPlotsPersos.setModel(self.mdlPlots)
@ -926,11 +926,11 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.tblDebugPlots.selectionModel().currentChanged.connect( self.tblDebugPlots.selectionModel().currentChanged.connect(
lambda: self.tblDebugPlotsPersos.setRootIndex(self.mdlPlots.index( lambda: self.tblDebugPlotsPersos.setRootIndex(self.mdlPlots.index(
self.tblDebugPlots.selectionModel().currentIndex().row(), self.tblDebugPlots.selectionModel().currentIndex().row(),
Plot.characters.value)), AUC) Plot.characters)), AUC)
self.tblDebugPlots.selectionModel().currentChanged.connect( self.tblDebugPlots.selectionModel().currentChanged.connect(
lambda: self.tblDebugSubPlots.setRootIndex(self.mdlPlots.index( lambda: self.tblDebugSubPlots.setRootIndex(self.mdlPlots.index(
self.tblDebugPlots.selectionModel().currentIndex().row(), self.tblDebugPlots.selectionModel().currentIndex().row(),
Plot.steps.value)), AUC) Plot.steps)), AUC)
self.treeDebugWorld.setModel(self.mdlWorld) self.treeDebugWorld.setModel(self.mdlWorld)
self.treeDebugOutline.setModel(self.mdlOutline) self.treeDebugOutline.setModel(self.mdlOutline)
self.lstDebugLabels.setModel(self.mdlLabels) self.lstDebugLabels.setModel(self.mdlLabels)
@ -997,15 +997,15 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.disconnectAll(self.tblDebugPersos.selectionModel().currentChanged, self.disconnectAll(self.tblDebugPersos.selectionModel().currentChanged,
lambda: self.tblDebugPersosInfos.setRootIndex(self.mdlCharacter.index( lambda: self.tblDebugPersosInfos.setRootIndex(self.mdlCharacter.index(
self.tblDebugPersos.selectionModel().currentIndex().row(), self.tblDebugPersos.selectionModel().currentIndex().row(),
Character.name.value))) Character.name)))
self.disconnectAll(self.tblDebugPlots.selectionModel().currentChanged, self.disconnectAll(self.tblDebugPlots.selectionModel().currentChanged,
lambda: self.tblDebugPlotsPersos.setRootIndex(self.mdlPlots.index( lambda: self.tblDebugPlotsPersos.setRootIndex(self.mdlPlots.index(
self.tblDebugPlots.selectionModel().currentIndex().row(), self.tblDebugPlots.selectionModel().currentIndex().row(),
Plot.characters.value))) Plot.characters)))
self.disconnectAll(self.tblDebugPlots.selectionModel().currentChanged, self.disconnectAll(self.tblDebugPlots.selectionModel().currentChanged,
lambda: self.tblDebugSubPlots.setRootIndex(self.mdlPlots.index( lambda: self.tblDebugSubPlots.setRootIndex(self.mdlPlots.index(
self.tblDebugPlots.selectionModel().currentIndex().row(), self.tblDebugPlots.selectionModel().currentIndex().row(),
Plot.steps.value))) Plot.steps)))
############################################################################### ###############################################################################
# HELP # HELP

View file

@ -132,7 +132,7 @@ class abstractItem():
# Checking if we will have to recount words # Checking if we will have to recount words
updateWordCount = False updateWordCount = False
if column in [Outline.wordCount.value, Outline.goal.value, Outline.setGoal]: if column in [Outline.wordCount, Outline.goal, Outline.setGoal]:
updateWordCount = not Outline(column) in self._data or self._data[Outline(column)] != data updateWordCount = not Outline(column) in self._data or self._data[Outline(column)] != data
# Stuff to do before # Stuff to do before
@ -149,7 +149,7 @@ class abstractItem():
self.emitDataChanged(cols=[Outline.text]) # new in 0.5.0 self.emitDataChanged(cols=[Outline.text]) # new in 0.5.0
if column == Outline.compile: if column == Outline.compile:
self.emitDataChanged(cols=[Outline.title.value, Outline.compile], recursive=True) self.emitDataChanged(cols=[Outline.title, Outline.compile], recursive=True)
if column == Outline.customIcon: if column == Outline.customIcon:
# If custom icon changed, we tell views to update title (so that icons # If custom icon changed, we tell views to update title (so that icons
@ -197,8 +197,8 @@ class abstractItem():
self.setData(Outline.goalPercentage, "") self.setData(Outline.goalPercentage, "")
if emit: if emit:
self.emitDataChanged([Outline.goal.value, Outline.setGoal, self.emitDataChanged([Outline.goal, Outline.setGoal,
Outline.wordCount.value, Outline.goalPercentage]) Outline.wordCount, Outline.goalPercentage])
if self.parent(): if self.parent():
self.parent().updateWordCount(emit) self.parent().updateWordCount(emit)
@ -492,8 +492,8 @@ class abstractItem():
elif self.type() == "html": elif self.type() == "html":
self.setData(Outline.type, "md") self.setData(Outline.type, "md")
self.setData(Outline.text.value, HTML2PlainText(self.data(Outline.text))) self.setData(Outline.text, HTML2PlainText(self.data(Outline.text)))
self.setData(Outline.notes.value, HTML2PlainText(self.data(Outline.notes))) self.setData(Outline.notes, HTML2PlainText(self.data(Outline.notes)))
for child in root: for child in root:
if child.tag == "outlineItem": if child.tag == "outlineItem":

View file

@ -28,8 +28,8 @@ class plotModel(QStandardItemModel):
def getPlotsByImportance(self): def getPlotsByImportance(self):
plots = [[], [], []] plots = [[], [], []]
for i in range(self.rowCount()): for i in range(self.rowCount()):
importance = self.item(i, Plot.importance.value).text() importance = self.item(i, Plot.importance).text()
ID = self.item(i, Plot.ID.value).text() ID = self.item(i, Plot.ID).text()
plots[2 - toInt(importance)].append(ID) plots[2 - toInt(importance)].append(ID)
return plots return plots
@ -37,23 +37,23 @@ class plotModel(QStandardItemModel):
index = self.getIndexFromID(ID) index = self.getIndexFromID(ID)
if not index.isValid(): if not index.isValid():
return return
index = index.sibling(index.row(), Plot.steps.value) index = index.sibling(index.row(), Plot.steps)
item = self.itemFromIndex(index) item = self.itemFromIndex(index)
lst = [] lst = []
for i in range(item.rowCount()): for i in range(item.rowCount()):
if item.child(i, PlotStep.ID.value): if item.child(i, PlotStep.ID):
_ID = item.child(i, PlotStep.ID.value).text() _ID = item.child(i, PlotStep.ID).text()
# Don't know why sometimes name is None (while drag'n'droping # Don't know why sometimes name is None (while drag'n'droping
# several items) # several items)
if item.child(i, PlotStep.name.value): if item.child(i, PlotStep.name):
name = item.child(i, PlotStep.name.value).text() name = item.child(i, PlotStep.name).text()
else: else:
name = "" name = ""
# Don't know why sometimes summary is None # Don't know why sometimes summary is None
if item.child(i, PlotStep.summary.value): if item.child(i, PlotStep.summary):
summary = item.child(i, PlotStep.summary.value).text() summary = item.child(i, PlotStep.summary).text()
else: else:
summary = "" summary = ""
@ -62,17 +62,17 @@ class plotModel(QStandardItemModel):
def getPlotNameByID(self, ID): def getPlotNameByID(self, ID):
for i in range(self.rowCount()): for i in range(self.rowCount()):
_ID = self.item(i, Plot.ID.value).text() _ID = self.item(i, Plot.ID).text()
if _ID == ID or toInt(_ID) == ID: if _ID == ID or toInt(_ID) == ID:
name = self.item(i, Plot.name.value).text() name = self.item(i, Plot.name).text()
return name return name
return None return None
def getPlotImportanceByID(self, ID): def getPlotImportanceByID(self, ID):
for i in range(self.rowCount()): for i in range(self.rowCount()):
_ID = self.item(i, Plot.ID.value).text() _ID = self.item(i, Plot.ID).text()
if _ID == ID or toInt(_ID) == ID: if _ID == ID or toInt(_ID) == ID:
importance = self.item(i, Plot.importance.value).text() importance = self.item(i, Plot.importance).text()
return importance return importance
return "0" # Default to "Minor" return "0" # Default to "Minor"
@ -81,13 +81,13 @@ class plotModel(QStandardItemModel):
is ``subplotRaw``, of plot whose ID is ``plotID``. is ``subplotRaw``, of plot whose ID is ``plotID``.
""" """
plotIndex = self.getIndexFromID(plotID) plotIndex = self.getIndexFromID(plotID)
name = plotIndex.child(subplotRaw, PlotStep.name.value).data() name = plotIndex.child(subplotRaw, PlotStep.name).data()
summary = plotIndex.child(subplotRaw, PlotStep.summary.value).data() summary = plotIndex.child(subplotRaw, PlotStep.summary).data()
return name, summary return name, summary
def getIndexFromID(self, ID): def getIndexFromID(self, ID):
for i in range(self.rowCount()): for i in range(self.rowCount()):
_ID = self.item(i, Plot.ID.value).text() _ID = self.item(i, Plot.ID).text()
if _ID == ID or toInt(_ID) == ID: if _ID == ID or toInt(_ID) == ID:
return self.index(i, 0) return self.index(i, 0)
return QModelIndex() return QModelIndex()
@ -115,8 +115,8 @@ class plotModel(QStandardItemModel):
parentItem = self.itemFromIndex(parent) parentItem = self.itemFromIndex(parent)
vals = [] vals = []
for i in range(self.rowCount(parent)): for i in range(self.rowCount(parent)):
index = self.index(i, Plot.ID.value, parent) index = self.index(i, Plot.ID, parent)
# item = self.item(i, Plot.ID.value) # item = self.item(i, Plot.ID)
if index.isValid() and index.data(): if index.isValid() and index.data():
vals.append(int(index.data())) vals.append(int(index.data()))
@ -135,9 +135,9 @@ class plotModel(QStandardItemModel):
def headerData(self, section, orientation, role=Qt.DisplayRole): def headerData(self, section, orientation, role=Qt.DisplayRole):
if role == Qt.DisplayRole: if role == Qt.DisplayRole:
if orientation == Qt.Horizontal: if orientation == Qt.Horizontal:
if section == PlotStep.name.value: if section == PlotStep.name:
return self.tr("Name") return self.tr("Name")
elif section == PlotStep.meta.value: elif section == PlotStep.meta:
return self.tr("Meta") return self.tr("Meta")
else: else:
return "" return ""
@ -148,8 +148,8 @@ class plotModel(QStandardItemModel):
def data(self, index, role=Qt.DisplayRole): def data(self, index, role=Qt.DisplayRole):
if index.parent().isValid() and \ if index.parent().isValid() and \
index.parent().column() == Plot.steps.value and \ index.parent().column() == Plot.steps and \
index.column() == PlotStep.meta.value: index.column() == PlotStep.meta:
if role == Qt.TextAlignmentRole: if role == Qt.TextAlignmentRole:
return Qt.AlignRight | Qt.AlignVCenter return Qt.AlignRight | Qt.AlignVCenter
elif role == Qt.ForegroundRole: elif role == Qt.ForegroundRole:
@ -165,8 +165,8 @@ class plotModel(QStandardItemModel):
if not index.isValid(): if not index.isValid():
return return
parent = index.sibling(index.row(), Plot.steps.value) parent = index.sibling(index.row(), Plot.steps)
parentItem = self.item(index.row(), Plot.steps.value) parentItem = self.item(index.row(), Plot.steps)
if not parentItem: if not parentItem:
return return
@ -216,10 +216,10 @@ class plotModel(QStandardItemModel):
def addPlotPerso(self, v): def addPlotPerso(self, v):
index = self.mw.lstPlots.currentPlotIndex() index = self.mw.lstPlots.currentPlotIndex()
if index.isValid(): if index.isValid():
if not self.item(index.row(), Plot.characters.value): if not self.item(index.row(), Plot.characters):
self.setItem(index.row(), Plot.characters.value, QStandardItem()) self.setItem(index.row(), Plot.characters, QStandardItem())
item = self.item(index.row(), Plot.characters.value) item = self.item(index.row(), Plot.characters)
# We check that the PersoID is not in the list yet # We check that the PersoID is not in the list yet
for i in range(item.rowCount()): for i in range(item.rowCount()):

View file

@ -72,7 +72,7 @@ class plotsProxyModel(QSortFilterProxyModel):
self.mapModel() self.mapModel()
def mapModelMaybe(self, topLeft, bottomRight): def mapModelMaybe(self, topLeft, bottomRight):
if topLeft.column() <= Plot.importance.value <= bottomRight.column(): if topLeft.column() <= Plot.importance <= bottomRight.column():
self.mapModel() self.mapModel()
def mapModel(self): def mapModel(self):
@ -85,7 +85,7 @@ class plotsProxyModel(QSortFilterProxyModel):
self._map.append(self._cats[i]) self._map.append(self._cats[i])
for p in range(src.rowCount()): for p in range(src.rowCount()):
item = src.item(p, Plot.importance.value) item = src.item(p, Plot.importance)
if item: if item:
imp = int(item.text()) imp = int(item.text())

View file

@ -279,15 +279,15 @@ def infos(ref):
# Description # Description
description = m.data(index.sibling(index.row(), description = m.data(index.sibling(index.row(),
Plot.description.value)) Plot.description))
# Result # Result
result = m.data(index.sibling(index.row(), result = m.data(index.sibling(index.row(),
Plot.result.value)) Plot.result))
# Characters # Characters
pM = mainWindow().mdlCharacter pM = mainWindow().mdlCharacter
item = m.item(index.row(), Plot.characters.value) item = m.item(index.row(), Plot.characters)
characters = "" characters = ""
if item: if item:
for r in range(item.rowCount()): for r in range(item.rowCount()):
@ -298,12 +298,12 @@ def infos(ref):
# Resolution steps # Resolution steps
steps = "" steps = ""
item = m.item(index.row(), Plot.steps.value) item = m.item(index.row(), Plot.steps)
if item: if item:
for r in range(item.rowCount()): for r in range(item.rowCount()):
title = item.child(r, PlotStep.name.value).text() title = item.child(r, PlotStep.name).text()
summary = item.child(r, PlotStep.summary.value).text() summary = item.child(r, PlotStep.summary).text()
meta = item.child(r, PlotStep.meta.value).text() meta = item.child(r, PlotStep.meta).text()
if meta: if meta:
meta = " <span style='color:gray;'>({})</span>".format(meta) meta = " <span style='color:gray;'>({})</span>".format(meta)
steps += "<li><b>{title}</b>{summary}{meta}</li>".format( steps += "<li><b>{title}</b>{summary}{meta}</li>".format(

View file

@ -46,24 +46,24 @@ class worldModel(QStandardItemModel):
def ID(self, index): def ID(self, index):
"""Returns the ID of the given index.""" """Returns the ID of the given index."""
index = index.sibling(index.row(), World.ID.value) index = index.sibling(index.row(), World.ID)
return self.data(index) return self.data(index)
def name(self, index): def name(self, index):
"""Returns the name of the given index.""" """Returns the name of the given index."""
index = index.sibling(index.row(), World.name.value) index = index.sibling(index.row(), World.name)
return self.data(index) return self.data(index)
def description(self, index): def description(self, index):
index = index.sibling(index.row(), World.description.value) index = index.sibling(index.row(), World.description)
return self.data(index) return self.data(index)
def conflict(self, index): def conflict(self, index):
index = index.sibling(index.row(), World.conflict.value) index = index.sibling(index.row(), World.conflict)
return self.data(index) return self.data(index)
def passion(self, index): def passion(self, index):
index = index.sibling(index.row(), World.passion.value) index = index.sibling(index.row(), World.passion)
return self.data(index) return self.data(index)
def itemID(self, item): def itemID(self, item):

View file

@ -46,9 +46,9 @@ autoSaveDelay = 5
autoSaveNoChanges = True autoSaveNoChanges = True
autoSaveNoChangesDelay = 5 autoSaveNoChangesDelay = 5
saveOnQuit = True saveOnQuit = True
outlineViewColumns = [Outline.title.value, Outline.POV.value, Outline.status, outlineViewColumns = [Outline.title, Outline.POV, Outline.status,
Outline.compile.value, Outline.wordCount.value, Outline.goal, Outline.compile, Outline.wordCount, Outline.goal,
Outline.goalPercentage.value, Outline.label] Outline.goalPercentage, Outline.label]
corkBackground = { corkBackground = {
"color": "#926239", "color": "#926239",
"image": "writingdesk" "image": "writingdesk"

View file

@ -105,9 +105,9 @@ class cheatSheet(QWidget, Ui_cheatSheet):
d = [] d = []
for r in range(self.plotModel.rowCount()): for r in range(self.plotModel.rowCount()):
name = self.plotModel.item(r, Plot.name.value).text() name = self.plotModel.item(r, Plot.name).text()
ID = self.plotModel.item(r, Plot.ID.value).text() ID = self.plotModel.item(r, Plot.ID).text()
imp = self.plotModel.item(r, Plot.importance.value).text() imp = self.plotModel.item(r, Plot.importance).text()
imp = [self.tr("Minor"), self.tr("Secondary"), self.tr("Main")][int(imp)] imp = [self.tr("Minor"), self.tr("Secondary"), self.tr("Main")][int(imp)]
d.append((name, ID, imp)) d.append((name, ID, imp))

View file

@ -45,7 +45,7 @@ class textFormat(QWidget, Ui_textFormat):
self.setVisible(False) self.setVisible(False)
return return
if index.column() not in [Outline.text.value, Outline.notes]: if index.column() not in [Outline.text, Outline.notes]:
self.setVisible(False) self.setVisible(False)
return return

View file

@ -44,11 +44,11 @@ class characterTreeView(QTreeWidget):
if topLeft.parent() != QModelIndex(): if topLeft.parent() != QModelIndex():
return return
if topLeft.column() <= Character.name.value <= bottomRight.column(): if topLeft.column() <= Character.name <= bottomRight.column():
# Update name # Update name
self.updateNames() self.updateNames()
elif topLeft.column() <= Character.importance.value <= bottomRight.column(): elif topLeft.column() <= Character.importance <= bottomRight.column():
# Importance changed # Importance changed
self.updateItems() self.updateItems()

View file

@ -114,7 +114,7 @@ class outlineCharacterDelegate(QStyledItemDelegate):
item = QModelIndex() item = QModelIndex()
character = self.mdlCharacter.getCharacterByID(index.data()) character = self.mdlCharacter.getCharacterByID(index.data())
if character: if character:
item = character.index(Character.name.value) item = character.index(Character.name)
opt = QStyleOptionViewItem(option) opt = QStyleOptionViewItem(option)
self.initStyleOption(opt, item) self.initStyleOption(opt, item)
@ -172,7 +172,7 @@ class outlineCharacterDelegate(QStyledItemDelegate):
itemIndex = QModelIndex() itemIndex = QModelIndex()
character = self.mdlCharacter.getCharacterByID(index.data()) character = self.mdlCharacter.getCharacterByID(index.data())
if character: if character:
itemIndex = character.index(Character.name.value) itemIndex = character.index(Character.name)
opt = QStyleOptionViewItem(option) opt = QStyleOptionViewItem(option)
self.initStyleOption(opt, itemIndex) self.initStyleOption(opt, itemIndex)

View file

@ -78,7 +78,7 @@ class plotTreeView(QTreeWidget):
def updateMaybe(self, topLeft, bottomRight): def updateMaybe(self, topLeft, bottomRight):
if topLeft.parent() != QModelIndex() and \ if topLeft.parent() != QModelIndex() and \
topLeft.column() <= PlotStep.name.value <= bottomRight.column() and \ topLeft.column() <= PlotStep.name <= bottomRight.column() and \
self._showSubPlot: self._showSubPlot:
# Name's of Step has been updated, we update Items if showing # Name's of Step has been updated, we update Items if showing
# subplots. # subplots.
@ -86,11 +86,11 @@ class plotTreeView(QTreeWidget):
elif topLeft.parent() != QModelIndex(): elif topLeft.parent() != QModelIndex():
return return
if topLeft.column() <= Plot.name.value <= bottomRight.column(): if topLeft.column() <= Plot.name <= bottomRight.column():
# Update name # Update name
self.updateNames() self.updateNames()
elif topLeft.column() <= Plot.importance.value <= bottomRight.column(): elif topLeft.column() <= Plot.importance <= bottomRight.column():
# Importance changed # Importance changed
self.updateItems() self.updateItems()

View file

@ -180,7 +180,7 @@ class textEditView(QTextEdit):
return return
# what type of text are we editing? # what type of text are we editing?
if self._column not in [Outline.text.value, Outline.notes]: if self._column not in [Outline.text, Outline.notes]:
self._textFormat = "text" self._textFormat = "text"
else: else:
@ -189,7 +189,7 @@ class textEditView(QTextEdit):
# Setting highlighter # Setting highlighter
if self._highlighting: if self._highlighting:
item = index.internalPointer() item = index.internalPointer()
if self._column in [Outline.text.value, Outline.notes]: if self._column in [Outline.text, Outline.notes]:
self.highlighter = MMDHighlighter(self) self.highlighter = MMDHighlighter(self)
else: else:
self.highlighter = basicHighlighter(self) self.highlighter = basicHighlighter(self)