Reorganization of pgLab project
This commit is contained in:
parent
7300865c77
commit
c71fdc4af7
78 changed files with 204 additions and 148 deletions
57
pglab/catalog/widgets/TriggerPage.cpp
Normal file
57
pglab/catalog/widgets/TriggerPage.cpp
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
#include "TriggerPage.h"
|
||||
#include "ResultTableModelUtil.h"
|
||||
#include "UserConfiguration.h"
|
||||
#include "catalog/PgClass.h"
|
||||
#include "SqlCodePreview.h"
|
||||
#include "catalog/models/TriggerTableModel.h"
|
||||
#include "CustomFilterSortModel.h"
|
||||
#include "CustomDataRole.h"
|
||||
#include "util/PgLabTableView.h"
|
||||
#include "catalog/PgProcContainer.h"
|
||||
#include <QHeaderView>
|
||||
#include <QStringBuilder>
|
||||
#include <unordered_set>
|
||||
|
||||
TriggerPage::TriggerPage(QWidget *parent)
|
||||
: CatalogPageBase(parent)
|
||||
{
|
||||
m_model = new TriggerTableModel(this);
|
||||
m_sortFilterProxy->setSourceModel(m_model);
|
||||
|
||||
connect(m_tableView->selectionModel(), &QItemSelectionModel::selectionChanged,
|
||||
this, &TriggerPage::tableView_selectionChanged);
|
||||
connect(m_model, &TriggerTableModel::modelReset, m_definitionView, &SqlCodePreview::clear);
|
||||
}
|
||||
|
||||
|
||||
void TriggerPage::catalogSet()
|
||||
{
|
||||
m_model->setCatalog(m_catalog);
|
||||
}
|
||||
|
||||
|
||||
void TriggerPage::setFilter(const std::optional<PgClass> &cls)
|
||||
{
|
||||
m_sortFilterProxy->setOidFilterTable(cls ? cls->oid() : InvalidOid, FirstHiddenValue);
|
||||
m_tableView->resizeColumnsToContents();
|
||||
}
|
||||
|
||||
|
||||
void TriggerPage::tableView_selectionChanged(const QItemSelection &/*selected*/, const QItemSelection &/*deselected*/)
|
||||
{
|
||||
auto rijen = selectedRows();
|
||||
|
||||
QString drops;
|
||||
QString creates;
|
||||
for (auto rij : rijen) {
|
||||
auto&& t = m_model->trigger(rij);
|
||||
drops += t.dropSql() % "\n";
|
||||
creates += t.createSql() % "\n";
|
||||
|
||||
const PgProc *proc = m_catalog->procs()->getByKey(t.foid);
|
||||
if (proc) {
|
||||
creates += "\n" % proc->createSql() % "\n";
|
||||
}
|
||||
}
|
||||
m_definitionView->setPlainText(drops % "\n" % creates);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue