]> git.zarvox.org Git - wp3.git/commitdiff
Fix a bug in DB loading and use statusbar for messages.
authorDrew Fisher <drew.m.fisher@gmail.com>
Wed, 8 Jul 2009 15:21:32 +0000 (08:21 -0700)
committerDrew Fisher <drew.m.fisher@gmail.com>
Wed, 8 Jul 2009 15:21:32 +0000 (08:21 -0700)
mainapp.py

index d7539f3c7df344f9b3f9190b65b210a933097610..599cd3dbeb0519f82b5eb60fffaa61c2a67a17eb 100644 (file)
@@ -55,22 +55,27 @@ class MainApp (QMainWindow):
 
 
        def newFile(self):
-               self.db.close()
                fileName = QFileDialog.getSaveFileName(self, "Save new file as:", ".", "Databases (*.db)")
-               self.db.setDatabaseName(fileName)
-               self.db.open()
-               q = QSqlQuery(self.db)
-               q.exec_(MainApp.schema)
-               print "Closed the existing database, created",fileName
+               if not fileName.isEmpty(): # If they cancelled, do nothing
+                       if not fileName.endsWith(".db"): # if they leave off the extension, add it
+                               fileName = fileName.append(".db")
+                       self.db.close()
+                       self.db.setDatabaseName(fileName)
+                       self.db.open()
+                       q = QSqlQuery(self.db)
+                       q.exec_(MainApp.schema)
+                       self.statusBar().showMessage("Closed the existing database, created " + fileName)
+               else:
+                       self.statusBar().showMessage("Cancelled creating new database")
        def openFile(self):
                fileName = QFileDialog.getOpenFileName(self, "Open dataset", ".", "Databases (*.db)")
                if not fileName.isEmpty():
                        self.db.close()
                        self.db.setDatabaseName(fileName)
                        self.db.open()
-                       print "Loaded database",fileName
+                       self.statusBar().showMessage("Successfully loaded database " + fileName)
                else:
-                       print "Canceled loading database"
+                       self.statusBar().showMessage("Canceled loading database")
        def mergeWizard(self):
                fileName = QFileDialog.getOpenFileName(self, "Import which dataset?", ".", "Databases (*.db)" )
                print "and then we'd import data from",fileName