pgLab/pglab/TablesPage.cpp
2017-12-19 19:55:12 +01:00

47 lines
1.2 KiB
C++

#include "TablesPage.h"
#include "ui_TablesPage.h"
#include "PgAttribute.h"
#include "TablesTableModel.h"
#include "ResultTableModelUtil.h"
#include "ColumnTableModel.h"
TablesPage::TablesPage(QWidget *parent) :
QWidget(parent),
ui(new Ui::TablesPage)
{
ui->setupUi(this);
SetTableViewDefault(ui->tableListTable);
m_tablesModel = new TablesTableModel(this);
ui->tableListTable->setModel(m_tablesModel);
SetTableViewDefault(ui->columnsTable);
m_columnsModel = new ColumnTableModel(this);
ui->columnsTable->setModel(m_columnsModel);
connect(ui->tableListTable->selectionModel(), &QItemSelectionModel::currentRowChanged, this,
&TablesPage::on_tableListTable_currentRowChanged);
}
TablesPage::~TablesPage()
{
delete ui;
}
void TablesPage::setCatalog(std::shared_ptr<PgDatabaseCatalog> cat)
{
m_catalog = cat;
m_tablesModel->setCatalog(cat);
ui->tableListTable->resizeColumnsToContents();
}
void TablesPage::on_tableListTable_currentRowChanged(const QModelIndex &current, const QModelIndex &previous)
{
if (current.row() != previous.row()) {
PgClass table = m_tablesModel->getTable(current.row());
m_columnsModel->setData(m_catalog, table);
ui->columnsTable->resizeColumnsToContents();
}
}