pgLab/pglab/CrudTab.cpp

57 lines
1.4 KiB
C++

#include "CrudTab.h"
#include "ui_CrudTab.h"
#include "CrudModel.h"
#include "MainWindow.h"
#include "ResultTableModelUtil.h"
#include "PgLabItemDelegate.h"
CrudTab::CrudTab(MainWindow *parent)
: QWidget(parent)
, ui(new Ui::CrudTab)
, m_window(parent)
{
ui->setupUi(this);
SetTableViewDefault(ui->tableView);
auto delegate = new PgLabItemDelegate(ui->tableView);
ui->tableView->setItemDelegate(delegate);
m_crudModel = new CrudModel(parent);
ui->tableView->setModel(m_crudModel);
ui->tableView->setSelectionMode(QAbstractItemView::SingleSelection);
//auto selection_model = ui->tableView->selectionModel();
// connect(ui->tableView->selectionModel(), &QItemSelectionModel::currentRowChanged, this,
// &CrudTab::tableView_currentRowChanged);
}
CrudTab::~CrudTab()
{
delete ui;
}
void CrudTab::setConfig(std::shared_ptr<OpenDatabase> db, const PgClass &table)
{
m_db = db;
m_table = table;
// m_catalog = cat;
// m_tablesModel->setCatalog(cat);
// ui->tableListTable->resizeColumnsToContents();
// m_namespaceFilterWidget->init(cat->namespaces());
// auto highlighter = new SqlSyntaxHighlighter(ui->constraintSqlEdit->document());
// highlighter->setTypes(*cat->types());
m_crudModel->setConfig(db, table);
}
//void CrudTab::tableView_currentRowChanged(const QModelIndex &current, const QModelIndex &previous)
//{
//}
void CrudTab::refresh()
{
m_crudModel->loadData();
}