First some code cleanup and fix of the filtered total
This commit is contained in:
@@ -48,7 +48,6 @@ class OptionState():
|
||||
"GuiSession": {
|
||||
"widthCol0",
|
||||
"widthCol1",
|
||||
"widthCol2",
|
||||
"sortCol",
|
||||
"sortOrder",
|
||||
"hideZeros",
|
||||
|
||||
+43
-43
@@ -44,43 +44,45 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
class GuiSessionLogView(QDialog):
|
||||
|
||||
C_TIME = 0
|
||||
C_LENGTH = 1
|
||||
C_COUNT = 2
|
||||
|
||||
def __init__(self, theParent, theProject):
|
||||
QDialog.__init__(self, theParent)
|
||||
|
||||
logger.debug("Initialising SessionLogView ...")
|
||||
|
||||
self.mainConf = nw.CONFIG
|
||||
self.theProject = theProject
|
||||
self.theParent = theParent
|
||||
self.optState = self.theProject.optState
|
||||
self.theProject = theProject
|
||||
self.theTheme = theParent.theTheme
|
||||
self.optState = theProject.optState
|
||||
|
||||
self.timeFilter = 0.0
|
||||
self.timeTotal = 0.0
|
||||
|
||||
self.outerBox = QGridLayout()
|
||||
self.bottomBox = QHBoxLayout()
|
||||
|
||||
self.setWindowTitle("Session Log")
|
||||
self.setMinimumWidth(self.mainConf.pxInt(420))
|
||||
self.setMinimumHeight(self.mainConf.pxInt(400))
|
||||
|
||||
# List Box
|
||||
wCol0 = self.mainConf.pxInt(self.optState.getInt("GuiSession", "widthCol0", 180))
|
||||
wCol1 = self.mainConf.pxInt(self.optState.getInt("GuiSession", "widthCol1", 80))
|
||||
wCol2 = self.mainConf.pxInt(self.optState.getInt("GuiSession", "widthCol2", 80))
|
||||
|
||||
self.listBox = QTreeWidget()
|
||||
self.listBox.setHeaderLabels(["Session Start","Length","Words",""])
|
||||
self.listBox.setHeaderLabels(["Session Start","Length","Words"])
|
||||
self.listBox.setIndentation(0)
|
||||
self.listBox.setColumnWidth(0, wCol0)
|
||||
self.listBox.setColumnWidth(1, wCol1)
|
||||
self.listBox.setColumnWidth(2, wCol2)
|
||||
self.listBox.setColumnWidth(3, 0)
|
||||
self.listBox.setColumnWidth(self.C_TIME, wCol0)
|
||||
self.listBox.setColumnWidth(self.C_LENGTH, wCol1)
|
||||
self.listBox.resizeColumnToContents(self.C_COUNT)
|
||||
|
||||
hHeader = self.listBox.headerItem()
|
||||
hHeader.setTextAlignment(1,Qt.AlignRight)
|
||||
hHeader.setTextAlignment(2,Qt.AlignRight)
|
||||
hHeader.setTextAlignment(self.C_LENGTH, Qt.AlignRight)
|
||||
hHeader.setTextAlignment(self.C_COUNT, Qt.AlignRight)
|
||||
|
||||
self.monoFont = QFont("Monospace", 10)
|
||||
self.monoFont = QFont()
|
||||
self.monoFont.setFamily(self.theTheme.guiFontFixed.family())
|
||||
|
||||
sortValid = (Qt.AscendingOrder, Qt.DescendingOrder)
|
||||
sortCol = self.optState.validIntRange(
|
||||
@@ -95,9 +97,9 @@ class GuiSessionLogView(QDialog):
|
||||
self.listBox.setSortingEnabled(True)
|
||||
|
||||
# Session Info
|
||||
self.infoBox = QGroupBox("Sum Total Time", self)
|
||||
self.infoBoxForm = QGridLayout(self)
|
||||
self.infoBox.setLayout(self.infoBoxForm)
|
||||
self.infoBox = QGroupBox("Sum Total Time", self)
|
||||
self.infoForm = QGridLayout(self)
|
||||
self.infoBox.setLayout(self.infoForm)
|
||||
|
||||
self.labelTotal = QLabel(self._formatTime(0))
|
||||
self.labelTotal.setFont(self.monoFont)
|
||||
@@ -107,15 +109,15 @@ class GuiSessionLogView(QDialog):
|
||||
self.labelFilter.setFont(self.monoFont)
|
||||
self.labelFilter.setAlignment(Qt.AlignVCenter | Qt.AlignRight)
|
||||
|
||||
self.infoBoxForm.addWidget(QLabel("All:"), 0, 0)
|
||||
self.infoBoxForm.addWidget(self.labelTotal, 0, 1)
|
||||
self.infoBoxForm.addWidget(QLabel("Filtered:"), 1, 0)
|
||||
self.infoBoxForm.addWidget(self.labelFilter, 1, 1)
|
||||
self.infoForm.addWidget(QLabel("All:"), 0, 0)
|
||||
self.infoForm.addWidget(self.labelTotal, 0, 1)
|
||||
self.infoForm.addWidget(QLabel("Filtered:"), 1, 0)
|
||||
self.infoForm.addWidget(self.labelFilter, 1, 1)
|
||||
|
||||
# Filter Options
|
||||
self.filterBox = QGroupBox("Filters", self)
|
||||
self.filterBoxForm = QGridLayout(self)
|
||||
self.filterBox.setLayout(self.filterBoxForm)
|
||||
self.filterBox = QGroupBox("Filters", self)
|
||||
self.filterForm = QGridLayout(self)
|
||||
self.filterBox.setLayout(self.filterForm)
|
||||
|
||||
self.hideZeros = QCheckBox("Hide zero word count", self)
|
||||
self.hideZeros.setChecked(
|
||||
@@ -129,14 +131,15 @@ class GuiSessionLogView(QDialog):
|
||||
)
|
||||
self.hideNegative.stateChanged.connect(self._doHideNegative)
|
||||
|
||||
self.filterBoxForm.addWidget(self.hideZeros, 0, 0)
|
||||
self.filterBoxForm.addWidget(self.hideNegative, 1, 0)
|
||||
self.filterForm.addWidget(self.hideZeros, 0, 0)
|
||||
self.filterForm.addWidget(self.hideNegative, 1, 0)
|
||||
|
||||
# Buttons
|
||||
self.buttonBox = QDialogButtonBox(QDialogButtonBox.Close)
|
||||
self.buttonBox.rejected.connect(self._doClose)
|
||||
|
||||
# Assemble
|
||||
self.outerBox = QGridLayout()
|
||||
self.outerBox.addWidget(self.listBox, 0, 0, 1, 2)
|
||||
self.outerBox.addWidget(self.infoBox, 1, 0)
|
||||
self.outerBox.addWidget(self.filterBox, 1, 1)
|
||||
@@ -144,8 +147,6 @@ class GuiSessionLogView(QDialog):
|
||||
|
||||
self.setLayout(self.outerBox)
|
||||
|
||||
self.show()
|
||||
|
||||
logger.debug("SessionLogView initialisation complete")
|
||||
|
||||
self._loadSessionLog()
|
||||
@@ -175,18 +176,16 @@ class GuiSessionLogView(QDialog):
|
||||
if len(inData) != 8:
|
||||
continue
|
||||
dStart = datetime.strptime(
|
||||
"%s %s" % (inData[1],inData[2]), nwConst.tStampFmt
|
||||
"%s %s" % (inData[1], inData[2]), nwConst.tStampFmt
|
||||
)
|
||||
dEnd = datetime.strptime(
|
||||
"%s %s" % (inData[4],inData[5]), nwConst.tStampFmt
|
||||
"%s %s" % (inData[4], inData[5]), nwConst.tStampFmt
|
||||
)
|
||||
nWords = int(inData[7])
|
||||
tDiff = dEnd - dStart
|
||||
sDiff = tDiff.total_seconds()
|
||||
|
||||
self.timeTotal += sDiff
|
||||
if abs(nWords) > 0:
|
||||
self.timeFilter += sDiff
|
||||
self.timeTotal += sDiff
|
||||
|
||||
if hideZeros and nWords == 0:
|
||||
continue
|
||||
@@ -194,16 +193,19 @@ class GuiSessionLogView(QDialog):
|
||||
if hideNegative and nWords < 0:
|
||||
continue
|
||||
|
||||
newItem = QTreeWidgetItem(
|
||||
[str(dStart), self._formatTime(sDiff), str(nWords), ""]
|
||||
)
|
||||
self.timeFilter += sDiff
|
||||
|
||||
newItem.setTextAlignment(1,Qt.AlignRight)
|
||||
newItem.setTextAlignment(2,Qt.AlignRight)
|
||||
newItem = QTreeWidgetItem()
|
||||
newItem.setText(self.C_TIME, str(dStart))
|
||||
newItem.setText(self.C_LENGTH, self._formatTime(sDiff))
|
||||
newItem.setText(self.C_COUNT, str(nWords))
|
||||
|
||||
newItem.setFont(0,self.monoFont)
|
||||
newItem.setFont(1,self.monoFont)
|
||||
newItem.setFont(2,self.monoFont)
|
||||
newItem.setTextAlignment(self.C_LENGTH, Qt.AlignRight)
|
||||
newItem.setTextAlignment(self.C_COUNT, Qt.AlignRight)
|
||||
|
||||
newItem.setFont(self.C_TIME, self.monoFont)
|
||||
newItem.setFont(self.C_LENGTH, self.monoFont)
|
||||
newItem.setFont(self.C_COUNT, self.monoFont)
|
||||
|
||||
self.listBox.addTopLevelItem(newItem)
|
||||
|
||||
@@ -222,7 +224,6 @@ class GuiSessionLogView(QDialog):
|
||||
|
||||
widthCol0 = self.mainConf.rpxInt(self.listBox.columnWidth(0))
|
||||
widthCol1 = self.mainConf.rpxInt(self.listBox.columnWidth(1))
|
||||
widthCol2 = self.mainConf.rpxInt(self.listBox.columnWidth(2))
|
||||
sortCol = self.listBox.sortColumn()
|
||||
sortOrder = self.listBox.header().sortIndicatorOrder()
|
||||
hideZeros = self.hideZeros.isChecked()
|
||||
@@ -230,7 +231,6 @@ class GuiSessionLogView(QDialog):
|
||||
|
||||
self.optState.setValue("GuiSession", "widthCol0", widthCol0)
|
||||
self.optState.setValue("GuiSession", "widthCol1", widthCol1)
|
||||
self.optState.setValue("GuiSession", "widthCol2", widthCol2)
|
||||
self.optState.setValue("GuiSession", "sortCol", sortCol)
|
||||
self.optState.setValue("GuiSession", "sortOrder", sortOrder)
|
||||
self.optState.setValue("GuiSession", "hideZeros", hideZeros)
|
||||
|
||||
@@ -139,6 +139,8 @@ class GuiTheme:
|
||||
logger.verbose("GUI Scale: %.2f" % self.guiScale)
|
||||
|
||||
self.guiFont = qApp.font()
|
||||
self.guiFontFixed = QFontDatabase.systemFont(QFontDatabase.FixedFont)
|
||||
|
||||
qMetric = QFontMetrics(self.guiFont)
|
||||
self.fontPointSize = self.guiFont.pointSizeF()
|
||||
self.fontPixelSize = int(round(qMetric.height()))
|
||||
|
||||
Reference in New Issue
Block a user