mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-20 11:00:44 -06:00
Export to CSV the currently browsed data as displayed
A new option is added to the Browse Data tab toolbar for exporting the data of the browsed table as currently displayed (after filters, display formats and order column) to a CSV file. This is done in coherence to the same popup options in the SQL tab for execution results. See issue #1402
This commit is contained in:
@@ -185,6 +185,12 @@ void MainWindow::init()
|
||||
ui->actionSqlResultsSave->setMenu(popupSaveSqlResultsMenu);
|
||||
qobject_cast<QToolButton*>(ui->toolbarSql->widgetForAction(ui->actionSqlResultsSave))->setPopupMode(QToolButton::InstantPopup);
|
||||
|
||||
popupSaveFilterAsMenu = new QMenu(this);
|
||||
popupSaveFilterAsMenu->addAction(ui->actionFilteredTableExportCsv);
|
||||
popupSaveFilterAsMenu->addAction(ui->actionFilterSaveAsView);
|
||||
ui->buttonSaveFilterAsPopup->setMenu(popupSaveFilterAsMenu);
|
||||
ui->buttonSaveFilterAsPopup->setPopupMode(QToolButton::InstantPopup);
|
||||
|
||||
popupBrowseDataHeaderMenu = new QMenu(this);
|
||||
popupBrowseDataHeaderMenu->addAction(ui->actionShowRowidColumn);
|
||||
popupBrowseDataHeaderMenu->addAction(ui->actionUnlockViewEditing);
|
||||
@@ -1600,7 +1606,7 @@ void MainWindow::activateFields(bool enable)
|
||||
ui->actionSaveProject->setEnabled(enable);
|
||||
ui->actionEncryption->setEnabled(enable && write);
|
||||
ui->buttonClearFilters->setEnabled(enable);
|
||||
ui->buttonSaveFilterAsView->setEnabled(enable);
|
||||
ui->buttonSaveFilterAsPopup->setEnabled(enable);
|
||||
ui->dockEdit->setEnabled(enable);
|
||||
ui->dockPlot->setEnabled(enable);
|
||||
|
||||
@@ -2954,6 +2960,11 @@ void MainWindow::saveAsView(QString query)
|
||||
QMessageBox::warning(this, qApp->applicationName(), tr("Error creating view: %1").arg(db.lastError()));
|
||||
}
|
||||
|
||||
void MainWindow::exportFilteredTable()
|
||||
{
|
||||
ExportDataDialog dialog(db, ExportDataDialog::ExportFormatCsv, this, m_browseTableModel->customQuery(false));
|
||||
dialog.exec();
|
||||
}
|
||||
|
||||
void MainWindow::saveFilterAsView()
|
||||
{
|
||||
|
||||
@@ -142,6 +142,7 @@ private:
|
||||
QMenu* recentFilesMenu;
|
||||
QMenu* popupSaveSqlFileMenu;
|
||||
QMenu* popupSaveSqlResultsMenu;
|
||||
QMenu* popupSaveFilterAsMenu;
|
||||
QMenu* popupBrowseDataHeaderMenu;
|
||||
|
||||
QLabel* statusEncodingLabel;
|
||||
@@ -281,6 +282,7 @@ private slots:
|
||||
void setFindFrameVisibility(bool show);
|
||||
void openFindReplaceDialog();
|
||||
void saveFilterAsView();
|
||||
void exportFilteredTable();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -167,12 +167,12 @@ You can drag SQL statements from an object row and drop them into other applicat
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="buttonSaveFilterAsView">
|
||||
<widget class="QToolButton" name="buttonSaveFilterAsPopup">
|
||||
<property name="toolTip">
|
||||
<string>Save the current filter, sort column and display formats as a view</string>
|
||||
<string>Save the table as currently displayed</string>
|
||||
</property>
|
||||
<property name="whatsThis">
|
||||
<string>This button saves the current setting of the browsed table (filters, display formats and order column) as an SQL view that you can later browse or use in SQL statements.</string>
|
||||
<string><html><head/><body><p>This popup menu provides the following options applying to the currently browsed and filtered table:</p><ul style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; -qt-list-indent: 1;"><li style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Export to CSV: this option exports the data of the browsed table as currently displayed (after filters, display formats and order column) to a CSV file.</li><li style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Save as view: this option saves the current setting of the browsed table (filters, display formats and order column) as an SQL view that you can later browse or use in SQL statements.</li></ul></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
@@ -396,8 +396,8 @@ You can drag SQL statements from an object row and drop them into other applicat
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>566</width>
|
||||
<height>531</height>
|
||||
<width>601</width>
|
||||
<height>484</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
@@ -887,7 +887,7 @@ You can drag SQL statements from an object row and drop them into other applicat
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1037</width>
|
||||
<height>25</height>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="fileMenu">
|
||||
@@ -2041,6 +2041,34 @@ You can drag SQL statements from the Schema column and drop them into the SQL ed
|
||||
<string>Extra DB Toolbar</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionFilteredTableExportCsv">
|
||||
<property name="text">
|
||||
<string>Export to &CSV</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Export the filtered data to CSV</string>
|
||||
</property>
|
||||
<property name="statusTip">
|
||||
<string>Export the filtered data to CSV</string>
|
||||
</property>
|
||||
<property name="whatsThis">
|
||||
<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>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionFilterSaveAsView">
|
||||
<property name="text">
|
||||
<string>Save as &view</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Save the current filter, sort column and display formats as a view</string>
|
||||
</property>
|
||||
<property name="statusTip">
|
||||
<string>Save the current filter, sort column and display formats as a view</string>
|
||||
</property>
|
||||
<property name="whatsThis">
|
||||
<string>This button saves the current setting of the browsed table (filters, display formats and order column) as an SQL view that you can later browse or use in SQL statements.</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
@@ -3206,7 +3234,7 @@ You can drag SQL statements from the Schema column and drop them into the SQL ed
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonSaveFilterAsView</sender>
|
||||
<sender>buttonSaveFilterAsPopup</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>MainWindow</receiver>
|
||||
<slot>saveFilterAsView()</slot>
|
||||
@@ -3301,6 +3329,38 @@ You can drag SQL statements from the Schema column and drop them into the SQL ed
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>actionFilteredTableExportCsv</sender>
|
||||
<signal>triggered()</signal>
|
||||
<receiver>MainWindow</receiver>
|
||||
<slot>exportFilteredTable()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>-1</x>
|
||||
<y>-1</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>518</x>
|
||||
<y>314</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>actionFilterSaveAsView</sender>
|
||||
<signal>triggered()</signal>
|
||||
<receiver>MainWindow</receiver>
|
||||
<slot>saveFilterAsView()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>-1</x>
|
||||
<y>-1</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>518</x>
|
||||
<y>314</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
<slots>
|
||||
<slot>fileOpen()</slot>
|
||||
|
||||
Reference in New Issue
Block a user