From 315019dd9ce028331caa1d6f8863829a8ce25e9d Mon Sep 17 00:00:00 2001 From: Martin Kleusberg Date: Mon, 4 Sep 2017 10:20:43 +0200 Subject: [PATCH] Improve foreign key editor when working on tables in non-main schemata This improves commit 44eb2d4f9922fd1a854d959602c6a2455eab0dc5 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. --- src/ForeignKeyEditorDelegate.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/ForeignKeyEditorDelegate.cpp b/src/ForeignKeyEditorDelegate.cpp index 78e8988d..b1c26b7d 100644 --- a/src/ForeignKeyEditorDelegate.cpp +++ b/src/ForeignKeyEditorDelegate.cpp @@ -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()->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()->fieldNames()); + } } } }