Rewrite and simplify import SQL code

Rewrite the import SQL code using a similar method to the one used in
executeQuery(). This makes the code much easier to read and removes the
last remnants of that C code stolen from some demo application.
This commit is contained in:
Martin Kleusberg
2013-03-20 22:17:36 +01:00
parent 0282533092
commit 0868f299af
6 changed files with 58 additions and 189 deletions

View File

@@ -933,11 +933,19 @@ void MainWindow::importDatabaseFromSQL()
if(!fileName.isNull())
db.create(newDBfile);
}
int lineErr;
if (!db.reload(fileName, &lineErr))
QMessageBox::information(this, QApplication::applicationName(), tr("Error importing data at line %1").arg(lineErr) );
// Open, read, execute and close file
QApplication::setOverrideCursor(Qt::WaitCursor);
QFile f(fileName);
f.open(QIODevice::ReadOnly);
if(!db.executeMultiSQL(f.readAll()))
QMessageBox::warning(this, QApplication::applicationName(), tr("Error importing data: %1").arg(db.lastErrorMessage));
else
QMessageBox::information(this, QApplication::applicationName(), tr("Import completed"));
QMessageBox::information(this, QApplication::applicationName(), tr("Import completed."));
f.close();
QApplication::restoreOverrideCursor();
// Resfresh window
populateStructure();
resetBrowser();
}