Skip to content

Commit

Permalink
Add CSV export to context menu of the Database Structure tab
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
MKleusberg committed Feb 14, 2014
1 parent 4cd5131 commit 30cef84
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down
29 changes: 28 additions & 1 deletion src/MainWindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>763</width>
<width>278</width>
<height>444</height>
</rect>
</property>
Expand Down Expand Up @@ -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>
Expand Down Expand Up @@ -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>
Expand Down

0 comments on commit 30cef84

Please sign in to comment.