mirror of
https://github.com/olivierkes/manuskript.git
synced 2024-05-11 00:12:24 +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)
|
||||
|
||||
else:
|
||||
ext = ".t2t" if item.isT2T() else \
|
||||
".html" if item.isHTML() else \
|
||||
".txt"
|
||||
ext = ".md"
|
||||
path2 = os.path.join(path, item.title() + ext)
|
||||
f = open(path2, "w")
|
||||
text = self.formatText(item.text(), item.type())
|
||||
|
|
|
@ -560,7 +560,7 @@ def outlineItemPath(item):
|
|||
name = "{ID}-{name}{ext}".format(
|
||||
ID=str(item.row()).zfill(len(str(siblings))),
|
||||
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]
|
||||
|
||||
|
|
|
@ -481,12 +481,8 @@ class outlineItem():
|
|||
elif role == Qt.DecorationRole and column == Outline.title.value:
|
||||
if self.isFolder():
|
||||
return QIcon.fromTheme("folder")
|
||||
elif self.isText:
|
||||
elif self.isMD():
|
||||
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:
|
||||
# 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
|
||||
|
||||
# Stuff to do before
|
||||
if column == Outline.type.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:
|
||||
if column == Outline.text.value:
|
||||
self.addRevision()
|
||||
|
||||
# Setting data
|
||||
|
@ -658,8 +646,8 @@ class outlineItem():
|
|||
def isFolder(self):
|
||||
return self._data[Outline.type] == "folder"
|
||||
|
||||
def isT2T(self):
|
||||
return self._data[Outline.type] == "t2t"
|
||||
def isText(self):
|
||||
return self._data[Outline.type] == "md"
|
||||
|
||||
def isMD(self):
|
||||
return self._data[Outline.type] == "md"
|
||||
|
@ -667,12 +655,6 @@ class outlineItem():
|
|||
def isMMD(self):
|
||||
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):
|
||||
return self.data(Outline.text.value)
|
||||
|
||||
|
|
|
@ -61,10 +61,6 @@ class textFormat(QWidget, Ui_textFormat):
|
|||
|
||||
elif item.isText():
|
||||
self.align.setVisible(False)
|
||||
self.format.setVisible(False)
|
||||
|
||||
elif item.isT2T() or item.isMD():
|
||||
self.align.setVisible(False)
|
||||
|
||||
def setFormat(self):
|
||||
act = self.sender()
|
||||
|
|
|
@ -45,12 +45,6 @@ class frequencyAnalyzer(QWidget, Ui_FrequencyAnalyzer):
|
|||
def listPhrases(item, nMin, nMax):
|
||||
txt = item.text()
|
||||
|
||||
# Convert to plain text
|
||||
if item.isHTML():
|
||||
e = QTextEdit()
|
||||
e.setHtml(item.text())
|
||||
txt = e.toPlainText()
|
||||
|
||||
# Split into words
|
||||
lst = re.findall(r"[\w']+", txt) # Ignores punctuation
|
||||
# lst = re.findall(r"[\w']+|[.,!?;]", txt) # Includes punctuation
|
||||
|
@ -92,12 +86,6 @@ class frequencyAnalyzer(QWidget, Ui_FrequencyAnalyzer):
|
|||
def listWords(item):
|
||||
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)
|
||||
for c in item.children():
|
||||
lst += listWords(c)
|
||||
|
|
Loading…
Reference in a new issue