2016-12-26 16:06:55 +01:00
|
|
|
|
#ifndef MAINWINDOW_H
|
|
|
|
|
|
#define MAINWINDOW_H
|
|
|
|
|
|
|
2017-01-06 07:23:40 +01:00
|
|
|
|
#include "asyncdbconnection.h"
|
2017-01-03 07:22:36 +01:00
|
|
|
|
#include "tsqueue.h"
|
2016-12-26 16:06:55 +01:00
|
|
|
|
#include <QMainWindow>
|
2016-12-27 15:41:11 +01:00
|
|
|
|
#include <QSocketNotifier>
|
2016-12-26 16:06:55 +01:00
|
|
|
|
#include <memory>
|
2016-12-27 21:22:49 +01:00
|
|
|
|
#include <future>
|
2016-12-27 15:41:11 +01:00
|
|
|
|
#include "PgsqlConn.h"
|
2016-12-26 16:06:55 +01:00
|
|
|
|
|
2016-12-29 13:48:35 +01:00
|
|
|
|
class ExplainRoot;
|
2016-12-26 16:06:55 +01:00
|
|
|
|
class QueryResultModel;
|
2016-12-29 13:48:35 +01:00
|
|
|
|
class QueryExplainModel;
|
2016-12-26 16:06:55 +01:00
|
|
|
|
class SqlHighlighter;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Ui {
|
|
|
|
|
|
class MainWindow;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2016-12-27 15:41:11 +01:00
|
|
|
|
namespace Pgsql {
|
|
|
|
|
|
|
|
|
|
|
|
class Connection;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2016-12-30 10:14:26 +01:00
|
|
|
|
#include <deque>
|
|
|
|
|
|
#include <mutex>
|
|
|
|
|
|
|
|
|
|
|
|
class TaskQueue {
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2016-12-26 16:06:55 +01:00
|
|
|
|
class MainWindow : public QMainWindow
|
|
|
|
|
|
{
|
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
explicit MainWindow(QWidget *parent = 0);
|
|
|
|
|
|
~MainWindow();
|
|
|
|
|
|
|
2016-12-30 10:14:26 +01:00
|
|
|
|
/* 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.
|
|
|
|
|
|
*/
|
2017-01-03 07:22:36 +01:00
|
|
|
|
void QueueTask(TSQueue::t_Callable c);
|
2016-12-30 10:14:26 +01:00
|
|
|
|
|
2016-12-26 16:06:55 +01:00
|
|
|
|
private:
|
2017-01-03 07:22:36 +01:00
|
|
|
|
TSQueue m_taskQueue;
|
2016-12-30 10:14:26 +01:00
|
|
|
|
|
|
|
|
|
|
|
2016-12-26 16:06:55 +01:00
|
|
|
|
std::unique_ptr<Ui::MainWindow> ui;
|
|
|
|
|
|
std::unique_ptr<SqlHighlighter> highlighter;
|
|
|
|
|
|
|
2017-01-06 07:23:40 +01:00
|
|
|
|
ASyncDBConnection m_dbConnection;
|
2016-12-26 16:06:55 +01:00
|
|
|
|
|
2017-01-06 07:23:40 +01:00
|
|
|
|
void connectionStateChanged(ASyncDBConnection::State state);
|
2016-12-30 10:38:46 +01:00
|
|
|
|
|
2017-01-08 09:58:34 +01:00
|
|
|
|
std::unique_ptr<QueryResultModel> resultModel;
|
|
|
|
|
|
std::unique_ptr<QueryExplainModel> explainModel;
|
2016-12-27 15:41:11 +01:00
|
|
|
|
|
2016-12-27 21:22:49 +01:00
|
|
|
|
// struct {
|
2017-01-06 07:23:40 +01:00
|
|
|
|
// std::unique_ptr<QSocketNotifier> notifier;
|
|
|
|
|
|
// PostgresPollingStatusType poll_state;
|
|
|
|
|
|
// } connectingState;
|
2016-12-27 21:22:49 +01:00
|
|
|
|
|
2017-01-06 07:23:40 +01:00
|
|
|
|
// void processNotice(const PGresult *result);
|
2017-01-08 09:58:34 +01:00
|
|
|
|
void query_ready(std::shared_ptr<Pgsql::Result> res);
|
|
|
|
|
|
void explain_ready(std::shared_ptr<ExplainRoot> explain);
|
2016-12-26 16:06:55 +01:00
|
|
|
|
private slots:
|
2016-12-27 15:41:11 +01:00
|
|
|
|
|
|
|
|
|
|
void startConnect();
|
|
|
|
|
|
|
2017-01-08 09:58:34 +01:00
|
|
|
|
void performQuery();
|
|
|
|
|
|
void performExplain();
|
2017-01-06 07:23:40 +01:00
|
|
|
|
// void socket_activate_connect(int socket);
|
2016-12-30 10:38:46 +01:00
|
|
|
|
|
2017-01-08 09:58:34 +01:00
|
|
|
|
void cancel_query();
|
2017-01-06 07:23:40 +01:00
|
|
|
|
// void receiveNotice(Pgsql::ErrorDetails notice);
|
2016-12-29 13:48:35 +01:00
|
|
|
|
|
2016-12-30 10:14:26 +01:00
|
|
|
|
void processCallableQueue();
|
2016-12-26 16:06:55 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // MAINWINDOW_H
|