Adds: cheat sheet

This commit is contained in:
Olivier Keshavjee 2015-06-30 12:27:43 +02:00
parent bbf8360b91
commit 49ca4b0898
14 changed files with 565 additions and 258 deletions

View file

@ -2,6 +2,7 @@ FORMS += ../src/ui/mainWindow.ui
FORMS += ../src/ui/settings.ui
FORMS += ../src/ui/welcome_ui.ui
FORMS += ../src/ui/sldImportance_ui.ui
FORMS += ../src/ui/cheatSheet_ui.ui
FORMS += ../src/ui/editors/editorWidget_ui.ui
@ -23,6 +24,7 @@ SOURCES += ../src/models/references.py
SOURCES += ../src/ui/helpLabel.py
SOURCES += ../src/ui/sldImportance.py
SOURCES += ../src/ui/welcome.py
SOURCES += ../src/ui/cheatSheet.py
SOURCES += ../src/ui/editors/editorWidget.py
SOURCES += ../src/ui/editors/fullScreenEditor.py
@ -30,7 +32,6 @@ SOURCES += ../src/ui/editors/textFormat.py
SOURCES += ../src/ui/editors/completer.py
SOURCES += ../src/ui/editors/mainEditor.py
SOURCES += ../src/ui/views/corkDelegate.py
SOURCES += ../src/ui/views/outlineDelegates.py
SOURCES += ../src/ui/views/outlineBasics.py

