Added menu items for saving, loading, export data, closing window and about.
Saving and loading of SQL and close is implemented.
This commit is contained in:
parent
2db661b7a6
commit
cc5bbab0f5
4 changed files with 134 additions and 4 deletions
|
|
@ -4,6 +4,9 @@
|
|||
#include "QueryResultModel.h"
|
||||
#include "QueryExplainModel.h"
|
||||
#include "sqlhighlighter.h"
|
||||
#include <QStandardPaths>
|
||||
#include <QFileDialog>
|
||||
#include <QTextStream>
|
||||
#include <QTextTable>
|
||||
#include <QTimer>
|
||||
#include <windows.h>
|
||||
|
|
@ -124,7 +127,7 @@ MainWindow::~MainWindow()
|
|||
{
|
||||
m_dbConnection.closeConnection();
|
||||
m_dbConnection.setStateCallback(nullptr);
|
||||
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void MainWindow::QueueTask(TSQueue::t_Callable c)
|
||||
|
|
@ -378,3 +381,57 @@ void MainWindow::endTimer()
|
|||
updateTimer();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_actionLoad_SQL_triggered()
|
||||
{
|
||||
//
|
||||
QString home_dir = QStandardPaths::locate(QStandardPaths::HomeLocation, "", QStandardPaths::LocateDirectory);
|
||||
QString file_name = QFileDialog::getOpenFileName(this,
|
||||
tr("Open sql query"), home_dir, tr("SQL files (*.sql *.txt)"));
|
||||
if ( ! file_name.isEmpty()) {
|
||||
QFile file(file_name);
|
||||
if (file.open(QIODevice::ReadWrite)) {
|
||||
QTextStream stream(&file);
|
||||
ui->queryEdit->clear();
|
||||
while (!stream.atEnd()){
|
||||
QString line = stream.readLine();
|
||||
ui->queryEdit->append(line);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_actionSave_SQL_triggered()
|
||||
{
|
||||
QString home_dir = QStandardPaths::locate(QStandardPaths::HomeLocation, "", QStandardPaths::LocateDirectory);
|
||||
QString file_name = QFileDialog::getSaveFileName(this,
|
||||
tr("Save query"), home_dir, tr("SQL file (*.sql)"));
|
||||
if ( ! file_name.isEmpty()) {
|
||||
QFile file(file_name);
|
||||
if (file.open(QIODevice::ReadWrite)) {
|
||||
QTextStream stream(&file);
|
||||
QString text = ui->queryEdit->toPlainText();
|
||||
stream << text;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_actionExport_data_triggered()
|
||||
{
|
||||
QString home_dir = QStandardPaths::locate(QStandardPaths::HomeLocation, "", QStandardPaths::LocateDirectory);
|
||||
QString file_name = QFileDialog::getSaveFileName(this,
|
||||
tr("Export data"), home_dir, tr("CSV file (*.csv)"));
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::on_actionClose_triggered()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
void MainWindow::on_actionAbout_triggered()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue