Query window has now buttons with icons made in the designer for better looks. Depending on received responses from the database the tabcontrol with the message, data and explain tab now switches to the appropriate tab.
91 lines
1.9 KiB
C++
91 lines
1.9 KiB
C++
#ifndef MAINWINDOW_H
|
|
#define MAINWINDOW_H
|
|
|
|
#include "asyncdbconnection.h"
|
|
#include "connectionconfig.h"
|
|
#include "tsqueue.h"
|
|
#include <QLabel>
|
|
#include <QMainWindow>
|
|
#include <QSocketNotifier>
|
|
#include <memory>
|
|
#include <future>
|
|
#include "PgsqlConn.h"
|
|
#include <deque>
|
|
#include <mutex>
|
|
|
|
class ExplainRoot;
|
|
class QueryResultModel;
|
|
class QueryExplainModel;
|
|
class SqlHighlighter;
|
|
|
|
namespace Ui {
|
|
class MainWindow;
|
|
}
|
|
|
|
namespace Pgsql {
|
|
class Connection;
|
|
}
|
|
|
|
|
|
class MainWindow : public QMainWindow
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
explicit MainWindow(QWidget *parent = 0);
|
|
~MainWindow();
|
|
|
|
void setConfig(const ConnectionConfig &config);
|
|
/* Meant to be called from other threads to pass a code block
|
|
* that has to be executed in the context of the thread of the window.
|
|
*/
|
|
void QueueTask(TSQueue::t_Callable c);
|
|
|
|
private:
|
|
TSQueue m_taskQueue;
|
|
QLabel *m_timeElapsedLabel;
|
|
std::unique_ptr<QTimer> m_timer;
|
|
std::chrono::time_point<std::chrono::steady_clock> m_startTime;
|
|
ConnectionConfig m_config;
|
|
|
|
|
|
void startTimer();
|
|
void endTimer();
|
|
|
|
|
|
Ui::MainWindow *ui;
|
|
std::unique_ptr<SqlHighlighter> highlighter;
|
|
|
|
ASyncDBConnection m_dbConnection;
|
|
|
|
void connectionStateChanged(ASyncDBConnection::State state);
|
|
|
|
std::unique_ptr<QueryResultModel> resultModel;
|
|
std::unique_ptr<QueryExplainModel> explainModel;
|
|
|
|
void query_ready(std::shared_ptr<Pgsql::Result> res);
|
|
void explain_ready(std::shared_ptr<ExplainRoot> explain);
|
|
private slots:
|
|
|
|
void startConnect();
|
|
|
|
void performQuery();
|
|
void performExplain();
|
|
|
|
void cancel_query();
|
|
void receiveNotice(Pgsql::ErrorDetails notice);
|
|
|
|
void processCallableQueue();
|
|
|
|
void addLog(QString s);
|
|
void updateTimer();
|
|
void on_actionLoad_SQL_triggered();
|
|
void on_actionSave_SQL_triggered();
|
|
void on_actionExport_data_triggered();
|
|
void on_actionClose_triggered();
|
|
void on_actionAbout_triggered();
|
|
void on_actionExecute_SQL_triggered();
|
|
void on_actionExplain_Analyze_triggered();
|
|
void on_actionCancel_triggered();
|
|
};
|
|
|
|
#endif // MAINWINDOW_H
|