Added document references pane to the bottom of the doc viewer
This commit is contained in:
@@ -113,6 +113,8 @@ class GuiDocViewer(QTextBrowser):
|
|||||||
self.theHandle = tHandle
|
self.theHandle = tHandle
|
||||||
self.theProject.setLastViewed(tHandle)
|
self.theProject.setLastViewed(tHandle)
|
||||||
|
|
||||||
|
self.theParent.docMeta.refreshReferences(tHandle)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def loadFromTag(self, theTag):
|
def loadFromTag(self, theTag):
|
||||||
|
|||||||
@@ -0,0 +1,82 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
"""novelWriter GUI DocView Details
|
||||||
|
|
||||||
|
novelWriter – GUI DocView Details
|
||||||
|
===================================
|
||||||
|
Class holding the document view details panel
|
||||||
|
|
||||||
|
File History:
|
||||||
|
Created: 2019-09-31 [0.3.2]
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
import logging
|
||||||
|
import nw
|
||||||
|
|
||||||
|
from PyQt5.QtGui import QFont
|
||||||
|
from PyQt5.QtWidgets import QWidget, QHBoxLayout, QLabel, QGroupBox, QComboBox
|
||||||
|
|
||||||
|
from nw.constants import nwLabels
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
class GuiDocViewDetails(QWidget):
|
||||||
|
|
||||||
|
def __init__(self, theParent, theProject):
|
||||||
|
QWidget.__init__(self, theParent)
|
||||||
|
|
||||||
|
logger.debug("Initialising DocViewDetails ...")
|
||||||
|
self.mainConf = nw.CONFIG
|
||||||
|
self.debugGUI = self.mainConf.debugGUI
|
||||||
|
self.theParent = theParent
|
||||||
|
self.theProject = theProject
|
||||||
|
|
||||||
|
self.outerBox = QHBoxLayout(self)
|
||||||
|
self.outerBox.setContentsMargins(4,4,4,4)
|
||||||
|
|
||||||
|
self.refTags = QGroupBox("Referenced From", self)
|
||||||
|
self.refTagsForm = QHBoxLayout(self.refTags)
|
||||||
|
self.refTags.setLayout(self.refTagsForm)
|
||||||
|
|
||||||
|
self.refList = QLabel("None")
|
||||||
|
self.refList.linkActivated.connect(self._linkClicked)
|
||||||
|
|
||||||
|
self.refTagsForm.addWidget(self.refList)
|
||||||
|
self.outerBox.addWidget(self.refTags)
|
||||||
|
self.setLayout(self.outerBox)
|
||||||
|
self.setContentsMargins(0,0,0,0)
|
||||||
|
|
||||||
|
logger.debug("DocViewDetails initialisation complete")
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
def refreshReferences(self, tHandle):
|
||||||
|
|
||||||
|
theRefs = self.theParent.theIndex.buildReferenceList(tHandle)
|
||||||
|
if theRefs:
|
||||||
|
self.setVisible(True)
|
||||||
|
else:
|
||||||
|
self.setVisible(False)
|
||||||
|
return
|
||||||
|
|
||||||
|
theList = []
|
||||||
|
for tHandle in theRefs:
|
||||||
|
tItem = self.theProject.getItem(tHandle)
|
||||||
|
if tItem is not None:
|
||||||
|
theList.append("<a href='#tag=%s'>%s</a>" % (tHandle,tItem.itemName))
|
||||||
|
|
||||||
|
self.refList.setText(", ".join(theList))
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
##
|
||||||
|
# Internal Functions
|
||||||
|
##
|
||||||
|
|
||||||
|
def _linkClicked(self, theLink):
|
||||||
|
if len(theLink) == 18:
|
||||||
|
tHandle = theLink[-13:]
|
||||||
|
self.theParent.viewDocument(tHandle)
|
||||||
|
return
|
||||||
|
|
||||||
|
# END Class GuiDocViewDetails
|
||||||
+2
-2
@@ -25,7 +25,7 @@ class GuiMainStatus(QStatusBar):
|
|||||||
def __init__(self, theParent):
|
def __init__(self, theParent):
|
||||||
QStatusBar.__init__(self, theParent)
|
QStatusBar.__init__(self, theParent)
|
||||||
|
|
||||||
logger.debug("Initialising GuiMainStatus ...")
|
logger.debug("Initialising MainStatus ...")
|
||||||
|
|
||||||
self.mainConf = nw.CONFIG
|
self.mainConf = nw.CONFIG
|
||||||
self.theParent = theParent
|
self.theParent = theParent
|
||||||
@@ -80,7 +80,7 @@ class GuiMainStatus(QStatusBar):
|
|||||||
self.sessionTimer.timeout.connect(self._updateTime)
|
self.sessionTimer.timeout.connect(self._updateTime)
|
||||||
self.sessionTimer.start()
|
self.sessionTimer.start()
|
||||||
|
|
||||||
logger.debug("GuiMainStatus initialisation complete")
|
logger.debug("MainStatus initialisation complete")
|
||||||
|
|
||||||
self.clearStatus()
|
self.clearStatus()
|
||||||
|
|
||||||
|
|||||||
+33
-24
@@ -31,6 +31,7 @@ from nw.gui.elements.docviewer import GuiDocViewer
|
|||||||
from nw.gui.elements.docdetails import GuiDocDetails
|
from nw.gui.elements.docdetails import GuiDocDetails
|
||||||
from nw.gui.elements.searchbar import GuiSearchBar
|
from nw.gui.elements.searchbar import GuiSearchBar
|
||||||
from nw.gui.elements.noticebar import GuiNoticeBar
|
from nw.gui.elements.noticebar import GuiNoticeBar
|
||||||
|
from nw.gui.elements.viewdetails import GuiDocViewDetails
|
||||||
from nw.gui.dialogs.configeditor import GuiConfigEditor
|
from nw.gui.dialogs.configeditor import GuiConfigEditor
|
||||||
from nw.gui.dialogs.projecteditor import GuiProjectEditor
|
from nw.gui.dialogs.projecteditor import GuiProjectEditor
|
||||||
from nw.gui.dialogs.export import GuiExport
|
from nw.gui.dialogs.export import GuiExport
|
||||||
@@ -72,14 +73,15 @@ class GuiMain(QMainWindow):
|
|||||||
self.setWindowIcon(QIcon(path.join(self.mainConf.appIcon)))
|
self.setWindowIcon(QIcon(path.join(self.mainConf.appIcon)))
|
||||||
|
|
||||||
# Main GUI Elements
|
# Main GUI Elements
|
||||||
self.statusBar = GuiMainStatus(self)
|
self.statusBar = GuiMainStatus(self)
|
||||||
self.noticeBar = GuiNoticeBar(self)
|
self.noticeBar = GuiNoticeBar(self)
|
||||||
self.docEditor = GuiDocEditor(self, self.theProject)
|
self.docEditor = GuiDocEditor(self, self.theProject)
|
||||||
self.docViewer = GuiDocViewer(self, self.theProject)
|
self.docViewer = GuiDocViewer(self, self.theProject)
|
||||||
self.docDetails = GuiDocDetails(self, self.theProject)
|
self.docMeta = GuiDocViewDetails(self, self.theProject)
|
||||||
self.searchBar = GuiSearchBar(self)
|
self.searchBar = GuiSearchBar(self)
|
||||||
self.treeView = GuiDocTree(self, self.theProject)
|
self.treeMeta = GuiDocDetails(self, self.theProject)
|
||||||
self.mainMenu = GuiMainMenu(self, self.theProject)
|
self.treeView = GuiDocTree(self, self.theProject)
|
||||||
|
self.mainMenu = GuiMainMenu(self, self.theProject)
|
||||||
|
|
||||||
# Minor Gui Elements
|
# Minor Gui Elements
|
||||||
self.statusIcons = []
|
self.statusIcons = []
|
||||||
@@ -90,20 +92,27 @@ class GuiMain(QMainWindow):
|
|||||||
self.treeBox = QVBoxLayout()
|
self.treeBox = QVBoxLayout()
|
||||||
self.treeBox.setContentsMargins(0,0,0,0)
|
self.treeBox.setContentsMargins(0,0,0,0)
|
||||||
self.treeBox.addWidget(self.treeView)
|
self.treeBox.addWidget(self.treeView)
|
||||||
self.treeBox.addWidget(self.docDetails)
|
self.treeBox.addWidget(self.treeMeta)
|
||||||
self.treePane.setLayout(self.treeBox)
|
self.treePane.setLayout(self.treeBox)
|
||||||
|
|
||||||
self.docPane = QFrame()
|
self.editPane = QFrame()
|
||||||
|
self.docEdit = QVBoxLayout()
|
||||||
|
self.docEdit.setContentsMargins(0,0,0,0)
|
||||||
|
self.docEdit.addWidget(self.searchBar)
|
||||||
|
self.docEdit.addWidget(self.noticeBar)
|
||||||
|
self.docEdit.addWidget(self.docEditor)
|
||||||
|
self.editPane.setLayout(self.docEdit)
|
||||||
|
|
||||||
|
self.viewPane = QFrame()
|
||||||
self.docView = QVBoxLayout()
|
self.docView = QVBoxLayout()
|
||||||
self.docView.setContentsMargins(0,0,0,0)
|
self.docView.setContentsMargins(0,0,0,0)
|
||||||
self.docView.addWidget(self.searchBar)
|
self.docView.addWidget(self.docViewer)
|
||||||
self.docView.addWidget(self.noticeBar)
|
self.docView.addWidget(self.docMeta)
|
||||||
self.docView.addWidget(self.docEditor)
|
self.viewPane.setLayout(self.docView)
|
||||||
self.docPane.setLayout(self.docView)
|
|
||||||
|
|
||||||
self.splitView = QSplitter(Qt.Horizontal)
|
self.splitView = QSplitter(Qt.Horizontal)
|
||||||
self.splitView.addWidget(self.docPane)
|
self.splitView.addWidget(self.editPane)
|
||||||
self.splitView.addWidget(self.docViewer)
|
self.splitView.addWidget(self.viewPane)
|
||||||
self.splitView.splitterMoved.connect(self._splitViewMove)
|
self.splitView.splitterMoved.connect(self._splitViewMove)
|
||||||
|
|
||||||
self.splitMain = QSplitter(Qt.Horizontal)
|
self.splitMain = QSplitter(Qt.Horizontal)
|
||||||
@@ -117,15 +126,15 @@ class GuiMain(QMainWindow):
|
|||||||
|
|
||||||
self.idxTree = self.splitMain.indexOf(self.treePane)
|
self.idxTree = self.splitMain.indexOf(self.treePane)
|
||||||
self.idxMain = self.splitMain.indexOf(self.splitView)
|
self.idxMain = self.splitMain.indexOf(self.splitView)
|
||||||
self.idxEditor = self.splitView.indexOf(self.docPane)
|
self.idxEditor = self.splitView.indexOf(self.editPane)
|
||||||
self.idxViewer = self.splitView.indexOf(self.docViewer)
|
self.idxViewer = self.splitView.indexOf(self.viewPane)
|
||||||
|
|
||||||
self.splitMain.setCollapsible(self.idxTree, False)
|
self.splitMain.setCollapsible(self.idxTree, False)
|
||||||
self.splitMain.setCollapsible(self.idxMain, False)
|
self.splitMain.setCollapsible(self.idxMain, False)
|
||||||
self.splitView.setCollapsible(self.idxEditor, False)
|
self.splitView.setCollapsible(self.idxEditor, False)
|
||||||
self.splitView.setCollapsible(self.idxViewer, True)
|
self.splitView.setCollapsible(self.idxViewer, True)
|
||||||
|
|
||||||
self.docViewer.setVisible(False)
|
self.viewPane.setVisible(False)
|
||||||
self.searchBar.setVisible(False)
|
self.searchBar.setVisible(False)
|
||||||
|
|
||||||
# Build The Tree View
|
# Build The Tree View
|
||||||
@@ -365,9 +374,9 @@ class GuiMain(QMainWindow):
|
|||||||
logger.debug("No document selected, giving up")
|
logger.debug("No document selected, giving up")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if self.docViewer.loadText(tHandle) and not self.docViewer.isVisible():
|
if self.docViewer.loadText(tHandle) and not self.viewPane.isVisible():
|
||||||
bPos = self.splitMain.sizes()
|
bPos = self.splitMain.sizes()
|
||||||
self.docViewer.setVisible(True)
|
self.viewPane.setVisible(True)
|
||||||
vPos = [0,0]
|
vPos = [0,0]
|
||||||
vPos[0] = int(bPos[1]/2)
|
vPos[0] = int(bPos[1]/2)
|
||||||
vPos[1] = bPos[1]-vPos[0]
|
vPos[1] = bPos[1]-vPos[0]
|
||||||
@@ -669,11 +678,11 @@ class GuiMain(QMainWindow):
|
|||||||
self.docViewer.clearViewer()
|
self.docViewer.clearViewer()
|
||||||
self.theProject.setLastViewed(None)
|
self.theProject.setLastViewed(None)
|
||||||
bPos = self.splitMain.sizes()
|
bPos = self.splitMain.sizes()
|
||||||
self.docViewer.setVisible(False)
|
self.viewPane.setVisible(False)
|
||||||
vPos = [bPos[1],0]
|
vPos = [bPos[1],0]
|
||||||
self.splitView.setSizes(vPos)
|
self.splitView.setSizes(vPos)
|
||||||
self.docEditor.changeWidth()
|
self.docEditor.changeWidth()
|
||||||
return not self.docViewer.isVisible()
|
return not self.viewPane.isVisible()
|
||||||
|
|
||||||
##
|
##
|
||||||
# Internal Functions
|
# Internal Functions
|
||||||
@@ -739,7 +748,7 @@ class GuiMain(QMainWindow):
|
|||||||
def _treeSingleClick(self):
|
def _treeSingleClick(self):
|
||||||
sHandle = self.treeView.getSelectedHandle()
|
sHandle = self.treeView.getSelectedHandle()
|
||||||
if sHandle is not None:
|
if sHandle is not None:
|
||||||
self.docDetails.buildViewBox(sHandle)
|
self.treeMeta.buildViewBox(sHandle)
|
||||||
return
|
return
|
||||||
|
|
||||||
def _treeDoubleClick(self, tItem, colNo):
|
def _treeDoubleClick(self, tItem, colNo):
|
||||||
|
|||||||
@@ -319,6 +319,28 @@ class NWIndex():
|
|||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def buildReferenceList(self, theHandle):
|
||||||
|
|
||||||
|
theRefs = {}
|
||||||
|
|
||||||
|
tItem = self.theProject.getItem(theHandle)
|
||||||
|
if theHandle is None:
|
||||||
|
return theRefs
|
||||||
|
|
||||||
|
theTag = None
|
||||||
|
for tTag in self.tagIndex:
|
||||||
|
if theHandle == self.tagIndex[tTag][1]:
|
||||||
|
theTag = tTag
|
||||||
|
break
|
||||||
|
|
||||||
|
if theTag is not None:
|
||||||
|
for tHandle in self.refIndex:
|
||||||
|
for nLine, tKey, tTag, nTitle in self.refIndex[tHandle]:
|
||||||
|
if tTag == theTag:
|
||||||
|
theRefs[tHandle] = nLine
|
||||||
|
|
||||||
|
return theRefs
|
||||||
|
|
||||||
def buildTagNovelMap(self, theTags, theFilters=None):
|
def buildTagNovelMap(self, theTags, theFilters=None):
|
||||||
|
|
||||||
tagMap = {}
|
tagMap = {}
|
||||||
|
|||||||
Reference in New Issue
Block a user