View file

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="fr" sourcelanguage="en">
<!DOCTYPE TS><TS version="2.0" language="fr" sourcelanguage="en">
<context>
<name>MainWindow</name>
<message>
@ -124,7 +123,7 @@
<translation>Noms</translation>
</message>
<message>
<location filename="../src/ui/mainWindow.ui" line="1631"/>
<location filename="../src/ui/mainWindow.ui" line="1056"/>
<source>Filter</source>
<translation>Filtre</translation>
</message>
@ -179,7 +178,7 @@
<translation>Informations détaillées</translation>
</message>
<message>
<location filename="../src/ui/mainWindow.ui" line="1710"/>
<location filename="../src/ui/mainWindow.ui" line="1692"/>
<source>Plots</source>
<translation>Intrigues</translation>
</message>
@ -214,7 +213,7 @@
<translation>Contexte</translation>
</message>
<message>
<location filename="../src/mainWindow.py" line="1014"/>
<location filename="../src/mainWindow.py" line="1017"/>
<source>Outline</source>
<translation>Plan</translation>
</message>
@ -224,207 +223,187 @@
<translation>Rédaction</translation>
</message>
<message>
<location filename="../src/ui/mainWindow.ui" line="1809"/>
<location filename="../src/ui/mainWindow.ui" line="1791"/>
<source>Tools</source>
<translation>Outils</translation>
</message>
<message>
<location filename="../src/ui/mainWindow.ui" line="1619"/>
<location filename="../src/ui/mainWindow.ui" line="1625"/>
<source>Cheat sheet</source>
<translation>Aide-mémoire</translation>
</message>
<message>
<location filename="../src/ui/mainWindow.ui" line="1639"/>
<source>Albert - perso</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/ui/mainWindow.ui" line="1644"/>
<source>Jean - perso</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/ui/mainWindow.ui" line="1649"/>
<source>Crapoquak - animal</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/ui/mainWindow.ui" line="1654"/>
<source>La revenche du capitaine - intrigue</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/ui/mainWindow.ui" line="1674"/>
<location filename="../src/ui/mainWindow.ui" line="1656"/>
<source>Debug</source>
<translation>Debug</translation>
</message>
<message>
<location filename="../src/ui/mainWindow.ui" line="1687"/>
<location filename="../src/ui/mainWindow.ui" line="1669"/>
<source>FlatData</source>
<translation>FlatData</translation>
</message>
<message>
<location filename="../src/ui/mainWindow.ui" line="1697"/>
<location filename="../src/ui/mainWindow.ui" line="1679"/>
<source>Persos</source>
<translation>Persos</translation>
</message>
<message>
<location filename="../src/ui/mainWindow.ui" line="1778"/>
<location filename="../src/ui/mainWindow.ui" line="1760"/>
<source>File</source>
<translation>Fichier</translation>
</message>
<message>
<location filename="../src/ui/mainWindow.ui" line="1803"/>
<location filename="../src/ui/mainWindow.ui" line="1785"/>
<source>Help</source>
<translation>Aide</translation>
</message>
<message>
<location filename="../src/ui/mainWindow.ui" line="1840"/>
<location filename="../src/ui/mainWindow.ui" line="1822"/>
<source>Open</source>
<translation>Ouvrir</translation>
</message>
<message>
<location filename="../src/ui/mainWindow.ui" line="1843"/>
<location filename="../src/ui/mainWindow.ui" line="1825"/>
<source>Ctrl+O</source>
<translation></translation>
</message>
<message>
<location filename="../src/ui/mainWindow.ui" line="1782"/>
<location filename="../src/ui/mainWindow.ui" line="1764"/>
<source>Recents</source>
<translation>Récents</translation>
</message>
<message>
<location filename="../src/ui/mainWindow.ui" line="1852"/>
<location filename="../src/ui/mainWindow.ui" line="1834"/>
<source>Save</source>
<translation>Enregistrer</translation>
</message>
<message>
<location filename="../src/ui/mainWindow.ui" line="1855"/>
<location filename="../src/ui/mainWindow.ui" line="1837"/>
<source>Ctrl+S</source>
<translation>Ctrl+S</translation>
</message>
<message>
<location filename="../src/ui/mainWindow.ui" line="1864"/>
<location filename="../src/ui/mainWindow.ui" line="1846"/>
<source>Save as...</source>
<translation>Enregistrer sous...</translation>
</message>
<message>
<location filename="../src/ui/mainWindow.ui" line="1867"/>
<location filename="../src/ui/mainWindow.ui" line="1849"/>
<source>Ctrl+Shift+S</source>
<translation></translation>
</message>
<message>
<location filename="../src/ui/mainWindow.ui" line="1876"/>
<location filename="../src/ui/mainWindow.ui" line="1858"/>
<source>Quit</source>
<translation>Quitter</translation>
</message>
<message>
<location filename="../src/ui/mainWindow.ui" line="1879"/>
<location filename="../src/ui/mainWindow.ui" line="1861"/>
<source>Ctrl+Q</source>
<translation></translation>
</message>
<message>
<location filename="../src/ui/mainWindow.ui" line="1894"/>
<location filename="../src/ui/mainWindow.ui" line="1876"/>
<source>Show help texts</source>
<translation>Montrer les bulles d&apos;aides</translation>
</message>
<message>
<location filename="../src/ui/mainWindow.ui" line="1897"/>
<location filename="../src/ui/mainWindow.ui" line="1879"/>
<source>Ctrl+Shift+B</source>
<translation></translation>
</message>
<message>
<location filename="../src/ui/mainWindow.ui" line="1912"/>
<location filename="../src/ui/mainWindow.ui" line="1894"/>
<source>Spellcheck</source>
<translation>Correcteur orthographique</translation>
</message>
<message>
<location filename="../src/ui/mainWindow.ui" line="1979"/>
<location filename="../src/ui/mainWindow.ui" line="1961"/>
<source>F8</source>
<translation></translation>
</message>
<message>
<location filename="../src/ui/mainWindow.ui" line="1795"/>
<location filename="../src/ui/mainWindow.ui" line="1777"/>
<source>Mode</source>
<translation>Mode</translation>
</message>
<message>
<location filename="../src/mainWindow.py" line="847"/>
<location filename="../src/mainWindow.py" line="850"/>
<source> (~{} pages)</source>
<translation> (~{} pages)</translation>
</message>
<message>
<location filename="../src/mainWindow.py" line="873"/>
<location filename="../src/mainWindow.py" line="876"/>
<source>Enter infos about your book, and yourself.</source>
<translation>Entrez toutes les informations relatives au livre, ainsi qu&apos;à vous.</translation>
</message>
<message>
<location filename="../src/mainWindow.py" line="879"/>
<location filename="../src/mainWindow.py" line="882"/>
<source>Take time to think about a one sentance (~50 words) summary of your book. Then expand it to a paragraph, then to a page, then to a full summary.</source>
<translation>Prenez le temps de réfléchir à un résumé de votre livre, en une phrase (~50 mots). Puis augmentez cette phrase en un paragraphe, puis en une page, puis en un résumé complet.</translation>
</message>
<message>
<location filename="../src/mainWindow.py" line="882"/>
<location filename="../src/mainWindow.py" line="885"/>
<source>Create your characters.</source>
<translation>Créez ici vos personnage.</translation>
</message>
<message>
<location filename="../src/mainWindow.py" line="885"/>
<location filename="../src/mainWindow.py" line="888"/>
<source>Develop plots.</source>
<translation>Développez vos intrigues.</translation>
</message>
<message>
<location filename="../src/mainWindow.py" line="888"/>
<location filename="../src/mainWindow.py" line="891"/>
<source>Create the outline of your masterpiece.</source>
<translation>Créez le plan de votre chef-d&apos;œuvre.</translation>
</message>
<message>
<location filename="../src/mainWindow.py" line="891"/>
<location filename="../src/mainWindow.py" line="894"/>
<source>Write.</source>
<translation>Écrivez.</translation>
</message>
<message>
<location filename="../src/mainWindow.py" line="894"/>
<location filename="../src/mainWindow.py" line="897"/>
<source>Debug infos. Sometimes useful.</source>
<translation>Des infos pour débugger des fois pendant qu&apos;on code c&apos;est utile.</translation>
</message>
<message>
<location filename="../src/mainWindow.py" line="908"/>
<location filename="../src/mainWindow.py" line="911"/>
<source>Dictionary</source>
<translation>Dictionnaire</translation>
</message>
<message>
<location filename="../src/mainWindow.py" line="921"/>
<location filename="../src/mainWindow.py" line="924"/>
<source>Install PyEnchant to use spellcheck</source>
<translation>Installez PyEnchant pour profiter du correcteur orthographique</translation>
</message>
<message>
<location filename="../src/mainWindow.py" line="851"/>
<location filename="../src/mainWindow.py" line="854"/>
<source>Words: {}{}</source>
<translation>Mots: {}{}</translation>
</message>
<message>
<location filename="../src/mainWindow.py" line="1025"/>
<location filename="../src/mainWindow.py" line="1028"/>
<source>Text</source>
<translation>Texte</translation>
</message>
<message>
<location filename="../src/ui/mainWindow.ui" line="1744"/>
<location filename="../src/ui/mainWindow.ui" line="1726"/>
<source>Labels</source>
<translation>Labels</translation>
</message>
<message>
<location filename="../src/ui/mainWindow.ui" line="1815"/>
<location filename="../src/ui/mainWindow.ui" line="1797"/>
<source>Edit</source>
<translation>Édition</translation>
</message>
<message>
<location filename="../src/ui/mainWindow.ui" line="1920"/>
<location filename="../src/ui/mainWindow.ui" line="1902"/>
<source>Labels...</source>
<translation>Labels...</translation>
</message>
<message>
<location filename="../src/ui/mainWindow.ui" line="1925"/>
<location filename="../src/ui/mainWindow.ui" line="1907"/>
<source>Status...</source>
<translation>Status...</translation>
</message>
@ -444,7 +423,7 @@
<translation>Et si...?</translation>
</message>
<message>
<location filename="../src/mainWindow.py" line="1013"/>
<location filename="../src/mainWindow.py" line="1016"/>
<source>Index cards</source>
<translation>Cartes</translation>
</message>
@ -454,37 +433,37 @@
<translation>Métadonnées</translation>
</message>
<message>
<location filename="../src/ui/mainWindow.ui" line="1823"/>
<location filename="../src/ui/mainWindow.ui" line="1805"/>
<source>View</source>
<translation>Vue</translation>
</message>
<message>
<location filename="../src/ui/mainWindow.ui" line="1915"/>
<location filename="../src/ui/mainWindow.ui" line="1897"/>
<source>F9</source>
<translation>F9</translation>
</message>
<message>
<location filename="../src/mainWindow.py" line="1012"/>
<location filename="../src/mainWindow.py" line="1015"/>
<source>Tree</source>
<translation>Arbre</translation>
</message>
<message>
<location filename="../src/ui/mainWindow.ui" line="1941"/>
<location filename="../src/ui/mainWindow.ui" line="1923"/>
<source>Normal</source>
<translation>Normal</translation>
</message>
<message>
<location filename="../src/ui/mainWindow.ui" line="1949"/>
<location filename="../src/ui/mainWindow.ui" line="1931"/>
<source>Simple</source>
<translation>Simple</translation>
</message>
<message>
<location filename="../src/ui/mainWindow.ui" line="1957"/>
<location filename="../src/ui/mainWindow.ui" line="1939"/>
<source>Fractal</source>
<translation>Fractal</translation>
</message>
<message>
<location filename="../src/ui/mainWindow.ui" line="1976"/>
<location filename="../src/ui/mainWindow.ui" line="1958"/>
<source>Settings</source>
<translation>Réglages</translation>
</message>
@ -499,72 +478,72 @@
<translation>Le projet {} a é chargé.</translation>
</message>
<message>
<location filename="../src/mainWindow.py" line="876"/>
<location filename="../src/mainWindow.py" line="879"/>
<source>The basic situation, in the form of a &apos;What if...?&apos; question. Ex: &apos;What if the most dangerous evil wizard could wasn&apos;t abled to kill a baby?&apos; (Harry Potter)</source>
<translation>La situation de base, sous la forme d&apos;une question: &quot;Et si...?&quot; Par exemple: &quot;Et si le plus dangereux magiciens mauvais n&apos;était pas capable de tuer un bébé?&quot; (Harry Potter)</translation>
</message>
<message>
<location filename="../src/mainWindow.py" line="1004"/>
<location filename="../src/mainWindow.py" line="1007"/>
<source>Nothing</source>
<translation>Rien</translation>
</message>
<message>
<location filename="../src/mainWindow.py" line="1005"/>
<location filename="../src/mainWindow.py" line="1008"/>
<source>POV</source>
<translation>POV</translation>
</message>
<message>
<location filename="../src/mainWindow.py" line="1006"/>
<location filename="../src/mainWindow.py" line="1009"/>
<source>Label</source>
<translation>Label</translation>
</message>
<message>
<location filename="../src/mainWindow.py" line="1007"/>
<location filename="../src/mainWindow.py" line="1010"/>
<source>Progress</source>
<translation>Progrès</translation>
</message>
<message>
<location filename="../src/mainWindow.py" line="1008"/>
<location filename="../src/mainWindow.py" line="1011"/>
<source>Compile</source>
<translation>Compilation</translation>
</message>
<message>
<location filename="../src/mainWindow.py" line="1031"/>
<location filename="../src/mainWindow.py" line="1034"/>
<source>Icon color</source>
<translation>Couleur de l&apos;icone</translation>
</message>
<message>
<location filename="../src/mainWindow.py" line="1032"/>
<location filename="../src/mainWindow.py" line="1035"/>
<source>Text color</source>
<translation>Couleur du texte</translation>
</message>
<message>
<location filename="../src/mainWindow.py" line="1033"/>
<location filename="../src/mainWindow.py" line="1036"/>
<source>Background color</source>
<translation>Couleur de l&apos;arrière-plan</translation>
</message>
<message>
<location filename="../src/mainWindow.py" line="1024"/>
<location filename="../src/mainWindow.py" line="1027"/>
<source>Icon</source>
<translation>Icone</translation>
</message>
<message>
<location filename="../src/mainWindow.py" line="1026"/>
<location filename="../src/mainWindow.py" line="1029"/>
<source>Background</source>
<translation>Arrière-plan</translation>
</message>
<message>
<location filename="../src/mainWindow.py" line="1027"/>
<location filename="../src/mainWindow.py" line="1030"/>
<source>Border</source>
<translation>Bordure</translation>
</message>
<message>
<location filename="../src/mainWindow.py" line="1028"/>
<location filename="../src/mainWindow.py" line="1031"/>
<source>Corner</source>
<translation>Coin</translation>
</message>
<message>
<location filename="../src/ui/mainWindow.ui" line="1989"/>
<location filename="../src/ui/mainWindow.ui" line="1971"/>
<source>Close project</source>
<translation>Fermer le projet</translation>
</message>
@ -1107,6 +1086,44 @@ des lignes:</translation>
<translation>Résumé en quelques phrases:</translation>
</message>
</context>
<context>
<name>cheatSheet</name>
<message>
<location filename="../src/ui/cheatSheet_ui.ui" line="14"/>
<source>Form</source>
<translation type="unfinished">Form</translation>
</message>
<message>
<location filename="../src/ui/cheatSheet_ui.ui" line="23"/>
<source>Filter</source>
<translation type="unfinished">Filtre</translation>
</message>
<message>
<location filename="../src/ui/cheatSheet.py" line="54"/>
<source>Minor</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/ui/cheatSheet.py" line="54"/>
<source>Secondary</source>
<translation type="unfinished">Secondaire</translation>
</message>
<message>
<location filename="../src/ui/cheatSheet.py" line="54"/>
<source>Main</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/ui/cheatSheet.py" line="57"/>
<source>Characters</source>
<translation type="unfinished">Personnages</translation>
</message>
<message>
<location filename="../src/ui/cheatSheet.py" line="69"/>
<source>Texts</source>
<translation type="unfinished">Textes</translation>
</message>
</context>
<context>
<name>cmbOutlineLabelChoser</name>
<message>
@ -1151,34 +1168,6 @@ des lignes:</translation>
<translation>Différentes valeurs</translation>
</message>
</context>
<context>
<name>completer</name>
<message>
<location filename="../src/ui/editors/completer.py" line="64"/>
<source>Texts</source>
<translation>Textes</translation>
</message>
<message>
<location filename="../src/ui/editors/completer.py" line="73"/>
<source>Minor</source>
<translation>Mineur</translation>
</message>
<message>
<location filename="../src/ui/editors/completer.py" line="73"/>
<source>Secondary</source>
<translation>Secondaire</translation>
</message>
<message>
<location filename="../src/ui/editors/completer.py" line="73"/>
<source>Main</source>
<translation>Principal</translation>
</message>
<message>
<location filename="../src/ui/editors/completer.py" line="76"/>
<source>Characters</source>
<translation>Personnages</translation>
</message>
</context>
<context>
<name>corkDelegate</name>
<message>
@ -1203,17 +1192,17 @@ des lignes:</translation>
<context>
<name>fullScreenEditor</name>
<message>
<location filename="../src/ui/editors/fullScreenEditor.py" line="79"/>
<location filename="../src/ui/editors/fullScreenEditor.py" line="80"/>
<source>Theme:</source>
<translation>Thème:</translation>
</message>
<message>
<location filename="../src/ui/editors/fullScreenEditor.py" line="238"/>
<location filename="../src/ui/editors/fullScreenEditor.py" line="239"/>
<source>{} words / {}</source>
<translation>{} mots / {}</translation>
</message>
<message>
<location filename="../src/ui/editors/fullScreenEditor.py" line="241"/>
<location filename="../src/ui/editors/fullScreenEditor.py" line="242"/>
<source>{} words</source>
<translation>{} mots</translation>
</message>
@ -1237,17 +1226,17 @@ des lignes:</translation>
<context>
<name>mainEditor</name>
<message>
<location filename="../src/ui/editors/mainEditor.py" line="102"/>
<location filename="../src/ui/editors/mainEditor.py" line="103"/>
<source>Root</source>
<translation>Racine</translation>
</message>
<message>
<location filename="../src/ui/editors/mainEditor.py" line="172"/>
<location filename="../src/ui/editors/mainEditor.py" line="169"/>
<source>{} words / {}</source>
<translation>{} mots / {}</translation>
</message>
<message>
<location filename="../src/ui/editors/mainEditor.py" line="177"/>
<location filename="../src/ui/editors/mainEditor.py" line="174"/>
<source>{} words</source>
<translation>{} mots</translation>
</message>

