2019-01-06 10:11:48 +01:00
|
|
|
|
#include "CatalogInspector.h"
|
|
|
|
|
|
#include "OpenDatabase.h"
|
2018-10-07 19:40:06 +02:00
|
|
|
|
#include "UserConfiguration.h"
|
2019-02-09 09:49:27 +01:00
|
|
|
|
#include "widgets/CatalogFunctionsPage.h"
|
2019-11-20 19:09:22 +01:00
|
|
|
|
#include "widgets/CatalogNamespacePage.h"
|
2019-02-09 09:49:27 +01:00
|
|
|
|
#include "widgets/CatalogSequencesPage.h"
|
|
|
|
|
|
#include "widgets/CatalogTablesPage.h"
|
2021-04-01 14:58:42 +02:00
|
|
|
|
#include "widgets/CatalogTypesPage.h"
|
2019-02-09 09:49:27 +01:00
|
|
|
|
|
|
|
|
|
|
#include <QApplication>
|
|
|
|
|
|
#include <QTabWidget>
|
2018-01-06 21:22:22 +01:00
|
|
|
|
#include <QStringBuilder>
|
2019-02-09 09:49:27 +01:00
|
|
|
|
#include <QVBoxLayout>
|
2018-12-23 08:39:38 +01:00
|
|
|
|
#include <unordered_set>
|
2017-12-10 14:20:45 +01:00
|
|
|
|
|
2019-08-15 16:38:01 +02:00
|
|
|
|
CatalogInspector::CatalogInspector(std::shared_ptr<OpenDatabase> open_database, QWidget *parent)
|
|
|
|
|
|
: QWidget(parent)
|
2017-12-10 08:17:07 +01:00
|
|
|
|
{
|
2019-02-09 09:49:27 +01:00
|
|
|
|
m_tabWidget = new QTabWidget(this);
|
2021-06-08 20:37:44 +02:00
|
|
|
|
// m_namespacePage = new CatalogNamespacePage(this);
|
2019-02-09 09:49:27 +01:00
|
|
|
|
m_tablesPage = new CatalogTablesPage(this);
|
|
|
|
|
|
m_functionsPage = new CatalogFunctionsPage(this);
|
|
|
|
|
|
m_sequencesPage = new CatalogSequencesPage(this);
|
2021-04-01 14:58:42 +02:00
|
|
|
|
m_typesPage = new CatalogTypesPage(this);
|
2018-12-29 10:56:24 +01:00
|
|
|
|
|
2019-02-09 09:49:27 +01:00
|
|
|
|
auto layout = new QVBoxLayout(this);
|
|
|
|
|
|
setLayout(layout);
|
|
|
|
|
|
layout->addWidget(m_tabWidget);
|
2021-06-08 20:37:44 +02:00
|
|
|
|
// m_tabWidget->addTab(m_namespacePage, "");
|
2019-02-09 09:49:27 +01:00
|
|
|
|
m_tabWidget->addTab(m_tablesPage, "");
|
|
|
|
|
|
m_tabWidget->addTab(m_functionsPage, "");
|
|
|
|
|
|
m_tabWidget->addTab(m_sequencesPage, "");
|
2021-04-01 14:58:42 +02:00
|
|
|
|
m_tabWidget->addTab(m_typesPage, "");
|
2018-12-29 10:56:24 +01:00
|
|
|
|
|
2019-08-15 16:38:01 +02:00
|
|
|
|
setCatalog(open_database->catalog());
|
2018-10-07 19:40:06 +02:00
|
|
|
|
retranslateUi(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-01-06 10:11:48 +01:00
|
|
|
|
void CatalogInspector::retranslateUi(bool all)
|
2018-10-07 19:40:06 +02:00
|
|
|
|
{
|
2019-02-09 09:49:27 +01:00
|
|
|
|
m_tablesPage->retranslateUi(all);
|
2018-11-30 18:41:38 +01:00
|
|
|
|
|
2021-06-08 20:37:44 +02:00
|
|
|
|
// m_tabWidget->setTabText(m_tabWidget->indexOf(m_namespacePage),
|
|
|
|
|
|
// QApplication::translate("CatalogInspector", "Schemas", nullptr));
|
2019-02-09 09:49:27 +01:00
|
|
|
|
m_tabWidget->setTabText(m_tabWidget->indexOf(m_tablesPage),
|
|
|
|
|
|
QApplication::translate("CatalogInspector", "Tables", nullptr));
|
|
|
|
|
|
m_tabWidget->setTabText(m_tabWidget->indexOf(m_functionsPage),
|
|
|
|
|
|
QApplication::translate("CatalogInspector", "Functions", nullptr));
|
|
|
|
|
|
m_tabWidget->setTabText(m_tabWidget->indexOf(m_sequencesPage),
|
|
|
|
|
|
QApplication::translate("CatalogInspector", "Sequences", nullptr));
|
2021-04-01 14:58:42 +02:00
|
|
|
|
m_tabWidget->setTabText(m_tabWidget->indexOf(m_typesPage),
|
|
|
|
|
|
QApplication::translate("CatalogInspector", "Types", nullptr));
|
2017-12-12 20:13:53 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2019-01-06 10:11:48 +01:00
|
|
|
|
CatalogInspector::~CatalogInspector()
|
2017-12-12 20:13:53 +01:00
|
|
|
|
{
|
2017-12-10 14:20:45 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2019-01-06 10:11:48 +01:00
|
|
|
|
void CatalogInspector::setCatalog(std::shared_ptr<PgDatabaseCatalog> cat)
|
2017-12-10 14:20:45 +01:00
|
|
|
|
{
|
|
|
|
|
|
m_catalog = cat;
|
2021-06-08 20:37:44 +02:00
|
|
|
|
// m_namespacePage->setCatalog(cat);
|
2019-02-09 09:49:27 +01:00
|
|
|
|
m_tablesPage->setCatalog(cat);
|
|
|
|
|
|
m_functionsPage->setCatalog(cat);
|
|
|
|
|
|
m_sequencesPage->setCatalog(cat);
|
2021-04-01 14:58:42 +02:00
|
|
|
|
m_typesPage->setCatalog(cat);
|
2017-12-10 08:17:07 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2019-02-09 20:37:34 +01:00
|
|
|
|
void CatalogInspector::setNamespaceFilter(NamespaceFilter filter)
|
2018-12-29 10:56:24 +01:00
|
|
|
|
{
|
2019-02-09 09:49:27 +01:00
|
|
|
|
m_tablesPage->setNamespaceFilter(filter);
|
2019-02-09 20:37:34 +01:00
|
|
|
|
m_functionsPage->setNamespaceFilter(filter);
|
|
|
|
|
|
m_sequencesPage->setNamespaceFilter(filter);
|
2019-01-06 10:11:48 +01:00
|
|
|
|
QString hint = "Catalog instpector";
|
|
|
|
|
|
QString caption = "Inspector";
|
|
|
|
|
|
switch (filter) {
|
2019-02-09 20:37:34 +01:00
|
|
|
|
case NamespaceFilter::PgCatalog:
|
2019-01-06 10:11:48 +01:00
|
|
|
|
hint += " - pg_catalog";
|
|
|
|
|
|
caption = "pg_catalog";
|
|
|
|
|
|
break;
|
2019-02-09 20:37:34 +01:00
|
|
|
|
case NamespaceFilter::InformationSchema:
|
2019-01-06 10:11:48 +01:00
|
|
|
|
hint += " - information_schema";
|
|
|
|
|
|
caption = "information_schema";
|
|
|
|
|
|
break;
|
|
|
|
|
|
default:
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
2019-08-15 16:38:01 +02:00
|
|
|
|
// context()->setCaption(this, caption, hint);
|
2018-12-29 10:56:24 +01:00
|
|
|
|
}
|
2019-08-16 10:49:38 +02:00
|
|
|
|
|
|
|
|
|
|
CatalogTablesPage *CatalogInspector::tablesPage()
|
|
|
|
|
|
{
|
|
|
|
|
|
return m_tablesPage;
|
|
|
|
|
|
}
|