mirror of
https://github.com/olivierkes/manuskript.git
synced 2024-06-16 01:44:34 +12:00
Optimization
This commit is contained in:
parent
cfa6c72328
commit
2c9b7b637a
|
@ -123,7 +123,7 @@ class editorWidget(QWidget, Ui_editorWidget_ui):
|
|||
addSpacer()
|
||||
self.scroll.setWidget(w)
|
||||
|
||||
elif item.isFolder() and self.folderView == "text":
|
||||
elif item and item.isFolder() and self.folderView == "text":
|
||||
self.stack.setCurrentIndex(1)
|
||||
|
||||
w = QWidget()
|
||||
|
@ -139,7 +139,7 @@ class editorWidget(QWidget, Ui_editorWidget_ui):
|
|||
addSpacer()
|
||||
self.scroll.setWidget(w)
|
||||
|
||||
elif item.isFolder() and self.folderView == "cork":
|
||||
elif item and item.isFolder() and self.folderView == "cork":
|
||||
self.stack.setCurrentIndex(2)
|
||||
self.corkView.setModel(self._model)
|
||||
self.corkView.setRootIndex(index)
|
||||
|
@ -149,7 +149,7 @@ class editorWidget(QWidget, Ui_editorWidget_ui):
|
|||
lambda: mainWindow().redacMetadata.selectionChanged(self.corkView))
|
||||
|
||||
|
||||
elif item.isFolder() and self.folderView == "outline":
|
||||
elif item and item.isFolder() and self.folderView == "outline":
|
||||
self.stack.setCurrentIndex(3)
|
||||
self.outlineView.setModelPersos(mainWindow().mdlPersos)
|
||||
self.outlineView.setModelLabels(mainWindow().mdlLabels)
|
||||
|
|
|
@ -22,7 +22,6 @@ class textEditView(QTextEdit):
|
|||
self._placeholderText = None
|
||||
self._updating = False
|
||||
self._item = None
|
||||
self._update = False
|
||||
self._highlighting = True
|
||||
|
||||
self.spellcheck = spellcheck
|
||||
|
@ -91,7 +90,7 @@ class textEditView(QTextEdit):
|
|||
self.updateText()
|
||||
|
||||
def update(self, topLeft, bottomRight):
|
||||
if self._update:
|
||||
if self._updating:
|
||||
return
|
||||
|
||||
elif self._index:
|
||||
|
@ -107,6 +106,7 @@ class textEditView(QTextEdit):
|
|||
self.updateText()
|
||||
|
||||
def updateText(self):
|
||||
self._updating = True
|
||||
if self._index:
|
||||
if self.toPlainText() != toString(self._model.data(self._index)):
|
||||
self.document().setPlainText(toString(self._model.data(self._index)))
|
||||
|
@ -132,12 +132,19 @@ class textEditView(QTextEdit):
|
|||
self._placeholderText = self.placeholderText()
|
||||
|
||||
self.setPlaceholderText(self.tr("Various"))
|
||||
self._updating = False
|
||||
|
||||
def submit(self):
|
||||
|
||||
if self._updating:
|
||||
return
|
||||
|
||||
if self._index:
|
||||
#item = self._index.internalPointer()
|
||||
if self.toPlainText() != self._model.data(self._index):
|
||||
self._updating = True
|
||||
self._model.setData(self._index, self.toPlainText())
|
||||
self._updating = False
|
||||
|
||||
elif self._indexes:
|
||||
self._updating = True
|
||||
|
|
Loading…
Reference in a new issue