Updated htaccess to Apache 2.4 compat
[biaweb_qt.git] / editor_dialog.py
1 # BiaWeb Website content manager (c) 2010 V.Harishankar
2 # Editor dialog class
3
4 import PyQt4
5 import ui_editor_dialog
6 import highlighter
7
8 class EditorDialog (PyQt4.QtGui.QDialog, ui_editor_dialog.Ui_EditorDialog):
9 def __init__ (self, master, title, init_text):
10 PyQt4.QtGui.QDialog.__init__ (self, master)
11 self.setupUi (self)
12
13 # set the flags to a normal maximizable window
14 self.setWindowFlags (PyQt4.QtCore.Qt.Window)
15
16 # set the title
17 self.setWindowTitle ("Editor - " + title)
18
19 # set text highlighting
20 highlighter.SimpleHtmlHighlighter (self.text.document ())
21
22 self.text.setPlainText (init_text)
23 # set modified flag to false
24 self.modified = False
25
26 # when cancelled check if modified and confirm first
27 def reject (self):
28 # if modified ask confirmation first
29 if self.modified == True:
30 ans = PyQt4.QtGui.QMessageBox.question (self, "Confirm",
31 "Changes will be lost. Are you sure you wish to cancel editing?",
32 PyQt4.QtGui.QMessageBox.Yes, PyQt4.QtGui.QMessageBox.No)
33 # if confirmed
34 if ans == PyQt4.QtGui.QMessageBox.Yes:
35 PyQt4.QtGui.QDialog.reject (self)
36 # not modified
37 else:
38 PyQt4.QtGui.QDialog.reject (self)
39
40 def onTextChanged (self):
41 self.modified = True