wip: codegenerator, basic widget present for showing the generated code and specifying
parameters. Some code is also generated but it is not complete yet. minimum still required - field assignments - properly format and escape the query string
This commit is contained in:
parent
daf9536bed
commit
f5145f36ed
19 changed files with 380 additions and 32 deletions
|
|
@ -22,6 +22,7 @@
|
|||
#include "QueryParamListController.h"
|
||||
#include "util.h"
|
||||
#include "GlobalIoService.h"
|
||||
#include "UserConfiguration.h"
|
||||
|
||||
QueryTab::QueryTab(MainWindow *win, QWidget *parent) :
|
||||
PlgPage(parent),
|
||||
|
|
@ -34,11 +35,7 @@ QueryTab::QueryTab(MainWindow *win, QWidget *parent) :
|
|||
connect(&m_dbConnection, &ASyncDBConnection::onStateChanged, this, &QueryTab::connectionStateChanged);
|
||||
connect(&m_dbConnection, &ASyncDBConnection::onNotice, this, &QueryTab::receiveNotice);
|
||||
|
||||
QFont font;
|
||||
font.setFamily("Source Code Pro");
|
||||
font.setFixedPitch(true);
|
||||
font.setPointSize(10);
|
||||
ui->queryEdit->setFont(font);
|
||||
ui->queryEdit->setFont(UserConfiguration::instance()->codeFont());
|
||||
|
||||
highlighter = new SqlSyntaxHighlighter(ui->queryEdit->document());
|
||||
auto open_database = m_win->getDatabase();
|
||||
|
|
@ -583,14 +580,30 @@ void QueryTab::copyQueryAsCString()
|
|||
QApplication::clipboard()->setText(cs);
|
||||
}
|
||||
|
||||
#include <codebuilder/CodeBuilder.h>
|
||||
#include <codebuilder/DefaultConfigs.h>
|
||||
|
||||
void QueryTab::copyQueryAsRawCppString()
|
||||
{
|
||||
//auto sql = getAllOrSelectedSql();
|
||||
QString command = getCommand();
|
||||
//auto sql = getAllOrSelectedSql();
|
||||
QString cs = ConvertToMultiLineRawCppString(command);
|
||||
QApplication::clipboard()->setText(cs);
|
||||
}
|
||||
|
||||
void QueryTab::generateCode()
|
||||
{
|
||||
QString command = getCommand();
|
||||
|
||||
if (resultList.empty()) {
|
||||
QMessageBox::question(this, "pglab", tr("Please execute the query first"), QMessageBox::Ok);
|
||||
}
|
||||
if (resultList.size() == 1) {
|
||||
std::shared_ptr<const Pgsql::Result> dbres = resultList[0]->GetPgsqlResult();
|
||||
m_win->newCodeGenPage(command, dbres);
|
||||
}
|
||||
}
|
||||
|
||||
void QueryTab::exportData(const QString &file_name)
|
||||
{
|
||||
auto widget = ui->tabWidget->currentWidget();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue