ConstraintPage now reacts to refreshed signal.

This commit is contained in:
eelke 2019-10-06 14:17:07 +02:00
parent fa46971930
commit 23899b6bb6
3 changed files with 17 additions and 10 deletions

View file

@ -9,18 +9,23 @@ ConstraintModel::ConstraintModel(QObject *parent)
{
}
void ConstraintModel::setData(std::shared_ptr<const PgDatabaseCatalog> cat, const std::optional<PgClass> &table)
{
if (cat != m_catalog) {
m_catalog = cat;
refreshConnection = connect(m_catalog.get(), &PgDatabaseCatalog::refreshed, this, &ConstraintModel::refresh);
}
m_table = table;
refresh();
}
void ConstraintModel::refresh()
{
beginResetModel();
SCOPE_EXIT { endResetModel(); };
m_table = table;
m_catalog = cat;
if (table) {
m_constraints = cat->constraints()->getConstraintsForRelation(table->oid());
if (m_table) {
m_constraints = m_catalog->constraints()->getConstraintsForRelation(m_table->oid());
std::sort(m_constraints.begin(), m_constraints.end(),
[] (auto &l, auto &r) {
return l.type < r.type ||
@ -116,8 +121,6 @@ QString IconForConstraintType(ConstraintType ct)
return s;
}
QVariant ConstraintModel::getData(const QModelIndex &index) const
{
QVariant v;