View file

@ -772,7 +772,10 @@ class MainWindow(QMainWindow, Ui_MainWindow):
#self.treeRedacOutline.selectionModel().selectionChanged.connect(self.outlineSelectionChanged, AUC)
#self.treePlanOutline.selectionModel().selectionChanged.connect(self.outlineSelectionChanged, AUC)
#self.treePlanOutline.selectionModel().selectionChanged.connect(self.outlineSelectionChanged, AUC)
# Cheat Sheet
self.cheatSheet.setModels()
#Debug
self.mdlFlatData.setVerticalHeaderLabels(["Infos générales", "Summary"])
self.tblDebugFlatData.setModel(self.mdlFlatData)

View file

@ -3,11 +3,12 @@
from qt import *
from enums import *
from enum import Enum
from lxml import etree as ET
from functions import *
import locale
locale.setlocale(locale.LC_ALL, '')
class outlineModel(QAbstractItemModel):
@ -626,18 +627,44 @@ class outlineItem():
def ID(self):
return self.data(Outline.ID.value)
def POV(self):
return self.data(Outline.POV.value)
def path(self):
"Returns path to item as string."
if self.parent().parent():
return "{} > {}".format(self.parent().path(), self.title())
else:
return self.title()
def pathID(self):
"Returns path to item as list of (ID, title)."
if self.parent().parent():
return self.parent().pathID() + [(self.ID(), self.title())]
else:
return [(self.ID(), self.title())]
def level(self):
if self.parent():
return self.parent().level() + 1
else:
return -1
def stats(self):
wc = self.data(Outline.wordCount.value)
goal = self.data(Outline.goal.value)
progress = self.data(Outline.goalPercentage.value)
if not wc:
wc = 0
if goal:
return qApp.translate("outlineModel", "{} words / {} ({})").format(
locale.format("%d", wc, grouping=True),
locale.format("%d", goal, grouping=True),
"{}%".format(str(int(progress * 100))))
else:
return qApp.translate("outlineModel", "{} words").format(
locale.format("%d", wc, grouping=True))
def toXML(self):
item = ET.Element("outlineItem")

