mirror of
https://github.com/olivierkes/manuskript.git
synced 2024-05-21 05:12:27 +12:00
Purging types from outlineModel and others
This commit is contained in:
parent
54ab5f0455
commit
7e954eab5e
|
@ -29,9 +29,7 @@ class arboExporter():
|
||||||
writeItem(c, path2)
|
writeItem(c, path2)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
ext = ".t2t" if item.isT2T() else \
|
ext = ".md"
|
||||||
".html" if item.isHTML() else \
|
|
||||||
".txt"
|
|
||||||
path2 = os.path.join(path, item.title() + ext)
|
path2 = os.path.join(path, item.title() + ext)
|
||||||
f = open(path2, "w")
|
f = open(path2, "w")
|
||||||
text = self.formatText(item.text(), item.type())
|
text = self.formatText(item.text(), item.type())
|
||||||
|
|
|
@ -560,7 +560,7 @@ def outlineItemPath(item):
|
||||||
name = "{ID}-{name}{ext}".format(
|
name = "{ID}-{name}{ext}".format(
|
||||||
ID=str(item.row()).zfill(len(str(siblings))),
|
ID=str(item.row()).zfill(len(str(siblings))),
|
||||||
name=slugify(item.title()),
|
name=slugify(item.title()),
|
||||||
ext="" if item.type() == "folder" else ".md" # ".{}".format(item.type()) # To have .txt, .t2t, .html, ...
|
ext="" if item.type() == "folder" else ".md"
|
||||||
)
|
)
|
||||||
return outlineItemPath(item.parent()) + [name]
|
return outlineItemPath(item.parent()) + [name]
|
||||||
|
|
||||||
|
|
|
@ -481,12 +481,8 @@ class outlineItem():
|
||||||
elif role == Qt.DecorationRole and column == Outline.title.value:
|
elif role == Qt.DecorationRole and column == Outline.title.value:
|
||||||
if self.isFolder():
|
if self.isFolder():
|
||||||
return QIcon.fromTheme("folder")
|
return QIcon.fromTheme("folder")
|
||||||
elif self.isText:
|
elif self.isMD():
|
||||||
return QIcon.fromTheme("text-x-generic")
|
return QIcon.fromTheme("text-x-generic")
|
||||||
elif self.isT2T() or self.isMD():
|
|
||||||
return QIcon.fromTheme("text-x-script")
|
|
||||||
elif self.isHTML():
|
|
||||||
return QIcon.fromTheme("text-html")
|
|
||||||
|
|
||||||
# elif role == Qt.ForegroundRole:
|
# elif role == Qt.ForegroundRole:
|
||||||
# if self.isCompile() in [0, "0"]:
|
# if self.isCompile() in [0, "0"]:
|
||||||
|
@ -527,15 +523,7 @@ class outlineItem():
|
||||||
updateWordCount = not Outline(column) in self._data or self._data[Outline(column)] != data
|
updateWordCount = not Outline(column) in self._data or self._data[Outline(column)] != data
|
||||||
|
|
||||||
# Stuff to do before
|
# Stuff to do before
|
||||||
if column == Outline.type.value:
|
if column == Outline.text.value:
|
||||||
oldType = self._data[Outline.type]
|
|
||||||
if oldType == "html" and data in ["txt", "t2t", "md"]:
|
|
||||||
# Resource inneficient way to convert HTML to plain text
|
|
||||||
self._data[Outline.text] = HTML2PlainText(self._data[Outline.text])
|
|
||||||
elif oldType in ["txt", "t2t", "md"] and data == "html" and Outline.text in self._data:
|
|
||||||
self._data[Outline.text] = self._data[Outline.text].replace("\n", "<br>")
|
|
||||||
|
|
||||||
elif column == Outline.text.value:
|
|
||||||
self.addRevision()
|
self.addRevision()
|
||||||
|
|
||||||
# Setting data
|
# Setting data
|
||||||
|
@ -658,8 +646,8 @@ class outlineItem():
|
||||||
def isFolder(self):
|
def isFolder(self):
|
||||||
return self._data[Outline.type] == "folder"
|
return self._data[Outline.type] == "folder"
|
||||||
|
|
||||||
def isT2T(self):
|
def isText(self):
|
||||||
return self._data[Outline.type] == "t2t"
|
return self._data[Outline.type] == "md"
|
||||||
|
|
||||||
def isMD(self):
|
def isMD(self):
|
||||||
return self._data[Outline.type] == "md"
|
return self._data[Outline.type] == "md"
|
||||||
|
@ -667,12 +655,6 @@ class outlineItem():
|
||||||
def isMMD(self):
|
def isMMD(self):
|
||||||
return self._data[Outline.type] == "md"
|
return self._data[Outline.type] == "md"
|
||||||
|
|
||||||
def isHTML(self):
|
|
||||||
return self._data[Outline.type] == "html"
|
|
||||||
|
|
||||||
def isText(self):
|
|
||||||
return self._data[Outline.type] == "txt"
|
|
||||||
|
|
||||||
def text(self):
|
def text(self):
|
||||||
return self.data(Outline.text.value)
|
return self.data(Outline.text.value)
|
||||||
|
|
||||||
|
|
|
@ -61,10 +61,6 @@ class textFormat(QWidget, Ui_textFormat):
|
||||||
|
|
||||||
elif item.isText():
|
elif item.isText():
|
||||||
self.align.setVisible(False)
|
self.align.setVisible(False)
|
||||||
self.format.setVisible(False)
|
|
||||||
|
|
||||||
elif item.isT2T() or item.isMD():
|
|
||||||
self.align.setVisible(False)
|
|
||||||
|
|
||||||
def setFormat(self):
|
def setFormat(self):
|
||||||
act = self.sender()
|
act = self.sender()
|
||||||
|
|
|
@ -45,12 +45,6 @@ class frequencyAnalyzer(QWidget, Ui_FrequencyAnalyzer):
|
||||||
def listPhrases(item, nMin, nMax):
|
def listPhrases(item, nMin, nMax):
|
||||||
txt = item.text()
|
txt = item.text()
|
||||||
|
|
||||||
# Convert to plain text
|
|
||||||
if item.isHTML():
|
|
||||||
e = QTextEdit()
|
|
||||||
e.setHtml(item.text())
|
|
||||||
txt = e.toPlainText()
|
|
||||||
|
|
||||||
# Split into words
|
# Split into words
|
||||||
lst = re.findall(r"[\w']+", txt) # Ignores punctuation
|
lst = re.findall(r"[\w']+", txt) # Ignores punctuation
|
||||||
# lst = re.findall(r"[\w']+|[.,!?;]", txt) # Includes punctuation
|
# lst = re.findall(r"[\w']+|[.,!?;]", txt) # Includes punctuation
|
||||||
|
@ -92,12 +86,6 @@ class frequencyAnalyzer(QWidget, Ui_FrequencyAnalyzer):
|
||||||
def listWords(item):
|
def listWords(item):
|
||||||
txt = item.text()
|
txt = item.text()
|
||||||
|
|
||||||
# Convert to plain text
|
|
||||||
if item.isHTML():
|
|
||||||
e = QTextEdit()
|
|
||||||
e.setHtml(item.text())
|
|
||||||
txt = e.toPlainText()
|
|
||||||
|
|
||||||
lst = re.findall(r"[\w']+", txt)
|
lst = re.findall(r"[\w']+", txt)
|
||||||
for c in item.children():
|
for c in item.children():
|
||||||
lst += listWords(c)
|
lst += listWords(c)
|
||||||
|
|
Loading…
Reference in a new issue