Add a new constants class named nwLists

This commit is contained in:
Veronica K. B. Olsen
2021-01-06 21:53:42 +01:00
parent b5eef748b4
commit 4a4ac1d6c8
3 changed files with 23 additions and 13 deletions
+10 -9
View File
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from nw.constants.iso import isoLanguage, isoCountry from nw.constants.iso import isoLanguage, isoCountry
from nw.constants.constants import ( from nw.constants.constants import (
nwConst, nwRegEx, nwFiles, nwKeyWords, nwLabels, nwQuotes, nwUnicode nwConst, nwLists, nwRegEx, nwFiles, nwKeyWords, nwLabels, nwQuotes, nwUnicode
) )
from nw.constants.enum import ( from nw.constants.enum import (
nwAlert, nwDocAction, nwItemClass, nwItemLayout, nwItemType, nwOutline, nwAlert, nwDocAction, nwItemClass, nwItemLayout, nwItemType, nwOutline,
@@ -11,18 +11,19 @@ from nw.constants.enum import (
__all__ = [ __all__ = [
"isoCountry", "isoCountry",
"isoLanguage", "isoLanguage",
"nwAlert",
"nwConst", "nwConst",
"nwDocAction", "nwLists",
"nwDocInsert", "nwRegEx",
"nwFiles", "nwFiles",
"nwKeyWords",
"nwLabels",
"nwQuotes",
"nwUnicode",
"nwAlert",
"nwDocAction",
"nwItemClass", "nwItemClass",
"nwItemLayout", "nwItemLayout",
"nwItemType", "nwItemType",
"nwKeyWords",
"nwLabels",
"nwOutline", "nwOutline",
"nwQuotes", "nwDocInsert",
"nwRegEx",
"nwUnicode",
] ]
+11 -2
View File
@@ -45,10 +45,19 @@ class nwConst():
SP_INTERNAL = "internal" SP_INTERNAL = "internal"
SP_ENCHANT = "enchant" SP_ENCHANT = "enchant"
# Check Lists # END Class nwConst
class nwLists():
"""Lists used for grouping various other constants.
"""
# Regular user-accessible item types
REG_TYPES = {nwItemType.ROOT, nwItemType.FOLDER, nwItemType.FILE} REG_TYPES = {nwItemType.ROOT, nwItemType.FOLDER, nwItemType.FILE}
# END Class nwConst # Item classes where the full list of novel layouts are allowed
CLS_NOVEL = {nwItemClass.NOVEL, nwItemClass.ARCHIVE}
# END Class nwLists
class nwRegEx(): class nwRegEx():
+2 -2
View File
@@ -47,7 +47,7 @@ from nw.gui import (
GuiTheme, GuiWritingStats GuiTheme, GuiWritingStats
) )
from nw.core import NWProject, NWDoc, NWIndex from nw.core import NWProject, NWDoc, NWIndex
from nw.constants import nwItemType, nwItemClass, nwAlert, nwConst from nw.constants import nwItemType, nwItemClass, nwAlert, nwLists
from nw.common import getGuiItem from nw.common import getGuiItem
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@@ -725,7 +725,7 @@ class GuiMain(QMainWindow):
tItem = self.theProject.projTree[tHandle] tItem = self.theProject.projTree[tHandle]
if tItem is None: if tItem is None:
return return
if tItem.itemType not in nwConst.REG_TYPES: if tItem.itemType not in nwLists.REG_TYPES:
return return
logger.verbose("Requesting change to item %s" % tHandle) logger.verbose("Requesting change to item %s" % tHandle)