Give the session log class a shorter name
This commit is contained in:
+1
-1
@@ -45,7 +45,7 @@ class OptionState():
|
|||||||
|
|
||||||
self.theState = {}
|
self.theState = {}
|
||||||
self.validMap = {
|
self.validMap = {
|
||||||
"GuiSession": {
|
"GuiSessionLog": {
|
||||||
"widthCol0",
|
"widthCol0",
|
||||||
"widthCol1",
|
"widthCol1",
|
||||||
"sortCol",
|
"sortCol",
|
||||||
|
|||||||
+2
-2
@@ -15,7 +15,7 @@ from nw.gui.preferences import GuiPreferences
|
|||||||
from nw.gui.projload import GuiProjectLoad
|
from nw.gui.projload import GuiProjectLoad
|
||||||
from nw.gui.projsettings import GuiProjectSettings
|
from nw.gui.projsettings import GuiProjectSettings
|
||||||
from nw.gui.projtree import GuiProjectTree
|
from nw.gui.projtree import GuiProjectTree
|
||||||
from nw.gui.sessionlog import GuiSessionLogView
|
from nw.gui.sessionlog import GuiSessionLog
|
||||||
from nw.gui.statusbar import GuiMainStatus
|
from nw.gui.statusbar import GuiMainStatus
|
||||||
from nw.gui.theme import GuiIcons, GuiTheme
|
from nw.gui.theme import GuiIcons, GuiTheme
|
||||||
|
|
||||||
@@ -36,7 +36,7 @@ __all__ = [
|
|||||||
"GuiProjectLoad",
|
"GuiProjectLoad",
|
||||||
"GuiProjectSettings",
|
"GuiProjectSettings",
|
||||||
"GuiProjectTree",
|
"GuiProjectTree",
|
||||||
"GuiSessionLogView",
|
"GuiSessionLog",
|
||||||
"GuiMainStatus",
|
"GuiMainStatus",
|
||||||
"GuiIcons",
|
"GuiIcons",
|
||||||
"GuiTheme",
|
"GuiTheme",
|
||||||
|
|||||||
+19
-21
@@ -42,7 +42,7 @@ from nw.constants import nwConst, nwFiles, nwAlert
|
|||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
class GuiSessionLogView(QDialog):
|
class GuiSessionLog(QDialog):
|
||||||
|
|
||||||
C_TIME = 0
|
C_TIME = 0
|
||||||
C_LENGTH = 1
|
C_LENGTH = 1
|
||||||
@@ -51,7 +51,7 @@ class GuiSessionLogView(QDialog):
|
|||||||
def __init__(self, theParent, theProject):
|
def __init__(self, theParent, theProject):
|
||||||
QDialog.__init__(self, theParent)
|
QDialog.__init__(self, theParent)
|
||||||
|
|
||||||
logger.debug("Initialising SessionLogView ...")
|
logger.debug("Initialising GuiSessionLog ...")
|
||||||
|
|
||||||
self.mainConf = nw.CONFIG
|
self.mainConf = nw.CONFIG
|
||||||
self.theParent = theParent
|
self.theParent = theParent
|
||||||
@@ -68,8 +68,8 @@ class GuiSessionLogView(QDialog):
|
|||||||
self.setMinimumHeight(self.mainConf.pxInt(400))
|
self.setMinimumHeight(self.mainConf.pxInt(400))
|
||||||
|
|
||||||
# List Box
|
# List Box
|
||||||
wCol0 = self.mainConf.pxInt(self.optState.getInt("GuiSession", "widthCol0", 180))
|
wCol0 = self.mainConf.pxInt(self.optState.getInt("GuiSessionLog", "widthCol0", 180))
|
||||||
wCol1 = self.mainConf.pxInt(self.optState.getInt("GuiSession", "widthCol1", 80))
|
wCol1 = self.mainConf.pxInt(self.optState.getInt("GuiSessionLog", "widthCol1", 80))
|
||||||
|
|
||||||
self.listBox = QTreeWidget()
|
self.listBox = QTreeWidget()
|
||||||
self.listBox.setHeaderLabels(["Session Start","Length","Words"])
|
self.listBox.setHeaderLabels(["Session Start","Length","Words"])
|
||||||
@@ -88,10 +88,10 @@ class GuiSessionLogView(QDialog):
|
|||||||
|
|
||||||
sortValid = (Qt.AscendingOrder, Qt.DescendingOrder)
|
sortValid = (Qt.AscendingOrder, Qt.DescendingOrder)
|
||||||
sortCol = self.optState.validIntRange(
|
sortCol = self.optState.validIntRange(
|
||||||
self.optState.getInt("GuiSession", "sortCol", 0), 0, 2, 0
|
self.optState.getInt("GuiSessionLog", "sortCol", 0), 0, 2, 0
|
||||||
)
|
)
|
||||||
sortOrder = self.optState.validIntTuple(
|
sortOrder = self.optState.validIntTuple(
|
||||||
self.optState.getInt("GuiSession", "sortOrder", Qt.DescendingOrder),
|
self.optState.getInt("GuiSessionLog", "sortOrder", Qt.DescendingOrder),
|
||||||
sortValid, Qt.DescendingOrder
|
sortValid, Qt.DescendingOrder
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -123,13 +123,13 @@ class GuiSessionLogView(QDialog):
|
|||||||
|
|
||||||
self.hideZeros = QCheckBox("Hide zero word count", self)
|
self.hideZeros = QCheckBox("Hide zero word count", self)
|
||||||
self.hideZeros.setChecked(
|
self.hideZeros.setChecked(
|
||||||
self.optState.getBool("GuiSession", "hideZeros", True)
|
self.optState.getBool("GuiSessionLog", "hideZeros", True)
|
||||||
)
|
)
|
||||||
self.hideZeros.stateChanged.connect(self._doHideZeros)
|
self.hideZeros.stateChanged.connect(self._doHideZeros)
|
||||||
|
|
||||||
self.hideNegative = QCheckBox("Hide negative word count", self)
|
self.hideNegative = QCheckBox("Hide negative word count", self)
|
||||||
self.hideNegative.setChecked(
|
self.hideNegative.setChecked(
|
||||||
self.optState.getBool("GuiSession", "hideNegative", False)
|
self.optState.getBool("GuiSessionLog", "hideNegative", False)
|
||||||
)
|
)
|
||||||
self.hideNegative.stateChanged.connect(self._doHideNegative)
|
self.hideNegative.stateChanged.connect(self._doHideNegative)
|
||||||
|
|
||||||
@@ -149,7 +149,7 @@ class GuiSessionLogView(QDialog):
|
|||||||
|
|
||||||
self.setLayout(self.outerBox)
|
self.setLayout(self.outerBox)
|
||||||
|
|
||||||
logger.debug("SessionLogView initialisation complete")
|
logger.debug("GuiSessionLog initialisation complete")
|
||||||
|
|
||||||
qApp.processEvents()
|
qApp.processEvents()
|
||||||
self._loadLogFile()
|
self._loadLogFile()
|
||||||
@@ -173,12 +173,12 @@ class GuiSessionLogView(QDialog):
|
|||||||
hideZeros = self.hideZeros.isChecked()
|
hideZeros = self.hideZeros.isChecked()
|
||||||
hideNegative = self.hideNegative.isChecked()
|
hideNegative = self.hideNegative.isChecked()
|
||||||
|
|
||||||
self.optState.setValue("GuiSession", "widthCol0", widthCol0)
|
self.optState.setValue("GuiSessionLog", "widthCol0", widthCol0)
|
||||||
self.optState.setValue("GuiSession", "widthCol1", widthCol1)
|
self.optState.setValue("GuiSessionLog", "widthCol1", widthCol1)
|
||||||
self.optState.setValue("GuiSession", "sortCol", sortCol)
|
self.optState.setValue("GuiSessionLog", "sortCol", sortCol)
|
||||||
self.optState.setValue("GuiSession", "sortOrder", sortOrder)
|
self.optState.setValue("GuiSessionLog", "sortOrder", sortOrder)
|
||||||
self.optState.setValue("GuiSession", "hideZeros", hideZeros)
|
self.optState.setValue("GuiSessionLog", "hideZeros", hideZeros)
|
||||||
self.optState.setValue("GuiSession", "hideNegative", hideNegative)
|
self.optState.setValue("GuiSessionLog", "hideNegative", hideNegative)
|
||||||
|
|
||||||
self.optState.saveSettings()
|
self.optState.saveSettings()
|
||||||
self.close()
|
self.close()
|
||||||
@@ -226,6 +226,7 @@ class GuiSessionLogView(QDialog):
|
|||||||
nWords = int(inData[7])
|
nWords = int(inData[7])
|
||||||
tDiff = dEnd - dStart
|
tDiff = dEnd - dStart
|
||||||
sDiff = tDiff.total_seconds()
|
sDiff = tDiff.total_seconds()
|
||||||
|
self.timeTotal += sDiff
|
||||||
|
|
||||||
self.logData.append((dStart, sDiff, nWords))
|
self.logData.append((dStart, sDiff, nWords))
|
||||||
|
|
||||||
@@ -235,6 +236,8 @@ class GuiSessionLogView(QDialog):
|
|||||||
)
|
)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
self.labelTotal.setText(self._formatTime(self.timeTotal))
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def _updateListBox(self):
|
def _updateListBox(self):
|
||||||
@@ -242,18 +245,14 @@ class GuiSessionLogView(QDialog):
|
|||||||
"""
|
"""
|
||||||
self.listBox.clear()
|
self.listBox.clear()
|
||||||
self.timeFilter = 0.0
|
self.timeFilter = 0.0
|
||||||
self.timeTotal = 0.0
|
|
||||||
|
|
||||||
hideZeros = self.hideZeros.isChecked()
|
hideZeros = self.hideZeros.isChecked()
|
||||||
hideNegative = self.hideNegative.isChecked()
|
hideNegative = self.hideNegative.isChecked()
|
||||||
|
|
||||||
for dStart, sDiff, nWords in self.logData:
|
for dStart, sDiff, nWords in self.logData:
|
||||||
|
|
||||||
self.timeTotal += sDiff
|
|
||||||
|
|
||||||
if hideZeros and nWords == 0:
|
if hideZeros and nWords == 0:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if hideNegative and nWords < 0:
|
if hideNegative and nWords < 0:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@@ -274,7 +273,6 @@ class GuiSessionLogView(QDialog):
|
|||||||
self.listBox.addTopLevelItem(newItem)
|
self.listBox.addTopLevelItem(newItem)
|
||||||
|
|
||||||
self.labelFilter.setText(self._formatTime(self.timeFilter))
|
self.labelFilter.setText(self._formatTime(self.timeFilter))
|
||||||
self.labelTotal.setText(self._formatTime(self.timeTotal))
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@@ -287,4 +285,4 @@ class GuiSessionLogView(QDialog):
|
|||||||
tS = tS - tM*60 - tH*3600
|
tS = tS - tM*60 - tH*3600
|
||||||
return "%02d:%02d:%02d" % (tH,tM,tS)
|
return "%02d:%02d:%02d" % (tH,tM,tS)
|
||||||
|
|
||||||
# END Class GuiSessionLogView
|
# END Class GuiSessionLog
|
||||||
|
|||||||
+2
-2
@@ -43,7 +43,7 @@ from nw.gui import (
|
|||||||
GuiBuildNovel, GuiDocEditor, GuiDocMerge, GuiDocSplit, GuiDocViewDetails,
|
GuiBuildNovel, GuiDocEditor, GuiDocMerge, GuiDocSplit, GuiDocViewDetails,
|
||||||
GuiDocViewer, GuiItemDetails, GuiItemEditor, GuiMainMenu, GuiMainStatus,
|
GuiDocViewer, GuiItemDetails, GuiItemEditor, GuiMainMenu, GuiMainStatus,
|
||||||
GuiOutline, GuiOutlineDetails, GuiPreferences, GuiProjectLoad, GuiTheme,
|
GuiOutline, GuiOutlineDetails, GuiPreferences, GuiProjectLoad, GuiTheme,
|
||||||
GuiProjectSettings, GuiProjectTree, GuiSessionLogView
|
GuiProjectSettings, GuiProjectTree, GuiSessionLog
|
||||||
)
|
)
|
||||||
from nw.core import NWProject, NWDoc, NWIndex
|
from nw.core import NWProject, NWDoc, NWIndex
|
||||||
from nw.constants import nwFiles, nwItemType, nwAlert
|
from nw.constants import nwFiles, nwItemType, nwAlert
|
||||||
@@ -810,7 +810,7 @@ class GuiMain(QMainWindow):
|
|||||||
"""Open the session log dialog.
|
"""Open the session log dialog.
|
||||||
"""
|
"""
|
||||||
if self.hasProject:
|
if self.hasProject:
|
||||||
dlgTLine = GuiSessionLogView(self, self.theProject)
|
dlgTLine = GuiSessionLog(self, self.theProject)
|
||||||
dlgTLine.exec_()
|
dlgTLine.exec_()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user