Crud page has now reload action.
F5 key is bound to the execute query, reload catalog and reload crud actions. By using addAction to add these actions to the relevant pages the ambiguity of the shortcut is resolved.
This commit is contained in:
parent
4278fe6ff4
commit
1a208a6a2d
4 changed files with 71 additions and 51 deletions
|
|
@ -106,16 +106,3 @@ void CrudTab::headerCustomContextMenu(const QPoint &pos)
|
||||||
auto horizontal_header = ui->tableView->horizontalHeader();
|
auto horizontal_header = ui->tableView->horizontalHeader();
|
||||||
menu->popup(horizontal_header->mapToGlobal(pos));
|
menu->popup(horizontal_header->mapToGlobal(pos));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CrudTab::initActions()
|
|
||||||
{
|
|
||||||
|
|
||||||
{
|
|
||||||
auto ac = new QAction(QIcon(":/icons/script_go.png"), tr("Refresh"), this);
|
|
||||||
ac->setShortcut(QKeySequence(Qt::Key_F5));
|
|
||||||
connect(ac, &QAction::triggered, this, &CrudTab::refresh);
|
|
||||||
m_refreshAction = ac;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO refresh action
|
|
||||||
|
|
|
||||||
|
|
@ -31,29 +31,13 @@ private:
|
||||||
std::optional<PgClass> m_table;
|
std::optional<PgClass> m_table;
|
||||||
|
|
||||||
CrudModel *m_crudModel = nullptr;
|
CrudModel *m_crudModel = nullptr;
|
||||||
QAction *m_refreshAction = nullptr;
|
|
||||||
|
|
||||||
void initActions();
|
void initActions();
|
||||||
|
|
||||||
// virtual QList<QAction *> actions() override;
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_actionRemove_rows_triggered();
|
void on_actionRemove_rows_triggered();
|
||||||
void headerCustomContextMenu(const QPoint &pos);
|
void headerCustomContextMenu(const QPoint &pos);
|
||||||
};
|
};
|
||||||
|
|
||||||
//class CrudPageModule: public PluginModule {
|
|
||||||
// Q_OBJECT
|
|
||||||
//public:
|
|
||||||
// using PluginModule::PluginModule;
|
|
||||||
|
|
||||||
// void init();
|
|
||||||
//private slots:
|
|
||||||
|
|
||||||
//private:
|
|
||||||
|
|
||||||
// void moduleAction_open(IPluginContentWidgetContext* context, const ModuleActionParameters ¶ms);
|
|
||||||
//};
|
|
||||||
|
|
||||||
|
|
||||||
#endif // CRUDTAB_H
|
#endif // CRUDTAB_H
|
||||||
|
|
|
||||||
|
|
@ -63,19 +63,6 @@ void DatabaseWindow::setTabIcon(QWidget *widget, const QString &iconname)
|
||||||
m_tabWidget->setTabIcon(index, QIcon(n));
|
m_tabWidget->setTabIcon(index, QIcon(n));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DatabaseWindow::newCreateTablePage()
|
|
||||||
{
|
|
||||||
auto w = new EditTableWidget(m_database, this);
|
|
||||||
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)
|
void DatabaseWindow::newCodeGenPage(QString query, std::shared_ptr<const Pgsql::Result> dbres)
|
||||||
{
|
{
|
||||||
auto cgtab = new CodeGenerator(this);
|
auto cgtab = new CodeGenerator(this);
|
||||||
|
|
@ -90,6 +77,13 @@ QueryTool *DatabaseWindow::GetActiveQueryTool()
|
||||||
return qt;
|
return qt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CrudTab *DatabaseWindow::GetActiveCrud()
|
||||||
|
{
|
||||||
|
auto widget = m_tabWidget->currentWidget();
|
||||||
|
auto ct = dynamic_cast<CrudTab*>(widget);
|
||||||
|
return ct;
|
||||||
|
}
|
||||||
|
|
||||||
void DatabaseWindow::setConfig(const ConnectionConfig &config)
|
void DatabaseWindow::setConfig(const ConnectionConfig &config)
|
||||||
{
|
{
|
||||||
m_config = config;
|
m_config = config;
|
||||||
|
|
@ -158,6 +152,7 @@ void DatabaseWindow::createActions()
|
||||||
auto action = actionExecuteQuery = new QAction(icon, tr("Execute query"), this);
|
auto action = actionExecuteQuery = new QAction(icon, tr("Execute query"), this);
|
||||||
action->setObjectName("actionExecuteQuery");
|
action->setObjectName("actionExecuteQuery");
|
||||||
action->setShortcut(QKeySequence(Qt::Key_F5));
|
action->setShortcut(QKeySequence(Qt::Key_F5));
|
||||||
|
action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
QIcon icon;
|
QIcon icon;
|
||||||
|
|
@ -225,8 +220,16 @@ void DatabaseWindow::createActions()
|
||||||
{
|
{
|
||||||
QIcon icon;
|
QIcon icon;
|
||||||
auto action = actionRefreshCatalog = new QAction(icon, tr("Refresh"), this);
|
auto action = actionRefreshCatalog = new QAction(icon, tr("Refresh"), this);
|
||||||
|
action->setShortcut(QKeySequence(Qt::Key_F5));
|
||||||
|
action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
|
||||||
action->setObjectName("actionRefreshCatalog");
|
action->setObjectName("actionRefreshCatalog");
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
auto action = actionRefreshCrud = new QAction(QIcon(), tr("Refresh"), this);
|
||||||
|
action->setShortcut(QKeySequence(Qt::Key_F5));
|
||||||
|
action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
|
||||||
|
action->setObjectName("actionRefreshCrud");
|
||||||
|
}
|
||||||
{
|
{
|
||||||
QIcon icon;
|
QIcon icon;
|
||||||
icon.addFile(QString::fromUtf8(":/icons/script_save.png"), QSize(), QIcon::Normal, QIcon::On);
|
icon.addFile(QString::fromUtf8(":/icons/script_save.png"), QSize(), QIcon::Normal, QIcon::On);
|
||||||
|
|
@ -289,6 +292,11 @@ void DatabaseWindow::initMenus()
|
||||||
actionRefreshCatalog
|
actionRefreshCatalog
|
||||||
});
|
});
|
||||||
|
|
||||||
|
menuCrud = mb->addMenu(tr("CRUD"));
|
||||||
|
menuCrud->addActions({
|
||||||
|
actionRefreshCrud
|
||||||
|
});
|
||||||
|
|
||||||
menuWindow = mb->addMenu(tr("Window"));
|
menuWindow = mb->addMenu(tr("Window"));
|
||||||
menuWindow->addActions({
|
menuWindow->addActions({
|
||||||
actionInspectUserSchemas,
|
actionInspectUserSchemas,
|
||||||
|
|
@ -315,14 +323,29 @@ QAction *DatabaseWindow::seperator()
|
||||||
return ac;
|
return ac;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DatabaseWindow::createCatalogInspector(QString caption, NamespaceFilter filter)
|
void DatabaseWindow::newCreateTablePage()
|
||||||
|
{
|
||||||
|
auto w = new EditTableWidget(m_database, this);
|
||||||
|
m_tabWidget->addTab(w, "Create table");
|
||||||
|
}
|
||||||
|
|
||||||
|
void DatabaseWindow::newCrudPage(Oid tableoid)
|
||||||
|
{
|
||||||
|
CrudTab *ct = new CrudTab(this, this);
|
||||||
|
ct->addAction(actionRefreshCrud);
|
||||||
|
addPage(ct, "crud");
|
||||||
|
ct->setConfig(tableoid);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DatabaseWindow::newCatalogInspectorPage(QString caption, NamespaceFilter filter)
|
||||||
{
|
{
|
||||||
auto ct = new CatalogInspector(m_database, this);
|
auto ct = new CatalogInspector(m_database, this);
|
||||||
|
ct->addAction(actionRefreshCatalog);
|
||||||
|
|
||||||
addPage(ct, caption);
|
addPage(ct, caption);
|
||||||
ct->setNamespaceFilter(filter);
|
ct->setNamespaceFilter(filter);
|
||||||
|
|
||||||
connect(ct->tablesPage(), &CatalogTablesPage::tableSelected, this, &DatabaseWindow::tableSelected);
|
connect(ct->tablesPage(), &CatalogTablesPage::tableSelected, this, &DatabaseWindow::tableSelected);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DatabaseWindow::closeTab(int index)
|
void DatabaseWindow::closeTab(int index)
|
||||||
|
|
@ -467,22 +490,23 @@ void DatabaseWindow::on_actionGenerateCode_triggered()
|
||||||
|
|
||||||
void DatabaseWindow::on_actionInspectInformationSchema_triggered()
|
void DatabaseWindow::on_actionInspectInformationSchema_triggered()
|
||||||
{
|
{
|
||||||
createCatalogInspector("information_schema", NamespaceFilter::InformationSchema);
|
newCatalogInspectorPage("information_schema", NamespaceFilter::InformationSchema);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DatabaseWindow::on_actionInspectPgCatalog_triggered()
|
void DatabaseWindow::on_actionInspectPgCatalog_triggered()
|
||||||
{
|
{
|
||||||
createCatalogInspector("pg_catalog", NamespaceFilter::PgCatalog);
|
newCatalogInspectorPage("pg_catalog", NamespaceFilter::PgCatalog);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DatabaseWindow::on_actionInspectUserSchemas_triggered()
|
void DatabaseWindow::on_actionInspectUserSchemas_triggered()
|
||||||
{
|
{
|
||||||
createCatalogInspector("Schema", NamespaceFilter::User);
|
newCatalogInspectorPage("Schema", NamespaceFilter::User);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DatabaseWindow::on_actionNewSql_triggered()
|
void DatabaseWindow::on_actionNewSql_triggered()
|
||||||
{
|
{
|
||||||
auto *ct = new QueryTool(this, this);
|
auto *ct = new QueryTool(this, this);
|
||||||
|
ct->addAction(actionExecuteQuery);
|
||||||
addPage(ct, "query");
|
addPage(ct, "query");
|
||||||
ct->newdoc();
|
ct->newdoc();
|
||||||
}
|
}
|
||||||
|
|
@ -516,6 +540,14 @@ void DatabaseWindow::on_actionRefreshCatalog_triggered()
|
||||||
m_database->refresh();
|
m_database->refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DatabaseWindow::on_actionRefreshCrud_triggered()
|
||||||
|
{
|
||||||
|
auto crud = GetActiveCrud();
|
||||||
|
if (crud) {
|
||||||
|
crud->refresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void DatabaseWindow::on_actionSaveSql_triggered()
|
void DatabaseWindow::on_actionSaveSql_triggered()
|
||||||
{
|
{
|
||||||
auto query_tool = GetActiveQueryTool();
|
auto query_tool = GetActiveQueryTool();
|
||||||
|
|
@ -550,6 +582,18 @@ void DatabaseWindow::on_m_tabWidget_tabCloseRequested(int index)
|
||||||
closeTab(index);
|
closeTab(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DatabaseWindow::on_m_tabWidget_currentChanged(int)
|
||||||
|
{
|
||||||
|
auto widget = m_tabWidget->currentWidget();
|
||||||
|
auto qt = dynamic_cast<QueryTool*>(widget);
|
||||||
|
auto ct = dynamic_cast<CrudTab*>(widget);
|
||||||
|
auto ci = dynamic_cast<CatalogInspector*>(widget);
|
||||||
|
|
||||||
|
menuQuery->menuAction()->setVisible(qt != nullptr);
|
||||||
|
menuCatalog->menuAction()->setVisible(ci != nullptr);
|
||||||
|
menuCrud->menuAction()->setVisible(ct != nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
void DatabaseWindow::setTitleForWidget(QWidget *widget, QString title, QString hint)
|
void DatabaseWindow::setTitleForWidget(QWidget *widget, QString title, QString hint)
|
||||||
{
|
{
|
||||||
int i = m_tabWidget->indexOf(widget);
|
int i = m_tabWidget->indexOf(widget);
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ namespace Pgsql {
|
||||||
class Connection;
|
class Connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class CrudTab;
|
||||||
class MasterController;
|
class MasterController;
|
||||||
class QCloseEvent;
|
class QCloseEvent;
|
||||||
class OpenDatabase;
|
class OpenDatabase;
|
||||||
|
|
@ -48,6 +49,7 @@ public:
|
||||||
virtual void newCodeGenPage(QString query, std::shared_ptr<const Pgsql::Result> dbres) override;
|
virtual void newCodeGenPage(QString query, std::shared_ptr<const Pgsql::Result> dbres) override;
|
||||||
|
|
||||||
QueryTool *GetActiveQueryTool();
|
QueryTool *GetActiveQueryTool();
|
||||||
|
CrudTab *GetActiveCrud();
|
||||||
private:
|
private:
|
||||||
QTabWidget *m_tabWidget = nullptr;
|
QTabWidget *m_tabWidget = nullptr;
|
||||||
QToolBar *m_mainToolBar = nullptr;
|
QToolBar *m_mainToolBar = nullptr;
|
||||||
|
|
@ -79,6 +81,7 @@ private:
|
||||||
QAction *actionOpenSql = nullptr;
|
QAction *actionOpenSql = nullptr;
|
||||||
QAction *actionPasteLangString = nullptr;
|
QAction *actionPasteLangString = nullptr;
|
||||||
QAction *actionRefreshCatalog = nullptr;
|
QAction *actionRefreshCatalog = nullptr;
|
||||||
|
QAction *actionRefreshCrud = nullptr;
|
||||||
QAction *actionSaveSql = nullptr;
|
QAction *actionSaveSql = nullptr;
|
||||||
QAction *actionSaveSqlAs = nullptr;
|
QAction *actionSaveSqlAs = nullptr;
|
||||||
QAction *actionSaveCopyOfSqlAs = nullptr;
|
QAction *actionSaveCopyOfSqlAs = nullptr;
|
||||||
|
|
@ -89,6 +92,7 @@ private:
|
||||||
QMenu *menuHelp = nullptr;
|
QMenu *menuHelp = nullptr;
|
||||||
QMenu *menuQuery = nullptr;
|
QMenu *menuQuery = nullptr;
|
||||||
QMenu *menuCatalog = nullptr;
|
QMenu *menuCatalog = nullptr;
|
||||||
|
QMenu *menuCrud = nullptr;
|
||||||
QMenu *menuWindow = nullptr;
|
QMenu *menuWindow = nullptr;
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -109,15 +113,14 @@ private:
|
||||||
|
|
||||||
QFutureWatcher<LoadCatalog::Result> loadWatcher;
|
QFutureWatcher<LoadCatalog::Result> loadWatcher;
|
||||||
|
|
||||||
void newCreateTablePage();
|
|
||||||
void newCrudPage(Oid tableoid);
|
|
||||||
|
|
||||||
void createActions();
|
void createActions();
|
||||||
void initMenus();
|
void initMenus();
|
||||||
|
|
||||||
QAction* seperator();
|
QAction* seperator();
|
||||||
|
|
||||||
void createCatalogInspector(QString caption, NamespaceFilter filter);
|
void newCreateTablePage();
|
||||||
|
void newCrudPage(Oid tableoid);
|
||||||
|
void newCatalogInspectorPage(QString caption, NamespaceFilter filter);
|
||||||
void closeTab(int index);
|
void closeTab(int index);
|
||||||
private slots:
|
private slots:
|
||||||
void catalogLoaded();
|
void catalogLoaded();
|
||||||
|
|
@ -143,11 +146,13 @@ private slots:
|
||||||
void on_actionOpenSql_triggered();
|
void on_actionOpenSql_triggered();
|
||||||
void on_actionPasteLangString_triggered();
|
void on_actionPasteLangString_triggered();
|
||||||
void on_actionRefreshCatalog_triggered();
|
void on_actionRefreshCatalog_triggered();
|
||||||
|
void on_actionRefreshCrud_triggered();
|
||||||
void on_actionSaveSql_triggered();
|
void on_actionSaveSql_triggered();
|
||||||
void on_actionSaveSqlAs_triggered();
|
void on_actionSaveSqlAs_triggered();
|
||||||
void on_actionSaveCopyOfSqlAs_triggered();
|
void on_actionSaveCopyOfSqlAs_triggered();
|
||||||
void on_actionShowConnectionManager_triggered();
|
void on_actionShowConnectionManager_triggered();
|
||||||
void on_m_tabWidget_tabCloseRequested(int index);
|
void on_m_tabWidget_tabCloseRequested(int index);
|
||||||
|
void on_m_tabWidget_currentChanged(int index);
|
||||||
|
|
||||||
// IDatabaseWindow interface
|
// IDatabaseWindow interface
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue