X-Git-Url: https://harishankar.org/repos/?p=biaweb_qt.git;a=blobdiff_plain;f=article_dialog.py;fp=article_dialog.py;h=02c07711f50c1e37919e534efef078cd1b73a346;hp=3494138d3cbff289bea366c251bc69f6847ff7a2;hb=3b4711c41851510b83c2c442bd6a00ee387c1bfb;hpb=903f2462bb6e7130191b1b0c667a9f6fce1e6189 diff --git a/article_dialog.py b/article_dialog.py index 3494138..02c0771 100644 --- a/article_dialog.py +++ b/article_dialog.py @@ -9,23 +9,33 @@ class ArticleDialog (PyQt4.QtGui.QDialog, ui_article_dialog.Ui_ArticleDialog): PyQt4.QtGui.QDialog.__init__ (self, parent) self.setupUi (self) + # when rejected, confirm first + def reject (self): + ans = PyQt4.QtGui.QMessageBox.question (self, "Confirm", + "Are you sure you wish to cancel all changes?", + PyQt4.QtGui.QMessageBox.Yes, PyQt4.QtGui.QMessageBox.No) + if ans == PyQt4.QtGui.QMessageBox.Yes: + PyQt4.QtGui.QDialog.reject (self) + + # when bold is clicked def onBold (self): textcur = self.content.textCursor () sel = textcur.selectedText () - boldsel = "" + str (sel) + "" + boldsel = "" + sel + "" textcur.insertText (boldsel) # when block quote is clicked def onBQuote (self): textcur = self.content.textCursor () sel = textcur.selectedText () - quotesel = "
\n" + str (sel) + "\n" + quotesel = "
\n" + sel + "\n" textcur.insertText (quotesel) # when bullet is clicked def onBullet (self): - pass + # insert bulleted list + self.insert_list_items () # when code is clicked def onCode (self): @@ -36,52 +46,166 @@ class ArticleDialog (PyQt4.QtGui.QDialog, ui_article_dialog.Ui_ArticleDialog): # when horiz rule is clicked def onHRule (self): - pass + textcur = self.content.textCursor () + hrule = "\n
' + sel + "
" + textcur.insertText (paracentersel) # when justify is clicked def onJustify (self): - pass + textcur = self.content.textCursor () + sel = textcur.selectedText () + parajustsel = '' + sel + "
" + textcur.insertText (parajustsel) # when left is clicked def onLeft (self): - pass + textcur = self.content.textCursor () + sel = textcur.selectedText () + paraleftsel = '' + sel + "
" + textcur.insertText (paraleftsel) # when right is clicked def onRight (self): - pass + textcur = self.content.textCursor () + sel = textcur.selectedText () + pararightsel = '' + sel + "
" + textcur.insertText (pararightsel) # when pre is clicked def onPre (self): - pass + textcur = self.content.textCursor () + sel = textcur.selectedText () + presel = "" + sel + "" + textcur.insertText (presel) # when para is clicked def onPara (self): - pass + textcur = self.content.textCursor () + sel = textcur.selectedText () + parasel = "
" + sel + "
" + textcur.insertText (parasel) # when table is clicked def onTable (self): - pass + # get the number of rows + rows, ok = PyQt4.QtGui.QInputDialog.getInt (self, "Table", "Number of table rows") + if not ok: + return + # get the number of columns + cols, ok = PyQt4.QtGui.QInputDialog.getInt (self, "Table", "Number of table columns") + if not ok: + return + # should there be a header row? + headerflag = PyQt4.QtGui.QMessageBox.question (self, "Header", "Do you want additional header row?", + PyQt4.QtGui.QMessageBox.Yes, PyQt4.QtGui.QMessageBox.No, + PyQt4.QtGui.QMessageBox.Cancel) + if headerflag == PyQt4.QtGui.QMessageBox.Cancel: + return + + # build the table tag + tablelist = ["\n\n") + tablelist.append (" |
---|
\n") + tablelist.append (" |