mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-05-14 15:59:18 -05:00
Show attached databases in the UI
Commits532fcd3f6b,44eb2d4f99, andea1659e1d0along with some smaller ones prepared our code for properly handling schemata other than "main". While working for any schema, they only exposed this funtionality for the "temp" schema. But with these preparations in place it's easy to add all known schemata to the UI and enable (almost) all features we have for them. This is done by this commit, adding all attached databases to the UI.
This commit is contained in:
@@ -148,12 +148,13 @@ void DbStructureModel::reloadData()
|
||||
browsablesRootItem->setIcon(ColumnName, QIcon(QString(":/icons/view")));
|
||||
browsablesRootItem->setText(ColumnName, tr("Browsables"));
|
||||
|
||||
// Make sure to always load the main schema first
|
||||
QTreeWidgetItem* itemAll = new QTreeWidgetItem(rootItem);
|
||||
itemAll->setIcon(ColumnName, QIcon(QString(":/icons/database")));
|
||||
itemAll->setText(ColumnName, tr("All"));
|
||||
buildTree(itemAll, "main");
|
||||
|
||||
// Add the temporary database as a node if it isn't empty
|
||||
// Add the temporary database as a node if it isn't empty. Make sure it's always second if it exists.
|
||||
if(!m_db.schemata["temp"].isEmpty())
|
||||
{
|
||||
QTreeWidgetItem* itemTemp = new QTreeWidgetItem(itemAll);
|
||||
@@ -162,6 +163,19 @@ void DbStructureModel::reloadData()
|
||||
buildTree(itemTemp, "temp");
|
||||
}
|
||||
|
||||
// Now load all the other schemata last
|
||||
for(auto it=m_db.schemata.constBegin();it!=m_db.schemata.constEnd();++it)
|
||||
{
|
||||
// Don't load the main and temp schema again
|
||||
if(it.key() != "main" && it.key() != "temp")
|
||||
{
|
||||
QTreeWidgetItem* itemSchema = new QTreeWidgetItem(itemAll);
|
||||
itemSchema->setIcon(ColumnName, QIcon(QString(":/icons/database")));
|
||||
itemSchema->setText(ColumnName, it.key());
|
||||
buildTree(itemSchema, it.key());
|
||||
}
|
||||
}
|
||||
|
||||
// Refresh the view
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user