Back-references not consideres all tags in a document, not just the first one
This commit is contained in:
@@ -395,6 +395,8 @@ class GuiDocEditor(QTextEdit):
|
||||
def setCursorPosition(self, thePosition):
|
||||
"""Move the cursor to a given position in the document.
|
||||
"""
|
||||
if not isinstance(thePosition, int):
|
||||
return False
|
||||
if thePosition >= 0:
|
||||
theCursor = self.textCursor()
|
||||
theCursor.setPosition(thePosition)
|
||||
@@ -410,12 +412,13 @@ class GuiDocEditor(QTextEdit):
|
||||
def setCursorLine(self, theLine):
|
||||
"""Move the cursor to a given line in the document.
|
||||
"""
|
||||
if theLine is None:
|
||||
if not isinstance(theLine, int):
|
||||
return False
|
||||
if theLine >= 0:
|
||||
theBlock = self.qDocument.findBlockByLineNumber(theLine)
|
||||
if theBlock:
|
||||
self.setCursorPosition(theBlock.position())
|
||||
logger.verbose("Cursor moved to line %d" % theLine)
|
||||
return True
|
||||
|
||||
##
|
||||
|
||||
@@ -206,6 +206,33 @@ class GuiDocViewer(QTextBrowser):
|
||||
self.docTitle.setTitleFromHandle(self.theHandle)
|
||||
return
|
||||
|
||||
##
|
||||
# Setters
|
||||
##
|
||||
|
||||
def setCursorPosition(self, thePosition):
|
||||
"""Move the cursor to a given position in the document.
|
||||
"""
|
||||
if not isinstance(thePosition, int):
|
||||
return False
|
||||
if thePosition >= 0:
|
||||
theCursor = self.textCursor()
|
||||
theCursor.setPosition(thePosition)
|
||||
self.setTextCursor(theCursor)
|
||||
return True
|
||||
|
||||
def setCursorLine(self, theLine):
|
||||
"""Move the cursor to a given line in the document.
|
||||
"""
|
||||
if not isinstance(theLine, int):
|
||||
return False
|
||||
if theLine >= 0:
|
||||
theBlock = self.qDocument.findBlockByLineNumber(theLine)
|
||||
if theBlock:
|
||||
self.setCursorPosition(theBlock.position())
|
||||
logger.verbose("Cursor moved to line %d" % theLine)
|
||||
return True
|
||||
|
||||
##
|
||||
# Events
|
||||
##
|
||||
|
||||
@@ -107,7 +107,11 @@ class GuiDocViewDetails(QWidget):
|
||||
for tHandle in theRefs:
|
||||
tItem = self.theProject.projTree[tHandle]
|
||||
if tItem is not None:
|
||||
theList.append("<a href='#tag=%s'>%s</a>" % (tHandle,tItem.itemName))
|
||||
theList.append("<a href='#tag=%s:%s'>%s</a>" % (
|
||||
tHandle, theRefs[tHandle], tItem.itemName
|
||||
))
|
||||
|
||||
# print(theList)
|
||||
|
||||
self.refList.setText(", ".join(theList))
|
||||
self.refList.adjustSize()
|
||||
@@ -122,9 +126,15 @@ class GuiDocViewDetails(QWidget):
|
||||
"""Capture the link-click and forward it to the document viewer
|
||||
class for handling.
|
||||
"""
|
||||
if len(theLink) == 18:
|
||||
tHandle = theLink[-13:]
|
||||
self.theParent.viewDocument(tHandle)
|
||||
logger.verbose("Clicked link: '%s'" % theLink)
|
||||
if len(theLink) == 26:
|
||||
tHandle = theLink[5:18]
|
||||
tLine = theLink[19:26]
|
||||
if tLine[1:].isdigit():
|
||||
nLine = int(tLine[1:])
|
||||
else:
|
||||
nLine = 1
|
||||
self.theParent.viewDocument(tHandle, nLine)
|
||||
return
|
||||
|
||||
def _doShowHide(self, chState):
|
||||
|
||||
Reference in New Issue
Block a user