def __init__ (self, parent):
PyQt4.QtGui.QDialog.__init__ (self, parent)
self.setupUi (self)
+ # set window to be able to be maximized or minimized
+ self.setWindowFlags (PyQt4.QtCore.Qt.Window)
# set the code highlighter to the document
self.hltext = highlighter.SimpleHtmlHighlighter (self.content.document ())
if ans == PyQt4.QtGui.QMessageBox.Yes:
PyQt4.QtGui.QDialog.reject (self)
+ # when accepted check the data
+ def accept (self):
+ title = str (self.article_title.text ()).strip ()
+ content = str (self.content.toPlainText ()).strip ()
+ stub = str (self.stub.text ()).strip ()
+
+ if title <> "" and content <> "" and stub <> "":
+ PyQt4.QtGui.QDialog.accept (self)
+ else:
+ PyQt4.QtGui.QMessageBox.critical (self, "Missing fields", "Some required fields are missing")
+
+ # populate categories in combo box
+ def populate_categories (self, category_list, selected_cat = None):
+ for catid, catname, catdesc, stub in category_list:
+ self.category.addItem (catname, int (catid))
+
+ # set the index to the selected category item
+ if selected_cat is not None:
+ self.category.setCurrentIndex (self.category.findData (selected_cat))
# when bold is clicked
def onBold (self):
# get a list of items in numbered or bulleted list
def insert_list_items (self, numbered = False):
- if numbered == True:
+ if numbered:
title = "Numbered list"
- otag = "<ol>\n"
+ otag = "\n<ol>\n"
ctag = "</ol>\n"
else:
title = "Bulleted list"
- otag = "<ul>\n"
+ otag = "\n<ul>\n"
ctag = "</ul>\n"
itemlist = [ otag ]
# when break is clicked
def onBreak (self):
textcur = self.content.textCursor ()
- breaktxt = "\n<br />\n"
+ breaktxt = "<br />\n"
textcur.clearSelection ()
textcur.insertText (breaktxt)