Skip to content

Commit a5cc259

Browse files
committed
Data Browser: export query results as JSON
In this case too, the corresponding menu entry for exporting the query results to JSON was missing although it was straight forward to add it with the same scheme as for CSV. Renamed the CSV action for consistency. Related to issue #2607
1 parent 2826e7b commit a5cc259

File tree

3 files changed

+43
-4
lines changed

3 files changed

+43
-4
lines changed

src/TableBrowser.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ TableBrowser::TableBrowser(DBBrowserDB* _db, QWidget* parent) :
5050

5151
popupSaveFilterAsMenu = new QMenu(this);
5252
popupSaveFilterAsMenu->addAction(ui->actionFilteredTableExportCsv);
53+
popupSaveFilterAsMenu->addAction(ui->actionFilteredTableExportJson);
5354
popupSaveFilterAsMenu->addAction(ui->actionFilterSaveAsView);
5455
ui->actionSaveFilterAsPopup->setMenu(popupSaveFilterAsMenu);
5556
qobject_cast<QToolButton*>(ui->browseToolbar->widgetForAction(ui->actionSaveFilterAsPopup))->setPopupMode(QToolButton::InstantPopup);
@@ -1403,12 +1404,18 @@ void TableBrowser::editDisplayFormat()
14031404
}
14041405
}
14051406

1406-
void TableBrowser::exportFilteredTable()
1407+
void TableBrowser::exportCsvFilteredTable()
14071408
{
14081409
ExportDataDialog dialog(*db, ExportDataDialog::ExportFormatCsv, this, m_model->customQuery(false));
14091410
dialog.exec();
14101411
}
14111412

1413+
void TableBrowser::exportJsonFilteredTable()
1414+
{
1415+
ExportDataDialog dialog(*db, ExportDataDialog::ExportFormatJson, this, m_model->customQuery(false));
1416+
dialog.exec();
1417+
}
1418+
14121419
void TableBrowser::saveFilterAsView()
14131420
{
14141421
// Save as view a custom query without rowid

src/TableBrowser.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,8 @@ private slots:
130130
void on_actionClearFilters_triggered();
131131
void on_actionClearSorting_triggered();
132132
void editDisplayFormat();
133-
void exportFilteredTable();
133+
void exportCsvFilteredTable();
134+
void exportJsonFilteredTable();
134135
void saveFilterAsView();
135136
void setTableEncoding(bool forAllTables = false);
136137
void setDefaultTableEncoding();

src/TableBrowser.ui

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -670,6 +670,20 @@
670670
<string>This button exports the data of the browsed table as currently displayed (after filters, display formats and order column) as a CSV file.</string>
671671
</property>
672672
</action>
673+
<action name="actionFilteredTableExportJson">
674+
<property name="text">
675+
<string>Export to &amp;JSON</string>
676+
</property>
677+
<property name="toolTip">
678+
<string>Export the filtered data to JSON</string>
679+
</property>
680+
<property name="statusTip">
681+
<string>Export the filtered data to JSON</string>
682+
</property>
683+
<property name="whatsThis">
684+
<string>This button exports the data of the browsed table as currently displayed (after filters, display formats and order column) as a JSON file.</string>
685+
</property>
686+
</action>
673687
<action name="actionFilterSaveAsView">
674688
<property name="text">
675689
<string>Save as &amp;view</string>
@@ -1324,7 +1338,23 @@
13241338
<sender>actionFilteredTableExportCsv</sender>
13251339
<signal>triggered()</signal>
13261340
<receiver>TableBrowser</receiver>
1327-
<slot>exportFilteredTable()</slot>
1341+
<slot>exportCsvFilteredTable()</slot>
1342+
<hints>
1343+
<hint type="sourcelabel">
1344+
<x>-1</x>
1345+
<y>-1</y>
1346+
</hint>
1347+
<hint type="destinationlabel">
1348+
<x>518</x>
1349+
<y>314</y>
1350+
</hint>
1351+
</hints>
1352+
</connection>
1353+
<connection>
1354+
<sender>actionFilteredTableExportJson</sender>
1355+
<signal>triggered()</signal>
1356+
<receiver>TableBrowser</receiver>
1357+
<slot>exportJsonFilteredTable()</slot>
13281358
<hints>
13291359
<hint type="sourcelabel">
13301360
<x>-1</x>
@@ -1431,7 +1461,8 @@
14311461
<slot>addRecord()</slot>
14321462
<slot>deleteRecord()</slot>
14331463
<slot>insertValues()</slot>
1434-
<slot>exportFilteredTable</slot>
1464+
<slot>exportCsvFilteredTable</slot>
1465+
<slot>exportJsonFilteredTable</slot>
14351466
<slot>saveFilterAsView</slot>
14361467
<slot>setDefaultTableEncoding()</slot>
14371468
<slot>hideColumns()</slot>

0 commit comments

Comments
 (0)