def save(self): """Called to perform the edits in the document.""" cursor = QTextCursor(self._range) start = cursor.selectionStart() # use cursordiff; don't destroy point and click positions cursordiff.insert_text(cursor, self.view.toPlainText()) cursor.setPosition(start, QTextCursor.KeepAnchor) with cursortools.compress_undo(cursor, True): # re-indent the inserted line(s) indent.re_indent(cursor)
def convert(mainwindow): """Shows the dialog.""" dlg = Dialog(mainwindow) dlg.addAction(mainwindow.actionCollection.help_whatsthis) dlg.setDocument(mainwindow.currentDocument()) dlg.setModal(True) dlg.show() dlg.run() if dlg.exec_(): c = mainwindow.textCursor() c.select(c.Document) text = dlg.convertedText() if dlg.copyCheck.isChecked(): msgs = textwrap.fill(dlg.messages.toPlainText()) text += '\n\n%{\n' + msgs + '\n%}\n' cursordiff.insert_text(c, text) dlg.deleteLater()