Add entity as another root folder type
This commit is contained in:
@@ -32,6 +32,20 @@ class nwFiles():
|
||||
|
||||
# END Class nwFiles
|
||||
|
||||
class nwKeyWords:
|
||||
|
||||
TAG_KEY = "@tag"
|
||||
POV_KEY = "@pov"
|
||||
CHAR_KEY = "@char"
|
||||
PLOT_KEY = "@plot"
|
||||
TIME_KEY = "@time"
|
||||
WORLD_KEY = "@location"
|
||||
OBJECT_KEY = "@object"
|
||||
ENTITY_KEY = "@entity"
|
||||
CUSTOM_KEY = "@custom"
|
||||
|
||||
# END Class nwKeyWords
|
||||
|
||||
class nwLabels():
|
||||
|
||||
CLASS_NAME = {
|
||||
@@ -42,6 +56,7 @@ class nwLabels():
|
||||
nwItemClass.WORLD : "Locations",
|
||||
nwItemClass.TIMELINE : "Timeline",
|
||||
nwItemClass.OBJECT : "Objects",
|
||||
nwItemClass.ENTITY : "Entity",
|
||||
nwItemClass.CUSTOM : "Custom",
|
||||
nwItemClass.TRASH : "Trash",
|
||||
}
|
||||
@@ -53,6 +68,7 @@ class nwLabels():
|
||||
nwItemClass.WORLD : "L",
|
||||
nwItemClass.TIMELINE : "T",
|
||||
nwItemClass.OBJECT : "O",
|
||||
nwItemClass.ENTITY : "E",
|
||||
nwItemClass.CUSTOM : "X",
|
||||
nwItemClass.TRASH : "R",
|
||||
}
|
||||
@@ -78,6 +94,17 @@ class nwLabels():
|
||||
nwItemLayout.SCENE : "Sc",
|
||||
nwItemLayout.NOTE : "Nt",
|
||||
}
|
||||
KEY_NAME = {
|
||||
nwKeyWords.TAG_KEY : "Tag",
|
||||
nwKeyWords.POV_KEY : "Point of View",
|
||||
nwKeyWords.CHAR_KEY : "Characters",
|
||||
nwKeyWords.PLOT_KEY : "Plot",
|
||||
nwKeyWords.TIME_KEY : "Time",
|
||||
nwKeyWords.WORLD_KEY : "Locations",
|
||||
nwKeyWords.OBJECT_KEY : "Objects",
|
||||
nwKeyWords.ENTITY_KEY : "Entities",
|
||||
nwKeyWords.CUSTOM_KEY : "Custom",
|
||||
}
|
||||
|
||||
# END Class nwLabels
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ import re
|
||||
import nw
|
||||
|
||||
from nw.convert.tokenizer import Tokenizer
|
||||
from nw.constants import nwUnicode
|
||||
from nw.constants import nwUnicode, nwLabels
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -134,17 +134,6 @@ class ToHtml(Tokenizer):
|
||||
if not self.forPreview:
|
||||
return "<pre>@%s</pre>\n" % tText
|
||||
|
||||
theLabel = {
|
||||
"@tag" : "Tag",
|
||||
"@pov" : "Point of View",
|
||||
"@char" : "Character(s)",
|
||||
"@plot" : "Plot",
|
||||
"@time" : "Time",
|
||||
"@location" : "Location(s)",
|
||||
"@object" : "Object(s)",
|
||||
"@custom" : "Custom",
|
||||
}
|
||||
|
||||
tText = "@"+tText
|
||||
isValid, theBits, thePos = self.theParent.theIndex.scanThis(tText)
|
||||
if not isValid or not theBits:
|
||||
@@ -152,8 +141,8 @@ class ToHtml(Tokenizer):
|
||||
|
||||
retText = ""
|
||||
refTags = []
|
||||
if theBits[0] in theLabel:
|
||||
retText += "<span class='tags'>%s:</span> " % theLabel[theBits[0]]
|
||||
if theBits[0] in nwLabels.KEY_NAME:
|
||||
retText += "<span class='tags'>%s:</span> " % nwLabels.KEY_NAME[theBits[0]]
|
||||
for tTag in theBits[1:]:
|
||||
refTags.append("<a href='#%s=%s'>%s</a>" % (
|
||||
theBits[0][1:], tTag, tTag
|
||||
|
||||
+3
-2
@@ -31,8 +31,9 @@ class nwItemClass(Enum):
|
||||
WORLD = 4
|
||||
TIMELINE = 5
|
||||
OBJECT = 6
|
||||
CUSTOM = 7
|
||||
TRASH = 8
|
||||
ENTITY = 7
|
||||
CUSTOM = 8
|
||||
TRASH = 9
|
||||
|
||||
# END Enum nwItemClass
|
||||
|
||||
|
||||
@@ -235,6 +235,7 @@ class GuiMainMenu(QMenuBar):
|
||||
self.rootItems[nwItemClass.WORLD] = QAction("Location Root", rootMenu)
|
||||
self.rootItems[nwItemClass.TIMELINE] = QAction("Timeline Root", rootMenu)
|
||||
self.rootItems[nwItemClass.OBJECT] = QAction("Object Root", rootMenu)
|
||||
self.rootItems[nwItemClass.ENTITY] = QAction("Entity Root", rootMenu)
|
||||
self.rootItems[nwItemClass.CUSTOM] = QAction("Custom Root", rootMenu)
|
||||
nCount = 0
|
||||
for itemClass in self.rootItems.keys():
|
||||
|
||||
+24
-25
@@ -18,33 +18,33 @@ from os import path
|
||||
|
||||
from nw.project.document import NWDoc
|
||||
from nw.enum import nwItemType, nwItemClass, nwItemLayout
|
||||
from nw.constants import nwFiles
|
||||
from nw.constants import nwFiles, nwKeyWords
|
||||
from nw.enum import nwAlert
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
class NWIndex():
|
||||
|
||||
TAG_KEY = "@tag"
|
||||
POV_KEY = "@pov"
|
||||
CHAR_KEY = "@char"
|
||||
PLOT_KEY = "@plot"
|
||||
TIME_KEY = "@time"
|
||||
WORLD_KEY = "@location"
|
||||
OBJECT_KEY = "@object"
|
||||
CUSTOM_KEY = "@custom"
|
||||
|
||||
NOTE_KEYS = [TAG_KEY]
|
||||
NOVEL_KEYS = [PLOT_KEY, POV_KEY, CHAR_KEY, WORLD_KEY, TIME_KEY, OBJECT_KEY, CUSTOM_KEY]
|
||||
VALID_KEYS = [TAG_KEY, PLOT_KEY, POV_KEY, CHAR_KEY, WORLD_KEY, TIME_KEY, OBJECT_KEY, CUSTOM_KEY]
|
||||
VALID_KEYS = [
|
||||
nwKeyWords.TAG_KEY,
|
||||
nwKeyWords.PLOT_KEY,
|
||||
nwKeyWords.POV_KEY,
|
||||
nwKeyWords.CHAR_KEY,
|
||||
nwKeyWords.WORLD_KEY,
|
||||
nwKeyWords.TIME_KEY,
|
||||
nwKeyWords.OBJECT_KEY,
|
||||
nwKeyWords.ENTITY_KEY,
|
||||
nwKeyWords.CUSTOM_KEY
|
||||
]
|
||||
TAG_CLASS = {
|
||||
CHAR_KEY : [nwItemClass.CHARACTER, 1],
|
||||
POV_KEY : [nwItemClass.CHARACTER, 2],
|
||||
PLOT_KEY : [nwItemClass.PLOT, 1],
|
||||
TIME_KEY : [nwItemClass.TIMELINE, 1],
|
||||
WORLD_KEY : [nwItemClass.WORLD, 1],
|
||||
OBJECT_KEY : [nwItemClass.OBJECT, 1],
|
||||
CUSTOM_KEY : [nwItemClass.CUSTOM, 1],
|
||||
nwKeyWords.CHAR_KEY : [nwItemClass.CHARACTER, 1],
|
||||
nwKeyWords.POV_KEY : [nwItemClass.CHARACTER, 2],
|
||||
nwKeyWords.PLOT_KEY : [nwItemClass.PLOT, 1],
|
||||
nwKeyWords.TIME_KEY : [nwItemClass.TIMELINE, 1],
|
||||
nwKeyWords.WORLD_KEY : [nwItemClass.WORLD, 1],
|
||||
nwKeyWords.OBJECT_KEY : [nwItemClass.OBJECT, 1],
|
||||
nwKeyWords.ENTITY_KEY : [nwItemClass.ENTITY, 1],
|
||||
nwKeyWords.CUSTOM_KEY : [nwItemClass.CUSTOM, 1],
|
||||
}
|
||||
|
||||
def __init__(self, theProject, theParent):
|
||||
@@ -275,10 +275,9 @@ class NWIndex():
|
||||
if not isValid or len(theBits) == 0:
|
||||
return False
|
||||
|
||||
theKey = theBits[0]
|
||||
if theKey in self.NOVEL_KEYS:
|
||||
if theBits[0] != nwKeyWords.TAG_KEY:
|
||||
for aVal in theBits[1:]:
|
||||
self.refIndex[tHandle].append([nLine, theKey, aVal, nTitle])
|
||||
self.refIndex[tHandle].append([nLine, theBits[0], aVal, nTitle])
|
||||
|
||||
return True
|
||||
|
||||
@@ -290,7 +289,7 @@ class NWIndex():
|
||||
if not isValid or len(theBits) != 2:
|
||||
return False
|
||||
|
||||
if theBits[0] == self.TAG_KEY:
|
||||
if theBits[0] == nwKeyWords.TAG_KEY:
|
||||
self.tagIndex[theBits[1]] = [nLine, tHandle, itemClass.name]
|
||||
|
||||
return True
|
||||
@@ -355,7 +354,7 @@ class NWIndex():
|
||||
return isGood
|
||||
|
||||
# If we have a tag, only the first value is accepted, the rest is ignored
|
||||
if theBits[0] == self.TAG_KEY and nBits > 1:
|
||||
if theBits[0] == nwKeyWords.TAG_KEY and nBits > 1:
|
||||
isGood[0] = True
|
||||
if theBits[1] in self.tagIndex.keys():
|
||||
if self.tagIndex[theBits[1]][1] == tItem.itemHandle:
|
||||
|
||||
Reference in New Issue
Block a user