Merge pull request #62 from vkbo/timeline_update

Minor improvements to timeline and session dialogs
This commit is contained in:
Veronica K. Berglyd Olsen
2019-10-22 20:00:48 +02:00
committed by GitHub
4 changed files with 91 additions and 12 deletions
+1
View File
@@ -27,6 +27,7 @@ class nwFiles():
INDEX_FILE = "tagsIndex.json"
EXPORT_OPT = "exportOptions.json"
TLINE_OPT = "timelineOptions.json"
SLOG_OPT = "sessionLogOptions.json"
# END Class nwFiles
+58 -8
View File
@@ -22,8 +22,9 @@ from PyQt5.QtWidgets import (
QGridLayout, QLabel, QGroupBox, QCheckBox
)
from nw.enum import nwAlert
from nw.constants import nwConst, nwFiles
from nw.tools.optlaststate import OptLastState
from nw.constants import nwConst, nwFiles
from nw.enum import nwAlert
logger = logging.getLogger(__name__)
@@ -37,6 +38,8 @@ class GuiSessionLogView(QDialog):
self.mainConf = nw.CONFIG
self.theProject = theProject
self.theParent = theParent
self.optState = SessionLogLastState(self.theProject,nwFiles.SLOG_OPT)
self.optState.loadSettings()
self.timeFilter = 0.0
self.timeTotal = 0.0
@@ -48,12 +51,16 @@ class GuiSessionLogView(QDialog):
self.setMinimumWidth(420)
self.setMinimumHeight(400)
widthCol0 = self.optState.validIntRange(self.optState.getSetting("widthCol0"), 30, 999, 180)
widthCol1 = self.optState.validIntRange(self.optState.getSetting("widthCol1"), 30, 999, 80)
widthCol2 = self.optState.validIntRange(self.optState.getSetting("widthCol2"), 30, 999, 80)
self.listBox = QTreeWidget()
self.listBox.setHeaderLabels(["Session Start","Length","Words",""])
self.listBox.setIndentation(0)
self.listBox.setColumnWidth(0,180)
self.listBox.setColumnWidth(1,80)
self.listBox.setColumnWidth(2,80)
self.listBox.setColumnWidth(0,widthCol0)
self.listBox.setColumnWidth(1,widthCol1)
self.listBox.setColumnWidth(2,widthCol2)
self.listBox.setColumnWidth(3,0)
hHeader = self.listBox.headerItem()
@@ -62,7 +69,11 @@ class GuiSessionLogView(QDialog):
self.monoFont = QFont("Monospace",10)
self.listBox.sortByColumn(0, Qt.DescendingOrder)
sortValid = (Qt.AscendingOrder, Qt.DescendingOrder)
sortCol = self.optState.validIntRange(self.optState.getSetting("sortCol"), 0, 2, 0)
sortOrder = self.optState.validIntTuple(self.optState.getSetting("sortOrder"), sortValid, Qt.DescendingOrder)
self.listBox.sortByColumn(sortCol, sortOrder)
self.listBox.setSortingEnabled(True)
# Session Info
@@ -89,11 +100,11 @@ class GuiSessionLogView(QDialog):
self.filterBox.setLayout(self.filterBoxForm)
self.hideZeros = QCheckBox("Hide zero word count", self)
self.hideZeros.setChecked(True)
self.hideZeros.setChecked(self.optState.getSetting("hideZeros"))
self.hideZeros.stateChanged.connect(self._doHideZeros)
self.hideNegative = QCheckBox("Hide negative word count", self)
self.hideNegative.setChecked(False)
self.hideNegative.setChecked(self.optState.getSetting("hideNegative"))
self.hideNegative.stateChanged.connect(self._doHideNegative)
self.filterBoxForm.addWidget(self.hideZeros, 0, 0)
@@ -178,7 +189,26 @@ class GuiSessionLogView(QDialog):
return True
def _doClose(self):
widthCol0 = self.listBox.columnWidth(0)
widthCol1 = self.listBox.columnWidth(1)
widthCol2 = self.listBox.columnWidth(2)
sortCol = self.listBox.sortColumn()
sortOrder = self.listBox.header().sortIndicatorOrder()
hideZeros = self.hideZeros.isChecked()
hideNegative = self.hideNegative.isChecked()
self.optState.setSetting("widthCol0", widthCol0)
self.optState.setSetting("widthCol1", widthCol1)
self.optState.setSetting("widthCol2", widthCol2)
self.optState.setSetting("sortCol", sortCol)
self.optState.setSetting("sortOrder", sortOrder)
self.optState.setSetting("hideZeros", hideZeros)
self.optState.setSetting("hideNegative",hideNegative)
self.optState.saveSettings()
self.close()
return
def _doHideZeros(self, newState):
@@ -197,3 +227,23 @@ class GuiSessionLogView(QDialog):
return "%02d:%02d:%02d" % (tH,tM,tS)
# END Class GuiSessionLogView
class SessionLogLastState(OptLastState):
def __init__(self, theProject, theFile):
OptLastState.__init__(self, theProject, theFile)
self.theState = {
"widthCol0" : 180,
"widthCol1" : 80,
"widthCol2" : 80,
"sortCol" : 0,
"sortOrder" : Qt.DescendingOrder,
"hideZeros" : True,
"hideNegative" : False,
}
self.stringOpt = ()
self.boolOpt = ("hideZeros","hideNegative")
self.intOpt = ("widthCol0","widthCol1","widthCol2","sortCol","sortOrder")
return
# END Class SessionLogLastState
+20 -4
View File
@@ -53,10 +53,10 @@ class GuiTimeLineView(QDialog):
self.setWindowTitle("Timeline View")
self.setMinimumWidth(700)
self.setMinimumHeight(400)
self.resize(
self.optState.getSetting("winWidth"),
self.optState.getSetting("winHeight")
)
winWidth = self.optState.validIntRange(self.optState.getSetting("winWidth"), 700, 10000, 700)
winHeight = self.optState.validIntRange(self.optState.getSetting("winHeight"), 400, 10000, 400)
self.resize(winWidth,winHeight)
# TimeLine Table
self.mainTable = QTableWidget()
@@ -77,16 +77,27 @@ class GuiTimeLineView(QDialog):
self.filterPlot = QCheckBox("Plot tags", self)
self.filterPlot.setChecked(self.optState.getSetting("fPlot"))
self.filterPlot.stateChanged.connect(self._filterChange)
self.filterChar = QCheckBox("Character tags", self)
self.filterChar.setChecked(self.optState.getSetting("fChar"))
self.filterChar.stateChanged.connect(self._filterChange)
self.filterWorld = QCheckBox("Location tags", self)
self.filterWorld.setChecked(self.optState.getSetting("fWorld"))
self.filterWorld.stateChanged.connect(self._filterChange)
self.filterTime = QCheckBox("Timeline tags", self)
self.filterTime.setChecked(self.optState.getSetting("fTime"))
self.filterTime.stateChanged.connect(self._filterChange)
self.filterObject = QCheckBox("Object tags", self)
self.filterObject.setChecked(self.optState.getSetting("fObject"))
self.filterObject.stateChanged.connect(self._filterChange)
self.filterCustom = QCheckBox("Custom tags", self)
self.filterCustom.setChecked(self.optState.getSetting("fCustom"))
self.filterCustom.stateChanged.connect(self._filterChange)
self.optFilterGrid.addWidget(self.filterPlot, 0, 1)
self.optFilterGrid.addWidget(self.filterChar, 1, 1)
@@ -101,6 +112,7 @@ class GuiTimeLineView(QDialog):
self.hideUnused = QCheckBox("Hide unused", self)
self.hideUnused.setChecked(self.optState.getSetting("hUnused"))
self.hideUnused.stateChanged.connect(self._filterChange)
self.optHideGrid.addWidget(self.hideUnused, 0, 1)
@@ -227,6 +239,10 @@ class GuiTimeLineView(QDialog):
return
def _filterChange(self, checkState):
self._buildNovelList()
return
# END Class GuiTimeLineView
class TimeLineLastState(OptLastState):
+12
View File
@@ -76,4 +76,16 @@ class OptLastState():
return checkInt(self.theState[setName],self.theState[setName],False)
return None
def validIntRange(self, theValue, intA, intB, intDefault):
if isinstance(theValue, int):
if theValue >= intA and theValue <= intB:
return theValue
return intDefault
def validIntTuple(self, theValue, theTuple, intDefault):
if isinstance(theValue, int):
if theValue in theTuple:
return theValue
return intDefault
# END Class OptLastState