Trigger page now reacts to catalog refreshed.
This commit is contained in:
parent
211d937c16
commit
f4f514efb0
3 changed files with 20 additions and 6 deletions
|
|
@ -19,6 +19,7 @@ TriggerPage::TriggerPage(QWidget *parent)
|
||||||
|
|
||||||
connect(m_tableView->selectionModel(), &QItemSelectionModel::selectionChanged,
|
connect(m_tableView->selectionModel(), &QItemSelectionModel::selectionChanged,
|
||||||
this, &TriggerPage::tableView_selectionChanged);
|
this, &TriggerPage::tableView_selectionChanged);
|
||||||
|
connect(m_model, &TriggerTableModel::modelReset, m_definitionView, &SqlCodePreview::clear);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
#include "catalog/PgDatabaseCatalog.h"
|
#include "catalog/PgDatabaseCatalog.h"
|
||||||
#include "catalog/PgTriggerContainer.h"
|
#include "catalog/PgTriggerContainer.h"
|
||||||
#include "CustomDataRole.h"
|
#include "CustomDataRole.h"
|
||||||
|
#include "ScopeGuard.h"
|
||||||
|
|
||||||
TriggerTableModel::TriggerTableModel(QObject *parent)
|
TriggerTableModel::TriggerTableModel(QObject *parent)
|
||||||
: QAbstractTableModel(parent)
|
: QAbstractTableModel(parent)
|
||||||
|
|
@ -30,12 +31,12 @@ QVariant TriggerTableModel::headerData(int section, Qt::Orientation orientation,
|
||||||
|
|
||||||
void TriggerTableModel::setCatalog(std::shared_ptr<const PgDatabaseCatalog> cat)
|
void TriggerTableModel::setCatalog(std::shared_ptr<const PgDatabaseCatalog> cat)
|
||||||
{
|
{
|
||||||
beginResetModel();
|
if (cat != m_catalog) {
|
||||||
|
m_catalog = cat;
|
||||||
m_catalog = cat;
|
refreshConnection = connect(m_catalog.get(), &PgDatabaseCatalog::refreshed, this,
|
||||||
m_triggers = cat->triggers();//->getTriggersForRelation(table);
|
&TriggerTableModel::refresh);
|
||||||
|
}
|
||||||
endResetModel();
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
int TriggerTableModel::rowCount(const QModelIndex &) const
|
int TriggerTableModel::rowCount(const QModelIndex &) const
|
||||||
|
|
@ -98,3 +99,11 @@ QVariant TriggerTableModel::getData(const QModelIndex &index) const
|
||||||
}
|
}
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TriggerTableModel::refresh()
|
||||||
|
{
|
||||||
|
beginResetModel();
|
||||||
|
SCOPE_EXIT { endResetModel(); };
|
||||||
|
|
||||||
|
m_triggers = m_catalog->triggers();
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -66,9 +66,13 @@ public:
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<const PgDatabaseCatalog> m_catalog;
|
std::shared_ptr<const PgDatabaseCatalog> m_catalog;
|
||||||
std::shared_ptr<const PgTriggerContainer> m_triggers;
|
std::shared_ptr<const PgTriggerContainer> m_triggers;
|
||||||
|
QMetaObject::Connection refreshConnection;
|
||||||
|
|
||||||
Oid getType(int column) const;
|
Oid getType(int column) const;
|
||||||
QVariant getData(const QModelIndex &index) const;
|
QVariant getData(const QModelIndex &index) const;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void refresh();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue