mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-17 01:09:36 -06:00
Show tables in foreign key editor in alphabetical order
Make sure to list the tables in the foreign key editor of the Edit Table dialog in alphabetical order instead sorting them randomly. See issue #2700.
This commit is contained in:
@@ -84,11 +84,7 @@ ForeignKeyEditorDelegate::ForeignKeyEditorDelegate(const DBBrowserDB& db, sqlb::
|
||||
for(const auto& it : m_db.schemata)
|
||||
{
|
||||
for(const auto& jt : it.second.tables)
|
||||
{
|
||||
// Don't insert the current table into the list. The name and fields of the current table are always taken from the m_table reference
|
||||
if(jt.first != m_table.name())
|
||||
m_tablesIds.insert({jt.first, jt.second->fieldNames()});
|
||||
}
|
||||
m_tablesIds.insert({jt.first, jt.second->fieldNames()});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,7 +122,6 @@ QWidget* ForeignKeyEditorDelegate::createEditor(QWidget* parent, const QStyleOpt
|
||||
editor->tablesComboBox->clear();
|
||||
for(const auto& i : m_tablesIds)
|
||||
editor->tablesComboBox->addItem(QString::fromStdString(i.first));
|
||||
editor->tablesComboBox->addItem(QString::fromStdString(m_table.name())); // For recursive foreign keys
|
||||
|
||||
return editor;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#define FOREIGNKEYDELEGATE_H
|
||||
|
||||
#include <QStyledItemDelegate>
|
||||
#include <unordered_map>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
@@ -28,7 +28,7 @@ public:
|
||||
private:
|
||||
const DBBrowserDB& m_db;
|
||||
sqlb::Table& m_table;
|
||||
mutable std::unordered_map<std::string, std::vector<std::string>> m_tablesIds;
|
||||
mutable std::map<std::string, std::vector<std::string>> m_tablesIds;
|
||||
};
|
||||
|
||||
#endif // FOREIGNKEYDELEGATE_H
|
||||
|
||||
Reference in New Issue
Block a user