DbViewer: can launch with a directory argument to set current workspace for convenience.

This commit is contained in:
matlabbe
2018-02-19 16:37:17 -05:00
parent 6cdb2a48fd
commit 5c04ce257b
+12
View File
@@ -689,6 +689,8 @@ bool DatabaseViewer::openDatabase(const QString & path)
{ {
UDEBUG("Open database \"%s\"", path.toStdString().c_str()); UDEBUG("Open database \"%s\"", path.toStdString().c_str());
if(QFile::exists(path)) if(QFile::exists(path))
{
if(QFileInfo(path).isFile())
{ {
std::string driverType = "sqlite3"; std::string driverType = "sqlite3";
@@ -777,6 +779,16 @@ bool DatabaseViewer::openDatabase(const QString & path)
return true; return true;
} }
} }
else // directory
{
pathDatabase_ = path;
if(pathDatabase_.isEmpty() || pathDatabase_.compare(".") == 0)
{
pathDatabase_ = QDir::currentPath();
}
ui_->graphViewer->setWorkingDirectory(pathDatabase_);
}
}
else else
{ {
QMessageBox::warning(this, "Database error", tr("Database \"%1\" does not exist.").arg(path)); QMessageBox::warning(this, "Database error", tr("Database \"%1\" does not exist.").arg(path));