X-Git-Url: https://harishankar.org/repos/?p=biaweb_qt.git;a=blobdiff_plain;f=article_dialog.py;h=6b51e705dc93942a207ec9b46a2384be744d542e;hp=02c07711f50c1e37919e534efef078cd1b73a346;hb=54389d5adbbb1830a7e85545b2bdde816713a272;hpb=3b4711c41851510b83c2c442bd6a00ee387c1bfb diff --git a/article_dialog.py b/article_dialog.py index 02c0771..6b51e70 100644 --- a/article_dialog.py +++ b/article_dialog.py @@ -1,13 +1,18 @@ # BiaWeb Website content manager (c) 2010 V.Harishankar -# Category dialog class +# Article dialog class import PyQt4 import ui_article_dialog +import highlighter class ArticleDialog (PyQt4.QtGui.QDialog, ui_article_dialog.Ui_ArticleDialog): 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 ()) # when rejected, confirm first def reject (self): @@ -17,6 +22,25 @@ class ArticleDialog (PyQt4.QtGui.QDialog, ui_article_dialog.Ui_ArticleDialog): 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): @@ -89,13 +113,13 @@ class ArticleDialog (PyQt4.QtGui.QDialog, ui_article_dialog.Ui_ArticleDialog): # 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 = "
    \n" + otag = "\n
      \n" ctag = "
    \n" else: title = "Bulleted list" - otag = "