Move outline generation to Tokenizer class instead
This commit is contained in:
@@ -41,13 +41,13 @@ from PyQt5.QtWidgets import (
|
||||
)
|
||||
|
||||
from novelwriter import CONFIG, SHARED
|
||||
from novelwriter.constants import nwHeaders, nwUnicode
|
||||
from novelwriter.core.tohtml import ToHtml
|
||||
from novelwriter.enum import nwItemType, nwDocAction, nwDocMode
|
||||
from novelwriter.error import logException
|
||||
from novelwriter.constants import nwHeaders, nwUnicode
|
||||
from novelwriter.extensions.eventfilters import WheelEventFilter
|
||||
from novelwriter.extensions.modified import NIconToolButton
|
||||
from novelwriter.gui.theme import STYLES_MIN_TOOLBUTTON
|
||||
from novelwriter.core.tohtml import ToHtml
|
||||
from novelwriter.extensions.eventfilters import WheelEventFilter
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -633,7 +633,7 @@ class GuiDocViewHeader(QWidget):
|
||||
|
||||
# Internal Variables
|
||||
self._docHandle = None
|
||||
self._docOutline: dict[int, tuple[str, int]] = {}
|
||||
self._docOutline: dict[str, tuple[str, int]] = {}
|
||||
|
||||
iPx = SHARED.theme.baseIconSize
|
||||
mPx = CONFIG.pxInt(4)
|
||||
@@ -730,7 +730,7 @@ class GuiDocViewHeader(QWidget):
|
||||
self.refreshButton.setVisible(False)
|
||||
return
|
||||
|
||||
def setOutline(self, data: dict[int, tuple[str, int]]) -> None:
|
||||
def setOutline(self, data: dict[str, tuple[str, int]]) -> None:
|
||||
"""Set the document outline dataset."""
|
||||
tHandle = self._docHandle
|
||||
if data != self._docOutline and tHandle:
|
||||
|
||||
@@ -23,10 +23,10 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Generator
|
||||
import logging
|
||||
|
||||
from time import time
|
||||
from collections.abc import Iterable
|
||||
|
||||
from PyQt5.QtGui import QTextBlock, QTextCursor, QTextDocument
|
||||
from PyQt5.QtCore import QObject, pyqtSlot
|
||||
@@ -114,7 +114,7 @@ class GuiTextDocument(QTextDocument):
|
||||
return word, cPos, cLen, SHARED.spelling.suggestWords(word)
|
||||
return "", -1, -1, []
|
||||
|
||||
def iterBlockByType(self, cType: int, maxCount: int = 1000) -> Generator[QTextBlock]:
|
||||
def iterBlockByType(self, cType: int, maxCount: int = 1000) -> Iterable[QTextBlock]:
|
||||
"""Iterate over all text blocks of a given type."""
|
||||
count = 0
|
||||
for i in range(self.blockCount()):
|
||||
|
||||
Reference in New Issue
Block a user