Completed default XHTML template for exporter
[biacv.git] / biacv_mainwindow.py
index 4a98c2d..65ed3fe 100644 (file)
@@ -2,6 +2,8 @@
 # class for main window
 
 import PyQt4
+import sys
+
 import biacv_mainwindow_ui as bui
 import biacv_lang as lang
 import biacv_data as data
@@ -14,6 +16,29 @@ class Biacv_mainwindow (PyQt4.QtGui.QMainWindow, bui.Ui_biacv_mainwindow):
                self.ismodified = False
                self.setWindowTitle ("BiaCV - untitled")
 
+       # on window closing
+       def closeEvent (self, event):
+               if self.ismodified is True:
+                       ans = PyQt4.QtGui.QMessageBox.question (self, lang.CONFIRM, lang.CONFIRM_DISCARD_SAVE,
+                               PyQt4.QtGui.QMessageBox.Yes, PyQt4.QtGui.QMessageBox.No)
+                       # ignore event if not confirmed
+                       if ans <> PyQt4.QtGui.QMessageBox.Yes:
+                               event.ignore ()
+
+       # on help about dialog box
+       def on_help_about (self):
+               PyQt4.QtGui.QMessageBox.about (self, lang.ABOUT_TITLE, lang.ABOUT_TEXT)
+
+       # on file exit
+       def on_exit (self):
+               # call the close event
+               self.close()
+
+       # on file export - export current document to any external format based on
+       # a template
+       def on_file_export (self):
+               pass
+
        # function to open a file
        def on_file_open (self):
                # if modified, confirm
@@ -62,6 +87,19 @@ class Biacv_mainwindow (PyQt4.QtGui.QMainWindow, bui.Ui_biacv_mainwindow):
                # set the window title
                self.setWindowTitle ("BiaCV - " + self.currentfile)
 
+       # function to save a file as a new document
+       def on_file_save_as (self):
+               savefilename = PyQt4.QtGui.QFileDialog.getSaveFileName (self,
+                       lang.SAVE_TITLE)
+
+               # if save file name is not none
+               if savefilename <> "":
+                       mydata = self.get_document_data ()
+                       mydata.save_data (savefilename)
+                       self.ismodified = False
+                       self.currentfile = savefilename
+                       self.setWindowTitle ("BiaCV - " + self.currentfile)
+
        # function to save a file
        def on_file_save (self):
                # only save modified file
@@ -75,7 +113,7 @@ class Biacv_mainwindow (PyQt4.QtGui.QMainWindow, bui.Ui_biacv_mainwindow):
 
                        if savefilename <> "":
                                mydata = self.get_document_data ()
-                               mydata.save_data (self.currentfile)
+                               mydata.save_data (savefilename)
                                self.ismodified = False
                                self.currentfile = savefilename
                                self.setWindowTitle ("BiaCV - " + self.currentfile)