Tie things together to ensure title is always updated, and add some needed comments here and there
This commit is contained in:
@@ -150,6 +150,7 @@ class GuiDocEditor(QTextEdit):
|
||||
|
||||
self.setDocumentChanged(False)
|
||||
self.theParent.noticeBar.hideNote()
|
||||
self.theParent.updateEditTitle()
|
||||
|
||||
return True
|
||||
|
||||
@@ -264,6 +265,7 @@ class GuiDocEditor(QTextEdit):
|
||||
else:
|
||||
self.theParent.noticeBar.showNote("This document is read only.")
|
||||
|
||||
self.theParent.updateEditTitle()
|
||||
self.hLight.spellCheck = spTemp
|
||||
qApp.restoreOverrideCursor()
|
||||
|
||||
|
||||
@@ -63,6 +63,10 @@ class GuiDocTitleBar(QLabel):
|
||||
|
||||
return
|
||||
|
||||
##
|
||||
# Setters
|
||||
##
|
||||
|
||||
def setTitleFromHandle(self, tHandle):
|
||||
"""Sets the document title from the handle, or alternatively,
|
||||
set the whole document path.
|
||||
@@ -91,4 +95,15 @@ class GuiDocTitleBar(QLabel):
|
||||
|
||||
return True
|
||||
|
||||
##
|
||||
# Events
|
||||
##
|
||||
|
||||
def mousePressEvent(self, theEvent):
|
||||
"""Capture a click on the title and ensure that the item is
|
||||
selected in the project tree.
|
||||
"""
|
||||
self.theParent.treeView.setSelectedHandle(self.theHandle)
|
||||
return
|
||||
|
||||
# END Class GuiDocTitleBar
|
||||
|
||||
@@ -457,6 +457,9 @@ class GuiDocTree(QTreeWidget):
|
||||
return True
|
||||
|
||||
def getSelectedHandle(self):
|
||||
"""Get the currently selected handle. If multiple items are
|
||||
selected, return the first.
|
||||
"""
|
||||
selItem = self.selectedItems()
|
||||
if len(selItem) == 0:
|
||||
return None
|
||||
@@ -465,6 +468,8 @@ class GuiDocTree(QTreeWidget):
|
||||
return None
|
||||
|
||||
def getSelectedHandles(self):
|
||||
"""Return a list of all currently selected item handles.
|
||||
"""
|
||||
selItems = self.selectedItems()
|
||||
selHandles = []
|
||||
for n in range(len(selItems)):
|
||||
@@ -472,6 +477,15 @@ class GuiDocTree(QTreeWidget):
|
||||
selHandles.append(selItems[n].text(self.C_HANDLE))
|
||||
return selHandles
|
||||
|
||||
def setSelectedHandle(self, tHandle):
|
||||
"""Set a specific handle as the selected item.
|
||||
"""
|
||||
if tHandle in self.theMap:
|
||||
self.clearSelection()
|
||||
self.theMap[tHandle].setSelected(True)
|
||||
return True
|
||||
return False
|
||||
|
||||
##
|
||||
# Internal Functions
|
||||
##
|
||||
|
||||
@@ -69,8 +69,12 @@ class GuiDocViewer(QTextBrowser):
|
||||
return
|
||||
|
||||
def clearViewer(self):
|
||||
"""Clear the content of the document and reset key variables.
|
||||
"""
|
||||
self.clear()
|
||||
self.setSearchPaths([""])
|
||||
self.theHandle = None
|
||||
self.theParent.updateViewTitle()
|
||||
return True
|
||||
|
||||
def initViewer(self):
|
||||
@@ -108,6 +112,8 @@ class GuiDocViewer(QTextBrowser):
|
||||
return True
|
||||
|
||||
def loadText(self, tHandle):
|
||||
"""Load text into the viewer from an item handle.
|
||||
"""
|
||||
|
||||
tItem = self.theProject.getItem(tHandle)
|
||||
if tItem is None:
|
||||
@@ -132,7 +138,9 @@ class GuiDocViewer(QTextBrowser):
|
||||
self.theHandle = tHandle
|
||||
self.theProject.setLastViewed(tHandle)
|
||||
|
||||
# Make sure the main GUI knows we changed the content
|
||||
self.theParent.viewMeta.refreshReferences(tHandle)
|
||||
self.theParent.updateViewTitle()
|
||||
|
||||
return True
|
||||
|
||||
|
||||
Reference in New Issue
Block a user