Initial commit. Contains a simple query tool.
This commit is contained in:
commit
edc6df25da
19 changed files with 1245 additions and 0 deletions
51
mainwindow.cpp
Normal file
51
mainwindow.cpp
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
#include "mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
|
||||
#include "QueryResultModel.h"
|
||||
#include "sqlhighlighter.h"
|
||||
|
||||
namespace pg = Pgsql;
|
||||
|
||||
const char * test_query =
|
||||
"SELECT id, program, version, lic_bedrijf, lic_plaats, "
|
||||
"lic_number, callstack_crc_1, callstack_crc_2, callstack_crc_3, exception_class, "
|
||||
"exception_message \nFROM foutrapport";
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::MainWindow)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
QFont font;
|
||||
font.setFamily("Source Code Pro");
|
||||
font.setFixedPitch(true);
|
||||
font.setPointSize(10);
|
||||
ui->queryEdit->setFont(font);
|
||||
highlighter.reset(new SqlHighlighter(ui->queryEdit->document()));
|
||||
ui->queryEdit->setPlainText(test_query);
|
||||
|
||||
ui->connectionStringEdit->setText("user=postgres dbname=foutrapport password=admin");
|
||||
|
||||
//performQuery();
|
||||
|
||||
QAction *action = ui->mainToolBar->addAction("execute");
|
||||
connect(action, &QAction::triggered, this, &MainWindow::performQuery);
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{}
|
||||
|
||||
void MainWindow::performQuery()
|
||||
{
|
||||
ui->ResultView->setModel(nullptr);
|
||||
resultModel.reset();
|
||||
|
||||
QString connstr = ui->connectionStringEdit->text();
|
||||
pg::Connection conn;
|
||||
if (conn.connect(connstr + " application_name=Ivory client_encoding=utf8")) {
|
||||
pg::Result dbres = conn.Query(ui->queryEdit->toPlainText());
|
||||
resultModel.reset(new QueryResultModel(this , std::move(dbres)));
|
||||
ui->ResultView->setModel(resultModel.get());
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue