Show moer information about the indexes.
This commit is contained in:
parent
8c20bd6a02
commit
61645d44ac
5 changed files with 110 additions and 25 deletions
|
|
@ -7,7 +7,7 @@
|
|||
#include "ResultTableModelUtil.h"
|
||||
#include "ColumnTableModel.h"
|
||||
#include "ConstraintModel.h"
|
||||
#include "NamespaceFilterWidget.h"
|
||||
//#include "NamespaceFilterWidget.h"
|
||||
#include "IconColumnDelegate.h"
|
||||
#include "IndexModel.h"
|
||||
#include "SqlFormattingUtils.h"
|
||||
|
|
@ -43,6 +43,7 @@ TablesPage::TablesPage(MainWindow *parent)
|
|||
font.setFixedPitch(true);
|
||||
font.setPointSize(10);
|
||||
ui->constraintSqlEdit->setFont(font);
|
||||
ui->indexSqlEdit->setFont(font);
|
||||
|
||||
SetTableViewDefault(ui->indexesTable);
|
||||
m_indexModel = new IndexModel(this);
|
||||
|
|
@ -50,8 +51,8 @@ TablesPage::TablesPage(MainWindow *parent)
|
|||
ui->indexesTable->setItemDelegate(new PgLabItemDelegate(ui->indexesTable));
|
||||
ui->indexesTable->setItemDelegateForColumn(0, delegate);
|
||||
|
||||
m_namespaceFilterWidget = new NamespaceFilterWidget(this);
|
||||
ui->verticalLayoutTableView->addWidget(m_namespaceFilterWidget);
|
||||
//m_namespaceFilterWidget = new NamespaceFilterWidget(this);
|
||||
//ui->verticalLayoutTableView->addWidget(m_namespaceFilterWidget);
|
||||
|
||||
|
||||
connect(ui->tableListTable->selectionModel(), &QItemSelectionModel::currentRowChanged, this,
|
||||
|
|
@ -63,6 +64,9 @@ TablesPage::TablesPage(MainWindow *parent)
|
|||
connect(ui->constraintsTable->selectionModel(), &QItemSelectionModel::selectionChanged, this,
|
||||
&TablesPage::constraintsTable_selectionChanged);
|
||||
|
||||
connect(ui->indexesTable->selectionModel(), &QItemSelectionModel::selectionChanged, this,
|
||||
&TablesPage::indexesTable_selectionChanged);
|
||||
|
||||
}
|
||||
|
||||
TablesPage::~TablesPage()
|
||||
|
|
@ -75,11 +79,12 @@ void TablesPage::setCatalog(std::shared_ptr<PgDatabaseCatalog> cat)
|
|||
m_catalog = cat;
|
||||
m_tablesModel->setCatalog(cat);
|
||||
ui->tableListTable->resizeColumnsToContents();
|
||||
m_namespaceFilterWidget->init(cat->namespaces());
|
||||
// m_namespaceFilterWidget->init(cat->namespaces());
|
||||
|
||||
auto highlighter = new SqlSyntaxHighlighter(ui->constraintSqlEdit->document());
|
||||
highlighter->setTypes(*cat->types());
|
||||
|
||||
highlighter = new SqlSyntaxHighlighter(ui->indexSqlEdit->document());
|
||||
highlighter->setTypes(*cat->types());
|
||||
}
|
||||
|
||||
void TablesPage::tableListTable_currentRowChanged(const QModelIndex ¤t, const QModelIndex &previous)
|
||||
|
|
@ -98,24 +103,26 @@ void TablesPage::tableListTable_currentRowChanged(const QModelIndex ¤t, co
|
|||
}
|
||||
}
|
||||
|
||||
void TablesPage::constraintsTable_currentRowChanged(const QModelIndex ¤t, const QModelIndex &previous)
|
||||
{
|
||||
if (current.row() != previous.row()) {
|
||||
// QString drop_definition = m_constraintModel->dropDefinition(current.row());
|
||||
// QString create_definition = m_constraintModel->createDefinition(current.row());
|
||||
const PgConstraint& constraint = m_constraintModel->constraint(current.row());
|
||||
QString drop = getDropConstraintDefinition(*m_catalog, constraint);
|
||||
QString add = getConstraintDefinition(*m_catalog, constraint);
|
||||
//void TablesPage::constraintsTable_currentRowChanged(const QModelIndex ¤t, const QModelIndex &previous)
|
||||
//{
|
||||
// if (current.row() != previous.row()) {
|
||||
//// QString drop_definition = m_constraintModel->dropDefinition(current.row());
|
||||
//// QString create_definition = m_constraintModel->createDefinition(current.row());
|
||||
// const PgConstraint& constraint = m_constraintModel->constraint(current.row());
|
||||
// QString drop = getDropConstraintDefinition(*m_catalog, constraint);
|
||||
// QString add = getConstraintDefinition(*m_catalog, constraint);
|
||||
|
||||
ui->constraintSqlEdit->setPlainText(drop % QString::fromUtf16(u"\n") % add);
|
||||
}
|
||||
}
|
||||
// ui->constraintSqlEdit->setPlainText(drop % QString::fromUtf16(u"\n") % add);
|
||||
// }
|
||||
//}
|
||||
|
||||
void TablesPage::constraintsTable_selectionChanged(const QItemSelection &/*selected*/, const QItemSelection &/*deselected*/)
|
||||
{
|
||||
const auto indexes = ui->constraintsTable->selectionModel()->selectedIndexes();
|
||||
boost::container::flat_set<int> rijen;
|
||||
for (const auto e : indexes) rijen.insert(e.row());
|
||||
for (const auto e : indexes)
|
||||
rijen.insert(e.row());
|
||||
|
||||
QString drops;
|
||||
QString creates;
|
||||
for (auto rij : rijen) {
|
||||
|
|
@ -126,6 +133,24 @@ void TablesPage::constraintsTable_selectionChanged(const QItemSelection &/*selec
|
|||
ui->constraintSqlEdit->setPlainText(drops % "\n" % creates);
|
||||
}
|
||||
|
||||
void TablesPage::indexesTable_selectionChanged(const QItemSelection &/*selected*/, const QItemSelection &/*deselected*/)
|
||||
{
|
||||
const auto indexes = ui->indexesTable->selectionModel()->selectedIndexes();
|
||||
boost::container::flat_set<int> rijen;
|
||||
for (const auto e : indexes)
|
||||
rijen.insert(e.row());
|
||||
|
||||
QString drops;
|
||||
QString creates;
|
||||
for (auto rij : rijen) {
|
||||
const PgIndex index = m_indexModel->getIndex(rij);
|
||||
//drops += getDropIndexDefinition(*m_catalog, index) % "\n";
|
||||
creates += getIndexDefinition(*m_catalog, index) % "\n";
|
||||
}
|
||||
ui->indexSqlEdit->setPlainText(drops % "\n" % creates);
|
||||
|
||||
}
|
||||
|
||||
void TablesPage::on_tableListTable_doubleClicked(const QModelIndex &index)
|
||||
{
|
||||
PgClass table = m_tablesModel->getTable(index.row());
|
||||
|
|
|
|||
|
|
@ -34,13 +34,14 @@ private:
|
|||
ColumnTableModel* m_columnsModel = nullptr;
|
||||
ConstraintModel* m_constraintModel = nullptr;
|
||||
IndexModel* m_indexModel = nullptr;
|
||||
NamespaceFilterWidget* m_namespaceFilterWidget;
|
||||
//NamespaceFilterWidget* m_namespaceFilterWidget;
|
||||
|
||||
private slots:
|
||||
|
||||
void tableListTable_currentRowChanged(const QModelIndex ¤t, const QModelIndex &previous);
|
||||
void constraintsTable_currentRowChanged(const QModelIndex ¤t, const QModelIndex &previous);
|
||||
// void constraintsTable_currentRowChanged(const QModelIndex ¤t, const QModelIndex &previous);
|
||||
void constraintsTable_selectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
|
||||
void indexesTable_selectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
|
||||
void on_tableListTable_doubleClicked(const QModelIndex &index);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1041</width>
|
||||
<height>830</height>
|
||||
<width>993</width>
|
||||
<height>754</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
|
@ -38,7 +38,7 @@
|
|||
</widget>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>1</number>
|
||||
<number>2</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="columnsTab">
|
||||
<attribute name="title">
|
||||
|
|
@ -76,7 +76,13 @@
|
|||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<widget class="QTableView" name="indexesTable"/>
|
||||
<widget class="QSplitter" name="splitter_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<widget class="QTableView" name="indexesTable"/>
|
||||
<widget class="QPlainTextEdit" name="indexSqlEdit"/>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue