Added line counter to document footer
This commit is contained in:
+43
-1
@@ -312,6 +312,8 @@ class GuiDocEditor(QTextEdit):
|
||||
else:
|
||||
self.setCursorLine(tLine)
|
||||
|
||||
self.docFooter.updateLineCount()
|
||||
|
||||
qApp.restoreOverrideCursor()
|
||||
|
||||
return True
|
||||
@@ -462,6 +464,7 @@ class GuiDocEditor(QTextEdit):
|
||||
theCursor = self.textCursor()
|
||||
theCursor.setPosition(thePosition)
|
||||
self.setTextCursor(theCursor)
|
||||
self.docFooter.updateLineCount()
|
||||
return True
|
||||
|
||||
def getCursorPosition(self):
|
||||
@@ -488,6 +491,7 @@ class GuiDocEditor(QTextEdit):
|
||||
theBlock = self.qDocument.findBlockByLineNumber(theLine)
|
||||
if theBlock:
|
||||
self.setCursorPosition(theBlock.position())
|
||||
self.docFooter.updateLineCount()
|
||||
logger.verbose("Cursor moved to line %d" % theLine)
|
||||
return True
|
||||
|
||||
@@ -736,6 +740,7 @@ class GuiDocEditor(QTextEdit):
|
||||
elif keyEvent == QKeySequence.Undo:
|
||||
self.docAction(nwDocAction.UNDO)
|
||||
else:
|
||||
self.docFooter.updateLineCount()
|
||||
QTextEdit.keyPressEvent(self, keyEvent)
|
||||
return
|
||||
|
||||
@@ -759,6 +764,7 @@ class GuiDocEditor(QTextEdit):
|
||||
if qApp.keyboardModifiers() == Qt.ControlModifier:
|
||||
theCursor = self.cursorForPosition(mEvent.pos())
|
||||
self._followTag(theCursor)
|
||||
self.docFooter.updateLineCount()
|
||||
QTextEdit.mouseReleaseEvent(self, mEvent)
|
||||
return
|
||||
|
||||
@@ -2166,6 +2172,7 @@ class GuiDocEditFooter(QWidget):
|
||||
self.sPx = int(round(0.9*self.theTheme.baseIconSize))
|
||||
fPx = int(0.9*self.theTheme.fontPixelSize)
|
||||
bSp = self.mainConf.pxInt(4)
|
||||
hSp = self.mainConf.pxInt(6)
|
||||
|
||||
lblFont = self.font()
|
||||
lblFont.setPointSizeF(0.9*self.theTheme.fontPointSize)
|
||||
@@ -2191,6 +2198,23 @@ class GuiDocEditFooter(QWidget):
|
||||
self.statusText.setPalette(self.thePalette)
|
||||
self.statusText.setFont(lblFont)
|
||||
|
||||
# Lines
|
||||
self.linesIcon = QLabel("")
|
||||
self.linesIcon.setPixmap(self.theTheme.getPixmap("status_lines", (self.sPx, self.sPx)))
|
||||
self.linesIcon.setContentsMargins(0, 0, 0, 0)
|
||||
self.linesIcon.setFixedHeight(self.sPx)
|
||||
self.linesIcon.setAlignment(Qt.AlignLeft | Qt.AlignTop)
|
||||
|
||||
self.linesText = QLabel("Line: 0 of 0")
|
||||
self.linesText.setIndent(0)
|
||||
self.linesText.setMargin(0)
|
||||
self.linesText.setContentsMargins(0, 0, 0, 0)
|
||||
self.linesText.setAutoFillBackground(True)
|
||||
self.linesText.setFixedHeight(fPx)
|
||||
self.linesText.setAlignment(Qt.AlignLeft | Qt.AlignTop)
|
||||
self.linesText.setPalette(self.thePalette)
|
||||
self.linesText.setFont(lblFont)
|
||||
|
||||
# Words
|
||||
self.wordsIcon = QLabel("")
|
||||
self.wordsIcon.setPixmap(self.theTheme.getPixmap("status_stats", (self.sPx, self.sPx)))
|
||||
@@ -2214,6 +2238,9 @@ class GuiDocEditFooter(QWidget):
|
||||
self.outerBox.addWidget(self.statusIcon)
|
||||
self.outerBox.addWidget(self.statusText)
|
||||
self.outerBox.addStretch(1)
|
||||
self.outerBox.addWidget(self.linesIcon)
|
||||
self.outerBox.addWidget(self.linesText)
|
||||
self.outerBox.addSpacing(hSp)
|
||||
self.outerBox.addWidget(self.wordsIcon)
|
||||
self.outerBox.addWidget(self.wordsText)
|
||||
self.setLayout(self.outerBox)
|
||||
@@ -2263,8 +2290,23 @@ class GuiDocEditFooter(QWidget):
|
||||
|
||||
return
|
||||
|
||||
def updateLineCount(self):
|
||||
"""Update the word count.
|
||||
"""
|
||||
if self.theItem is None:
|
||||
iLine = 0
|
||||
nLine = 0
|
||||
else:
|
||||
theCursor = self.docEditor.textCursor()
|
||||
iLine = theCursor.blockNumber() + 1
|
||||
nLine = self.docEditor.qDocument.blockCount()
|
||||
|
||||
self.linesText.setText("Line: %d of %d" % (iLine, nLine))
|
||||
|
||||
return
|
||||
|
||||
def updateCounts(self):
|
||||
"""Update the word counts.
|
||||
"""Update the word count.
|
||||
"""
|
||||
if self.theItem is None:
|
||||
wCount = 0
|
||||
|
||||
Reference in New Issue
Block a user