CatalogInspector is normal QWidget now
added actions to open the inspector
This commit is contained in:
parent
edb789ca4a
commit
09ef4cdf6b
4 changed files with 62 additions and 57 deletions
|
|
@ -1,7 +1,6 @@
|
||||||
#include "CatalogInspector.h"
|
#include "CatalogInspector.h"
|
||||||
#include "OpenDatabase.h"
|
#include "OpenDatabase.h"
|
||||||
#include "UserConfiguration.h"
|
#include "UserConfiguration.h"
|
||||||
#include "plugin_support/IPluginContentWidgetContext.h"
|
|
||||||
#include "widgets/CatalogFunctionsPage.h"
|
#include "widgets/CatalogFunctionsPage.h"
|
||||||
#include "widgets/CatalogSequencesPage.h"
|
#include "widgets/CatalogSequencesPage.h"
|
||||||
#include "widgets/CatalogTablesPage.h"
|
#include "widgets/CatalogTablesPage.h"
|
||||||
|
|
@ -12,8 +11,8 @@
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
|
|
||||||
CatalogInspector::CatalogInspector(IPluginContentWidgetContext *context_, PluginModule *module, QWidget *parent)
|
CatalogInspector::CatalogInspector(std::shared_ptr<OpenDatabase> open_database, QWidget *parent)
|
||||||
: PluginContentWidget(context_, module, parent)
|
: QWidget(parent)
|
||||||
{
|
{
|
||||||
m_tabWidget = new QTabWidget(this);
|
m_tabWidget = new QTabWidget(this);
|
||||||
m_tablesPage = new CatalogTablesPage(this);
|
m_tablesPage = new CatalogTablesPage(this);
|
||||||
|
|
@ -27,8 +26,7 @@ CatalogInspector::CatalogInspector(IPluginContentWidgetContext *context_, Plugin
|
||||||
m_tabWidget->addTab(m_functionsPage, "");
|
m_tabWidget->addTab(m_functionsPage, "");
|
||||||
m_tabWidget->addTab(m_sequencesPage, "");
|
m_tabWidget->addTab(m_sequencesPage, "");
|
||||||
|
|
||||||
auto db = context_->getObject<OpenDatabase>();
|
setCatalog(open_database->catalog());
|
||||||
setCatalog(db->catalog());
|
|
||||||
retranslateUi(false);
|
retranslateUi(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -75,32 +73,5 @@ void CatalogInspector::setNamespaceFilter(NamespaceFilter filter)
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
context()->setCaption(this, caption, hint);
|
// context()->setCaption(this, caption, hint);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CatalogInspectorModule::init()
|
|
||||||
{
|
|
||||||
registerModuleAction("open",
|
|
||||||
[this] (IPluginContentWidgetContext* context,
|
|
||||||
const ModuleActionParameters ¶ms)
|
|
||||||
{
|
|
||||||
moduleAction_open(context, params);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void CatalogInspectorModule::moduleAction_open(
|
|
||||||
IPluginContentWidgetContext* context,
|
|
||||||
const ModuleActionParameters ¶ms
|
|
||||||
)
|
|
||||||
{
|
|
||||||
auto ct = new CatalogInspector(context, this);
|
|
||||||
context->addContentWidget(ct);
|
|
||||||
auto nsf = params.at("namespace-filter").toString();
|
|
||||||
NamespaceFilter filter = NamespaceFilter::User;
|
|
||||||
if (nsf == "pg_catalog") filter = NamespaceFilter::PgCatalog;
|
|
||||||
else if (nsf == "information_schema") filter = NamespaceFilter::InformationSchema;
|
|
||||||
ct->setNamespaceFilter(filter);
|
|
||||||
}
|
|
||||||
|
|
||||||
REGISTER_PLUGIN_MODULE_CAT(CatalogInspectorModule, "Catalog inspector tool",
|
|
||||||
"pglab.catalog-inspector", "database")
|
|
||||||
|
|
|
||||||
|
|
@ -4,20 +4,18 @@
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include "NamespaceFilter.h"
|
#include "NamespaceFilter.h"
|
||||||
#include "plugin_support/PluginContentWidget.h"
|
|
||||||
#include "plugin_support/PluginModule.h"
|
|
||||||
|
|
||||||
class CatalogFunctionsPage;
|
class CatalogFunctionsPage;
|
||||||
class CatalogSequencesPage;
|
class CatalogSequencesPage;
|
||||||
class CatalogTablesPage;
|
class CatalogTablesPage;
|
||||||
|
class OpenDatabase;
|
||||||
class PgDatabaseCatalog;
|
class PgDatabaseCatalog;
|
||||||
class QTabWidget;
|
class QTabWidget;
|
||||||
|
|
||||||
class CatalogInspector : public PluginContentWidget {
|
class CatalogInspector : public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit CatalogInspector(IPluginContentWidgetContext *context, PluginModule *module,
|
explicit CatalogInspector(std::shared_ptr<OpenDatabase> open_database, QWidget *parent = nullptr);
|
||||||
QWidget *parent = nullptr);
|
|
||||||
~CatalogInspector();
|
~CatalogInspector();
|
||||||
|
|
||||||
void setCatalog(std::shared_ptr<PgDatabaseCatalog> cat);
|
void setCatalog(std::shared_ptr<PgDatabaseCatalog> cat);
|
||||||
|
|
@ -34,17 +32,4 @@ private:
|
||||||
private slots:
|
private slots:
|
||||||
};
|
};
|
||||||
|
|
||||||
class CatalogInspectorModule: public PluginModule {
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
using PluginModule::PluginModule;
|
|
||||||
|
|
||||||
void init();
|
|
||||||
private slots:
|
|
||||||
|
|
||||||
private:
|
|
||||||
void moduleAction_open(IPluginContentWidgetContext* context, const ModuleActionParameters ¶ms);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#endif // TABLESPAGE_H
|
#endif // TABLESPAGE_H
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@
|
||||||
#include <QTableView>
|
#include <QTableView>
|
||||||
|
|
||||||
#include "EditTableWidget.h"
|
#include "EditTableWidget.h"
|
||||||
|
#include "CatalogInspector.h"
|
||||||
#include "CodeGenerator.h"
|
#include "CodeGenerator.h"
|
||||||
#include "QueryTool.h"
|
#include "QueryTool.h"
|
||||||
|
|
||||||
|
|
@ -98,24 +99,46 @@ void DatabaseWindow::createActions()
|
||||||
{
|
{
|
||||||
QIcon icon;
|
QIcon icon;
|
||||||
icon.addFile(QString::fromUtf8(":/icons/about.png"), QSize(), QIcon::Normal, QIcon::On);
|
icon.addFile(QString::fromUtf8(":/icons/about.png"), QSize(), QIcon::Normal, QIcon::On);
|
||||||
actionAbout = new QAction(icon, tr("About"), this);
|
auto action = actionAbout = new QAction(icon, tr("About"), this);
|
||||||
|
action->setObjectName("actionAbout");
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
QIcon icon;
|
QIcon icon;
|
||||||
icon.addFile(QString::fromUtf8(":/icons/page_white_delete.png"), QSize(), QIcon::Normal, QIcon::On);
|
icon.addFile(QString::fromUtf8(":/icons/page_white_delete.png"), QSize(), QIcon::Normal, QIcon::On);
|
||||||
auto action = actionClose = new QAction(icon, tr("Close"), this);
|
auto action = actionClose = new QAction(icon, tr("Close"), this);
|
||||||
|
action->setObjectName("actionClose");
|
||||||
action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_W));
|
action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_W));
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
QIcon icon;
|
||||||
|
icon.addFile(QString::fromUtf8(":/icons/page_white_add.png"), QSize(), QIcon::Normal, QIcon::On);
|
||||||
|
auto action = actionInspectInformationSchema = new QAction(icon, tr("Inspect information_schema"), this);
|
||||||
|
action->setObjectName("actionInspectInformationSchema");
|
||||||
|
}
|
||||||
|
{
|
||||||
|
QIcon icon;
|
||||||
|
icon.addFile(QString::fromUtf8(":/icons/page_white_add.png"), QSize(), QIcon::Normal, QIcon::On);
|
||||||
|
auto action = actionInspectPgCatalog = new QAction(icon, tr("Inspect pg_catalog"), this);
|
||||||
|
action->setObjectName("actionInspectPgCatalog");
|
||||||
|
}
|
||||||
|
{
|
||||||
|
QIcon icon;
|
||||||
|
icon.addFile(QString::fromUtf8(":/icons/page_white_add.png"), QSize(), QIcon::Normal, QIcon::On);
|
||||||
|
auto action = actionInspectUserSchemas = new QAction(icon, tr("Inspect user schemas"), this);
|
||||||
|
action->setObjectName("actionInspectUserSchemas");
|
||||||
|
}
|
||||||
{
|
{
|
||||||
QIcon icon;
|
QIcon icon;
|
||||||
icon.addFile(QString::fromUtf8(":/icons/new_query_tab.png"), QSize(), QIcon::Normal, QIcon::On);
|
icon.addFile(QString::fromUtf8(":/icons/new_query_tab.png"), QSize(), QIcon::Normal, QIcon::On);
|
||||||
auto action = actionNewSql = new QAction(icon, tr("New Query"), this);
|
auto action = actionNewSql = new QAction(icon, tr("New Query"), this);
|
||||||
|
action->setObjectName("actionNewSql");
|
||||||
action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_N));
|
action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_N));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
QIcon icon;
|
QIcon icon;
|
||||||
icon.addFile(QString::fromUtf8(":/icons/folder.png"), QSize(), QIcon::Normal, QIcon::On);
|
icon.addFile(QString::fromUtf8(":/icons/folder.png"), QSize(), QIcon::Normal, QIcon::On);
|
||||||
auto action = actionOpenSql = new QAction(icon, tr("Open Query"), this);
|
auto action = actionOpenSql = new QAction(icon, tr("Open Query"), this);
|
||||||
|
action->setObjectName("actionOpenSql");
|
||||||
action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_O));
|
action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_O));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -146,7 +169,6 @@ void DatabaseWindow::createActions()
|
||||||
|
|
||||||
void DatabaseWindow::initMenus()
|
void DatabaseWindow::initMenus()
|
||||||
{
|
{
|
||||||
// TODO construct menubar
|
|
||||||
auto seperator = new QAction(this);
|
auto seperator = new QAction(this);
|
||||||
seperator->setSeparator(true);
|
seperator->setSeparator(true);
|
||||||
|
|
||||||
|
|
@ -156,6 +178,9 @@ void DatabaseWindow::initMenus()
|
||||||
actionNewSql,
|
actionNewSql,
|
||||||
actionOpenSql,
|
actionOpenSql,
|
||||||
seperator,
|
seperator,
|
||||||
|
actionInspectUserSchemas,
|
||||||
|
actionInspectPgCatalog,
|
||||||
|
actionInspectInformationSchema,
|
||||||
seperator,
|
seperator,
|
||||||
actionClose
|
actionClose
|
||||||
});
|
});
|
||||||
|
|
@ -166,9 +191,6 @@ void DatabaseWindow::initMenus()
|
||||||
actionAbout
|
actionAbout
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
setMenuBar(mb);
|
setMenuBar(mb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -181,10 +203,31 @@ void DatabaseWindow::on_actionClose_triggered()
|
||||||
void DatabaseWindow::on_actionNewSql_triggered()
|
void DatabaseWindow::on_actionNewSql_triggered()
|
||||||
{
|
{
|
||||||
auto *ct = new QueryTool(m_database, this);
|
auto *ct = new QueryTool(m_database, this);
|
||||||
addPage(ct, "");
|
addPage(ct, "query");
|
||||||
ct->newdoc();
|
ct->newdoc();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DatabaseWindow::on_actionInspectInformationSchema_triggered()
|
||||||
|
{
|
||||||
|
auto ct = new CatalogInspector(m_database, this);
|
||||||
|
addPage(ct, "information_schema");
|
||||||
|
ct->setNamespaceFilter(NamespaceFilter::InformationSchema);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DatabaseWindow::on_actionInspectPgCatalog_triggered()
|
||||||
|
{
|
||||||
|
auto ct = new CatalogInspector(m_database, this);
|
||||||
|
addPage(ct, "pg_catalog");
|
||||||
|
ct->setNamespaceFilter(NamespaceFilter::PgCatalog);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DatabaseWindow::on_actionInspectUserSchemas_triggered()
|
||||||
|
{
|
||||||
|
auto ct = new CatalogInspector(m_database, this);
|
||||||
|
addPage(ct, "Schema");
|
||||||
|
ct->setNamespaceFilter(NamespaceFilter::User);
|
||||||
|
}
|
||||||
|
|
||||||
void DatabaseWindow::on_actionOpenSql_triggered()
|
void DatabaseWindow::on_actionOpenSql_triggered()
|
||||||
{
|
{
|
||||||
QString home_dir = QStandardPaths::locate(QStandardPaths::HomeLocation, "", QStandardPaths::LocateDirectory);
|
QString home_dir = QStandardPaths::locate(QStandardPaths::HomeLocation, "", QStandardPaths::LocateDirectory);
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,9 @@ private:
|
||||||
// Standard actions
|
// Standard actions
|
||||||
QAction *actionAbout = nullptr;
|
QAction *actionAbout = nullptr;
|
||||||
QAction *actionClose = nullptr;
|
QAction *actionClose = nullptr;
|
||||||
|
QAction *actionInspectInformationSchema = nullptr; ///< Create or switch to pgcatalog tab
|
||||||
|
QAction *actionInspectPgCatalog = nullptr; ///< Create or switch to pgcatalog tab
|
||||||
|
QAction *actionInspectUserSchemas = nullptr; ///< Create or switch to pgcatalog tab
|
||||||
QAction *actionNewSql = nullptr;
|
QAction *actionNewSql = nullptr;
|
||||||
QAction *actionOpenSql = nullptr;
|
QAction *actionOpenSql = nullptr;
|
||||||
|
|
||||||
|
|
@ -96,6 +99,9 @@ private slots:
|
||||||
|
|
||||||
void on_actionClose_triggered();
|
void on_actionClose_triggered();
|
||||||
void on_actionNewSql_triggered();
|
void on_actionNewSql_triggered();
|
||||||
|
void on_actionInspectInformationSchema_triggered();
|
||||||
|
void on_actionInspectPgCatalog_triggered();
|
||||||
|
void on_actionInspectUserSchemas_triggered();
|
||||||
void on_actionOpenSql_triggered();
|
void on_actionOpenSql_triggered();
|
||||||
void on_actionAbout_triggered();
|
void on_actionAbout_triggered();
|
||||||
void on_actionShow_connection_manager_triggered();
|
void on_actionShow_connection_manager_triggered();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue