Improve foreign key editor when working on tables in non-main schemata

This improves commit 44eb2d4f99 by
allowing to choose tables from other schemata than "main" in the foreign
key editor in the Edit Table dialog. This still isn't perfect as only
tables from the schema of the current table should be shown but with
some care it should work for all use cases.
This commit is contained in:
Martin Kleusberg
2017-09-04 10:20:43 +02:00
parent fbaf78ea65
commit 315019dd9c

View File

@@ -81,11 +81,15 @@ ForeignKeyEditorDelegate::ForeignKeyEditorDelegate(const DBBrowserDB& db, sqlb::
, m_db(db)
, m_table(table)
{
const auto objects = m_db.getBrowsableObjects("main");
for (auto& obj : objects) {
if (obj->type() == sqlb::Object::Types::Table) {
QString tableName = obj->name();
m_tablesIds.insert(tableName, obj.dynamicCast<sqlb::Table>()->fieldNames());
for(auto it=m_db.schemata.constBegin();it!=m_db.schemata.constEnd();++it)
{
for(auto jt=it->constBegin();jt!=it->constEnd();++jt)
{
if((*jt)->type() == sqlb::Object::Types::Table)
{
QString tableName = (*jt)->name();
m_tablesIds.insert(tableName, (*jt).dynamicCast<sqlb::Table>()->fieldNames());
}
}
}
}