E5Gui/E5MessageBox.py

changeset 549
fe99d46d56c8
parent 545
1538031b5175
child 550
22b951013193
diff -r ac7af05dd54a -r fe99d46d56c8 E5Gui/E5MessageBox.py
--- a/E5Gui/E5MessageBox.py	Fri Sep 03 10:21:47 2010 +0200
+++ b/E5Gui/E5MessageBox.py	Fri Sep 03 13:39:08 2010 +0200
@@ -150,3 +150,24 @@
                        QMessageBox.StandardButtons(QMessageBox.Yes | QMessageBox.No), 
                        yesDefault and QMessageBox.Yes or QMessageBox.No)
     return res == QMessageBox.Yes
+
+def okToClearData(parent, title, text, saveFunc):
+    """
+    Function to show a model message box to ask for clearing the data.
+    
+    @param parent parent widget of the message box (QWidget)
+    @param title caption of the message box (string)
+    @param text text to be shown by the message box (string)
+    @param saveFunc reference to a function performing the save action. It
+        must be a parameterless function returning a flag indicating success.
+    @return flag indicating that it is ok to clear the data (boolean)
+    """
+    res = __messageBox(parent, title, text, QMessageBox.Warning, 
+        QMessageBox.StandardButtons(
+            QMessageBox.Abort | QMessageBox.Discard | QMessageBox.Save), 
+        QMessageBox.Save)
+    if res == QMessageBox.Abort:
+        return False
+    if res == QMessageBox.Save:
+        return saveFunc()
+    return True

eric ide

mercurial