Skip to content

Commit a5ca756

Browse files
committed
Show attached databases in the UI
Commits 532fcd3, 44eb2d4, and ea1659e 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.
1 parent ea1659e commit a5ca756

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/DbStructureModel.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,13 @@ void DbStructureModel::reloadData()
148148
browsablesRootItem->setIcon(ColumnName, QIcon(QString(":/icons/view")));
149149
browsablesRootItem->setText(ColumnName, tr("Browsables"));
150150

151+
// Make sure to always load the main schema first
151152
QTreeWidgetItem* itemAll = new QTreeWidgetItem(rootItem);
152153
itemAll->setIcon(ColumnName, QIcon(QString(":/icons/database")));
153154
itemAll->setText(ColumnName, tr("All"));
154155
buildTree(itemAll, "main");
155156

156-
// Add the temporary database as a node if it isn't empty
157+
// Add the temporary database as a node if it isn't empty. Make sure it's always second if it exists.
157158
if(!m_db.schemata["temp"].isEmpty())
158159
{
159160
QTreeWidgetItem* itemTemp = new QTreeWidgetItem(itemAll);
@@ -162,6 +163,19 @@ void DbStructureModel::reloadData()
162163
buildTree(itemTemp, "temp");
163164
}
164165

166+
// Now load all the other schemata last
167+
for(auto it=m_db.schemata.constBegin();it!=m_db.schemata.constEnd();++it)
168+
{
169+
// Don't load the main and temp schema again
170+
if(it.key() != "main" && it.key() != "temp")
171+
{
172+
QTreeWidgetItem* itemSchema = new QTreeWidgetItem(itemAll);
173+
itemSchema->setIcon(ColumnName, QIcon(QString(":/icons/database")));
174+
itemSchema->setText(ColumnName, it.key());
175+
buildTree(itemSchema, it.key());
176+
}
177+
}
178+
165179
// Refresh the view
166180
endResetModel();
167181
}

0 commit comments

Comments
 (0)