pgLab/pglab/widgets/CatalogConstraintPage.cpp
eelke 42432b06a9 Restructuring catalog tabs
- Moved detail tabs of table to their own components
- Table list has become seperate component on seperate tab
- Table list does not use designer anymore
- Moved sequences and functions tabs into the catalog inspector
2019-02-09 11:36:22 +01:00

42 lines
1.2 KiB
C++

#include "CatalogConstraintPage.h"
#include "ConstraintModel.h"
#include "CustomFilterSortModel.h"
#include "IconColumnDelegate.h"
#include "PgLabTableView.h"
#include "SqlCodePreview.h"
#include <QStringBuilder>
CatalogConstraintPage::CatalogConstraintPage(QWidget *parent)
: CatalogPageBase(parent)
{
m_constraintModel = new ConstraintModel(this);
m_sortFilterProxy->setSourceModel(m_constraintModel);
m_tableView->setItemDelegateForColumn(0, new IconColumnDelegate(this));
connect(m_tableView->selectionModel(), &QItemSelectionModel::selectionChanged,
this, &CatalogConstraintPage::tableView_selectionChanged);
}
void CatalogConstraintPage::catalogSet()
{
}
void CatalogConstraintPage::setFilter(const std::optional<PgClass> &cls)
{
m_constraintModel->setData(m_catalog, cls);
m_tableView->resizeColumnsToContents();
}
void CatalogConstraintPage::tableView_selectionChanged(const QItemSelection &/*selected*/, const QItemSelection &/*deselected*/)
{
auto rijen = selectedRows();
QString drops;
QString creates;
for (auto rij : rijen) {
const PgConstraint constraint = m_constraintModel->constraint(rij);
drops += constraint.dropSql() % "\n";
creates += constraint.createSql() % "\n";
}
m_definitionView->setPlainText(drops % "\n" % creates);
}