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