Renamed MainWindow to DatabaseWindow so the name tells us the functionality provided by the window.
MainWindow was really a bad name as the app doesn't have a main window.
This commit is contained in:
parent
437736a023
commit
69473d65d2
10 changed files with 58 additions and 55 deletions
|
|
@ -1,7 +1,7 @@
|
|||
#include "CrudTab.h"
|
||||
#include "ui_CrudTab.h"
|
||||
#include "CrudModel.h"
|
||||
#include "MainWindow.h"
|
||||
#include "DatabaseWindow.h"
|
||||
#include "ResultTableModelUtil.h"
|
||||
#include "PgLabItemDelegate.h"
|
||||
#include "IntegerRange.h"
|
||||
|
|
@ -12,7 +12,7 @@
|
|||
#include <set>
|
||||
|
||||
|
||||
CrudTab::CrudTab(MainWindow *parent)
|
||||
CrudTab::CrudTab(DatabaseWindow *parent)
|
||||
: PlgPage(parent)
|
||||
, ui(new Ui::CrudTab)
|
||||
, m_window(parent)
|
||||
|
|
|
|||
|
|
@ -13,14 +13,14 @@ namespace Ui {
|
|||
|
||||
class OpenDatabase;
|
||||
class CrudModel;
|
||||
class MainWindow;
|
||||
class DatabaseWindow;
|
||||
|
||||
class CrudTab : public PlgPage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CrudTab(MainWindow *parent = 0);
|
||||
explicit CrudTab(DatabaseWindow *parent = 0);
|
||||
~CrudTab() override;
|
||||
|
||||
void setConfig(std::shared_ptr<OpenDatabase> db, const PgClass &table);
|
||||
|
|
@ -31,7 +31,7 @@ public:
|
|||
private:
|
||||
Ui::CrudTab *ui;
|
||||
|
||||
MainWindow *m_window;
|
||||
DatabaseWindow *m_window;
|
||||
|
||||
std::shared_ptr<OpenDatabase> m_db;
|
||||
std::optional<PgClass> m_table;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#include "MainWindow.h"
|
||||
#include "DatabaseWindow.h"
|
||||
#include "ui_MainWindow.h"
|
||||
#include "TablesPage.h"
|
||||
#include "FunctionsPage.h"
|
||||
|
|
@ -26,7 +26,7 @@
|
|||
namespace pg = Pgsql;
|
||||
|
||||
|
||||
MainWindow::MainWindow(MasterController *master, QWidget *parent)
|
||||
DatabaseWindow::DatabaseWindow(MasterController *master, QWidget *parent)
|
||||
: ASyncWindow(parent)
|
||||
, ui(new Ui::MainWindow)
|
||||
, m_masterController(master)
|
||||
|
|
@ -35,13 +35,13 @@ MainWindow::MainWindow(MasterController *master, QWidget *parent)
|
|||
ui->tabWidget->setDocumentMode(true);
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
DatabaseWindow::~DatabaseWindow()
|
||||
{
|
||||
loader.reset();
|
||||
delete ui;
|
||||
}
|
||||
|
||||
QueryTab* MainWindow::newSqlPage()
|
||||
QueryTab* DatabaseWindow::newSqlPage()
|
||||
{
|
||||
QueryTab *qt = new QueryTab(this);
|
||||
qt->setConfig(m_config, m_database->catalog());
|
||||
|
|
@ -51,20 +51,20 @@ QueryTab* MainWindow::newSqlPage()
|
|||
return qt;
|
||||
}
|
||||
|
||||
void MainWindow::newCreateTablePage()
|
||||
void DatabaseWindow::newCreateTablePage()
|
||||
{
|
||||
auto w = new EditTableWidget(m_database, this);
|
||||
ui->tabWidget->addTab(w, "Create table");
|
||||
}
|
||||
|
||||
void MainWindow::newCrudPage(const PgClass &table)
|
||||
void DatabaseWindow::newCrudPage(const PgClass &table)
|
||||
{
|
||||
CrudTab *ct = new CrudTab(this);
|
||||
ct->setConfig(m_database, table);
|
||||
addPage(ct, table.objectName());
|
||||
}
|
||||
|
||||
void MainWindow::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);
|
||||
cgtab->Init(m_database->catalog(), query, dbres);
|
||||
|
|
@ -72,14 +72,14 @@ void MainWindow::newCodeGenPage(QString query, std::shared_ptr<const Pgsql::Resu
|
|||
}
|
||||
|
||||
|
||||
QueryTab *MainWindow::GetActiveQueryTab()
|
||||
QueryTab *DatabaseWindow::GetActiveQueryTab()
|
||||
{
|
||||
QWidget *widget = ui->tabWidget->currentWidget();
|
||||
QueryTab *qt = dynamic_cast<QueryTab*>(widget);
|
||||
return qt;
|
||||
}
|
||||
|
||||
void MainWindow::setConfig(const ConnectionConfig &config)
|
||||
void DatabaseWindow::setConfig(const ConnectionConfig &config)
|
||||
{
|
||||
m_config = config;
|
||||
try {
|
||||
|
|
@ -99,7 +99,7 @@ void MainWindow::setConfig(const ConnectionConfig &config)
|
|||
}
|
||||
}
|
||||
|
||||
void MainWindow::catalogLoaded()
|
||||
void DatabaseWindow::catalogLoaded()
|
||||
{
|
||||
try {
|
||||
SCOPE_EXIT { loader.reset(); };
|
||||
|
|
@ -127,7 +127,7 @@ void MainWindow::catalogLoaded()
|
|||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_actionLoad_SQL_triggered()
|
||||
void DatabaseWindow::on_actionLoad_SQL_triggered()
|
||||
{
|
||||
QString home_dir = QStandardPaths::locate(QStandardPaths::HomeLocation, "", QStandardPaths::LocateDirectory);
|
||||
QString file_name = QFileDialog::getOpenFileName(this,
|
||||
|
|
@ -139,7 +139,7 @@ void MainWindow::on_actionLoad_SQL_triggered()
|
|||
|
||||
}
|
||||
|
||||
void MainWindow::on_actionSave_SQL_triggered()
|
||||
void DatabaseWindow::on_actionSave_SQL_triggered()
|
||||
{
|
||||
QueryTab *tab = GetActiveQueryTab();
|
||||
if (tab) {
|
||||
|
|
@ -147,7 +147,7 @@ void MainWindow::on_actionSave_SQL_triggered()
|
|||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_actionSave_SQL_as_triggered()
|
||||
void DatabaseWindow::on_actionSave_SQL_as_triggered()
|
||||
{
|
||||
QueryTab *tab = GetActiveQueryTab();
|
||||
if (tab) {
|
||||
|
|
@ -156,7 +156,7 @@ void MainWindow::on_actionSave_SQL_as_triggered()
|
|||
|
||||
}
|
||||
|
||||
void MainWindow::on_actionSave_copy_of_SQL_as_triggered()
|
||||
void DatabaseWindow::on_actionSave_copy_of_SQL_as_triggered()
|
||||
{
|
||||
QueryTab *tab = GetActiveQueryTab();
|
||||
if (tab) {
|
||||
|
|
@ -164,7 +164,7 @@ void MainWindow::on_actionSave_copy_of_SQL_as_triggered()
|
|||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_actionExport_data_triggered()
|
||||
void DatabaseWindow::on_actionExport_data_triggered()
|
||||
{
|
||||
QueryTab *tab = GetActiveQueryTab();
|
||||
if (tab) {
|
||||
|
|
@ -176,13 +176,13 @@ void MainWindow::on_actionExport_data_triggered()
|
|||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_actionClose_triggered()
|
||||
void DatabaseWindow::on_actionClose_triggered()
|
||||
{
|
||||
//close();
|
||||
on_tabWidget_tabCloseRequested(ui->tabWidget->currentIndex());
|
||||
}
|
||||
|
||||
void MainWindow::on_actionAbout_triggered()
|
||||
void DatabaseWindow::on_actionAbout_triggered()
|
||||
{
|
||||
QMessageBox::about(this, "pgLab 0.1", tr(
|
||||
"Copyrights 2016-2017, Eelke Klein, All Rights Reserved.\n"
|
||||
|
|
@ -200,7 +200,7 @@ void MainWindow::on_actionAbout_triggered()
|
|||
|
||||
}
|
||||
|
||||
void MainWindow::closeEvent(QCloseEvent* /*event*/)
|
||||
void DatabaseWindow::closeEvent(QCloseEvent* /*event*/)
|
||||
{
|
||||
// TODO collect which files need saving
|
||||
// std::vector<QString> files_to_save;
|
||||
|
|
@ -232,7 +232,7 @@ void MainWindow::closeEvent(QCloseEvent* /*event*/)
|
|||
|
||||
}
|
||||
|
||||
void MainWindow::showEvent(QShowEvent *event)
|
||||
void DatabaseWindow::showEvent(QShowEvent *event)
|
||||
{
|
||||
if (!event->spontaneous()) {
|
||||
// m_queryTextChanged = false;
|
||||
|
|
@ -240,13 +240,13 @@ void MainWindow::showEvent(QShowEvent *event)
|
|||
event->accept();
|
||||
}
|
||||
|
||||
void MainWindow::on_actionNew_SQL_triggered()
|
||||
void DatabaseWindow::on_actionNew_SQL_triggered()
|
||||
{
|
||||
newSqlPage();
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::on_tabWidget_tabCloseRequested(int index)
|
||||
void DatabaseWindow::on_tabWidget_tabCloseRequested(int index)
|
||||
{
|
||||
QWidget *widget = ui->tabWidget->widget(index);
|
||||
PlgPage *plg_page = dynamic_cast<PlgPage*>(widget);
|
||||
|
|
@ -270,12 +270,12 @@ void MainWindow::on_tabWidget_tabCloseRequested(int index)
|
|||
}
|
||||
|
||||
|
||||
void MainWindow::on_actionShow_connection_manager_triggered()
|
||||
void DatabaseWindow::on_actionShow_connection_manager_triggered()
|
||||
{
|
||||
m_masterController->showConnectionManager();
|
||||
}
|
||||
|
||||
void MainWindow::on_actionCopy_triggered()
|
||||
void DatabaseWindow::on_actionCopy_triggered()
|
||||
{
|
||||
// What should be copied?
|
||||
|
||||
|
|
@ -295,7 +295,7 @@ void MainWindow::on_actionCopy_triggered()
|
|||
}
|
||||
|
||||
|
||||
void MainWindow::on_actionCopy_as_C_string_triggered()
|
||||
void DatabaseWindow::on_actionCopy_as_C_string_triggered()
|
||||
{
|
||||
// Find which edit is active, copy the selected text or all text if no selection present
|
||||
// Put quote's around each line and add escapes.
|
||||
|
|
@ -307,7 +307,7 @@ void MainWindow::on_actionCopy_as_C_string_triggered()
|
|||
}
|
||||
|
||||
|
||||
void MainWindow::on_actionCopy_as_raw_Cpp_string_triggered()
|
||||
void DatabaseWindow::on_actionCopy_as_raw_Cpp_string_triggered()
|
||||
{
|
||||
QueryTab *tab = GetActiveQueryTab();
|
||||
if (tab) {
|
||||
|
|
@ -315,7 +315,7 @@ void MainWindow::on_actionCopy_as_raw_Cpp_string_triggered()
|
|||
}
|
||||
}
|
||||
|
||||
void MainWindow::addToolBarButtonsForPage(PlgPage *page)
|
||||
void DatabaseWindow::addToolBarButtonsForPage(PlgPage *page)
|
||||
{
|
||||
std::vector<QAction*> actions = page->getToolbarActions();
|
||||
QList<QAction*> list;
|
||||
|
|
@ -325,7 +325,7 @@ void MainWindow::addToolBarButtonsForPage(PlgPage *page)
|
|||
ui->mainToolBar->addActions(list);
|
||||
}
|
||||
|
||||
void MainWindow::removeToolBarButtonsForPage(PlgPage *page)
|
||||
void DatabaseWindow::removeToolBarButtonsForPage(PlgPage *page)
|
||||
{
|
||||
std::vector<QAction*> actions = page->getToolbarActions();
|
||||
for (auto act : actions) {
|
||||
|
|
@ -334,7 +334,7 @@ void MainWindow::removeToolBarButtonsForPage(PlgPage *page)
|
|||
}
|
||||
|
||||
|
||||
void MainWindow::addPage(PlgPage* page, QString caption)
|
||||
void DatabaseWindow::addPage(PlgPage* page, QString caption)
|
||||
{
|
||||
ui->tabWidget->addTab(page, caption);
|
||||
ui->tabWidget->setCurrentWidget(page);
|
||||
|
|
@ -342,12 +342,12 @@ void MainWindow::addPage(PlgPage* page, QString caption)
|
|||
//addToolBarButtonsForPage(page);
|
||||
}
|
||||
|
||||
void MainWindow::removePage(PlgPage *)
|
||||
void DatabaseWindow::removePage(PlgPage *)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::on_tabWidget_currentChanged(int index)
|
||||
void DatabaseWindow::on_tabWidget_currentChanged(int index)
|
||||
{
|
||||
// remove buttons of old page
|
||||
if (m_previousPage) {
|
||||
|
|
@ -366,7 +366,7 @@ void MainWindow::on_tabWidget_currentChanged(int index)
|
|||
m_previousPage = page;
|
||||
}
|
||||
|
||||
void MainWindow::on_actionGenerate_code_triggered()
|
||||
void DatabaseWindow::on_actionGenerate_code_triggered()
|
||||
{
|
||||
QueryTab *tab = GetActiveQueryTab();
|
||||
if (tab) {
|
||||
|
|
@ -35,11 +35,14 @@ class OpenDatabase;
|
|||
class PgClass;
|
||||
class PlgPage;
|
||||
|
||||
class MainWindow : public ASyncWindow {
|
||||
/** This is the class for windows that handle tasks for a specific database/catalog
|
||||
*
|
||||
*/
|
||||
class DatabaseWindow : public ASyncWindow {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit MainWindow(MasterController *master, QWidget *parent);
|
||||
~MainWindow();
|
||||
explicit DatabaseWindow(MasterController *master, QWidget *parent);
|
||||
~DatabaseWindow();
|
||||
|
||||
void setConfig(const ConnectionConfig &config);
|
||||
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
#include "ConnectionList.h"
|
||||
#include "ConnectionListModel.h"
|
||||
#include "PasswordManager.h"
|
||||
#include "MainWindow.h"
|
||||
#include "DatabaseWindow.h"
|
||||
#include "ServerWindow.h"
|
||||
#include "BackupDialog.h"
|
||||
#include "PasswordPromptDialog.h"
|
||||
|
|
@ -80,7 +80,7 @@ void MasterController::openSqlWindowForConnection(size_t connection_index)
|
|||
// TODO instead of directly openening the mainwindow
|
||||
// do async connect and only open window when we have
|
||||
// working connection
|
||||
auto w = new MainWindow(this, nullptr);
|
||||
auto w = new DatabaseWindow(this, nullptr);
|
||||
w->setAttribute( Qt::WA_DeleteOnClose );
|
||||
w->setConfig(cc);
|
||||
w->show();
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
#include <QClipboard>
|
||||
#include "ExplainTreeModelItem.h"
|
||||
#include "json/json.h"
|
||||
#include "MainWindow.h"
|
||||
#include "DatabaseWindow.h"
|
||||
#include "OpenDatabase.h"
|
||||
#include "catalog/PgDatabaseCatalog.h"
|
||||
#include "QueryParamListController.h"
|
||||
|
|
@ -23,7 +23,7 @@
|
|||
#include "GlobalIoService.h"
|
||||
#include "UserConfiguration.h"
|
||||
|
||||
QueryTab::QueryTab(MainWindow *win, QWidget *parent) :
|
||||
QueryTab::QueryTab(DatabaseWindow *win, QWidget *parent) :
|
||||
PlgPage(parent),
|
||||
ui(new Ui::QueryTab),
|
||||
m_win(win),
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ namespace Pgsql {
|
|||
class QTableView;
|
||||
|
||||
class QTabWidget;
|
||||
class MainWindow;
|
||||
class DatabaseWindow;
|
||||
class SqlSyntaxHighlighter;
|
||||
class ExplainRoot;
|
||||
class QueryResultModel;
|
||||
|
|
@ -35,7 +35,7 @@ class PgDatabaseCatalog;
|
|||
class QueryTab : public PlgPage {
|
||||
Q_OBJECT
|
||||
public:
|
||||
QueryTab(MainWindow *win, QWidget *parent = nullptr);
|
||||
QueryTab(DatabaseWindow *win, QWidget *parent = nullptr);
|
||||
~QueryTab();
|
||||
|
||||
void setConfig(const ConnectionConfig &config, std::shared_ptr<PgDatabaseCatalog>cat);
|
||||
|
|
@ -69,7 +69,7 @@ private:
|
|||
using ResultTabContainer = std::vector<TuplesResultWidget*>;
|
||||
|
||||
Ui::QueryTab *ui;
|
||||
MainWindow *m_win;
|
||||
DatabaseWindow *m_win;
|
||||
SqlSyntaxHighlighter* highlighter;
|
||||
ConnectionConfig m_config;
|
||||
StopWatch m_stopwatch;
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
#include "ConstraintModel.h"
|
||||
#include "IconColumnDelegate.h"
|
||||
#include "IndexModel.h"
|
||||
#include "MainWindow.h"
|
||||
#include "DatabaseWindow.h"
|
||||
#include "PgLabItemDelegate.h"
|
||||
#include "PropertiesPage.h"
|
||||
#include "ResultTableModelUtil.h"
|
||||
|
|
@ -23,7 +23,7 @@
|
|||
#include <QStringBuilder>
|
||||
#include <unordered_set>
|
||||
|
||||
TablesPage::TablesPage(MainWindow *parent)
|
||||
TablesPage::TablesPage(DatabaseWindow *parent)
|
||||
: QWidget(parent)
|
||||
, ui(new Ui::TablesPage)
|
||||
, m_window(parent)
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ class ConstraintModel;
|
|||
class PgDatabaseCatalog;
|
||||
class NamespaceFilterWidget;
|
||||
class IndexModel;
|
||||
class MainWindow;
|
||||
class DatabaseWindow;
|
||||
class PropertiesPage;
|
||||
class TriggerPage;
|
||||
class PgClass;
|
||||
|
|
@ -28,13 +28,13 @@ class TablesPage : public QWidget
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TablesPage(MainWindow *parent = nullptr);
|
||||
explicit TablesPage(DatabaseWindow *parent = nullptr);
|
||||
~TablesPage();
|
||||
|
||||
void setCatalog(std::shared_ptr<PgDatabaseCatalog> cat);
|
||||
private:
|
||||
Ui::TablesPage *ui;
|
||||
MainWindow *m_window;
|
||||
DatabaseWindow *m_window;
|
||||
// QWidget *m_columnsTab;
|
||||
ColumnPage *m_columnsPage;
|
||||
// QWidget *m_propertiesTab;
|
||||
|
|
|
|||
|
|
@ -40,7 +40,6 @@ SOURCES += main.cpp\
|
|||
MasterController.cpp \
|
||||
ParamTypeDelegate.cpp \
|
||||
OpenDatabase.cpp \
|
||||
MainWindow.cpp \
|
||||
SqlSyntaxHighlighter.cpp \
|
||||
ServerWindow.cpp \
|
||||
ASyncWindow.cpp \
|
||||
|
|
@ -83,7 +82,8 @@ PropertyProxyModel.cpp \
|
|||
EditTableWidget.cpp \
|
||||
EditColumnTableModel.cpp \
|
||||
SequenceModel.cpp \
|
||||
SequencesPage.cpp
|
||||
SequencesPage.cpp \
|
||||
DatabaseWindow.cpp
|
||||
|
||||
HEADERS += \
|
||||
QueryResultModel.h \
|
||||
|
|
@ -99,7 +99,6 @@ HEADERS += \
|
|||
MasterController.h \
|
||||
ParamTypeDelegate.h \
|
||||
OpenDatabase.h \
|
||||
MainWindow.h \
|
||||
SqlSyntaxHighlighter.h \
|
||||
ServerWindow.h \
|
||||
ASyncWindow.h \
|
||||
|
|
@ -144,7 +143,8 @@ CustomDataRole.h \
|
|||
EditTableWidget.h \
|
||||
EditColumnTableModel.h \
|
||||
SequenceModel.h \
|
||||
SequencesPage.h
|
||||
SequencesPage.h \
|
||||
DatabaseWindow.h
|
||||
|
||||
FORMS += mainwindow.ui \
|
||||
ConnectionManagerWindow.ui \
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue