pgLab/mainwindow.h
Eelke Klein fa9787adfd After an insert, update, delete the number of rows affected is reported.
This also makes it clearer the command was executed succesfully.

Times are now printed with no more then two decimals. This prevents confusion
between thousand and decimal seperators.
2017-01-16 18:57:50 +01:00

94 lines
2 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 <chrono>
#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();
std::chrono::duration<float, std::milli> elapsedTime;
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);
std::string getCommand() const;
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