diff --git a/nw/gui/timelineview.py b/nw/gui/timelineview.py index a6acf870..2920623d 100644 --- a/nw/gui/timelineview.py +++ b/nw/gui/timelineview.py @@ -84,11 +84,6 @@ class GuiTimeLineView(QDialog): self.theMatrix["tags"].append(tTag) self.numCols += 1 - # theTable = [[0]*(self.numCols-1)]*(self.numRows-1) - - # for i in range(self.numCols): - # for j in range(self.numRows): - return def _buildNovelList(self): @@ -105,18 +100,15 @@ class GuiTimeLineView(QDialog): newItem = QTableWidgetItem(" "*iDepth + iTitle) self.mainTable.setItem(n+1, 0, newItem) - theTag = self.theMatrix["tags"][0] - theMap = self.theIndex.buildTagNovelMap(theTag) - newItem = QTableWidgetItem(theTag) - self.mainTable.setItem(0, 1, newItem) - for n in range(self.numRows-1): - newItem = QTableWidgetItem(str(theMap[n])) - self.mainTable.setItem(n+1, 1, newItem) - - # for n in range(self.numCols-1): - # iTag = self.theMatrix["tags"][n] - # newItem = QTableWidgetItem(iTag) - # self.mainTable.setItem(0, n+1, newItem) + theMap = self.theIndex.buildTagNovelMap(self.theMatrix["tags"]) + nCol = 1 + for theTag, theCols in theMap.items(): + newItem = QTableWidgetItem(theTag) + self.mainTable.setItem(0, nCol, newItem) + for n in range(self.numRows-1): + newItem = QTableWidgetItem(str(theCols[n])) + self.mainTable.setItem(n+1, nCol, newItem) + nCol += 1 return diff --git a/nw/project/index.py b/nw/project/index.py index 543caa31..8a4c6bf1 100644 --- a/nw/project/index.py +++ b/nw/project/index.py @@ -48,13 +48,13 @@ class NWIndex(): NOTE_KEYS = [TAG_KEY] NOVEL_KEYS = [PLOT_KEY, POV_KEY, CHAR_KEY, WORLD_KEY, TIME_KEY, OBJECT_KEY, CUSTOM_KEY] TAG_CLASS = { - POV_KEY : nwItemClass.CHARACTER, - CHAR_KEY : nwItemClass.CHARACTER, - PLOT_KEY : nwItemClass.PLOT, - TIME_KEY : nwItemClass.TIMELINE, - WORLD_KEY : nwItemClass.WORLD, - OBJECT_KEY : nwItemClass.OBJECT, - CUSTOM_KEY : nwItemClass.CUSTOM, + 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], } def __init__(self, theProject, theParent): @@ -66,7 +66,7 @@ class NWIndex(): # Indices self.tagIndex = {} - self.noteIndex = {} + self.refIndex = {} self.novelIndex = {} # Lists @@ -76,7 +76,7 @@ class NWIndex(): def clearIndex(self): self.tagIndex = {} - self.noteIndex = {} + self.refIndex = {} self.novelIndex = {} return @@ -101,8 +101,8 @@ class NWIndex(): if "tagIndex" in theData.keys(): self.tagIndex = theData["tagIndex"] - if "noteIndex" in theData.keys(): - self.noteIndex = theData["noteIndex"] + if "refIndex" in theData.keys(): + self.refIndex = theData["refIndex"] if "novelIndex" in theData.keys(): self.novelIndex = theData["novelIndex"] @@ -122,7 +122,7 @@ class NWIndex(): with open(indexFile,mode="w+") as outFile: outFile.write(json.dumps({ "tagIndex" : self.tagIndex, - "noteIndex" : self.noteIndex, + "refIndex" : self.refIndex, "novelIndex" : self.novelIndex, }, indent=nIndent)) except Exception as e: @@ -149,7 +149,7 @@ class NWIndex(): # Check file type, and reset its old index if itemClass == nwItemClass.NOVEL: self.novelIndex[tHandle] = [] - self.noteIndex[tHandle] = [] + self.refIndex[tHandle] = [] isNovel = True else: isNovel = False @@ -162,7 +162,8 @@ class NWIndex(): for aTag in clearTags: self.tagIndex.pop(aTag) - nLine = 0 + nLine = 0 + nTitle = 0 for aLine in theText.splitlines(): aLine = aLine.strip() nLine += 1 @@ -170,10 +171,12 @@ class NWIndex(): if nChar == 0: continue if aLine[0] == "#": if isNovel: - self.indexTitle(tHandle, aLine, nLine, itemLayout) + isTitle = self.indexTitle(tHandle, aLine, nLine, itemLayout) + if isTitle: + nTitle = nLine elif aLine[0] == "@": if isNovel: - self.indexNoteRef(tHandle, aLine, nLine) + self.indexNoteRef(tHandle, aLine, nLine, nTitle) else: self.indexTag(tHandle, aLine, nLine, itemClass) @@ -201,7 +204,7 @@ class NWIndex(): return True - def indexNoteRef(self, tHandle, aLine, nLine): + def indexNoteRef(self, tHandle, aLine, nLine, nTitle): isValid, theBits, thePos = self.scanThis(aLine) if not isValid or len(theBits) == 0: @@ -210,7 +213,7 @@ class NWIndex(): theKey = theBits[0] if theKey in self.NOVEL_KEYS: for aVal in theBits[1:]: - self.noteIndex[tHandle].append([nLine, theKey, aVal]) + self.refIndex[tHandle].append([nLine, theKey, aVal, nTitle]) return True @@ -295,7 +298,7 @@ class NWIndex(): for n in range(1,nBits): if theBits[n] in self.tagIndex: - isGood[n] = self.TAG_CLASS[theBits[0]].name == self.tagIndex[theBits[n]][2] + isGood[n] = self.TAG_CLASS[theBits[0]][0].name == self.tagIndex[theBits[n]][2] return isGood @@ -305,29 +308,40 @@ class NWIndex(): def buildNovelList(self): - self.novelList = [] + self.novelList = [] + self.novelOrder = [] for tHandle in self.theProject.treeOrder: if tHandle not in self.novelIndex: continue for tEntry in self.novelIndex[tHandle]: self.novelList.append(tEntry) + self.novelOrder.append("%s:%d" % (tHandle,tEntry[0])) return True - def buildTagNovelMap(self, theTag): + def buildTagNovelMap(self, theTags): - tagList = [] - if theTag not in self.tagIndex: - return tagList + tagMap = {} + tagClass = {} - try: - tagClass = nwItemClass[self.tagIndex[theTag][2]] - except: - logger.error("Could not map '%s' to nwItemClass" % self.tagIndex[theTag][2]) - return tagList + for theTag in theTags: + tagMap[theTag] = [0]*len(self.novelOrder) + try: + tagClass[theTag] = nwItemClass[self.tagIndex[theTag][2]] + except: + logger.error("Could not map '%s' to nwItemClass" % self.tagIndex[theTag][2]) + tagClass[theTag] = None - tagList = [0]*len(self.novelList) + for tHandle in self.refIndex: + for nLine, tKey, tTag, nTitle in self.refIndex[tHandle]: + if tTag in tagMap.keys() and tKey in self.TAG_CLASS: + try: + nPos = self.novelOrder.index("%s:%d" % (tHandle, nTitle)) + if self.TAG_CLASS[tKey][0] == tagClass[tTag]: + tagMap[tTag][nPos] = self.TAG_CLASS[tKey][1] + except: + logger.error("Could not find '%s:%d' in novelOrder" % (tHandle, nTitle)) - return tagList + return tagMap # END Class NWIndex diff --git a/sample/sampleNovel/data_6/36b6aa9b697b_main.nwd b/sample/sampleNovel/data_6/36b6aa9b697b_main.nwd index 831ee9fe..a084c76f 100644 --- a/sample/sampleNovel/data_6/36b6aa9b697b_main.nwd +++ b/sample/sampleNovel/data_6/36b6aa9b697b_main.nwd @@ -4,7 +4,7 @@ % Begin Meta @pov: Jane -@char: Jane, John +@char: John @location: Earth % End Meta diff --git a/sample/sampleNovel/data_b/c0cbd2a407f3_main.nwd b/sample/sampleNovel/data_b/c0cbd2a407f3_main.nwd index 6edf9061..0a39ca10 100644 --- a/sample/sampleNovel/data_b/c0cbd2a407f3_main.nwd +++ b/sample/sampleNovel/data_b/c0cbd2a407f3_main.nwd @@ -1,3 +1,6 @@ # This is a New File! +@pov: John +@location: Space + Although, not so new now that it has text in it an everything … \ No newline at end of file diff --git a/sample/sampleNovel/data_f/1471bef9f2ae_main.nwd b/sample/sampleNovel/data_f/1471bef9f2ae_main.nwd new file mode 100644 index 00000000..caae39bc --- /dev/null +++ b/sample/sampleNovel/data_f/1471bef9f2ae_main.nwd @@ -0,0 +1,6 @@ +# Space + +@tag: Space + +This is somewhere in outer space. + diff --git a/sample/sampleNovel/meta/sessionInfo.log b/sample/sampleNovel/meta/sessionInfo.log index 4ac50074..ecc8f9ce 100644 --- a/sample/sampleNovel/meta/sessionInfo.log +++ b/sample/sampleNovel/meta/sessionInfo.log @@ -134,3 +134,22 @@ Start: 2019-05-30 21:59:33 End: 2019-05-30 22:00:08 Words: 0 Start: 2019-05-30 22:00:27 End: 2019-05-30 22:01:18 Words: 0 Start: 2019-05-30 22:01:35 End: 2019-05-30 22:01:57 Words: 0 Start: 2019-05-30 22:02:05 End: 2019-05-30 22:02:24 Words: 0 +Start: 2019-05-30 22:07:43 End: 2019-05-30 22:08:48 Words: 0 +Start: 2019-05-30 22:18:15 End: 2019-05-30 22:18:24 Words: 0 +Start: 2019-05-31 00:01:48 End: 2019-05-31 00:01:57 Words: 0 +Start: 2019-05-31 00:10:01 End: 2019-05-31 00:10:07 Words: 0 +Start: 2019-05-31 00:11:12 End: 2019-05-31 00:11:21 Words: 0 +Start: 2019-05-31 00:11:49 End: 2019-05-31 00:12:04 Words: 0 +Start: 2019-05-31 00:12:42 End: 2019-05-31 00:13:24 Words: 0 +Start: 2019-05-31 00:38:11 End: 2019-05-31 00:38:38 Words: 0 +Start: 2019-05-31 00:39:35 End: 2019-05-31 00:40:23 Words: 0 +Start: 2019-05-31 00:40:27 End: 2019-05-31 00:40:54 Words: 0 +Start: 2019-05-31 00:56:15 End: 2019-05-31 00:56:23 Words: 0 +Start: 2019-05-31 00:59:56 End: 2019-05-31 01:00:05 Words: 0 +Start: 2019-05-31 01:00:39 End: 2019-05-31 01:00:56 Words: 0 +Start: 2019-05-31 19:10:29 End: 2019-05-31 19:21:11 Words: 0 +Start: 2019-05-31 19:50:56 End: 2019-05-31 19:51:03 Words: 0 +Start: 2019-05-31 19:58:24 End: 2019-05-31 19:59:04 Words: 0 +Start: 2019-05-31 20:11:22 End: 2019-05-31 20:11:56 Words: 0 +Start: 2019-05-31 20:23:06 End: 2019-05-31 20:23:18 Words: 0 +Start: 2019-05-31 20:23:56 End: 2019-05-31 20:27:02 Words: 7 diff --git a/sample/sampleNovel/nwProject.nwx b/sample/sampleNovel/nwProject.nwx index 2437ad48..7cad49d7 100644 --- a/sample/sampleNovel/nwProject.nwx +++ b/sample/sampleNovel/nwProject.nwx @@ -1,5 +1,5 @@ - + Sample Project Sample Project @@ -8,9 +8,9 @@ True - bb2c23b3c42cc + bc0cbd2a407f3 None - 558 + 565 New Notes @@ -27,7 +27,7 @@ Main - + Novel ROOT @@ -76,7 +76,7 @@ 656 121 5 - 69 + 77 New File @@ -88,7 +88,7 @@ 82 19 1 - 0 + 69 Characters @@ -147,6 +147,18 @@ 1 20 + + Space + FILE + WORLD + None + False + NOTE + 38 + 7 + 1 + 57 + Trash TRASH