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