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