def addMenuContent(self, parent, desc, menuContents, box, messages, additivesDict): self.addMenuLine(parent, desc, box) if desc in menuContents: contentList = menuContents[desc] else: contentList = [(messages[u'noContents'], None, [], None)] log_debug("lunch menu does not contain key '%s'" % desc) textview = GrowingTextEdit(parent, messages, additivesDict) textview.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) textview.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) textview.setLineWrapMode(QTextEdit.WidgetWidth) textview.setReadOnly(True) textview.document().setIndentWidth(10) if len(contentList) == 1: title, description, additives, keyInfo = contentList[0] textview.append( self.formatTitleAndDescription(title, description, keyInfo), additives) elif len(contentList) > 1: cursor = textview.textCursor() listFormat = QTextListFormat() listFormat.setStyle(QTextListFormat.ListDisc) listFormat.setIndent(1) cursor.createList(listFormat) for title, description, additives, keyInfo in contentList: textview.append( self.formatTitleAndDescription(title, description, keyInfo), additives) box.addWidget(textview, 0)
def insertUnorderedList(self): """ Inserts an ordered list into the editor. """ cursor = self.editor().textCursor() currlist = cursor.currentList() new_style = QTextListFormat.ListDisc indent = 1 if currlist: format = currlist.format() indent = format.indent() + 1 style = format.style() if style == QTextListFormat.ListDisc: new_style = QTextListFormat.ListCircle elif style == QTextListFormat.ListCircle: new_style = QTextListFormat.ListSquare new_format = QTextListFormat() new_format.setStyle(new_style) new_format.setIndent(indent) new_list = cursor.createList(new_format) self.editor().setFocus() return new_list
def addMenuContent(self, parent, desc, menuContents, box, messages, additivesDict): self.addMenuLine(parent, desc, box) if desc in menuContents: contentList = menuContents[desc] else: contentList = [(messages[u'noContents'], None, [], None)] log_debug("lunch menu does not contain key '%s'" % desc) textview = GrowingTextEdit(parent, messages, additivesDict) textview.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) textview.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) textview.setLineWrapMode(QTextEdit.WidgetWidth) textview.setReadOnly(True) textview.document().setIndentWidth(10) if len(contentList) == 1: title, description, additives, keyInfo = contentList[0] textview.append(self.formatTitleAndDescription(title, description, keyInfo), additives) elif len(contentList) > 1: cursor = textview.textCursor() listFormat = QTextListFormat() listFormat.setStyle(QTextListFormat.ListDisc) listFormat.setIndent(1) cursor.createList(listFormat) for title, description, additives, keyInfo in contentList: textview.append(self.formatTitleAndDescription(title, description, keyInfo), additives) box.addWidget(textview, 0)
def insertOrderedList(self): """ Inserts an ordered list into the editor. """ cursor = self.editor().textCursor() currlist = cursor.currentList() new_style = QTextListFormat.ListDecimal indent = 1 if currlist: format = currlist.format() indent = format.indent() + 1 style = format.style() if style == QTextListFormat.ListDecimal: new_style = QTextListFormat.ListLowerRoman elif style == QTextListFormat.ListLowerRoman: new_style = QTextListFormat.ListUpperAlpha elif style == QTextListFormat.ListUpperAlpha: new_style = QTextListFormat.ListLowerAlpha new_format = QTextListFormat() new_format.setStyle(new_style) new_format.setIndent(indent) new_list = cursor.createList(new_format) self.editor().setFocus() return new_list
def setAppChangeLog(self, log): self._appChangeLog.clear() document = self._appChangeLog.document() document.setIndentWidth(20) cursor = QTextCursor(document) cursor.insertText("Changes:\n") listFormat = QTextListFormat() listFormat.setStyle(QTextListFormat.ListDisc) listFormat2 = QTextListFormat() listFormat2.setStyle(QTextListFormat.ListDisc) listFormat2.setIndent(2) for line in log: if line.startswith("*"): cursor.insertList(listFormat2) line = line[1:] else: cursor.insertList(listFormat) cursor.insertText(line) self.setChangelogVisible(True)