Code cleanups
This commit is contained in:
parent
b0cd47ef46
commit
456180325e
10 changed files with 10 additions and 90 deletions
|
|
@ -1,47 +0,0 @@
|
||||||
#include "WorkManager.h"
|
|
||||||
|
|
||||||
#include <QRunnable>
|
|
||||||
#include <QThreadPool>
|
|
||||||
#include <deque>
|
|
||||||
#include <functional>
|
|
||||||
#include <mutex>
|
|
||||||
|
|
||||||
|
|
||||||
class WorkManagerImpl: public WorkManager {
|
|
||||||
public:
|
|
||||||
void addRunnable(QRunnable *runnable) override;
|
|
||||||
void addWork(Work work) override;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
std::shared_ptr<WorkManager> WorkManager::getWorkManager()
|
|
||||||
{
|
|
||||||
static std::shared_ptr<WorkManager> wm = std::make_shared<WorkManagerImpl>();
|
|
||||||
return wm;
|
|
||||||
}
|
|
||||||
|
|
||||||
void WorkManagerImpl::addRunnable(QRunnable *runnable)
|
|
||||||
{
|
|
||||||
auto tp = QThreadPool::globalInstance();
|
|
||||||
tp->start(runnable);
|
|
||||||
}
|
|
||||||
|
|
||||||
class CallableTask : public QRunnable {
|
|
||||||
public:
|
|
||||||
CallableTask(WorkManager::Work &&w)
|
|
||||||
: work(std::move(w))
|
|
||||||
{}
|
|
||||||
protected:
|
|
||||||
void run() final
|
|
||||||
{
|
|
||||||
work();
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
WorkManager::Work work;
|
|
||||||
};
|
|
||||||
|
|
||||||
void WorkManagerImpl::addWork(Work work)
|
|
||||||
{
|
|
||||||
addRunnable(new CallableTask(std::move(work)));
|
|
||||||
}
|
|
||||||
|
|
@ -1,22 +0,0 @@
|
||||||
#ifndef WORKMANAGER_H
|
|
||||||
#define WORKMANAGER_H
|
|
||||||
|
|
||||||
#include <functional>
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
class QRunnable;
|
|
||||||
|
|
||||||
class WorkManager {
|
|
||||||
public:
|
|
||||||
|
|
||||||
static std::shared_ptr<WorkManager> getWorkManager();
|
|
||||||
|
|
||||||
using Work = std::function<void()>;
|
|
||||||
|
|
||||||
virtual ~WorkManager() = default;
|
|
||||||
virtual void addRunnable(QRunnable *runnable) = 0;
|
|
||||||
virtual void addWork(Work work) = 0;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // WORKMANAGER_H
|
|
||||||
|
|
@ -31,7 +31,6 @@ SOURCES += my_boost_assert_handler.cpp \
|
||||||
QueuedBackgroundTask.cpp \
|
QueuedBackgroundTask.cpp \
|
||||||
ExplainTreeModelItem.cpp \
|
ExplainTreeModelItem.cpp \
|
||||||
jsoncpp.cpp \
|
jsoncpp.cpp \
|
||||||
WorkManager.cpp \
|
|
||||||
SqlParser.cpp \
|
SqlParser.cpp \
|
||||||
SqlAstNode.cpp \
|
SqlAstNode.cpp \
|
||||||
SqlAstSelectList.cpp \
|
SqlAstSelectList.cpp \
|
||||||
|
|
@ -48,7 +47,6 @@ HEADERS += PasswordManager.h \
|
||||||
Expected.h \
|
Expected.h \
|
||||||
ExplainTreeModelItem.h \
|
ExplainTreeModelItem.h \
|
||||||
json/json.h \
|
json/json.h \
|
||||||
WorkManager.h \
|
|
||||||
TaskControl.h \
|
TaskControl.h \
|
||||||
ControllableTask.h \
|
ControllableTask.h \
|
||||||
RunControllableTask.h \
|
RunControllableTask.h \
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@
|
||||||
#include "catalog/PgConstraintContainer.h"
|
#include "catalog/PgConstraintContainer.h"
|
||||||
#include "GlobalIoService.h"
|
#include "GlobalIoService.h"
|
||||||
#include "SqlFormattingUtils.h"
|
#include "SqlFormattingUtils.h"
|
||||||
#include "WorkManager.h"
|
|
||||||
#include "Pgsql_oids.h"
|
#include "Pgsql_oids.h"
|
||||||
#include <QtConcurrent>
|
#include <QtConcurrent>
|
||||||
#include <QFuture>
|
#include <QFuture>
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
#include "DatabaseWindow.h"
|
#include "DatabaseWindow.h"
|
||||||
#include "ui_MainWindow.h"
|
#include "ui_DatabaseWindow.h"
|
||||||
#include "TablesPage.h"
|
#include "TablesPage.h"
|
||||||
#include "FunctionsPage.h"
|
#include "FunctionsPage.h"
|
||||||
#include "SequencesPage.h"
|
#include "SequencesPage.h"
|
||||||
|
|
@ -18,7 +18,6 @@
|
||||||
#include "plugin_support/PluginContentWidget.h"
|
#include "plugin_support/PluginContentWidget.h"
|
||||||
#include "CodeGenerator.h"
|
#include "CodeGenerator.h"
|
||||||
#include "MasterController.h"
|
#include "MasterController.h"
|
||||||
#include "WorkManager.h"
|
|
||||||
#include "ScopeGuard.h"
|
#include "ScopeGuard.h"
|
||||||
#include "EditTableWidget.h"
|
#include "EditTableWidget.h"
|
||||||
#include "plugin_support/PluginContentWidgetContextBase.h"
|
#include "plugin_support/PluginContentWidgetContextBase.h"
|
||||||
|
|
@ -68,7 +67,7 @@ using namespace DatabaseWindow_details;
|
||||||
|
|
||||||
DatabaseWindow::DatabaseWindow(MasterController *master, QWidget *parent)
|
DatabaseWindow::DatabaseWindow(MasterController *master, QWidget *parent)
|
||||||
: QMainWindow(parent)
|
: QMainWindow(parent)
|
||||||
, ui(new Ui::MainWindow)
|
, ui(new Ui::DatabaseWindow)
|
||||||
, m_context(new DatabaseWindowContentContext(this))
|
, m_context(new DatabaseWindowContentContext(this))
|
||||||
, m_masterController(master)
|
, m_masterController(master)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,6 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <future>
|
#include <future>
|
||||||
#include "Pgsql_Connection.h"
|
#include "Pgsql_Connection.h"
|
||||||
//#include "QueuedBackgroundTask.h"
|
|
||||||
#include "ControllableTask.h"
|
#include "ControllableTask.h"
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <deque>
|
#include <deque>
|
||||||
|
|
@ -24,7 +23,7 @@
|
||||||
#include <QFutureWatcher>
|
#include <QFutureWatcher>
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class MainWindow;
|
class DatabaseWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Pgsql {
|
namespace Pgsql {
|
||||||
|
|
@ -64,7 +63,7 @@ public:
|
||||||
void addPage(PluginContentWidget* page, QString caption);
|
void addPage(PluginContentWidget* page, QString caption);
|
||||||
private:
|
private:
|
||||||
|
|
||||||
Ui::MainWindow *ui;
|
Ui::DatabaseWindow *ui;
|
||||||
DatabaseWindow_details::DatabaseWindowContentContext *m_context;
|
DatabaseWindow_details::DatabaseWindowContentContext *m_context;
|
||||||
|
|
||||||
ConnectionConfig m_config;
|
ConnectionConfig m_config;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<ui version="4.0">
|
<ui version="4.0">
|
||||||
<class>MainWindow</class>
|
<class>DatabaseWindow</class>
|
||||||
<widget class="QMainWindow" name="MainWindow">
|
<widget class="QMainWindow" name="DatabaseWindow">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
|
|
@ -45,7 +45,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>993</width>
|
<width>993</width>
|
||||||
<height>25</height>
|
<height>20</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QMenu" name="menuTest">
|
<widget class="QMenu" name="menuTest">
|
||||||
|
|
@ -10,7 +10,6 @@
|
||||||
#include "ConstraintModel.h"
|
#include "ConstraintModel.h"
|
||||||
#include "IconColumnDelegate.h"
|
#include "IconColumnDelegate.h"
|
||||||
#include "IndexModel.h"
|
#include "IndexModel.h"
|
||||||
#include "DatabaseWindow.h"
|
|
||||||
#include "PgLabItemDelegate.h"
|
#include "PgLabItemDelegate.h"
|
||||||
#include "PropertiesPage.h"
|
#include "PropertiesPage.h"
|
||||||
#include "ResultTableModelUtil.h"
|
#include "ResultTableModelUtil.h"
|
||||||
|
|
|
||||||
|
|
@ -37,11 +37,8 @@ public:
|
||||||
void setNamespaceFilter(TablesTableModel::NamespaceFilter filter);
|
void setNamespaceFilter(TablesTableModel::NamespaceFilter filter);
|
||||||
private:
|
private:
|
||||||
Ui::TablesPage *ui;
|
Ui::TablesPage *ui;
|
||||||
// QWidget *m_columnsTab;
|
|
||||||
ColumnPage *m_columnsPage;
|
ColumnPage *m_columnsPage;
|
||||||
// QWidget *m_propertiesTab;
|
|
||||||
PropertiesPage *m_propertiesPage;
|
PropertiesPage *m_propertiesPage;
|
||||||
// QWidget *m_triggerTab;
|
|
||||||
TriggerPage *m_triggerPage;
|
TriggerPage *m_triggerPage;
|
||||||
SqlCodePreview *m_sqlCodePreview;
|
SqlCodePreview *m_sqlCodePreview;
|
||||||
std::shared_ptr<PgDatabaseCatalog> m_catalog;
|
std::shared_ptr<PgDatabaseCatalog> m_catalog;
|
||||||
|
|
@ -49,10 +46,8 @@ private:
|
||||||
ColumnTableModel* m_columnsModel = nullptr;
|
ColumnTableModel* m_columnsModel = nullptr;
|
||||||
ConstraintModel* m_constraintModel = nullptr;
|
ConstraintModel* m_constraintModel = nullptr;
|
||||||
IndexModel* m_indexModel = nullptr;
|
IndexModel* m_indexModel = nullptr;
|
||||||
//NamespaceFilterWidget* m_namespaceFilterWidget;
|
|
||||||
|
|
||||||
void retranslateUi(bool all = true);
|
void retranslateUi(bool all = true);
|
||||||
// QWidget* addDetailTab(QWidget *contents, bool infront = false);
|
|
||||||
|
|
||||||
void selectedTableChanged(const std::optional<PgClass> &table);
|
void selectedTableChanged(const std::optional<PgClass> &table);
|
||||||
void updateSqlTab(const std::optional<PgClass> &table);
|
void updateSqlTab(const std::optional<PgClass> &table);
|
||||||
|
|
@ -60,7 +55,6 @@ private slots:
|
||||||
|
|
||||||
void tableListTable_currentRowChanged(const QModelIndex ¤t, const QModelIndex &previous);
|
void tableListTable_currentRowChanged(const QModelIndex ¤t, const QModelIndex &previous);
|
||||||
void tableListTable_layoutChanged(const QList<QPersistentModelIndex> &parents, QAbstractItemModel::LayoutChangeHint hint);
|
void tableListTable_layoutChanged(const QList<QPersistentModelIndex> &parents, QAbstractItemModel::LayoutChangeHint hint);
|
||||||
// void constraintsTable_currentRowChanged(const QModelIndex ¤t, const QModelIndex &previous);
|
|
||||||
void constraintsTable_selectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
|
void constraintsTable_selectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
|
||||||
void constraintsTable_modelReset();
|
void constraintsTable_modelReset();
|
||||||
void indexesTable_selectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
|
void indexesTable_selectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
|
||||||
|
|
|
||||||
|
|
@ -158,7 +158,7 @@ CustomDataRole.h \
|
||||||
plugin_support/IPluginContentWidgetContext.h \
|
plugin_support/IPluginContentWidgetContext.h \
|
||||||
plugin_support/PluginContentWidgetContextBase.h
|
plugin_support/PluginContentWidgetContextBase.h
|
||||||
|
|
||||||
FORMS += mainwindow.ui \
|
FORMS += \
|
||||||
ConnectionManagerWindow.ui \
|
ConnectionManagerWindow.ui \
|
||||||
CreateDatabaseDialog.ui \
|
CreateDatabaseDialog.ui \
|
||||||
TuplesResultWidget.ui \
|
TuplesResultWidget.ui \
|
||||||
|
|
@ -170,7 +170,8 @@ FORMS += mainwindow.ui \
|
||||||
NamespaceFilterWidget.ui \
|
NamespaceFilterWidget.ui \
|
||||||
ApplicationWindow.ui \
|
ApplicationWindow.ui \
|
||||||
CrudTab.ui \
|
CrudTab.ui \
|
||||||
CodeGenerator.ui
|
CodeGenerator.ui \
|
||||||
|
DatabaseWindow.ui
|
||||||
|
|
||||||
RESOURCES += \
|
RESOURCES += \
|
||||||
resources.qrc
|
resources.qrc
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue