#include <createview.h>
Public Member Functions | |
CreateView (QWidget *parent=0) | |
~CreateView () | |
void | generateQuery () |
void | setDbName () |
void | startAlter () |
Public Attributes | |
QSqlDatabase | db |
QString | dbName |
QString | viewToAlter |
Definition at line 11 of file createview.h.
CreateView::CreateView | ( | QWidget * | parent = 0 ) |
[explicit] |
Definition at line 8 of file createview.cpp.
: QDialog(parent), ui(new Ui::CreateView) { ui->setupUi(this); isNew = true; ui->txtGeneratedQuery->setReadOnly(true); ui->txtGeneratedQuery->setLexer(new QsciLexerSQL); ui->txtGeneratedQuery->setFolding(QsciScintilla::PlainFoldStyle, 2); ui->txtGeneratedQuery->setAutoCompletionSource(QsciScintilla::AcsAll); ui->txtGeneratedQuery->setAutoCompletionFillupsEnabled(true); ui->txtGeneratedQuery->setBraceMatching(QsciScintilla::StrictBraceMatch); ui->txtGeneratedQuery->setCallTipsVisible(true); ui->txtGeneratedQuery->setCallTipsStyle(QsciScintilla::CallTipsNoContext); ui->txtGeneratedQuery->setCaretLineVisible(true); ui->txtGeneratedQuery->setMarginWidth(1, 40); ui->txtGeneratedQuery->setMarginLineNumbers(1, true); ui->txtViewQuery->setLexer(new QsciLexerSQL); ui->txtViewQuery->setFolding(QsciScintilla::PlainFoldStyle, 2); ui->txtViewQuery->setAutoCompletionSource(QsciScintilla::AcsAll); ui->txtViewQuery->setAutoCompletionFillupsEnabled(true); ui->txtViewQuery->setBraceMatching(QsciScintilla::StrictBraceMatch); ui->txtViewQuery->setCallTipsVisible(true); ui->txtViewQuery->setCallTipsStyle(QsciScintilla::CallTipsNoContext); ui->txtViewQuery->setCaretLineVisible(true); ui->txtViewQuery->setMarginWidth(1, 40); ui->txtViewQuery->setMarginLineNumbers(1, true); }
CreateView::~CreateView | ( | ) |
Definition at line 37 of file createview.cpp.
{
delete ui;
}
void CreateView::generateQuery | ( | ) |
Definition at line 42 of file createview.cpp.
References dbName, and viewToAlter.
Referenced by startAlter().
{ QString newViewSnippet = tr("CREATE\n/*[ALGORITHM = {UNDEFINED | MERGE |TEMPTABLE}]\n[DEFINER = { user | CURRENT_USER ]}\n [SQL_SECURITY = {DESIGNER | INVOKER}]*/\nVIEW `%1`.`%2` AS\n(\n%3\n)").arg(dbName, ui->txtViewName->text(), ui->txtViewQuery->text()); if (!isNew) { newViewSnippet = tr("DROP VIEW IF EXISTS `%1`.`%2`;\n%3") .arg(dbName, viewToAlter, ui->txtViewQuery->text()); } ui->txtGeneratedQuery->setText(newViewSnippet); }
void CreateView::setDbName | ( | ) |
Definition at line 62 of file createview.cpp.
References dbName.
{ ui->txtDbName->setText(dbName); }
void CreateView::startAlter | ( | ) |
Definition at line 87 of file createview.cpp.
References db, dbName, generateQuery(), and viewToAlter.
{ isNew = false; ui->txtViewName->setText(viewToAlter); ui->txtDbName->setText(dbName); ui->txtViewName->setReadOnly(true); db.open(); if (db.open()) { QSqlQuery qu(db); qu.exec(tr("use `%1`").arg(dbName)); qu.clear(); if (qu.exec(tr("SHOW CREATE VIEW `%1`.`%2`").arg(dbName, viewToAlter))) { qu.first(); ui->txtViewQuery->setText(qu.value(1).toString()); generateQuery(); } else { QMessageBox::warning(this, "Error", tr("There was an error when generating the view. \n%1").arg(qu.lastError().text())); } } }
QSqlDatabase CreateView::db |
Definition at line 18 of file createview.h.
Referenced by startAlter().
QString CreateView::dbName |
Definition at line 19 of file createview.h.
Referenced by generateQuery(), setDbName(), and startAlter().
QString CreateView::viewToAlter |
Definition at line 20 of file createview.h.
Referenced by generateQuery(), and startAlter().