mirror of
https://github.com/olivierkes/manuskript.git
synced 2024-05-17 11:22:28 +12:00
Better cheat sheet
This commit is contained in:
parent
91de15e542
commit
719f6e6fe0
Binary file not shown.
|
@ -1100,27 +1100,27 @@ des lignes:</translation>
|
|||
<translation>Filtre</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/ui/cheatSheet.py" line="55"/>
|
||||
<location filename="../src/ui/cheatSheet.py" line="56"/>
|
||||
<source>Minor</source>
|
||||
<translation>Mineur</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/ui/cheatSheet.py" line="55"/>
|
||||
<location filename="../src/ui/cheatSheet.py" line="56"/>
|
||||
<source>Secondary</source>
|
||||
<translation>Secondaire</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/ui/cheatSheet.py" line="55"/>
|
||||
<location filename="../src/ui/cheatSheet.py" line="56"/>
|
||||
<source>Main</source>
|
||||
<translation>Principal</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/ui/cheatSheet.py" line="58"/>
|
||||
<location filename="../src/ui/cheatSheet.py" line="59"/>
|
||||
<source>Characters</source>
|
||||
<translation>Personnages</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/ui/cheatSheet.py" line="70"/>
|
||||
<location filename="../src/ui/cheatSheet.py" line="71"/>
|
||||
<source>Texts</source>
|
||||
<translation>Textes</translation>
|
||||
</message>
|
||||
|
@ -1346,47 +1346,47 @@ des lignes:</translation>
|
|||
<context>
|
||||
<name>outlineModel</name>
|
||||
<message>
|
||||
<location filename="../src/models/outlineModel.py" line="132"/>
|
||||
<location filename="../src/models/outlineModel.py" line="140"/>
|
||||
<source>Title</source>
|
||||
<translation>Titre</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/models/outlineModel.py" line="134"/>
|
||||
<location filename="../src/models/outlineModel.py" line="142"/>
|
||||
<source>POV</source>
|
||||
<translation>POV</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/models/outlineModel.py" line="136"/>
|
||||
<location filename="../src/models/outlineModel.py" line="144"/>
|
||||
<source>Label</source>
|
||||
<translation>Label</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/models/outlineModel.py" line="138"/>
|
||||
<location filename="../src/models/outlineModel.py" line="146"/>
|
||||
<source>Status</source>
|
||||
<translation>Status</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/models/outlineModel.py" line="140"/>
|
||||
<location filename="../src/models/outlineModel.py" line="148"/>
|
||||
<source>Compile</source>
|
||||
<translation>Compilation</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/models/outlineModel.py" line="142"/>
|
||||
<location filename="../src/models/outlineModel.py" line="150"/>
|
||||
<source>Word count</source>
|
||||
<translation>Nombre de mots</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/models/outlineModel.py" line="144"/>
|
||||
<location filename="../src/models/outlineModel.py" line="152"/>
|
||||
<source>Goal</source>
|
||||
<translation>Goal</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/models/outlineModel.py" line="665"/>
|
||||
<location filename="../src/models/outlineModel.py" line="679"/>
|
||||
<source>{} words / {} ({})</source>
|
||||
<translation>{} mots / {} ({})</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/models/outlineModel.py" line="670"/>
|
||||
<location filename="../src/models/outlineModel.py" line="684"/>
|
||||
<source>{} words</source>
|
||||
<translation>{} mots</translation>
|
||||
</message>
|
||||
|
@ -1542,24 +1542,109 @@ des lignes:</translation>
|
|||
<context>
|
||||
<name>references</name>
|
||||
<message>
|
||||
<location filename="../src/models/references.py" line="123"/>
|
||||
<location filename="../src/models/references.py" line="243"/>
|
||||
<source>Unknown reference: {}.</source>
|
||||
<translation>Référence inconnue: {}.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/models/references.py" line="112"/>
|
||||
<location filename="../src/models/references.py" line="232"/>
|
||||
<source>Text: <b>{}</b></source>
|
||||
<translation>Texte: <b>{}</b></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/models/references.py" line="120"/>
|
||||
<location filename="../src/models/references.py" line="240"/>
|
||||
<source>Character: <b>{}</b></source>
|
||||
<translation>Personnage: <b>{}</b></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/models/references.py" line="111"/>
|
||||
<source>Basic infos</source>
|
||||
<translation>Informations générales</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/models/references.py" line="112"/>
|
||||
<source>Detailed infos</source>
|
||||
<translation>Informations détaillées</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/models/references.py" line="113"/>
|
||||
<source>POV of:</source>
|
||||
<translation>POV de:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/models/references.py" line="114"/>
|
||||
<source>Referenced in:</source>
|
||||
<translation>Référencé dans:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/models/references.py" line="119"/>
|
||||
<source>Motivation</source>
|
||||
<translation>Motivation</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/models/references.py" line="120"/>
|
||||
<source>Goal</source>
|
||||
<translation>Goal</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/models/references.py" line="121"/>
|
||||
<source>Conflict</source>
|
||||
<translation>Conflit</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/models/references.py" line="122"/>
|
||||
<source>Epiphany</source>
|
||||
<translation>Épiphanie</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/models/references.py" line="123"/>
|
||||
<source>Short summary</source>
|
||||
<translation>Résumé court</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/models/references.py" line="124"/>
|
||||
<source>Longer summary</source>
|
||||
<translation>Résumé long</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/models/references.py" line="26"/>
|
||||
<source>Path:</source>
|
||||
<translation>Chemin:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/models/references.py" line="27"/>
|
||||
<source>Stats:</source>
|
||||
<translation>Stats:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/models/references.py" line="28"/>
|
||||
<source>POV:</source>
|
||||
<translation>POV:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/models/references.py" line="29"/>
|
||||
<source>Status:</source>
|
||||
<translation>Status:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/models/references.py" line="30"/>
|
||||
<source>Label:</source>
|
||||
<translation>Label:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/models/references.py" line="31"/>
|
||||
<source>Short summary:</source>
|
||||
<translation>Résumé court:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/models/references.py" line="32"/>
|
||||
<source>Long summary:</source>
|
||||
<translation>Résumé long:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/models/references.py" line="33"/>
|
||||
<source>None</source>
|
||||
<translation>Aucun</translation>
|
||||
<source>Notes:</source>
|
||||
<translation>Notes:</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
|
|
|
@ -55,6 +55,14 @@ class outlineModel(QAbstractItemModel):
|
|||
item = index.internalPointer()
|
||||
return item.ID()
|
||||
|
||||
def findItemsByPOV(self, POV):
|
||||
"Returns a list of IDs of all items whose POV is ``POV``."
|
||||
return self.rootItem.findItemsByPOV(POV)
|
||||
|
||||
def findItemsContaining(self, text, column):
|
||||
"Returns a list of IDs of all items containing ``text`` in column ``column``."
|
||||
return self.rootItem.findItemsContaining(text, column)
|
||||
|
||||
def getIndexByID(self, ID):
|
||||
"Returns the index of item whose ID is ``ID``. If none, returns QModelIndex()."
|
||||
def search(item):
|
||||
|
@ -630,6 +638,12 @@ class outlineItem():
|
|||
def POV(self):
|
||||
return self.data(Outline.POV.value)
|
||||
|
||||
def status(self):
|
||||
return self.data(Outline.status.value)
|
||||
|
||||
def label(self):
|
||||
return self.data(Outline.label.value)
|
||||
|
||||
def path(self):
|
||||
"Returns path to item as string."
|
||||
if self.parent().parent():
|
||||
|
@ -737,4 +751,28 @@ class outlineItem():
|
|||
path = self.data(Outline.ID.value)
|
||||
if self.parent().parent():
|
||||
path = "{}:{}".format(self.parent().pathToItem(), path)
|
||||
return path
|
||||
return path
|
||||
|
||||
def findItemsByPOV(self, POV):
|
||||
"Returns a list of IDs of all subitems whose POV is ``POV``."
|
||||
lst = []
|
||||
if self.POV() == POV:
|
||||
lst.append(self.ID())
|
||||
|
||||
for c in self.children():
|
||||
lst.extend(c.findItemsByPOV(POV))
|
||||
|
||||
return lst
|
||||
|
||||
def findItemsContaining(self, text, column):
|
||||
"""Returns a list if IDs of all subitems
|
||||
containing ``text`` in column ``column``.
|
||||
"""
|
||||
lst = []
|
||||
if text in self.data(column):
|
||||
lst.append(self.ID())
|
||||
|
||||
for c in self.children():
|
||||
lst.extend(c.findItemsContaining(text, column))
|
||||
|
||||
return lst
|
|
@ -165,5 +165,13 @@ class persosModel(QStandardItemModel):
|
|||
rm.reverse()
|
||||
for r in rm:
|
||||
perso.takeRow(r)
|
||||
|
||||
|
||||
def listPersoInfos(self, index):
|
||||
infos = []
|
||||
for i in range(self.rowCount(index)):
|
||||
name = self.data(index.child(i, Perso.infoName.value))
|
||||
val = self.data(index.child(i, Perso.infoData.value))
|
||||
infos.append((name, val))
|
||||
|
||||
return infos
|
||||
|
|
@ -22,15 +22,33 @@ def infoForRef(ref):
|
|||
|
||||
item = idx.internalPointer()
|
||||
|
||||
#<p><b>Status:</b> {status}</p>
|
||||
#<p><b>Label:</b> {label}</p>
|
||||
|
||||
#Titles
|
||||
pathTitle = qApp.translate("references", "Path:")
|
||||
statsTitle = qApp.translate("references", "Stats:")
|
||||
POVTitle = qApp.translate("references", "POV:")
|
||||
statusTitle = qApp.translate("references", "Status:")
|
||||
labelTitle = qApp.translate("references", "Label:")
|
||||
ssTitle = qApp.translate("references", "Short summary:")
|
||||
lsTitle = qApp.translate("references", "Long summary:")
|
||||
notesTitle = qApp.translate("references", "Notes:")
|
||||
|
||||
POV = ""
|
||||
if item.POV():
|
||||
POV = "<a href='{ref}'>{text}</a>".format(
|
||||
ref="::C:{}::".format(item.POV()),
|
||||
text=mainWindow().mdlPersos.getPersoNameByID(item.POV()))
|
||||
|
||||
status = item.status()
|
||||
if status:
|
||||
status = mainWindow().mdlStatus.item(int(status), 0).text()
|
||||
else:
|
||||
POV = qApp.translate("references", "None")
|
||||
status = ""
|
||||
|
||||
label = item.label()
|
||||
if label:
|
||||
label = mainWindow().mdlLabels.item(int(label), 0).text()
|
||||
else:
|
||||
label = ""
|
||||
|
||||
path = item.pathID()
|
||||
pathStr = []
|
||||
|
@ -40,28 +58,125 @@ def infoForRef(ref):
|
|||
text=title))
|
||||
path = " > ".join(pathStr)
|
||||
|
||||
ss = item.data(Outline.summarySentance.value)
|
||||
ls = item.data(Outline.summaryFull.value)
|
||||
notes = item.data(Outline.notes.value)
|
||||
|
||||
text = """<h1>{title}</h1>
|
||||
<p><b>Path:</b> {path}</p>
|
||||
<p><b>Stats:</b> {stats}</p>
|
||||
<p><b>POV:</b> {POV}</p>
|
||||
<p><b>Short summary:</b> {ss}</p>
|
||||
<p><b>Long summary:</b> {ls}</p>
|
||||
<p><b>Notes:</b> {notes}</p>
|
||||
<p><b>{pathTitle}</b> {path}</p>
|
||||
<p><b>{statsTitle}</b> {stats}<br>
|
||||
{POV}
|
||||
{status}
|
||||
{label}</p>
|
||||
{ss}
|
||||
{ls}
|
||||
{notes}
|
||||
""".format(
|
||||
title=item.title(),
|
||||
pathTitle=pathTitle,
|
||||
path=path,
|
||||
statsTitle=statsTitle,
|
||||
stats=item.stats(),
|
||||
POV=POV,
|
||||
ss=item.data(Outline.summarySentance.value).replace("\n", "<br>"),
|
||||
ls=item.data(Outline.summaryFull.value).replace("\n", "<br>"),
|
||||
notes=linkifyAllRefs(item.data(Outline.notes.value)).replace("\n", "<br>"))
|
||||
POV="<b>{POVTitle}</b> {POV}<br>".format(
|
||||
POVTitle=POVTitle,
|
||||
POV=POV) if POV else "",
|
||||
status="<b>{statusTitle}</b> {status}<br>".format(
|
||||
statusTitle=statusTitle,
|
||||
status=status) if status else "",
|
||||
label="<b>{labelTitle}</b> {label}</p>".format(
|
||||
labelTitle=labelTitle,
|
||||
label=label) if label else "",
|
||||
ss="<p><b>{ssTitle}</b> {ss}</p>".format(
|
||||
ssTitle=ssTitle,
|
||||
ss=ss.replace("\n", "<br>")) if ss else "",
|
||||
ls="<p><b>{lsTitle}</b><br>{ls}</p>".format(
|
||||
lsTitle=lsTitle,
|
||||
ls=ls.replace("\n", "<br>")) if ls else "",
|
||||
notes="<p><b>{notesTitle}</b><br>{notes}</p>".format(
|
||||
notesTitle=notesTitle,
|
||||
notes=linkifyAllRefs(notes).replace("\n", "<br>")) if notes else "",
|
||||
)
|
||||
|
||||
return text
|
||||
|
||||
elif _type == "C":
|
||||
m = mainWindow().mdlPersos
|
||||
name = m.item(int(_ref), Perso.name.value).text()
|
||||
return "<h1>{}</h1>".format(name)
|
||||
index = m.getIndexFromID(_ref)
|
||||
name = m.name(index.row())
|
||||
|
||||
# Titles
|
||||
basicTitle = qApp.translate("references", "Basic infos")
|
||||
detailedTitle = qApp.translate("references", "Detailed infos")
|
||||
POVof = qApp.translate("references", "POV of:")
|
||||
referencedIn = qApp.translate("references", "Referenced in:")
|
||||
|
||||
# basic infos
|
||||
basic = []
|
||||
for i in [
|
||||
(Perso.motivation, qApp.translate("references", "Motivation"), False),
|
||||
(Perso.goal, qApp.translate("references", "Goal"), False),
|
||||
(Perso.conflict, qApp.translate("references", "Conflict"), False),
|
||||
(Perso.epiphany, qApp.translate("references", "Epiphany"), False),
|
||||
(Perso.summarySentance, qApp.translate("references", "Short summary"), True),
|
||||
(Perso.summaryPara, qApp.translate("references", "Longer summary"), True),
|
||||
]:
|
||||
val = m.data(index.sibling(index.row(), i[0].value))
|
||||
if val:
|
||||
basic .append("<b>{title}:</b>{n}{val}".format(
|
||||
title=i[1],
|
||||
n = "\n" if i[2] else " ",
|
||||
val=val))
|
||||
basic = "<br>".join(basic)
|
||||
|
||||
# detailed infos
|
||||
detailed = []
|
||||
for _name, _val in m.listPersoInfos(index):
|
||||
detailed.append("<b>{}:</b> {}".format(
|
||||
_name,
|
||||
_val))
|
||||
detailed = "<br>".join(detailed)
|
||||
|
||||
# list scenes of which it is POV
|
||||
oM = mainWindow().mdlOutline
|
||||
lst = oM.findItemsByPOV(_ref)
|
||||
|
||||
listPOV = ""
|
||||
for t in lst:
|
||||
idx = oM.getIndexByID(t)
|
||||
listPOV += "<li><a href='{link}'>{text}</a>".format(
|
||||
link="::T:{}::".format(t),
|
||||
text=oM.data(idx, Outline.title.value))
|
||||
|
||||
# List scences where character is referenced
|
||||
listRefs = ""
|
||||
lst = oM.findItemsContaining(ref, Outline.notes.value)
|
||||
for t in lst:
|
||||
idx = oM.getIndexByID(t)
|
||||
listRefs += "<li><a href='{link}'>{text}</a>".format(
|
||||
link="::T:{}::".format(t),
|
||||
text=oM.data(idx, Outline.title.value))
|
||||
|
||||
text = """<h1>{name}</h1>
|
||||
{basicInfos}
|
||||
{detailedInfos}
|
||||
{POV}
|
||||
{references}
|
||||
""".format(
|
||||
name=name,
|
||||
basicInfos="<h2>{basicTitle}</h2>{basic}".format(
|
||||
basicTitle=basicTitle,
|
||||
basic=basic) if basic else "",
|
||||
detailedInfos="<h2>{detailedTitle}</h2>{detailed}".format(
|
||||
detailedTitle=detailedTitle,
|
||||
detailed=detailed) if detailed else "",
|
||||
POV="<h2>{POVof}</h2><ul>{listPOV}</ul>".format(
|
||||
POVof=POVof,
|
||||
listPOV=listPOV) if listPOV else "",
|
||||
references="<h2>{referencedIn}</h2><ul>{listRefs}</ul>".format(
|
||||
referencedIn=referencedIn,
|
||||
listRefs=listRefs) if listRefs else "",
|
||||
)
|
||||
return text
|
||||
|
||||
else:
|
||||
return qApp.translate("references", "Unknown reference: {}.").format(ref)
|
||||
|
|
|
@ -24,6 +24,7 @@ class cheatSheet(QWidget, Ui_cheatSheet):
|
|||
self.list.setItemDelegate(self.listDelegate)
|
||||
self.list.itemActivated.connect(self.showInfos)
|
||||
self.view.linkActivated.connect(self.openLink)
|
||||
self.view.linkHovered.connect(self.linkHovered)
|
||||
|
||||
self.outlineModel = None
|
||||
self.persoModel = None
|
||||
|
@ -104,6 +105,10 @@ class cheatSheet(QWidget, Ui_cheatSheet):
|
|||
def openLink(self, link):
|
||||
openReference(link)
|
||||
|
||||
def linkHovered(self, link):
|
||||
if link:
|
||||
QToolTip.showText(QCursor.pos(), tooltipForRef(link))
|
||||
|
||||
def keyPressEvent(self, event):
|
||||
if event.key() in [Qt.Key_Up, Qt.Key_Down]:
|
||||
self.list.keyPressEvent(event)
|
||||
|
|
Loading…
Reference in a new issue