Bezig met crudmodel/tab

This commit is contained in:
eelke 2018-01-08 20:45:52 +01:00
parent ee321b3fb1
commit 14ab400ccb
15 changed files with 308 additions and 33 deletions

View file

@ -24,12 +24,12 @@ void TablesTableModel::setCatalog(std::shared_ptr<const PgDatabaseCatalog> cat)
// How many?
int n = 0;
for (const auto &e : *classes)
if (e.kind == RelKind::Table) ++n;
if (e.kind == RelKind::Table && !e.system_namespace) ++n;
m_tables.clear();
m_tables.reserve(n); // reserve space
for (const auto &e : *classes) {
if (e.kind == RelKind::Table) {
if (e.kind == RelKind::Table && !e.system_namespace) {
m_tables.push_back(e);
}
}
@ -49,8 +49,11 @@ void TablesTableModel::doSort(int so)
{
if (so == 1)
std::sort(m_tables.begin(), m_tables.end(),
[] (auto l, auto r) -> bool { return l.relnamespace < r.relnamespace
|| (l.relnamespace == r.relnamespace && l.name < r.name); });
[] (auto l, auto r) -> bool { return l.relnamespace_name < r.relnamespace_name
|| (l.relnamespace_name == r.relnamespace_name && l.name < r.name); });
else
std::sort(m_tables.begin(), m_tables.end(),
[] (auto l, auto r) -> bool { return l.name < r.name; });
}