mirror of
https://github.com/olivierkes/manuskript.git
synced 2024-06-01 18:49:38 +12:00
Changes some more 'persos' to 'characters'
This commit is contained in:
parent
50dc7f3739
commit
599a60ecff
|
@ -26,7 +26,7 @@ class Plot(Enum):
|
||||||
name = 0
|
name = 0
|
||||||
ID = 1
|
ID = 1
|
||||||
importance = 2
|
importance = 2
|
||||||
persos = 3
|
characters = 3
|
||||||
description = 4
|
description = 4
|
||||||
result = 5
|
result = 5
|
||||||
subplots = 6
|
subplots = 6
|
||||||
|
@ -64,4 +64,3 @@ class Outline(Enum):
|
||||||
# (sum of all sub-items' goals)
|
# (sum of all sub-items' goals)
|
||||||
textFormat = 15
|
textFormat = 15
|
||||||
revisions = 16
|
revisions = 16
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ from PyQt5.QtCore import Qt, QModelIndex
|
||||||
from PyQt5.QtGui import QColor
|
from PyQt5.QtGui import QColor
|
||||||
|
|
||||||
from manuskript import settings
|
from manuskript import settings
|
||||||
from manuskript.enums import Character, World
|
from manuskript.enums import Character, World, Plot
|
||||||
from manuskript.functions import mainWindow, iconColor
|
from manuskript.functions import mainWindow, iconColor
|
||||||
from lxml import etree as ET
|
from lxml import etree as ET
|
||||||
|
|
||||||
|
@ -217,7 +217,15 @@ def saveProject(zip=None):
|
||||||
# Either in XML or lots of plain texts?
|
# Either in XML or lots of plain texts?
|
||||||
# More probably XML since there is not really a lot if writing to do (third-party)
|
# More probably XML since there is not really a lot if writing to do (third-party)
|
||||||
|
|
||||||
# TODO
|
path = "plots.opml"
|
||||||
|
mdl = mw.mdlPlots
|
||||||
|
|
||||||
|
root = ET.Element("opml")
|
||||||
|
root.attrib["version"] = "1.0"
|
||||||
|
body = ET.SubElement(root, "body")
|
||||||
|
addPlotItem(body, mdl)
|
||||||
|
content = ET.tostring(root, encoding="UTF-8", xml_declaration=True, pretty_print=True)
|
||||||
|
files.append((path, content))
|
||||||
|
|
||||||
# Settings
|
# Settings
|
||||||
# Saved in readable text (json) for easier versionning. But they mustn't be shared, it seems.
|
# Saved in readable text (json) for easier versionning. But they mustn't be shared, it seems.
|
||||||
|
@ -301,6 +309,52 @@ def addWorldItem(root, mdl, parent=QModelIndex()):
|
||||||
|
|
||||||
return root
|
return root
|
||||||
|
|
||||||
|
|
||||||
|
def addPlotItem(root, mdl, parent=QModelIndex()):
|
||||||
|
"""
|
||||||
|
Lists elements in a plot model and create an OPML xml file.
|
||||||
|
@param root: an Etree element
|
||||||
|
@param mdl: a plotModel
|
||||||
|
@param parent: the parent index in the plot model
|
||||||
|
@return: root, to which sub element have been added
|
||||||
|
"""
|
||||||
|
|
||||||
|
# List every row (every plot item)
|
||||||
|
for x in range(mdl.rowCount(parent)):
|
||||||
|
|
||||||
|
# For each row, create an outline item.
|
||||||
|
outline = ET.SubElement(root, "outline")
|
||||||
|
for y in range(mdl.columnCount(parent)):
|
||||||
|
|
||||||
|
index = mdl.index(x, y, parent)
|
||||||
|
val = mdl.data(index)
|
||||||
|
|
||||||
|
if not val:
|
||||||
|
continue
|
||||||
|
|
||||||
|
for w in Plot:
|
||||||
|
if y == w.value:
|
||||||
|
outline.attrib[w.name] = val
|
||||||
|
|
||||||
|
if y == Plot.characters.value:
|
||||||
|
if mdl.hasChildren(index):
|
||||||
|
characters = []
|
||||||
|
for cX in range(mdl.rowCount(index)):
|
||||||
|
for cY in range(mdl.columnCount(index)):
|
||||||
|
cIndex = mdl.index(cX, cY, index)
|
||||||
|
characters.append(mdl.data(cIndex))
|
||||||
|
outline.attrib[Plot.characters.name] = ",".join(characters)
|
||||||
|
else:
|
||||||
|
outline.attrib.pop(Plot.characters.name)
|
||||||
|
|
||||||
|
elif y == Plot.subplots.value and mdl.hasChildren(index):
|
||||||
|
outline.attrib.pop(Plot.subplots.name)
|
||||||
|
|
||||||
|
|
||||||
|
# addWorldItem(outline, mdl, index)
|
||||||
|
|
||||||
|
return root
|
||||||
|
|
||||||
def loadProject(project):
|
def loadProject(project):
|
||||||
"""
|
"""
|
||||||
Loads a project.
|
Loads a project.
|
||||||
|
|
|
@ -205,7 +205,7 @@ 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.persos.value))
|
Plot.characters.value))
|
||||||
subplotindex = index.sibling(index.row(), Plot.subplots.value)
|
subplotindex = index.sibling(index.row(), Plot.subplots.value)
|
||||||
self.lstSubPlots.setRootIndex(subplotindex)
|
self.lstSubPlots.setRootIndex(subplotindex)
|
||||||
if self.mdlPlots.rowCount(subplotindex):
|
if self.mdlPlots.rowCount(subplotindex):
|
||||||
|
@ -678,7 +678,7 @@ 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.persos.value)), AUC)
|
Plot.characters.value)), 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(),
|
||||||
|
|
|
@ -182,10 +182,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.persos.value):
|
if not self.item(index.row(), Plot.characters.value):
|
||||||
self.setItem(index.row(), Plot.persos.value, QStandardItem())
|
self.setItem(index.row(), Plot.characters.value, QStandardItem())
|
||||||
|
|
||||||
item = self.item(index.row(), Plot.persos.value)
|
item = self.item(index.row(), Plot.characters.value)
|
||||||
|
|
||||||
# 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()):
|
||||||
|
|
|
@ -277,7 +277,7 @@ def infos(ref):
|
||||||
|
|
||||||
# Characters
|
# Characters
|
||||||
pM = mainWindow().mdlCharacter
|
pM = mainWindow().mdlCharacter
|
||||||
item = m.item(index.row(), Plot.persos.value)
|
item = m.item(index.row(), Plot.characters.value)
|
||||||
characters = ""
|
characters = ""
|
||||||
if item:
|
if item:
|
||||||
for r in range(item.rowCount()):
|
for r in range(item.rowCount()):
|
||||||
|
|
Loading…
Reference in a new issue