Make double clicking on table in CatalogInspector open crud for selected table/view.

This commit is contained in:
eelke 2019-08-16 10:49:38 +02:00
parent 1a2ec6a224
commit 6fdf631fac
8 changed files with 53 additions and 47 deletions

View file

@ -1,5 +1,7 @@
#include "DatabaseWindow.h"
#include "util.h"
#include "CrudTab.h"
#include "widgets/CatalogTablesPage.h"
#include "OpenDatabase.h"
#include "MasterController.h"
#include "TaskExecutor.h"
@ -14,7 +16,6 @@
#include <QTableView>
#include "EditTableWidget.h"
#include "CatalogInspector.h"
#include "CodeGenerator.h"
#include "QueryTool.h"
@ -65,6 +66,13 @@ void DatabaseWindow::newCreateTablePage()
m_tabWidget->addTab(w, "Create table");
}
void DatabaseWindow::newCrudPage(Oid tableoid)
{
CrudTab *ct = new CrudTab(this, this);
addPage(ct, "crud");
ct->setConfig(tableoid);
}
void DatabaseWindow::newCodeGenPage(QString query, std::shared_ptr<const Pgsql::Result> dbres)
{
// TODO should this call be this direct or should it go through module system
@ -288,6 +296,15 @@ QAction *DatabaseWindow::seperator()
return ac;
}
void DatabaseWindow::createCatalogInspector(QString caption, NamespaceFilter filter)
{
auto ct = new CatalogInspector(m_database, this);
addPage(ct, caption);
ct->setNamespaceFilter(filter);
connect(ct->tablesPage(), &CatalogTablesPage::tableSelected, this, &DatabaseWindow::tableSelected);
}
void DatabaseWindow::catalogLoaded()
@ -307,6 +324,11 @@ void DatabaseWindow::catalogLoaded()
}
}
void DatabaseWindow::tableSelected(Oid tableoid)
{
newCrudPage(tableoid);
}
void DatabaseWindow::on_actionAbout_triggered()
{
@ -414,23 +436,17 @@ void DatabaseWindow::on_actionClose_triggered()
void DatabaseWindow::on_actionInspectInformationSchema_triggered()
{
auto ct = new CatalogInspector(m_database, this);
addPage(ct, "information_schema");
ct->setNamespaceFilter(NamespaceFilter::InformationSchema);
createCatalogInspector("information_schema", NamespaceFilter::InformationSchema);
}
void DatabaseWindow::on_actionInspectPgCatalog_triggered()
{
auto ct = new CatalogInspector(m_database, this);
addPage(ct, "pg_catalog");
ct->setNamespaceFilter(NamespaceFilter::PgCatalog);
createCatalogInspector("pg_catalog", NamespaceFilter::PgCatalog);
}
void DatabaseWindow::on_actionInspectUserSchemas_triggered()
{
auto ct = new CatalogInspector(m_database, this);
addPage(ct, "Schema");
ct->setNamespaceFilter(NamespaceFilter::User);
createCatalogInspector("Schema", NamespaceFilter::User);
}
void DatabaseWindow::on_actionNewSql_triggered()