mirror of
https://github.com/olivierkes/manuskript.git
synced 2024-06-16 09:54:33 +12:00
Adds enums
This commit is contained in:
parent
239095a2e3
commit
0cdd017340
25
src/enums.py
Normal file
25
src/enums.py
Normal file
|
@ -0,0 +1,25 @@
|
|||
#!/usr/bin/env python
|
||||
#--!-- coding: utf8 --!--
|
||||
|
||||
from __future__ import print_function
|
||||
from __future__ import unicode_literals
|
||||
|
||||
# As seen on http://stackoverflow.com/questions/36932/how-can-i-represent-an-enum-in-python
|
||||
|
||||
from enum import Enum
|
||||
|
||||
#def enum(**enums):
|
||||
#return type(str('Enum'), (), enums)
|
||||
|
||||
class Perso(Enum):
|
||||
name = 0
|
||||
ID = 1
|
||||
importance = 2
|
||||
motivation = 3
|
||||
goal = 4
|
||||
conflict = 5
|
||||
epiphany = 6
|
||||
summarySentance = 7
|
||||
summaryPara = 8
|
||||
summaryFull = 9
|
||||
|
|
@ -9,6 +9,7 @@ from PyQt4.QtGui import *
|
|||
|
||||
from ui.mainWindow import *
|
||||
from loadSave import *
|
||||
from enums import *
|
||||
|
||||
class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
def __init__(self):
|
||||
|
@ -96,13 +97,11 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|||
# Persos
|
||||
self.mdlPersos = QStandardItemModel(0, 10)
|
||||
self.mdlPersosInfos = QStandardItemModel(1, 0)
|
||||
self.mdlPersosInfos.insertColumn(0, [QStandardItem(i) for i in ["ID"]])
|
||||
self.mdlPersosInfos.insertColumn(0, [QStandardItem("ID")])
|
||||
self.mdlPersosInfos.setHorizontalHeaderLabels(["Description"])
|
||||
self.lstPersos.setModel(self.mdlPersos)
|
||||
self.tblDebugPersos.setModel(self.mdlPersos)
|
||||
self.tblPersoInfos.setModel(self.mdlPersosInfos)
|
||||
self.tblPersoInfos.setRowHidden(0, True)
|
||||
self.tblDebugPersosInfos.setModel(self.mdlPersosInfos)
|
||||
|
||||
self.btnAddPerso.clicked.connect(self.createPerso)
|
||||
self.btnRmPerso.clicked.connect(self.removePerso)
|
||||
|
@ -111,18 +110,18 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|||
self.mprPersos.setModel(self.mdlPersos)
|
||||
|
||||
mapping = [
|
||||
(self.txtPersoName, 0),
|
||||
(self.txtPersoMotivation, 2),
|
||||
(self.txtPersoGoal, 3),
|
||||
(self.txtPersoConflict, 4),
|
||||
(self.txtPersoEpiphany, 5),
|
||||
(self.txtPersoSummarySentance, 6),
|
||||
(self.txtPersoSummaryPara, 7),
|
||||
(self.txtPersoSummaryFull, 8)
|
||||
(self.txtPersoName, Perso.name.value),
|
||||
(self.txtPersoMotivation, Perso.motivation.value),
|
||||
(self.txtPersoGoal, Perso.goal.value),
|
||||
(self.txtPersoConflict, Perso.conflict.value),
|
||||
(self.txtPersoEpiphany, Perso.epiphany.value),
|
||||
(self.txtPersoSummarySentance, Perso.summarySentance.value),
|
||||
(self.txtPersoSummaryPara, Perso.summaryPara.value),
|
||||
(self.txtPersoSummaryFull, Perso.summaryFull.value)
|
||||
]
|
||||
for w, i in mapping:
|
||||
self.mprPersos.addMapping(w, i)
|
||||
self.mprPersos.addMapping(self.sldPersoImportance, 8, "importance")
|
||||
self.mprPersos.addMapping(self.sldPersoImportance, Perso.importance.value, "importance")
|
||||
self.sldPersoImportance.importanceChanged.connect(self.mprPersos.submit)
|
||||
|
||||
self.mprPersos.setCurrentIndex(0)
|
||||
|
@ -133,6 +132,8 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|||
#Debug
|
||||
self.mdlFlatData.setVerticalHeaderLabels(["Infos générales", "Summary"])
|
||||
self.tblDebugFlatData.setModel(self.mdlFlatData)
|
||||
self.tblDebugPersos.setModel(self.mdlPersos)
|
||||
self.tblDebugPersosInfos.setModel(self.mdlPersosInfos)
|
||||
|
||||
|
||||
self.loadProject("test_project")
|
||||
|
@ -156,7 +157,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|||
"Returns an unused perso ID (row 1)"
|
||||
vals = []
|
||||
for i in range(self.mdlPersos.rowCount()):
|
||||
item = self.mdlPersos.item(i, 1)
|
||||
item = self.mdlPersos.item(i, Perso.ID.value)
|
||||
if item and item.text():
|
||||
vals.append(int(item.text()))
|
||||
|
||||
|
@ -168,11 +169,11 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|||
"Checks whether some persos ID (row 1) are empty, if so, assign an ID"
|
||||
empty = []
|
||||
for i in range(self.mdlPersos.rowCount()):
|
||||
item = self.mdlPersos.item(i, 1)
|
||||
item = self.mdlPersos.item(i, Perso.ID.value)
|
||||
if not item:
|
||||
item = QStandardItem()
|
||||
item.setText(self.getPersosID())
|
||||
self.mdlPersos.setItem(i, 1, item)
|
||||
self.mdlPersos.setItem(i, Perso.ID.value, item)
|
||||
|
||||
def removePerso(self):
|
||||
i = self.lstPersos.currentIndex()
|
||||
|
@ -181,7 +182,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|||
|
||||
def changeCurrentPerso(self, trash=None):
|
||||
idx = self.lstPersos.currentIndex()
|
||||
pid = self.mdlPersos.item(idx.row(), 1).text()
|
||||
pid = self.mdlPersos.item(idx.row(), Perso.ID.value).text()
|
||||
for c in range(self.mdlPersosInfos.columnCount()):
|
||||
pid2 = self.mdlPersosInfos.item(0, c).text()
|
||||
self.tblPersoInfos.setColumnHidden(c, c <> 0 and pid <> pid2)
|
||||
|
@ -208,6 +209,9 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|||
|
||||
# Stuff
|
||||
self.checkPersosID()
|
||||
# Adds header labels
|
||||
self.mdlPersos.setHorizontalHeaderLabels(
|
||||
[i.name for i in Perso])
|
||||
|
||||
def readSettings(self):
|
||||
# Load State and geometry
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
# Form implementation generated from reading ui file 'src/ui/mainWindow.ui'
|
||||
#
|
||||
# Created: Sun May 31 22:39:01 2015
|
||||
# by: PyQt4 UI code generator 4.11.3
|
||||
# Created: Mon Jun 1 12:00:14 2015
|
||||
# by: PyQt4 UI code generator 4.10.4
|
||||
#
|
||||
# WARNING! All changes made in this file will be lost!
|
||||
|
||||
|
@ -983,7 +983,7 @@ class Ui_MainWindow(object):
|
|||
self.menubar.addAction(self.menuMode.menuAction())
|
||||
|
||||
self.retranslateUi(MainWindow)
|
||||
self.tabMain.setCurrentIndex(6)
|
||||
self.tabMain.setCurrentIndex(2)
|
||||
self.tabSummary.setCurrentIndex(0)
|
||||
self.tabPersos.setCurrentIndex(0)
|
||||
self.tabPlot.setCurrentIndex(0)
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
<item>
|
||||
<widget class="QTabWidget" name="tabMain">
|
||||
<property name="currentIndex">
|
||||
<number>6</number>
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="documentMode">
|
||||
<bool>true</bool>
|
||||
|
|
|
@ -6,41 +6,41 @@
|
|||
<label row="1" text="2"/>
|
||||
</vertical>
|
||||
<horizontal>
|
||||
<label row="0" text="1"/>
|
||||
<label row="1" text="2"/>
|
||||
<label row="2" text="3"/>
|
||||
<label row="3" text="4"/>
|
||||
<label row="4" text="5"/>
|
||||
<label row="5" text="6"/>
|
||||
<label row="6" text="7"/>
|
||||
<label row="7" text="8"/>
|
||||
<label row="8" text="9"/>
|
||||
<label row="9" text="10"/>
|
||||
<label row="0" text="name"/>
|
||||
<label row="1" text="ID"/>
|
||||
<label row="2" text="importance"/>
|
||||
<label row="3" text="motivation"/>
|
||||
<label row="4" text="goal"/>
|
||||
<label row="5" text="conflict"/>
|
||||
<label row="6" text="epiphany"/>
|
||||
<label row="7" text="summarySentance"/>
|
||||
<label row="8" text="summaryPara"/>
|
||||
<label row="9" text="summaryFull"/>
|
||||
</horizontal>
|
||||
</header>
|
||||
<data>
|
||||
<row row="0">
|
||||
<col col="0">Albert</col>
|
||||
<col col="1">0</col>
|
||||
<col col="2"></col>
|
||||
<col col="2">2</col>
|
||||
<col col="3"></col>
|
||||
<col col="4"></col>
|
||||
<col col="5"></col>
|
||||
<col col="6"></col>
|
||||
<col col="7"></col>
|
||||
<col col="8">1</col>
|
||||
<col col="8"></col>
|
||||
<col col="9"></col>
|
||||
</row>
|
||||
<row row="1">
|
||||
<col col="0">Jean</col>
|
||||
<col col="0">Ginette</col>
|
||||
<col col="1">1</col>
|
||||
<col col="2"></col>
|
||||
<col col="2">1</col>
|
||||
<col col="3"></col>
|
||||
<col col="4"></col>
|
||||
<col col="5"></col>
|
||||
<col col="6"></col>
|
||||
<col col="7"></col>
|
||||
<col col="8">2</col>
|
||||
<col col="8"></col>
|
||||
<col col="9"></col>
|
||||
</row>
|
||||
</data>
|
||||
|
|
|
@ -4,9 +4,6 @@
|
|||
<vertical>
|
||||
<label row="0" text="1"/>
|
||||
<label row="1" text="2"/>
|
||||
<label row="2" text="3"/>
|
||||
<label row="3" text="4"/>
|
||||
<label row="4" text="5"/>
|
||||
</vertical>
|
||||
<horizontal>
|
||||
<label row="0" text="Description"/>
|
||||
|
@ -21,24 +18,9 @@
|
|||
<col col="2">1</col>
|
||||
</row>
|
||||
<row row="1">
|
||||
<col col="0">Àge</col>
|
||||
<col col="1">14</col>
|
||||
<col col="2">42</col>
|
||||
</row>
|
||||
<row row="2">
|
||||
<col col="0">Animal favori</col>
|
||||
<col col="1"></col>
|
||||
<col col="2"></col>
|
||||
</row>
|
||||
<row row="3">
|
||||
<col col="0">Histoire préférée</col>
|
||||
<col col="1"></col>
|
||||
<col col="2"></col>
|
||||
</row>
|
||||
<row row="4">
|
||||
<col col="0">Couleur des cheveux</col>
|
||||
<col col="1"></col>
|
||||
<col col="2"></col>
|
||||
<col col="0">Age</col>
|
||||
<col col="1">42</col>
|
||||
<col col="2">12</col>
|
||||
</row>
|
||||
</data>
|
||||
</model>
|
||||
|
|
Loading…
Reference in a new issue