diff options
| author | 2015-04-19 22:30:43 -0400 | |
|---|---|---|
| committer | 2015-04-19 22:30:43 -0400 | |
| commit | 094918f048c81474b22f9ba2940c96dc4033d753 (patch) | |
| tree | 2b89c77ad7dc9c55e9ba383f23f9f25b82df358e /SQLiteStudio3/guiSQLiteStudio/dbtree/dbtreemodel.cpp | |
| parent | 640fff60ceecde402131937dddb3458f7a003e9c (diff) | |
| parent | a308f430f694423064ebc86fd0506c8c6fdb3d93 (diff) | |
Merge tag 'upstream/3.0.5'
Upstream version 3.0.5
# gpg: Signature made Sun 19 Apr 2015 10:30:41 PM EDT using RSA key ID EBE9BD91
# gpg: Good signature from "Unit 193 <unit193@gmail.com>"
# gpg: aka "Unit 193 <unit193@ninthfloor.org>"
# gpg: aka "Unit 193 <unit193@ubuntu.com>"
# gpg: aka "Unit 193 <unit193@ninthfloor.com>"
Diffstat (limited to 'SQLiteStudio3/guiSQLiteStudio/dbtree/dbtreemodel.cpp')
| -rw-r--r-- | SQLiteStudio3/guiSQLiteStudio/dbtree/dbtreemodel.cpp | 29 |
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("")); |
