List of databases and roles moved to a "Server tab" within the database window.
Opened by selecting "Inspect Server" from the menu.
This commit is contained in:
parent
50cd865b1a
commit
f0e5488ce0
12 changed files with 271 additions and 2 deletions
|
|
@ -5,18 +5,31 @@
|
||||||
#include "UserConfiguration.h"
|
#include "UserConfiguration.h"
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
|
|
||||||
|
class CodeGeneratorViewModel {
|
||||||
|
public:
|
||||||
|
QProperty<QString> StructName;
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
CodeGenerator::CodeGenerator(QWidget *parent)
|
CodeGenerator::CodeGenerator(QWidget *parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
, ui(new Ui::CodeGenerator)
|
, ui(new Ui::CodeGenerator)
|
||||||
|
, Model(new CodeGeneratorViewModel)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
ui->generatedCodeEditor->setFont(UserConfiguration::instance()->codeFont());
|
ui->generatedCodeEditor->setFont(UserConfiguration::instance()->codeFont());
|
||||||
ui->generatedCodeEditor->setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard);
|
ui->generatedCodeEditor->setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard);
|
||||||
|
|
||||||
|
|
||||||
|
auto v = Model->StructName.onValueChanged([this]() { ui->structNameEdit->setText(Model->StructName); });
|
||||||
}
|
}
|
||||||
|
|
||||||
CodeGenerator::~CodeGenerator()
|
CodeGenerator::~CodeGenerator()
|
||||||
{
|
{
|
||||||
|
delete Model;
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ class CodeGenerator;
|
||||||
}
|
}
|
||||||
|
|
||||||
class PgDatabaseCatalog;
|
class PgDatabaseCatalog;
|
||||||
|
class CodeGeneratorViewModel;
|
||||||
|
|
||||||
class CodeGenerator : public QWidget {
|
class CodeGenerator : public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
@ -23,6 +24,8 @@ private slots:
|
||||||
private:
|
private:
|
||||||
Ui::CodeGenerator *ui;
|
Ui::CodeGenerator *ui;
|
||||||
|
|
||||||
|
CodeGeneratorViewModel *Model;
|
||||||
|
|
||||||
std::shared_ptr<PgDatabaseCatalog> m_catalog;
|
std::shared_ptr<PgDatabaseCatalog> m_catalog;
|
||||||
QString m_query;
|
QString m_query;
|
||||||
std::shared_ptr<const Pgsql::Result> m_dbres;
|
std::shared_ptr<const Pgsql::Result> m_dbres;
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@
|
||||||
#include "EditTableWidget.h"
|
#include "EditTableWidget.h"
|
||||||
#include "CodeGenerator.h"
|
#include "CodeGenerator.h"
|
||||||
#include "QueryTool.h"
|
#include "QueryTool.h"
|
||||||
|
#include <serverinspector/ServerInspector.h>
|
||||||
|
|
||||||
namespace pg = Pgsql;
|
namespace pg = Pgsql;
|
||||||
|
|
||||||
|
|
@ -202,6 +203,12 @@ void DatabaseWindow::createActions()
|
||||||
auto action = actionInspectInformationSchema = new QAction(icon, tr("Inspect information_schema"), this);
|
auto action = actionInspectInformationSchema = new QAction(icon, tr("Inspect information_schema"), this);
|
||||||
action->setObjectName("actionInspectInformationSchema");
|
action->setObjectName("actionInspectInformationSchema");
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
QIcon icon;
|
||||||
|
icon.addFile(QString::fromUtf8(":/icons/page_white_add.png"), QSize(), QIcon::Normal, QIcon::On);
|
||||||
|
auto action = actionServerInspector = new QAction(icon, tr("Inspect server"), this);
|
||||||
|
action->setObjectName("actionServerInspector");
|
||||||
|
}
|
||||||
{
|
{
|
||||||
QIcon icon;
|
QIcon icon;
|
||||||
icon.addFile(QString::fromUtf8(":/icons/page_white_add.png"), QSize(), QIcon::Normal, QIcon::On);
|
icon.addFile(QString::fromUtf8(":/icons/page_white_add.png"), QSize(), QIcon::Normal, QIcon::On);
|
||||||
|
|
@ -320,6 +327,7 @@ void DatabaseWindow::initMenus()
|
||||||
actionInspectUserSchemas,
|
actionInspectUserSchemas,
|
||||||
actionInspectPgCatalog,
|
actionInspectPgCatalog,
|
||||||
actionInspectInformationSchema,
|
actionInspectInformationSchema,
|
||||||
|
actionServerInspector,
|
||||||
seperator(),
|
seperator(),
|
||||||
actionShowConnectionManager
|
actionShowConnectionManager
|
||||||
});
|
});
|
||||||
|
|
@ -366,6 +374,14 @@ void DatabaseWindow::newCatalogInspectorPage(QString caption, NamespaceFilter fi
|
||||||
connect(ct->tablesPage(), &CatalogTablesPage::tableSelected, this, &DatabaseWindow::tableSelected);
|
connect(ct->tablesPage(), &CatalogTablesPage::tableSelected, this, &DatabaseWindow::tableSelected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DatabaseWindow::newServerInspectorPage()
|
||||||
|
{
|
||||||
|
auto si = new ServerInspector(m_database, this);
|
||||||
|
// si->addAction(actionRefreshCatalog);
|
||||||
|
addPage(si, tr("Server"));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void DatabaseWindow::closeTab(int index)
|
void DatabaseWindow::closeTab(int index)
|
||||||
{
|
{
|
||||||
QWidget *widget = m_tabWidget->widget(index);
|
QWidget *widget = m_tabWidget->widget(index);
|
||||||
|
|
@ -523,6 +539,11 @@ void DatabaseWindow::on_actionInspectUserSchemas_triggered()
|
||||||
newCatalogInspectorPage("Schema", NamespaceFilter::User);
|
newCatalogInspectorPage("Schema", NamespaceFilter::User);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DatabaseWindow::on_actionServerInspector_triggered()
|
||||||
|
{
|
||||||
|
newServerInspectorPage();
|
||||||
|
}
|
||||||
|
|
||||||
void DatabaseWindow::on_actionNewSql_triggered()
|
void DatabaseWindow::on_actionNewSql_triggered()
|
||||||
{
|
{
|
||||||
auto *ct = new QueryTool(this, this);
|
auto *ct = new QueryTool(this, this);
|
||||||
|
|
|
||||||
|
|
@ -81,6 +81,7 @@ private:
|
||||||
QAction *actionInspectInformationSchema = nullptr; ///< Create or switch to pgcatalog tab
|
QAction *actionInspectInformationSchema = nullptr; ///< Create or switch to pgcatalog tab
|
||||||
QAction *actionInspectPgCatalog = 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 *actionInspectUserSchemas = nullptr; ///< Create or switch to pgcatalog tab
|
||||||
|
QAction *actionServerInspector = nullptr;
|
||||||
QAction *actionNewSql = nullptr;
|
QAction *actionNewSql = nullptr;
|
||||||
QAction *actionOpenSql = nullptr;
|
QAction *actionOpenSql = nullptr;
|
||||||
QAction *actionPasteLangString = nullptr;
|
QAction *actionPasteLangString = nullptr;
|
||||||
|
|
@ -125,6 +126,7 @@ private:
|
||||||
void newCreateTablePage();
|
void newCreateTablePage();
|
||||||
void newCrudPage(Oid tableoid);
|
void newCrudPage(Oid tableoid);
|
||||||
void newCatalogInspectorPage(QString caption, NamespaceFilter filter);
|
void newCatalogInspectorPage(QString caption, NamespaceFilter filter);
|
||||||
|
void newServerInspectorPage();
|
||||||
void closeTab(int index);
|
void closeTab(int index);
|
||||||
private slots:
|
private slots:
|
||||||
void catalogLoaded();
|
void catalogLoaded();
|
||||||
|
|
@ -146,6 +148,7 @@ private slots:
|
||||||
void on_actionInspectInformationSchema_triggered();
|
void on_actionInspectInformationSchema_triggered();
|
||||||
void on_actionInspectPgCatalog_triggered();
|
void on_actionInspectPgCatalog_triggered();
|
||||||
void on_actionInspectUserSchemas_triggered();
|
void on_actionInspectUserSchemas_triggered();
|
||||||
|
void on_actionServerInspector_triggered();
|
||||||
void on_actionNewSql_triggered();
|
void on_actionNewSql_triggered();
|
||||||
void on_actionOpenSql_triggered();
|
void on_actionOpenSql_triggered();
|
||||||
void on_actionPasteLangString_triggered();
|
void on_actionPasteLangString_triggered();
|
||||||
|
|
|
||||||
40
pglab/PgLabTableViewHelper.h
Normal file
40
pglab/PgLabTableViewHelper.h
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QTableWidget>
|
||||||
|
#include <QSortFilterProxyModel>
|
||||||
|
#include "PgLabTableView.h"
|
||||||
|
|
||||||
|
template <typename TableModel>
|
||||||
|
class PgLabTableViewHelper {
|
||||||
|
public:
|
||||||
|
PgLabTableViewHelper(QWidget * parent)
|
||||||
|
{
|
||||||
|
m_tableView = new PgLabTableView(parent);
|
||||||
|
|
||||||
|
m_dataModel = new TableModel(parent);
|
||||||
|
m_sortFilter = new QSortFilterProxyModel(parent);
|
||||||
|
m_sortFilter->setSourceModel(m_dataModel);
|
||||||
|
m_tableView->setModel(m_dataModel);
|
||||||
|
m_tableView->setSortingEnabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
PgLabTableView *tableView() const
|
||||||
|
{
|
||||||
|
return m_tableView;
|
||||||
|
}
|
||||||
|
|
||||||
|
TableModel *dataModel() const
|
||||||
|
{
|
||||||
|
return m_dataModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
QSortFilterProxyModel *sortFilter() const
|
||||||
|
{
|
||||||
|
return m_sortFilter;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
PgLabTableView *m_tableView = nullptr;
|
||||||
|
TableModel *m_dataModel = nullptr;
|
||||||
|
QSortFilterProxyModel *m_sortFilter = nullptr;
|
||||||
|
};
|
||||||
|
|
@ -36,6 +36,9 @@ SOURCES += main.cpp\
|
||||||
ConnectionManagerWindow.cpp \
|
ConnectionManagerWindow.cpp \
|
||||||
ConnectionListModel.cpp \
|
ConnectionListModel.cpp \
|
||||||
SslModeModel.cpp \
|
SslModeModel.cpp \
|
||||||
|
serverinspector/DatabasesPage.cpp \
|
||||||
|
serverinspector/RolesPage.cpp \
|
||||||
|
serverinspector/ServerInspector.cpp \
|
||||||
stopwatch.cpp \
|
stopwatch.cpp \
|
||||||
TuplesResultWidget.cpp \
|
TuplesResultWidget.cpp \
|
||||||
BackupDialog.cpp \
|
BackupDialog.cpp \
|
||||||
|
|
@ -101,12 +104,16 @@ HEADERS += \
|
||||||
NotificationModel.h \
|
NotificationModel.h \
|
||||||
NotificationService.h \
|
NotificationService.h \
|
||||||
PgDumpOutputHighlighter.h \
|
PgDumpOutputHighlighter.h \
|
||||||
|
PgLabTableViewHelper.h \
|
||||||
QueryResultModel.h \
|
QueryResultModel.h \
|
||||||
QueryExplainModel.h \
|
QueryExplainModel.h \
|
||||||
CreateDatabaseDialog.h \
|
CreateDatabaseDialog.h \
|
||||||
ConnectionManagerWindow.h \
|
ConnectionManagerWindow.h \
|
||||||
ConnectionListModel.h \
|
ConnectionListModel.h \
|
||||||
SslModeModel.h \
|
SslModeModel.h \
|
||||||
|
serverinspector/DatabasesPage.h \
|
||||||
|
serverinspector/RolesPage.h \
|
||||||
|
serverinspector/ServerInspector.h \
|
||||||
stopwatch.h \
|
stopwatch.h \
|
||||||
TuplesResultWidget.h \
|
TuplesResultWidget.h \
|
||||||
BackupDialog.h \
|
BackupDialog.h \
|
||||||
|
|
|
||||||
32
pglab/serverinspector/DatabasesPage.cpp
Normal file
32
pglab/serverinspector/DatabasesPage.cpp
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
#include "DatabasesPage.h"
|
||||||
|
|
||||||
|
#include "DatabasesTableModel.h"
|
||||||
|
#include "catalog/PgDatabaseCatalog.h"
|
||||||
|
#include "PgLabTableView.h"
|
||||||
|
|
||||||
|
|
||||||
|
DatabasesPage::DatabasesPage(QWidget * parent)
|
||||||
|
: QSplitter(Qt::Horizontal, parent)
|
||||||
|
, m_databasesTableView(this)
|
||||||
|
{
|
||||||
|
auto tv = m_databasesTableView.tableView();
|
||||||
|
tv->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||||
|
|
||||||
|
m_detailsTabs = new QTabWidget(this);
|
||||||
|
|
||||||
|
addWidget(tv);
|
||||||
|
addWidget(m_detailsTabs);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DatabasesPage::setCatalog(std::shared_ptr<PgDatabaseCatalog> cat)
|
||||||
|
{
|
||||||
|
m_catalog = cat;
|
||||||
|
m_databasesTableView.dataModel()->setDatabaseList(cat);
|
||||||
|
m_databasesTableView.tableView()->resizeColumnsToContents();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
28
pglab/serverinspector/DatabasesPage.h
Normal file
28
pglab/serverinspector/DatabasesPage.h
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QSplitter>
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
|
#include "PgLabTableViewHelper.h"
|
||||||
|
|
||||||
|
class DatabasesTableModel;
|
||||||
|
class PgDatabaseCatalog;
|
||||||
|
class PgLabTableView;
|
||||||
|
class QSortFilterProxyModel;
|
||||||
|
|
||||||
|
class DatabasesPage: public QSplitter {
|
||||||
|
public:
|
||||||
|
explicit DatabasesPage(QWidget * parent = nullptr);
|
||||||
|
|
||||||
|
void setCatalog(std::shared_ptr<PgDatabaseCatalog> cat);
|
||||||
|
|
||||||
|
void retranslateUi(bool all = true);
|
||||||
|
|
||||||
|
private:
|
||||||
|
PgLabTableViewHelper<DatabasesTableModel> m_databasesTableView;
|
||||||
|
QTabWidget *m_detailsTabs = nullptr;
|
||||||
|
|
||||||
|
std::shared_ptr<PgDatabaseCatalog> m_catalog;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
23
pglab/serverinspector/RolesPage.cpp
Normal file
23
pglab/serverinspector/RolesPage.cpp
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
#include "RolesPage.h"
|
||||||
|
#include "catalog/PgDatabaseCatalog.h"
|
||||||
|
#include "RolesTableModel.h"
|
||||||
|
|
||||||
|
RolesPage::RolesPage(QWidget * parent)
|
||||||
|
: QSplitter(Qt::Horizontal, parent)
|
||||||
|
, m_rolesTableView(this)
|
||||||
|
{
|
||||||
|
auto tv = m_rolesTableView.tableView();
|
||||||
|
tv->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||||
|
|
||||||
|
m_detailsTabs = new QTabWidget(this);
|
||||||
|
|
||||||
|
addWidget(tv);
|
||||||
|
addWidget(m_detailsTabs);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RolesPage::setCatalog(std::shared_ptr<PgDatabaseCatalog> cat)
|
||||||
|
{
|
||||||
|
m_catalog = cat;
|
||||||
|
m_rolesTableView.dataModel()->setRoleList(cat->authIds());
|
||||||
|
m_rolesTableView.tableView()->resizeColumnsToContents();
|
||||||
|
}
|
||||||
26
pglab/serverinspector/RolesPage.h
Normal file
26
pglab/serverinspector/RolesPage.h
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QSplitter>
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
|
#include "PgLabTableViewHelper.h"
|
||||||
|
|
||||||
|
class RolesTableModel;
|
||||||
|
class PgDatabaseCatalog;
|
||||||
|
class PgLabTableView;
|
||||||
|
class QSortFilterProxyModel;
|
||||||
|
|
||||||
|
|
||||||
|
class RolesPage: public QSplitter {
|
||||||
|
public:
|
||||||
|
RolesPage(QWidget * parent = nullptr);
|
||||||
|
|
||||||
|
void setCatalog(std::shared_ptr<PgDatabaseCatalog> cat);
|
||||||
|
private:
|
||||||
|
PgLabTableViewHelper<RolesTableModel> m_rolesTableView;
|
||||||
|
QTabWidget *m_detailsTabs = nullptr;
|
||||||
|
|
||||||
|
std::shared_ptr<PgDatabaseCatalog> m_catalog;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
44
pglab/serverinspector/ServerInspector.cpp
Normal file
44
pglab/serverinspector/ServerInspector.cpp
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
#include "ServerInspector.h"
|
||||||
|
#include "DatabasesPage.h"
|
||||||
|
#include "OpenDatabase.h"
|
||||||
|
#include "RolesPage.h"
|
||||||
|
|
||||||
|
#include <QTabWidget>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
|
ServerInspector::ServerInspector(std::shared_ptr<OpenDatabase> open_database, QWidget *parent)
|
||||||
|
: QWidget(parent)
|
||||||
|
{
|
||||||
|
m_databasesPage = new DatabasesPage(this);
|
||||||
|
m_rolesPage = new RolesPage(this);
|
||||||
|
|
||||||
|
m_tabWidget = new QTabWidget(this);
|
||||||
|
m_tabWidget->addTab(m_databasesPage, tr("Databases"));
|
||||||
|
m_tabWidget->addTab(m_rolesPage, tr("Roles"));
|
||||||
|
|
||||||
|
auto layout = new QVBoxLayout(this);
|
||||||
|
setLayout(layout);
|
||||||
|
layout->addWidget(m_tabWidget);
|
||||||
|
|
||||||
|
setCatalog(open_database->catalog());
|
||||||
|
retranslateUi(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ServerInspector::setCatalog(std::shared_ptr<PgDatabaseCatalog> cat)
|
||||||
|
{
|
||||||
|
m_catalog = cat;
|
||||||
|
m_databasesPage->setCatalog(cat);
|
||||||
|
m_rolesPage->setCatalog(cat);
|
||||||
|
// m_tablesPage->setCatalog(cat);
|
||||||
|
// m_functionsPage->setCatalog(cat);
|
||||||
|
// m_sequencesPage->setCatalog(cat);
|
||||||
|
// m_typesPage->setCatalog(cat);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ServerInspector::retranslateUi(bool )
|
||||||
|
{
|
||||||
|
// m_tabWidget->setTabText(m_tabWidget->indexOf(m_namespacePage),
|
||||||
|
// QApplication::translate("CatalogInspector", "Schemas", nullptr));
|
||||||
|
|
||||||
|
}
|
||||||
29
pglab/serverinspector/ServerInspector.h
Normal file
29
pglab/serverinspector/ServerInspector.h
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
class DatabasesPage;
|
||||||
|
class OpenDatabase;
|
||||||
|
class PgDatabaseCatalog;
|
||||||
|
class QTabWidget;
|
||||||
|
class RolesPage;
|
||||||
|
|
||||||
|
|
||||||
|
class ServerInspector : public QWidget {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit ServerInspector(std::shared_ptr<OpenDatabase> open_database, QWidget *parent = nullptr);
|
||||||
|
|
||||||
|
void setCatalog(std::shared_ptr<PgDatabaseCatalog> cat);
|
||||||
|
private:
|
||||||
|
QTabWidget *m_tabWidget = nullptr;
|
||||||
|
|
||||||
|
DatabasesPage *m_databasesPage = nullptr;
|
||||||
|
RolesPage *m_rolesPage = nullptr;
|
||||||
|
|
||||||
|
std::shared_ptr<PgDatabaseCatalog> m_catalog;
|
||||||
|
|
||||||
|
void retranslateUi(bool all = true);
|
||||||
|
};
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue