def printEntry(self, match, term, pages, notes): if match.field is SearchFieldKind.TERM: text = term elif match.field is SearchFieldKind.PAGES: text = pages elif match.field is SearchFieldKind.NOTES: text = notes doc = QTextDocument() doc.setHtml(text) print("{: 3d}: [{}]".format(match.eid, doc.toPlainText()))
def testUndoRedo(self): text = 'foobar' doc = QTextDocument(text) self.assertFalse(doc.isRedoAvailable()) self.assertTrue(doc.isUndoAvailable()) self.assertEqual(doc.toPlainText(), text) cursor = QTextCursor(doc) doc.undo(cursor) self.assertTrue(doc.isRedoAvailable()) self.assertFalse(doc.isUndoAvailable()) self.assertEqual(doc.toPlainText(), '') doc.redo(cursor) self.assertFalse(doc.isRedoAvailable()) self.assertTrue(doc.isUndoAvailable()) self.assertEqual(doc.toPlainText(), text)