pgLab/querytab.h
Eelke Klein 6e852f466f The querytab now shows the elapsed time of the query using the new stopwatch class.
The old elapsedtime code from the mainwindow has been removed.
2017-01-22 08:50:41 +01:00

82 lines
1.6 KiB
C++

#ifndef QUERYTAB_H
#define QUERYTAB_H
#include "asyncdbconnection.h"
#include "queryresultmodel.h"
#include "queryexplainmodel.h"
#include "stopwatch.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 newdoc();
// void open();
bool load(const QString &filename);
void save();
void saveAs();
void saveCopyAs();
void execute();
void explainAnalyze();
void cancel();
bool canClose();
private:
Ui::QueryTab *ui;
MainWindow *m_win;
std::unique_ptr<SqlHighlighter> highlighter;
ConnectionConfig m_config;
StopWatch m_stopwatch;
QString m_fileName; ///< use setFileName function to set
bool m_queryTextChanged = false;
void setFileName(const QString &filename);
bool continueWithoutSavingWarning();
bool 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);
void setTabCaption(const QString &caption);
void clearResult();
private slots:
void queryTextChanged();
void connectionStateChanged(ASyncDBConnection::State state);
void receiveNotice(Pgsql::ErrorDetails notice);
void startConnect();
};
#endif // QUERYTAB_H