Skip to content

Commit 614504d

Browse files
MKleusbergrp-
authored andcommitted
ExportCsvDialog: Set table selection to current table in Browse Data tab
When called while the Browse Data tab of the main window is selected also select the current table or view in the ExportCsvDialog. Sort the table names in the combobox of the ExportCsvDialog. Conflicts: src/ExportCsvDialog.cpp
1 parent c077d4c commit 614504d

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

src/ExportCsvDialog.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
#include "PreferencesDialog.h"
99
#include "sqlitetablemodel.h"
1010

11-
ExportCsvDialog::ExportCsvDialog(DBBrowserDB* db, QWidget* parent, const QString& query)
11+
12+
ExportCsvDialog::ExportCsvDialog(DBBrowserDB* db, QWidget* parent, const QString& query, const QString& selection)
1213
: QDialog(parent),
1314
ui(new Ui::ExportCsvDialog),
1415
pdb(db),
@@ -24,6 +25,13 @@ ExportCsvDialog::ExportCsvDialog(DBBrowserDB* db, QWidget* parent, const QString
2425
objectMap objects = pdb->getBrowsableObjects();
2526
for(objectMap::ConstIterator i=objects.begin();i!=objects.end();++i)
2627
ui->comboTable->addItem(QIcon(QString(":icons/%1").arg(i.value().gettype())), i.value().getname());
28+
29+
// Sort list of tables and select the table specified in the selection parameter or alternatively the first one
30+
ui->comboTable->model()->sort(0);
31+
if(selection.isEmpty())
32+
ui->comboTable->setCurrentIndex(0);
33+
else
34+
ui->comboTable->setCurrentIndex(ui->comboTable->findText(selection));
2735
} else {
2836
// Hide table combo box
2937
ui->labelTable->setVisible(false);

src/ExportCsvDialog.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class ExportCsvDialog : public QDialog
1313
Q_OBJECT
1414

1515
public:
16-
explicit ExportCsvDialog(DBBrowserDB* db, QWidget* parent = 0, const QString& query = "");
16+
explicit ExportCsvDialog(DBBrowserDB* db, QWidget* parent = 0, const QString& query = "", const QString& selection = "");
1717
~ExportCsvDialog();
1818

1919
private slots:

src/MainWindow.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,13 @@ void MainWindow::importTableFromCSV()
749749

750750
void MainWindow::exportTableToCSV()
751751
{
752-
ExportCsvDialog dialog(&db, this);
752+
// Get the current table name if we are in the Browse Data tab
753+
QString current_table;
754+
if(ui->mainTab->currentIndex() == 1)
755+
current_table = ui->comboBrowseTable->currentText();
756+
757+
// Open dialog
758+
ExportCsvDialog dialog(&db, this, "", current_table);
753759
dialog.exec();
754760
}
755761

0 commit comments

Comments
 (0)