Move some variables around
This commit is contained in:
@@ -29,8 +29,8 @@ from enum import Enum
|
||||
|
||||
from PyQt5.QtCore import QModelIndex, Qt, pyqtSignal, pyqtSlot
|
||||
from PyQt5.QtWidgets import (
|
||||
QAbstractItemView, QFrame, QHeaderView, QMenu, QTabWidget, QToolButton,
|
||||
QTreeWidget, QTreeWidgetItem, QVBoxLayout, QWidget
|
||||
QAbstractItemView, QFrame, QMenu, QTabWidget, QToolButton, QTreeWidget,
|
||||
QTreeWidgetItem, QVBoxLayout, QWidget
|
||||
)
|
||||
|
||||
from novelwriter import CONFIG, SHARED
|
||||
@@ -40,7 +40,7 @@ from novelwriter.core.index import IndexHeading, IndexItem
|
||||
from novelwriter.enum import nwDocMode, nwItemClass
|
||||
from novelwriter.extensions.modified import NIconToolButton
|
||||
from novelwriter.gui.theme import STYLES_FLAT_TABS, STYLES_MIN_TOOLBUTTON
|
||||
from novelwriter.types import QtDecoration, QtUserRole
|
||||
from novelwriter.types import QtDecoration, QtHeaderFixed, QtHeaderToContents, QtUserRole
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -259,10 +259,10 @@ class _ViewPanelBackRefs(QTreeWidget):
|
||||
treeHeader = self.header()
|
||||
treeHeader.setStretchLastSection(True)
|
||||
treeHeader.setMinimumSectionSize(iPx + cMg) # See Issue #1627
|
||||
treeHeader.setSectionResizeMode(self.C_DOC, QHeaderView.ResizeMode.ResizeToContents)
|
||||
treeHeader.setSectionResizeMode(self.C_EDIT, QHeaderView.ResizeMode.Fixed)
|
||||
treeHeader.setSectionResizeMode(self.C_VIEW, QHeaderView.ResizeMode.Fixed)
|
||||
treeHeader.setSectionResizeMode(self.C_TITLE, QHeaderView.ResizeMode.ResizeToContents)
|
||||
treeHeader.setSectionResizeMode(self.C_DOC, QtHeaderToContents)
|
||||
treeHeader.setSectionResizeMode(self.C_EDIT, QtHeaderFixed)
|
||||
treeHeader.setSectionResizeMode(self.C_VIEW, QtHeaderFixed)
|
||||
treeHeader.setSectionResizeMode(self.C_TITLE, QtHeaderToContents)
|
||||
treeHeader.resizeSection(self.C_EDIT, iPx + cMg)
|
||||
treeHeader.resizeSection(self.C_VIEW, iPx + cMg)
|
||||
treeHeader.setSectionsMovable(False)
|
||||
@@ -407,8 +407,8 @@ class _ViewPanelKeyWords(QTreeWidget):
|
||||
treeHeader = self.header()
|
||||
treeHeader.setStretchLastSection(True)
|
||||
treeHeader.setMinimumSectionSize(iPx + cMg) # See Issue #1627
|
||||
treeHeader.setSectionResizeMode(self.C_EDIT, QHeaderView.ResizeMode.Fixed)
|
||||
treeHeader.setSectionResizeMode(self.C_VIEW, QHeaderView.ResizeMode.Fixed)
|
||||
treeHeader.setSectionResizeMode(self.C_EDIT, QtHeaderFixed)
|
||||
treeHeader.setSectionResizeMode(self.C_VIEW, QtHeaderFixed)
|
||||
treeHeader.resizeSection(self.C_EDIT, iPx + cMg)
|
||||
treeHeader.resizeSection(self.C_VIEW, iPx + cMg)
|
||||
treeHeader.setSectionsMovable(False)
|
||||
|
||||
@@ -33,9 +33,8 @@ from time import time
|
||||
from PyQt5.QtCore import QModelIndex, QPoint, Qt, pyqtSignal, pyqtSlot
|
||||
from PyQt5.QtGui import QFocusEvent, QFont, QMouseEvent, QPalette, QResizeEvent
|
||||
from PyQt5.QtWidgets import (
|
||||
QAbstractItemView, QActionGroup, QFrame, QHBoxLayout, QHeaderView,
|
||||
QInputDialog, QMenu, QToolTip, QTreeWidget, QTreeWidgetItem, QVBoxLayout,
|
||||
QWidget
|
||||
QAbstractItemView, QActionGroup, QFrame, QHBoxLayout, QInputDialog, QMenu,
|
||||
QToolTip, QTreeWidget, QTreeWidgetItem, QVBoxLayout, QWidget
|
||||
)
|
||||
|
||||
from novelwriter import CONFIG, SHARED
|
||||
@@ -47,8 +46,9 @@ from novelwriter.extensions.modified import NIconToolButton
|
||||
from novelwriter.extensions.novelselector import NovelSelector
|
||||
from novelwriter.gui.theme import STYLES_MIN_TOOLBUTTON
|
||||
from novelwriter.types import (
|
||||
QtAlignRight, QtDecoration, QtMouseLeft, QtMouseMiddle, QtScrollAlwaysOff,
|
||||
QtScrollAsNeeded, QtSizeExpanding, QtUserRole
|
||||
QtAlignRight, QtDecoration, QtHeaderStretch, QtHeaderToContents,
|
||||
QtMouseLeft, QtMouseMiddle, QtScrollAlwaysOff, QtScrollAsNeeded,
|
||||
QtSizeExpanding, QtUserRole
|
||||
)
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -406,10 +406,10 @@ class GuiNovelTree(QTreeWidget):
|
||||
treeHeader = self.header()
|
||||
treeHeader.setStretchLastSection(False)
|
||||
treeHeader.setMinimumSectionSize(iPx + cMg)
|
||||
treeHeader.setSectionResizeMode(self.C_TITLE, QHeaderView.ResizeMode.Stretch)
|
||||
treeHeader.setSectionResizeMode(self.C_WORDS, QHeaderView.ResizeMode.ResizeToContents)
|
||||
treeHeader.setSectionResizeMode(self.C_EXTRA, QHeaderView.ResizeMode.ResizeToContents)
|
||||
treeHeader.setSectionResizeMode(self.C_MORE, QHeaderView.ResizeMode.ResizeToContents)
|
||||
treeHeader.setSectionResizeMode(self.C_TITLE, QtHeaderStretch)
|
||||
treeHeader.setSectionResizeMode(self.C_WORDS, QtHeaderToContents)
|
||||
treeHeader.setSectionResizeMode(self.C_EXTRA, QtHeaderToContents)
|
||||
treeHeader.setSectionResizeMode(self.C_MORE, QtHeaderToContents)
|
||||
|
||||
# Pre-Generate Tree Formatting
|
||||
fH1 = self.font()
|
||||
|
||||
+12
-58
@@ -34,8 +34,8 @@ from enum import Enum
|
||||
from PyQt5.QtCore import QModelIndex, QPoint, Qt, pyqtSignal, pyqtSlot
|
||||
from PyQt5.QtGui import QIcon, QMouseEvent, QPalette
|
||||
from PyQt5.QtWidgets import (
|
||||
QAbstractItemView, QAction, QFrame, QHBoxLayout, QHeaderView, QLabel,
|
||||
QMenu, QShortcut, QTreeView, QVBoxLayout, QWidget
|
||||
QAbstractItemView, QAction, QFrame, QHBoxLayout, QLabel, QMenu, QShortcut,
|
||||
QTreeView, QVBoxLayout, QWidget
|
||||
)
|
||||
|
||||
from novelwriter import CONFIG, SHARED
|
||||
@@ -48,8 +48,8 @@ from novelwriter.enum import nwDocMode, nwItemClass, nwItemType
|
||||
from novelwriter.extensions.modified import NIconToolButton
|
||||
from novelwriter.gui.theme import STYLES_MIN_TOOLBUTTON
|
||||
from novelwriter.types import (
|
||||
QtMouseLeft, QtMouseMiddle, QtScrollAlwaysOff, QtScrollAsNeeded,
|
||||
QtSizeExpanding
|
||||
QtHeaderFixed, QtHeaderStretch, QtHeaderToContents, QtMouseLeft,
|
||||
QtMouseMiddle, QtScrollAlwaysOff, QtScrollAsNeeded, QtSizeExpanding
|
||||
)
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -226,8 +226,8 @@ class GuiProjectView(QWidget):
|
||||
@pyqtSlot(str)
|
||||
def updateItemValues(self, tHandle: str) -> None:
|
||||
"""Update tree item."""
|
||||
if nwItem := SHARED.project.tree[tHandle]:
|
||||
self.projTree.setTreeItemValues(nwItem)
|
||||
# if nwItem := SHARED.project.tree[tHandle]:
|
||||
# self.projTree.setTreeItemValues(nwItem)
|
||||
return
|
||||
|
||||
@pyqtSlot(str)
|
||||
@@ -496,15 +496,6 @@ class GuiProjectToolBar(QWidget):
|
||||
|
||||
class GuiProjectTree(QTreeView):
|
||||
|
||||
# C_DATA = 0
|
||||
C_NAME = 0
|
||||
C_COUNT = 1
|
||||
C_ACTIVE = 2
|
||||
C_STATUS = 3
|
||||
|
||||
# D_HANDLE = QtUserRole
|
||||
# D_WORDS = QtUserRole + 1
|
||||
|
||||
itemRefreshed = pyqtSignal(str, NWItem, QIcon)
|
||||
|
||||
def __init__(self, projView: GuiProjectView) -> None:
|
||||
@@ -612,12 +603,12 @@ class GuiProjectTree(QTreeView):
|
||||
treeHeader = self.header()
|
||||
treeHeader.setStretchLastSection(False)
|
||||
treeHeader.setMinimumSectionSize(iPx + cMg)
|
||||
treeHeader.setSectionResizeMode(self.C_NAME, QHeaderView.ResizeMode.Stretch)
|
||||
treeHeader.setSectionResizeMode(self.C_COUNT, QHeaderView.ResizeMode.ResizeToContents)
|
||||
treeHeader.setSectionResizeMode(self.C_ACTIVE, QHeaderView.ResizeMode.Fixed)
|
||||
treeHeader.setSectionResizeMode(self.C_STATUS, QHeaderView.ResizeMode.Fixed)
|
||||
treeHeader.resizeSection(self.C_ACTIVE, iPx + cMg)
|
||||
treeHeader.resizeSection(self.C_STATUS, iPx + cMg)
|
||||
treeHeader.setSectionResizeMode(ProjectNode.C_NAME, QtHeaderStretch)
|
||||
treeHeader.setSectionResizeMode(ProjectNode.C_COUNT, QtHeaderToContents)
|
||||
treeHeader.setSectionResizeMode(ProjectNode.C_ACTIVE, QtHeaderFixed)
|
||||
treeHeader.setSectionResizeMode(ProjectNode.C_STATUS, QtHeaderFixed)
|
||||
treeHeader.resizeSection(ProjectNode.C_ACTIVE, iPx + cMg)
|
||||
treeHeader.resizeSection(ProjectNode.C_STATUS, iPx + cMg)
|
||||
|
||||
self.restoreExpandedState()
|
||||
|
||||
@@ -955,43 +946,6 @@ class GuiProjectTree(QTreeView):
|
||||
# self.setTreeItemValues(nwItem)
|
||||
return
|
||||
|
||||
def setTreeItemValues(self, nwItem: NWItem | None) -> None:
|
||||
"""Set the name and flag values for a tree item in the project
|
||||
tree. Does not trigger a tree change as the data is already
|
||||
coming from project data.
|
||||
"""
|
||||
# if isinstance(nwItem, NWItem) and (trItem := self._getTreeItem(nwItem.itemHandle)):
|
||||
# itemStatus, statusIcon = nwItem.getImportStatus()
|
||||
# hLevel = nwItem.mainHeading
|
||||
# itemIcon = SHARED.theme.getItemIcon(
|
||||
# nwItem.itemType, nwItem.itemClass, nwItem.itemLayout, hLevel
|
||||
# )
|
||||
|
||||
# trItem.setIcon(self.C_NAME, itemIcon)
|
||||
# trItem.setText(self.C_NAME, nwItem.itemName)
|
||||
# trItem.setIcon(self.C_STATUS, statusIcon)
|
||||
# trItem.setToolTip(self.C_STATUS, itemStatus)
|
||||
|
||||
# if nwItem.isFileType():
|
||||
# iconName = "checked" if nwItem.isActive else "unchecked"
|
||||
# toolTip = self.trActive if nwItem.isActive else self.trInactive
|
||||
# trItem.setToolTip(self.C_ACTIVE, toolTip)
|
||||
# else:
|
||||
# iconName = "noncheckable"
|
||||
|
||||
# trItem.setIcon(self.C_ACTIVE, SHARED.theme.getIcon(iconName))
|
||||
|
||||
# if CONFIG.emphLabels and nwItem.isDocumentLayout():
|
||||
# trFont = trItem.font(self.C_NAME)
|
||||
# trFont.setBold(hLevel == "H1" or hLevel == "H2")
|
||||
# trFont.setUnderline(hLevel == "H1")
|
||||
# trItem.setFont(self.C_NAME, trFont)
|
||||
|
||||
# # Emit Refresh Signal
|
||||
# self.itemRefreshed.emit(nwItem.itemHandle, nwItem, itemIcon)
|
||||
|
||||
return
|
||||
|
||||
def propagateCount(self, tHandle: str, newCount: int, countChildren: bool = False) -> None:
|
||||
"""Recursive function setting the word count for a given item,
|
||||
and propagating that count upwards in the tree until reaching a
|
||||
|
||||
@@ -30,15 +30,18 @@ from time import time
|
||||
from PyQt5.QtCore import Qt, pyqtSignal, pyqtSlot
|
||||
from PyQt5.QtGui import QCursor, QKeyEvent
|
||||
from PyQt5.QtWidgets import (
|
||||
QApplication, QFrame, QHBoxLayout, QHeaderView, QLabel, QLineEdit,
|
||||
QToolBar, QTreeWidget, QTreeWidgetItem, QVBoxLayout, QWidget
|
||||
QApplication, QFrame, QHBoxLayout, QLabel, QLineEdit, QToolBar,
|
||||
QTreeWidget, QTreeWidgetItem, QVBoxLayout, QWidget
|
||||
)
|
||||
|
||||
from novelwriter import CONFIG, SHARED
|
||||
from novelwriter.common import checkInt, cssCol
|
||||
from novelwriter.core.coretools import DocSearch
|
||||
from novelwriter.core.item import NWItem
|
||||
from novelwriter.types import QtAlignMiddle, QtAlignRight, QtUserRole
|
||||
from novelwriter.types import (
|
||||
QtAlignMiddle, QtAlignRight, QtHeaderStretch, QtHeaderToContents,
|
||||
QtUserRole
|
||||
)
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -120,8 +123,8 @@ class GuiProjectSearch(QWidget):
|
||||
|
||||
treeHeader = self.searchResult.header()
|
||||
treeHeader.setStretchLastSection(False)
|
||||
treeHeader.setSectionResizeMode(self.C_NAME, QHeaderView.ResizeMode.Stretch)
|
||||
treeHeader.setSectionResizeMode(self.C_COUNT, QHeaderView.ResizeMode.ResizeToContents)
|
||||
treeHeader.setSectionResizeMode(self.C_NAME, QtHeaderStretch)
|
||||
treeHeader.setSectionResizeMode(self.C_COUNT, QtHeaderToContents)
|
||||
|
||||
# Assemble
|
||||
self.headerBox = QHBoxLayout()
|
||||
|
||||
Reference in New Issue
Block a user