Add basic JSON export feature

This adds some basic functionality for exporting JSON files by extending
the CSV export dialog. There is still a bit of work required for
fine-tuning the JSON export feature though. But a standard export of a
table s working well already.

See issue #688.
This commit is contained in:
Martin Kleusberg
2016-08-25 01:01:46 +02:00
parent 0ff6a44f61
commit f91773b291
8 changed files with 471 additions and 292 deletions

View File

@@ -1053,7 +1053,24 @@ void MainWindow::exportTableToCSV()
current_table = ui->comboBrowseTable->currentText();
// Open dialog
ExportCsvDialog dialog(&db, this, "", current_table);
ExportCsvDialog dialog(&db, ExportCsvDialog::ExportFormatCsv, this, "", current_table);
dialog.exec();
}
void MainWindow::exportTableToJson()
{
// Get the current table name if we are in the Browse Data tab
QString current_table;
if(ui->mainTab->currentIndex() == StructureTab) {
QString type = ui->dbTreeWidget->model()->data(ui->dbTreeWidget->currentIndex().sibling(ui->dbTreeWidget->currentIndex().row(), 1)).toString();
if(type == "table" || type == "view")
current_table = ui->dbTreeWidget->model()->data(ui->dbTreeWidget->currentIndex().sibling(ui->dbTreeWidget->currentIndex().row(), 0)).toString();
}
else if(ui->mainTab->currentIndex() == BrowseTab)
current_table = ui->comboBrowseTable->currentText();
// Open dialog
ExportCsvDialog dialog(&db, ExportCsvDialog::ExportFormatJson, this, "", current_table);
dialog.exec();
}