mirror of
https://github.com/olivierkes/manuskript.git
synced 2024-09-28 07:21:31 +12:00
Changing text type should work. Sort of.
This commit is contained in:
parent
e3ceedabd2
commit
546eb4d819
2 changed files with 34 additions and 20 deletions
|
@ -94,8 +94,13 @@ class outlineModel(QAbstractItemModel):
|
|||
#self.dataChanged.emit(index.sibling(index.row(), 0),
|
||||
#index.sibling(index.row(), max([i.value for i in Outline])))
|
||||
#print("Model emit", index.row(), index.column())
|
||||
self.dataChanged.emit(index.sibling(index.row(), index.column()),
|
||||
index.sibling(index.row(), index.column()))
|
||||
self.dataChanged.emit(index, index)
|
||||
|
||||
if index.column() == Outline.type.value:
|
||||
# If type changed, then the icon of title changed.
|
||||
# Some views might be glad to know it.
|
||||
self.dataChanged.emit(index.sibling(index.row(), Outline.title.value),
|
||||
index.sibling(index.row(), Outline.title.value))
|
||||
|
||||
return True
|
||||
|
||||
|
@ -435,14 +440,7 @@ class outlineItem():
|
|||
if column in [Outline.wordCount.value, Outline.goal.value, Outline.setGoal.value]:
|
||||
updateWordCount = not Outline(column) in self._data or self._data[Outline(column)] != data
|
||||
|
||||
# Setting data
|
||||
self._data[Outline(column)] = data
|
||||
|
||||
# Stuff to do afterwards
|
||||
if column == Outline.text.value:
|
||||
wc = wordCount(data)
|
||||
self.setData(Outline.wordCount.value, wc)
|
||||
|
||||
# Stuff to do before
|
||||
if column == Outline.type.value:
|
||||
oldType = self._data[Outline.type]
|
||||
if oldType == "html" and data in ["txt", "t2t"]:
|
||||
|
@ -451,6 +449,14 @@ class outlineItem():
|
|||
e.setHtml(self._data[Outline.text])
|
||||
self._data[Outline.text] = e.toPlainText()
|
||||
|
||||
# Setting data
|
||||
self._data[Outline(column)] = data
|
||||
|
||||
# Stuff to do afterwards
|
||||
if column == Outline.text.value:
|
||||
wc = wordCount(data)
|
||||
self.setData(Outline.wordCount.value, wc)
|
||||
|
||||
if updateWordCount:
|
||||
self.updateWordCount()
|
||||
|
||||
|
|
|
@ -137,6 +137,12 @@ class textEditView(QTextEdit):
|
|||
else:
|
||||
self._textFormat = "text"
|
||||
|
||||
# Accept richtext maybe
|
||||
if self._textFormat == "html":
|
||||
self.setAcceptRichText(True)
|
||||
else:
|
||||
self.setAcceptRichText(False)
|
||||
|
||||
# Setting highlighter
|
||||
if self._highlighting:
|
||||
item = index.internalPointer()
|
||||
|
@ -147,12 +153,6 @@ class textEditView(QTextEdit):
|
|||
|
||||
self.highlighter.setDefaultBlockFormat(self._defaultBlockFormat)
|
||||
|
||||
# Accept richtext maybe
|
||||
if self._textFormat == "html":
|
||||
self.setAcceptRichText(True)
|
||||
else:
|
||||
self.setAcceptRichText
|
||||
|
||||
def setCurrentModelIndexes(self, indexes):
|
||||
self._index = None
|
||||
self._indexes = []
|
||||
|
@ -175,15 +175,22 @@ class textEditView(QTextEdit):
|
|||
if topLeft.parent() != self._index.parent():
|
||||
return
|
||||
|
||||
#print("Model changed: ({}:{}), ({}:{}/{}), ({}:{}) for {} of {}".format(
|
||||
#topLeft.row(), topLeft.column(),
|
||||
#self._index.row(), self._index.row(), self._column,
|
||||
#bottomRight.row(), bottomRight.column(),
|
||||
#self.objectName(), self.parent().objectName()))
|
||||
|
||||
if topLeft.row() <= self._index.row() <= bottomRight.row():
|
||||
if topLeft.column() <= Outline.type.value <= bottomRight.column():
|
||||
# If item type change, we reset the index to set the proper
|
||||
if self._column == Outline.text.value and \
|
||||
topLeft.column() <= Outline.type.value <= bottomRight.column():
|
||||
# If item type change, and we display the main text,
|
||||
# we reset the index to set the proper
|
||||
# highlighter and other defaults
|
||||
self.setupEditorForIndex(self._index)
|
||||
self.updateText()
|
||||
|
||||
elif topLeft.column() <= self._column <= bottomRight.column():
|
||||
print(topLeft.column(), self._column, bottomRight.column())
|
||||
self.updateText()
|
||||
|
||||
elif self._indexes:
|
||||
|
@ -400,3 +407,4 @@ class textEditView(QTextEdit):
|
|||
def applyFormat(self, _format):
|
||||
#FIXME
|
||||
print(_format)
|
||||
|
Loading…
Reference in a new issue