View file

@ -22,15 +22,39 @@ def infoForRef(ref):
item = idx.internalPointer()
text = "<h1>{}</h1>".format(item.title())
text += "<b>Path:</b> {}<br>".format(item.path())
ss = item.data(Outline.summarySentance.value)
if ss:
text += "\n<b>Short summary:</b> {}<br>".format(ss)
ls = item.data(Outline.summaryFull.value)
if ls:
text += "\n<b>Long summary:</b> {}<br>".format(ls)
#<p><b>Status:</b> {status}</p>
#<p><b>Label:</b> {label}</p>
if item.POV():
POV = "<a href='{ref}'>{text}</a>".format(
ref="::C:{}::".format(item.POV()),
text=mainWindow().mdlPersos.getPersoNameByID(item.POV()))
else:
POV = qApp.translate("references", "None")
path = item.pathID()
pathStr = []
for _id, title in path:
pathStr.append("<a href='{ref}'>{text}</a>".format(
ref="::T:{}::".format(_id),
text=title))
path = " > ".join(pathStr)
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>
""".format(
title=item.title(),
path=path,
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>"))
return text
@ -42,6 +66,33 @@ def infoForRef(ref):
else:
return qApp.translate("references", "Unknown reference: {}.").format(ref)
def refToLink(ref):
match = re.fullmatch("::(\w):(\d+?)::", ref)
if match:
_type = match.group(1)
_ref = match.group(2)
text = ""
if _type == "T":
m = mainWindow().mdlOutline
idx = m.getIndexByID(_ref)
if idx.isValid():
item = idx.internalPointer()
text = item.title()
elif _type == "C":
m = mainWindow().mdlPersos
text = m.item(int(_ref), Perso.name.value).text()
if text:
return "<a href='{ref}'>{text}</a>".format(
ref=ref,
text=text)
else:
return ref
def linkifyAllRefs(text):
return re.sub(r"::(\w):(\d+?)::", lambda m: refToLink(m.group(0)), text)
def tooltipForRef(ref):
match = re.fullmatch("::(\w):(\d+?)::", ref)
if match:

138
src/ui/cheatSheet.py Normal file
View file

@ -0,0 +1,138 @@
#!/usr/bin/env python
#--!-- coding: utf8 --!--
from qt import *
from enums import *
from models.outlineModel import *
from ui.cheatSheet_ui import *
from functions import *
from models.references import *
class cheatSheet(QWidget, Ui_cheatSheet):
activated = pyqtSignal(str)
def __init__(self, parent=None):
QWidget.__init__(self, parent)
self.setupUi(self)
self.splitter.setStretchFactor(0, 3)
self.splitter.setStretchFactor(1, 70)
self.txtFilter.textChanged.connect(self.updateListFromData)
self.txtFilter.returnPressed.connect(self.showInfos)
self.listDelegate = listCompleterDelegate(self)
self.list.setItemDelegate(self.listDelegate)
self.list.itemActivated.connect(self.showInfos)
self.view.linkActivated.connect(self.openLink)
self.outlineModel = None
self.persoModel = None
self.populateTimer = QTimer(self)
self.populateTimer.setSingleShot(True)
self.populateTimer.setInterval(500)
self.populateTimer.timeout.connect(self.populate)
self.populateTimer.stop()
self.data = {}
self.populate()
def setModels(self):
self.outlineModel = mainWindow().mdlOutline
self.persoModel = mainWindow().mdlPersos
self.outlineModel.dataChanged.connect(self.populateTimer.start)
self.persoModel.dataChanged.connect(self.populateTimer.start)
def populate(self):
if self.persoModel:
d = []
for r in range(self.persoModel.rowCount()):
name = self.persoModel.item(r, Perso.name.value).text()
ID = self.persoModel.item(r, Perso.ID.value).text()
imp = self.persoModel.item(r, Perso.importance.value).text()
imp = [self.tr("Minor"), self.tr("Secondary"), self.tr("Main")][int(imp)]
d.append((name, ID, imp))
self.data[(self.tr("Characters"), "C")] = d
if self.outlineModel:
d = []
def addChildren(item):
for c in item.children():
d.append((c.title(), c.ID(), c.path()))
addChildren(c)
r = self.outlineModel.rootItem
addChildren(r)
self.data[(self.tr("Texts"), "T")] = d
self.updateListFromData()
def addCategory(self, title):
item = QListWidgetItem(title)
item.setBackground(QBrush(lightBlue()))
item.setForeground(QBrush(Qt.darkBlue))
item.setFlags(Qt.ItemIsEnabled)
f = item.font()
f.setBold(True)
item.setFont(f)
self.list.addItem(item)
def updateListFromData(self):
self.list.clear()
for cat in self.data:
filtered = [i for i in self.data[cat] if self.txtFilter.text().lower() in i[0].lower()]
if filtered:
self.addCategory(cat[0])
for item in filtered:
i = QListWidgetItem(item[0])
i.setData(Qt.UserRole, "::{}:{}::".format(cat[1], item[1]))
i.setData(Qt.UserRole+1, item[2])
self.list.addItem(i)
self.list.setCurrentRow(1)
def showInfos(self):
i = self.list.currentItem()
ref = i.data(Qt.UserRole)
if ref:
self.view.setText(infoForRef(ref))
def openLink(self, link):
openReference(link)
def keyPressEvent(self, event):
if event.key() in [Qt.Key_Up, Qt.Key_Down]:
self.list.keyPressEvent(event)
else:
QWidget.keyPressEvent(self, event)
class listCompleterDelegate(QStyledItemDelegate):
def __init__(self, parent=None):
QStyledItemDelegate.__init__(self, parent)
def paint(self, painter, option, index):
extra = index.data(Qt.UserRole+1)
if not extra:
return QStyledItemDelegate.paint(self, painter, option, index)
else:
if option.state & QStyle.State_Selected:
painter.fillRect(option.rect, option.palette.color(QPalette.Inactive, QPalette.Highlight))
title = index.data()
extra = " - {}".format(extra)
painter.drawText(option.rect, Qt.AlignLeft, title)
fm = QFontMetrics(option.font)
w = fm.width(title)
r = QRect(option.rect)
r.setLeft(r.left() + w)
painter.save()
painter.setPen(Qt.gray)
painter.drawText(r, Qt.AlignLeft, extra)
painter.restore()

62
src/ui/cheatSheet_ui.py Normal file
View file

@ -0,0 +1,62 @@
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'src/ui/cheatSheet_ui.ui'
#
# Created by: PyQt5 UI code generator 5.4.1
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_cheatSheet(object):
def setupUi(self, cheatSheet):
cheatSheet.setObjectName("cheatSheet")
cheatSheet.resize(400, 344)
self.verticalLayout_2 = QtWidgets.QVBoxLayout(cheatSheet)
self.verticalLayout_2.setContentsMargins(0, 0, 0, 0)
self.verticalLayout_2.setObjectName("verticalLayout_2")
self.txtFilter = QtWidgets.QLineEdit(cheatSheet)
self.txtFilter.setProperty("clearButtonEnabled", True)
self.txtFilter.setObjectName("txtFilter")
self.verticalLayout_2.addWidget(self.txtFilter)
self.splitter = QtWidgets.QSplitter(cheatSheet)
self.splitter.setOrientation(QtCore.Qt.Vertical)
self.splitter.setObjectName("splitter")
self.list = QtWidgets.QListWidget(self.splitter)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.list.sizePolicy().hasHeightForWidth())
self.list.setSizePolicy(sizePolicy)
self.list.setObjectName("list")
self.scrollArea = QtWidgets.QScrollArea(self.splitter)
self.scrollArea.setWidgetResizable(True)
self.scrollArea.setObjectName("scrollArea")
self.scrollAreaWidgetContents = QtWidgets.QWidget()
self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 396, 119))
self.scrollAreaWidgetContents.setObjectName("scrollAreaWidgetContents")
self.verticalLayout = QtWidgets.QVBoxLayout(self.scrollAreaWidgetContents)
self.verticalLayout.setObjectName("verticalLayout")
self.view = QtWidgets.QLabel(self.scrollAreaWidgetContents)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.view.sizePolicy().hasHeightForWidth())
self.view.setSizePolicy(sizePolicy)
self.view.setText("")
self.view.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop)
self.view.setWordWrap(True)
self.view.setTextInteractionFlags(QtCore.Qt.LinksAccessibleByMouse|QtCore.Qt.TextSelectableByMouse)
self.view.setObjectName("view")
self.verticalLayout.addWidget(self.view)
self.scrollArea.setWidget(self.scrollAreaWidgetContents)
self.verticalLayout_2.addWidget(self.splitter)
self.retranslateUi(cheatSheet)
QtCore.QMetaObject.connectSlotsByName(cheatSheet)
def retranslateUi(self, cheatSheet):
_translate = QtCore.QCoreApplication.translate
cheatSheet.setWindowTitle(_translate("cheatSheet", "Form"))
self.txtFilter.setPlaceholderText(_translate("cheatSheet", "Filter"))

88
src/ui/cheatSheet_ui.ui Normal file
View file

@ -0,0 +1,88 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>cheatSheet</class>
<widget class="QWidget" name="cheatSheet">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>344</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QLineEdit" name="txtFilter">
<property name="placeholderText">
<string>Filter</string>
</property>
<property name="clearButtonEnabled" stdset="0">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<widget class="QListWidget" name="list">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
<widget class="QScrollArea" name="scrollArea">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>396</width>
<height>119</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="view">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View file

@ -1,8 +1,5 @@
#!/usr/bin/env python
#--!-- coding: utf8 --!--
from qt import *
@ -33,6 +30,7 @@ class collapsibleGroupBox2(QWidget):
self.switched = True
self.vPolicy = self.sizePolicy().verticalPolicy()
self.parent().layout().setAlignment(Qt.AlignTop)
def setFlat(self, val):
if val:

View file

@ -20,24 +20,11 @@ class completer(QWidget, Ui_completer):
self.listDelegate = listCompleterDelegate(self)
self.list.setItemDelegate(self.listDelegate)
self.list.itemActivated.connect(self.submit)
self.outlineModel = mainWindow().mdlOutline
self.persoModel = mainWindow().mdlPersos
self.populateTimer = QTimer(self)
self.populateTimer.setSingleShot(True)
self.populateTimer.setInterval(500)
self.populateTimer.timeout.connect(self.populate)
self.populateTimer.stop()
self.outlineModel.dataChanged.connect(self.populateTimer.start)
self.persoModel.dataChanged.connect(self.populateTimer.start)
self.data = {}
self.populate()
self.list.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
self.hide()
def popup(self, completion=""):
self.updateListFromData()
self.text.setText(completion)
self.text.setFocus(Qt.PopupFocusReason)
self.show()
@ -48,39 +35,12 @@ class completer(QWidget, Ui_completer):
item.setForeground(QBrush(Qt.darkBlue))
item.setFlags(Qt.ItemIsEnabled)
self.list.addItem(item)
def populate(self):
if self.outlineModel:
d = []
def addChildren(item):
for c in item.children():
d.append((c.title(), c.ID(), c.path()))
addChildren(c)
r = self.outlineModel.rootItem
addChildren(r)
self.data[(self.tr("Texts"), "T")] = d
if self.persoModel:
d = []
for r in range(self.persoModel.rowCount()):
name = self.persoModel.item(r, Perso.name.value).text()
ID = self.persoModel.item(r, Perso.ID.value).text()
imp = self.persoModel.item(r, Perso.importance.value).text()
imp = [self.tr("Minor"), self.tr("Secondary"), self.tr("Main")][int(imp)]
d.append((name, ID, imp))
self.data[(self.tr("Characters"), "C")] = d
self.updateListFromData()
def updateListFromData(self):
data = mainWindow().cheatSheet.data
self.list.clear()
for cat in self.data:
filtered = [i for i in self.data[cat] if self.text.text().lower() in i[0].lower()]
for cat in data:
filtered = [i for i in data[cat] if self.text.text().lower() in i[0].lower()]
if filtered:
self.addCategory(cat[0])
for item in filtered:

View file

@ -836,29 +836,23 @@ class Ui_MainWindow(object):
self.verticalLayout_21 = QtWidgets.QVBoxLayout(self.tab_18)
self.verticalLayout_21.setContentsMargins(0, 0, 0, 0)
self.verticalLayout_21.setObjectName("verticalLayout_21")
self.groupBox_3 = QtWidgets.QGroupBox(self.tab_18)
self.groupBox_3 = collapsibleGroupBox2(self.tab_18)
font = QtGui.QFont()
font.setBold(True)
font.setWeight(75)
self.groupBox_3.setFont(font)
self.groupBox_3.setFlat(True)
self.groupBox_3.setObjectName("groupBox_3")
self.verticalLayout_15 = QtWidgets.QVBoxLayout(self.groupBox_3)
self.verticalLayout_15.setContentsMargins(0, 0, 0, 0)
self.verticalLayout_15.setObjectName("verticalLayout_15")
self.lineEdit_3 = QtWidgets.QLineEdit(self.groupBox_3)
self.lineEdit_3.setObjectName("lineEdit_3")
self.verticalLayout_15.addWidget(self.lineEdit_3)
self.listWidget_5 = QtWidgets.QListWidget(self.groupBox_3)
self.listWidget_5.setObjectName("listWidget_5")
item = QtWidgets.QListWidgetItem()
self.listWidget_5.addItem(item)
item = QtWidgets.QListWidgetItem()
self.listWidget_5.addItem(item)
item = QtWidgets.QListWidgetItem()
self.listWidget_5.addItem(item)
item = QtWidgets.QListWidgetItem()
self.listWidget_5.addItem(item)
self.verticalLayout_15.addWidget(self.listWidget_5)
self.textEdit = QtWidgets.QTextEdit(self.groupBox_3)
self.textEdit.setObjectName("textEdit")
self.verticalLayout_15.addWidget(self.textEdit)
self.cheatSheet = cheatSheet(self.groupBox_3)
font = QtGui.QFont()
font.setBold(False)
font.setWeight(50)
self.cheatSheet.setFont(font)
self.cheatSheet.setObjectName("cheatSheet")
self.verticalLayout_15.addWidget(self.cheatSheet)
self.verticalLayout_21.addWidget(self.groupBox_3)
self.tabRedacInfos.addTab(self.tab_18, "")
self.verticalLayout_16.addWidget(self.splitterRedac)
@ -1039,7 +1033,7 @@ class Ui_MainWindow(object):
self.tabPlot.setCurrentIndex(0)
self.comboBox_2.setCurrentIndex(0)
self.stkPlotSummary.setCurrentIndex(0)
self.tabRedacInfos.setCurrentIndex(0)
self.tabRedacInfos.setCurrentIndex(1)
self.tabWidget.setCurrentIndex(1)
self.btnPlotShowSummary.toggled['bool'].connect(self.grpPlotSummary.setVisible)
self.comboBox_2.currentIndexChanged['int'].connect(self.stkPlotSummary.setCurrentIndex)
@ -1119,18 +1113,6 @@ class Ui_MainWindow(object):
self.tabMain.setTabText(self.tabMain.indexOf(self.lytTabOutline), _translate("MainWindow", "Outline"))
self.tabRedacInfos.setTabText(self.tabRedacInfos.indexOf(self.tab_17), _translate("MainWindow", "Metadata"))
self.groupBox_3.setTitle(_translate("MainWindow", "Cheat sheet"))
self.lineEdit_3.setPlaceholderText(_translate("MainWindow", "Filter"))
__sortingEnabled = self.listWidget_5.isSortingEnabled()
self.listWidget_5.setSortingEnabled(False)
item = self.listWidget_5.item(0)
item.setText(_translate("MainWindow", "Albert - perso"))
item = self.listWidget_5.item(1)
item.setText(_translate("MainWindow", "Jean - perso"))
item = self.listWidget_5.item(2)
item.setText(_translate("MainWindow", "Crapoquak - animal"))
item = self.listWidget_5.item(3)
item.setText(_translate("MainWindow", "La revenche du capitaine - intrigue"))
self.listWidget_5.setSortingEnabled(__sortingEnabled)
self.tabRedacInfos.setTabText(self.tabRedacInfos.indexOf(self.tab_18), _translate("MainWindow", "Tools"))
self.tabMain.setTabText(self.tabMain.indexOf(self.lytTabRedac), _translate("MainWindow", "Redaction"))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_9), _translate("MainWindow", "FlatData"))
@ -1170,14 +1152,16 @@ class Ui_MainWindow(object):
self.actSettings.setShortcut(_translate("MainWindow", "F8"))
self.actCloseProject.setText(_translate("MainWindow", "Close project"))
from ui.views.persoTreeView import persoTreeView
from ui.views.textEditView import textEditView
from ui.sldImportance import sldImportance
from ui.views.metadataView import metadataView
from ui.views.treeView import treeView
from ui.editors.mainEditor import mainEditor
from ui.views.persoTreeView import persoTreeView
from ui.sldImportance import sldImportance
from ui.cheatSheet import cheatSheet
from ui.views.basicItemView import basicItemView
from ui.views.outlineView import outlineView
from ui.collapsibleGroupBox2 import collapsibleGroupBox2
from ui.views.metadataView import metadataView
from ui.views.lineEditView import lineEditView
from ui.welcome import welcome
from ui.views.plotTreeView import plotTreeView
from ui.views.treeView import treeView
from ui.views.textEditView import textEditView
from ui.welcome import welcome

View file

@ -1584,7 +1584,7 @@
<enum>QTabWidget::South</enum>
</property>
<property name="currentIndex">
<number>0</number>
<number>1</number>
</property>
<property name="documentMode">
<bool>true</bool>
@ -1614,7 +1614,13 @@
<number>0</number>
</property>
<item>
<widget class="QGroupBox" name="groupBox_3">
<widget class="collapsibleGroupBox2" name="groupBox_3">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="title">
<string>Cheat sheet</string>
</property>
@ -1626,39 +1632,15 @@
<number>0</number>
</property>
<item>
<widget class="QLineEdit" name="lineEdit_3">
<property name="placeholderText">
<string>Filter</string>
<widget class="cheatSheet" name="cheatSheet" native="true">
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
</widget>
</item>
<item>
<widget class="QListWidget" name="listWidget_5">
<item>
<property name="text">
<string>Albert - perso</string>
</property>
</item>
<item>
<property name="text">
<string>Jean - perso</string>
</property>
</item>
<item>
<property name="text">
<string>Crapoquak - animal</string>
</property>
</item>
<item>
<property name="text">
<string>La revenche du capitaine - intrigue</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QTextEdit" name="textEdit"/>
</item>
</layout>
</widget>
</item>
@ -2051,6 +2033,18 @@
<extends>QTreeWidget</extends>
<header>ui.views.persoTreeView.h</header>
</customwidget>
<customwidget>
<class>cheatSheet</class>
<extends>QWidget</extends>
<header>ui.cheatSheet.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>collapsibleGroupBox2</class>
<extends>QGroupBox</extends>
<header>ui.collapsibleGroupBox2.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections>

View file

@ -11,11 +11,16 @@ from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_metadataView(object):
def setupUi(self, metadataView):
metadataView.setObjectName("metadataView")
metadataView.resize(400, 425)
metadataView.resize(400, 537)
self.verticalLayout = QtWidgets.QVBoxLayout(metadataView)
self.verticalLayout.setContentsMargins(0, 0, 0, 0)
self.verticalLayout.setObjectName("verticalLayout")
self.textFormat = textFormat(metadataView)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.textFormat.sizePolicy().hasHeightForWidth())
self.textFormat.setSizePolicy(sizePolicy)
self.textFormat.setObjectName("textFormat")
self.verticalLayout.addWidget(self.textFormat)
self.groupBox_4 = collapsibleGroupBox2(metadataView)
@ -73,9 +78,9 @@ class Ui_metadataView(object):
self.txtSummarySentance.setPlaceholderText(_translate("metadataView", "One line summary"))
self.groupBox_6.setTitle(_translate("metadataView", "Notes"))
from ui.views.textEditCompleter import textEditCompleter
from ui.views.textEditView import textEditView
from ui.editors.textFormat import textFormat
from ui.views.textEditCompleter import textEditCompleter
from ui.views.lineEditView import lineEditView
from ui.collapsibleGroupBox2 import collapsibleGroupBox2
from ui.views.propertiesView import propertiesView
from ui.collapsibleGroupBox2 import collapsibleGroupBox2

View file

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>400</width>
<height>425</height>
<height>537</height>
</rect>
</property>
<property name="windowTitle">
@ -18,7 +18,14 @@
<number>0</number>
</property>
<item>
<widget class="textFormat" name="textFormat" native="true"/>
<widget class="textFormat" name="textFormat" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<widget class="collapsibleGroupBox2" name="groupBox_4">
@ -114,6 +121,11 @@
<extends>QTextEdit</extends>
<header>ui.views.textEditView.h</header>
</customwidget>
<customwidget>
<class>lineEditView</class>
<extends>QLineEdit</extends>
<header>ui.views.lineEditView.h</header>
</customwidget>
<customwidget>
<class>collapsibleGroupBox2</class>
<extends>QGroupBox</extends>
@ -126,11 +138,6 @@
<header>ui.views.propertiesView.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>lineEditView</class>
<extends>QLineEdit</extends>
<header>ui.views.lineEditView.h</header>
</customwidget>
<customwidget>
<class>textFormat</class>
<extends>QWidget</extends>