aboutsummaryrefslogtreecommitdiffstats
path: root/SQLiteStudio3/guiSQLiteStudio/dbtree/dbtreemodel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'SQLiteStudio3/guiSQLiteStudio/dbtree/dbtreemodel.cpp')
-rw-r--r--SQLiteStudio3/guiSQLiteStudio/dbtree/dbtreemodel.cpp29
1 files changed, 24 insertions, 5 deletions
diff --git a/SQLiteStudio3/guiSQLiteStudio/dbtree/dbtreemodel.cpp b/SQLiteStudio3/guiSQLiteStudio/dbtree/dbtreemodel.cpp
index a4e736f..78f0db8 100644
--- a/SQLiteStudio3/guiSQLiteStudio/dbtree/dbtreemodel.cpp
+++ b/SQLiteStudio3/guiSQLiteStudio/dbtree/dbtreemodel.cpp
@@ -250,8 +250,19 @@ void DbTreeModel::restoreGroup(const Config::DbGroupPtr& group, QList<Db*>* dbLi
{
if (db)
{
- if (db->open())
+ // If the db was stored in cfg as open, it was already open by DbManager.
+ // Now the DbTreeModel didn't catch that (as it didn't exist yet), so we need to
+ // call handler for 'connected' event, instead of forcing another open call.
+ // Otherwise the database that could not be open would be requested to open twice:
+ // 1. when restoring DbManager
+ // 2. here
+ // Instead of that, we just check if the database is already open (by DbManager)
+ // and call proper handler to refresh database's schema and create tree nodes.
+ if (db->isOpen())
+ {
+ dbConnected(db);
treeView->expand(item->index());
+ }
}
else
{
@@ -401,8 +412,12 @@ QString DbTreeModel::getDbToolTip(DbTreeItem* item) const
QStringList rows;
Db* db = item->getDb();
- QFile dbFile(db->getPath());
QString iconPath = db->isValid() ? ICONS.DATABASE.toImgSrc() : ICONS.DATABASE_INVALID.toImgSrc();
+ int fileSize = -1;
+
+ QUrl url(db->getPath());
+ if (url.scheme().isEmpty() || url.scheme() == "file")
+ fileSize = QFile(db->getPath()).size();
rows << toolTipHdrRowTmp.arg(iconPath).arg(tr("Database: %1", "dbtree tooltip").arg(db->getName()));
rows << toolTipRowTmp.arg("URI:").arg(db->getPath());
@@ -410,13 +425,17 @@ QString DbTreeModel::getDbToolTip(DbTreeItem* item) const
if (db->isValid())
{
rows << toolTipRowTmp.arg(tr("Version:", "dbtree tooltip")).arg(QString("SQLite %1").arg(db->getVersion()));
- rows << toolTipRowTmp.arg(tr("File size:", "dbtree tooltip")).arg(formatFileSize(dbFile.size()));
- rows << toolTipRowTmp.arg(tr("Encoding:", "dbtree tooltip")).arg(db->getEncoding());
+
+ if (fileSize > -1)
+ rows << toolTipRowTmp.arg(tr("File size:", "dbtree tooltip")).arg(formatFileSize(fileSize));
+
+ if (db->isOpen())
+ rows << toolTipRowTmp.arg(tr("Encoding:", "dbtree tooltip")).arg(db->getEncoding());
}
else
{
InvalidDb* idb = dynamic_cast<InvalidDb*>(db);
- rows << toolTipRowTmp.arg(tr("Error details:", "dbtree tooltip")).arg(idb->getError());
+ rows << toolTipRowTmp.arg(tr("Error:", "dbtree tooltip")).arg(idb->getError());
}
return toolTipTableTmp.arg(rows.join(""));