Add CSV export to context menu of the Database Structure tab

Add an entry for the CSV export to the context menu of the Database
Structure tab of the main windows as well which preselects the currently
selected table.

When opening the CSV export dialog via the standard menu also preselect
the currently selected table when the Database Structure tab is active.
This commit is contained in:
Martin Kleusberg
2014-02-14 16:40:44 +01:00
parent 4cd5131d1a
commit 30cef84f09
2 changed files with 34 additions and 3 deletions

View File

@@ -95,8 +95,9 @@ void MainWindow::init()
// Create popup menus
popupTableMenu = new QMenu(this);
popupTableMenu->addAction(ui->editModifyTableAction);
popupTableMenu->addSeparator();
popupTableMenu->addAction(ui->editDeleteObjectAction);
popupTableMenu->addSeparator();
popupTableMenu->addAction(ui->actionExportCsvPopup);
// Set state of checkable menu actions
ui->viewMenu->insertAction(ui->viewDBToolbarAction, ui->dockLog->toggleViewAction());
@@ -740,7 +741,9 @@ void MainWindow::exportTableToCSV()
{
// Get the current table name if we are in the Browse Data tab
QString current_table;
if(ui->mainTab->currentIndex() == 1)
if(ui->mainTab->currentIndex() == 0)
current_table = ui->dbTreeWidget->model()->data(ui->dbTreeWidget->currentIndex().sibling(ui->dbTreeWidget->currentIndex().row(), 0)).toString();
else if(ui->mainTab->currentIndex() == 1)
current_table = ui->comboBrowseTable->currentText();
// Open dialog
@@ -908,6 +911,7 @@ void MainWindow::changeTreeSelection()
} else if(type == "view" || type == "trigger" || type == "index") {
ui->editDeleteObjectAction->setEnabled(true);
}
ui->actionExportCsvPopup->setEnabled(type == "table" || type == "view");
}
void MainWindow::openRecentFile()

View File

@@ -272,7 +272,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>763</width>
<width>278</width>
<height>444</height>
</rect>
</property>
@@ -1267,6 +1267,17 @@
<string>Ctrl+F5</string>
</property>
</action>
<action name="actionExportCsvPopup">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Export as CSV file</string>
</property>
<property name="toolTip">
<string>Export table as comma separated values file</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>
@@ -1983,6 +1994,22 @@
</hint>
</hints>
</connection>
<connection>
<sender>actionExportCsvPopup</sender>
<signal>triggered()</signal>
<receiver>MainWindow</receiver>
<slot>exportTableToCSV()</slot>
<hints>
<hint type="sourcelabel">
<x>-1</x>
<y>-1</y>
</hint>
<hint type="destinationlabel">
<x>399</x>
<y>299</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>fileOpen()</slot>