Show attached databases in the UI

Commits 532fcd3f6b,
44eb2d4f99, and
ea1659e1d0 along 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:
Martin Kleusberg
2017-09-04 12:45:41 +02:00
parent ea1659e1d0
commit a5ca75655c
+15 -1
View File
@@ -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();
}