mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-20 02:50:46 -06:00
55 lines
1.3 KiB
C++
55 lines
1.3 KiB
C++
#include "SqlExecutionArea.h"
|
|
#include "ui_SqlExecutionArea.h"
|
|
#include "sqltextedit.h"
|
|
#include "ExtendedTableWidget.h"
|
|
#include "SQLiteSyntaxHighlighter.h"
|
|
#include "sqlitetablemodel.h"
|
|
#include "sqlitedb.h"
|
|
#include "PreferencesDialog.h"
|
|
|
|
SqlExecutionArea::SqlExecutionArea(QWidget* parent, DBBrowserDB* db) :
|
|
QWidget(parent),
|
|
ui(new Ui::SqlExecutionArea)
|
|
{
|
|
// Create UI
|
|
ui->setupUi(this);
|
|
|
|
// Create syntax highlighter
|
|
highlighter = new SQLiteSyntaxHighlighter(ui->editEditor->document());
|
|
|
|
// Create model
|
|
model = new SqliteTableModel(this, db, PreferencesDialog::getSettingsValue("db", "prefetchsize").toInt());
|
|
ui->tableResult->setModel(model);
|
|
}
|
|
|
|
SqlExecutionArea::~SqlExecutionArea()
|
|
{
|
|
delete ui;
|
|
}
|
|
|
|
void SqlExecutionArea::setTableNames(const QStringList& tables)
|
|
{
|
|
highlighter->setTableNames(tables);
|
|
}
|
|
|
|
QString SqlExecutionArea::getSql() const
|
|
{
|
|
return ui->editEditor->toPlainText().trimmed();
|
|
}
|
|
|
|
QString SqlExecutionArea::getSelectedSql() const
|
|
{
|
|
return ui->editEditor->textCursor().selectedText().trimmed();
|
|
}
|
|
|
|
void SqlExecutionArea::finishExecution(const QString& result)
|
|
{
|
|
ui->labelErrors->setText(result);
|
|
ui->tableResult->resizeColumnsToContents();
|
|
}
|
|
|
|
SqlTextEdit* SqlExecutionArea::getEditor()
|
|
{
|
|
return ui->editEditor;
|
|
}
|