It is now possible to create multiple independent query tabs. However somethings are currently a bit broken.
73 lines
1.5 KiB
C++
73 lines
1.5 KiB
C++
#ifndef QUERYTAB_H
|
|
#define QUERYTAB_H
|
|
|
|
#include "asyncdbconnection.h"
|
|
#include "QueryResultModel.h"
|
|
#include "QueryExplainModel.h"
|
|
|
|
#include <QWidget>
|
|
#include <memory>
|
|
|
|
namespace Ui {
|
|
class QueryTab;
|
|
}
|
|
|
|
class MainWindow;
|
|
class SqlHighlighter;
|
|
class ExplainRoot;
|
|
class QueryResultModel;
|
|
class QueryExplainModel;
|
|
|
|
|
|
class QueryTab : public QWidget
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
QueryTab(MainWindow *win, QWidget *parent = 0);
|
|
~QueryTab();
|
|
|
|
void setConfig(const ConnectionConfig &config);
|
|
|
|
void open();
|
|
void save();
|
|
void saveAs();
|
|
void saveCopyAs();
|
|
|
|
void execute();
|
|
void explainAnalyze();
|
|
void cancel();
|
|
private:
|
|
Ui::QueryTab *ui;
|
|
MainWindow *m_win;
|
|
std::unique_ptr<SqlHighlighter> highlighter;
|
|
ConnectionConfig m_config;
|
|
|
|
QString m_fileName; ///< use setFileName function to set
|
|
bool m_queryTextChanged = false;
|
|
|
|
void setFileName(const QString &filename);
|
|
bool continueWithoutSavingWarning();
|
|
void saveSqlTo(const QString &filename);
|
|
QString promptUserForSaveSqlFilename();
|
|
|
|
|
|
ASyncDBConnection m_dbConnection;
|
|
std::unique_ptr<QueryResultModel> resultModel;
|
|
std::unique_ptr<QueryExplainModel> explainModel;
|
|
|
|
void addLog(QString s);
|
|
|
|
std::string getCommand() const;
|
|
void explain_ready(ExplainRoot::SPtr explain);
|
|
void query_ready(std::shared_ptr<Pgsql::Result> dbres);
|
|
private slots:
|
|
|
|
void queryTextChanged();
|
|
void connectionStateChanged(ASyncDBConnection::State state);
|
|
void receiveNotice(Pgsql::ErrorDetails notice);
|
|
|
|
void startConnect();
|
|
};
|
|
|
|
#endif // QUERYTAB_H
|