Tables are now sorted by not perfect yet.
This commit is contained in:
parent
ec78dafa94
commit
a79357db87
2 changed files with 19 additions and 0 deletions
|
|
@ -34,9 +34,25 @@ void TablesTableModel::setCatalog(std::shared_ptr<const PgDatabaseCatalog> cat)
|
|||
}
|
||||
}
|
||||
|
||||
doSort(1);
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
void TablesTableModel::setSortOrder(int so)
|
||||
{
|
||||
beginResetModel();
|
||||
doSort(so);
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
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); });
|
||||
}
|
||||
|
||||
|
||||
QVariant TablesTableModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@ public:
|
|||
|
||||
void setCatalog(std::shared_ptr<const PgDatabaseCatalog> cat);
|
||||
|
||||
void setSortOrder(int so);
|
||||
|
||||
// Header:
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
|
||||
|
||||
|
|
@ -46,6 +48,7 @@ private:
|
|||
t_Tables m_tables;
|
||||
|
||||
QString formatTableName(const PgClass &cls) const;
|
||||
void doSort(int so);
|
||||
};
|
||||
|
||||
#endif // TABLESTABLEMODEL_H
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue