Esempio n. 1
0
    def canCloseDocument(self):
        if not self.documentModified:
            return True

        action = chooseAction(self, "Do you want to save the changes you made in the document \"%s\"?" % self.documentTitle, 
                             "Your changes will be lost if you don't save them.", "Save%s" % (self.fileName is None and "..." or ""), "Don't Save")
        if action == QMessageBox.Yes:
            return self.saveDocument()
        else:
            return action == QMessageBox.Discard
Esempio n. 2
0
    def closeAllDocuments(self):
        modifiedCount = len(self.modifiedDocuments())

        if modifiedCount == 0:
            return True

        docs = list(self.documents)
        docs.reverse()
        
        action = None
        if modifiedCount > 1:
            action = chooseAction(None, "You have %i %s documents with unsaved changes. Do you want to review these changes before quitting?" % (modifiedCount, self.app.applicationName()), 
                                  "If you don't review your documents, all your changes will be lost.", "Review Changes...", "Discard Changes")
            
        if modifiedCount == 1 or action == QMessageBox.Yes:            
            for doc in docs:
                if not doc.close():
                    return False
            return True
        else:
            return action == QMessageBox.Discard
Esempio n. 3
0
 def revertDocumentToSaved(self):
     if self.fileName is not None and self._documentModified:
         if chooseAction(self, "Do you want to revert to the most recently saved version of the document \"%s\"?" %  self.documentTitle,
     "Your current changes will be lost.", "Revert") == QMessageBox.Yes:
             if self.readFromFile(self.fileName):
                 self.documentModfied = False