Moved definition of widget instance actions to the module so other parts of the system can no about them.

The plugin system will create the Action objects and bind them to the specified slots of the
specific widget instances.
This commit is contained in:
eelke 2019-01-05 19:58:23 +01:00
parent d0c4dabe8b
commit f4f2474a81
21 changed files with 418 additions and 204 deletions

116
pglab/QueryTool.h Normal file
View file

@ -0,0 +1,116 @@
#ifndef QUERYTAB_H
#define QUERYTAB_H
#include "ASyncDBConnection.h"
#include "QueryResultModel.h"
#include "QueryExplainModel.h"
#include "stopwatch.h"
#include "tuplesresultwidget.h"
#include <QWidget>
#include "plugin_support/PluginContentWidget.h"
#include <memory>
namespace Ui {
class QueryTab;
}
namespace Pgsql {
class ErrorDetails ;
}
class QTableView;
class QTabWidget;
class SqlSyntaxHighlighter;
class ExplainRoot;
class QueryResultModel;
class QueryExplainModel;
class PgTypeContainer;
class OpenDatabase;
class QueryParamListController;
class PgDatabaseCatalog;
class QueryTool : public PluginContentWidget {
Q_OBJECT
public:
QueryTool(IPluginContentWidgetContext *context, QWidget *parent = nullptr);
~QueryTool() override;
void newdoc();
bool load(const QString &filename);
void saveCopyAs();
void explain(bool analyze);
bool canClose() override;
void copyQueryAsCString();
void copyQueryAsRawCppString();
void generateCode();
void exportData(const QString &filename);
QString fileName() const { return m_fileName; }
bool isChanged() const { return m_queryTextChanged; }
bool isNew() const { return m_new; }
void focusEditor();
public slots:
void execute();
bool save();
bool saveAs();
void explain();
void analyze();
void cancel();
private:
using ResultTabContainer = std::vector<TuplesResultWidget*>;
Ui::QueryTab *ui;
SqlSyntaxHighlighter* highlighter;
ConnectionConfig m_config;
StopWatch m_stopwatch;
QueryParamListController *m_queryParamListController = nullptr;
bool m_new = true;
QString m_fileName; ///< use setFileName function to set
bool m_queryTextChanged = false;
std::shared_ptr<PgDatabaseCatalog> m_catalog;
ASyncDBConnection m_dbConnection;
std::unique_ptr<QueryExplainModel> explainModel;
ResultTabContainer resultList;
void setFileName(const QString &filename);
bool continueWithoutSavingWarning();
bool saveSqlTo(const QString &filename);
QString promptUserForSaveSqlFilename();
void addLog(QString s);
QString getCommand() const;
std::string getCommandUtf8() const;
//QTabWidget *getTabWidget();
//void setTabCaption(const QString &caption, const QString &tooltip);
void clearResult();
void markError(const Pgsql::ErrorDetails &details);
private slots:
void explain_ready(ExplainRoot::SPtr explain);
void query_ready(std::shared_ptr<Pgsql::Result>, qint64 elapsedms);
void queryTextChanged();
void connectionStateChanged(ASyncDBConnection::State state);
void receiveNotice(Pgsql::ErrorDetails notice);
void startConnect();
};
#endif // QUERYTAB_H