Skip to content

Commit

Permalink
Add a 'Copy Create statement' popup action to Database Browser tab
Browse files Browse the repository at this point in the history
  • Loading branch information
MKleusberg committed May 18, 2015
1 parent 5578056 commit 75483d0
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 3 deletions.
14 changes: 14 additions & 0 deletions src/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ void MainWindow::init()
popupTableMenu->addAction(ui->editModifyTableAction);
popupTableMenu->addAction(ui->editDeleteObjectAction);
popupTableMenu->addSeparator();
popupTableMenu->addAction(ui->actionEditCopyCreateStatement);
popupTableMenu->addAction(ui->actionExportCsvPopup);

popupSaveSqlFileMenu = new QMenu(this);
Expand Down Expand Up @@ -2095,3 +2096,16 @@ void MainWindow::on_buttonClearFilters_clicked()
{
ui->dataTable->filterHeader()->clearFilters();
}

void MainWindow::copyCurrentCreateStatement()
{
// Cancel if no field is currently selected
if(!ui->dbTreeWidget->selectionModel()->hasSelection())
return;

// Get the CREATE statement from the Schema column
QString stmt = ui->dbTreeWidget->model()->data(ui->dbTreeWidget->currentIndex().sibling(ui->dbTreeWidget->currentIndex().row(), 3)).toString();

// Copy the statement to the global application clipboard
QApplication::clipboard()->setText(stmt);
}
1 change: 1 addition & 0 deletions src/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ private slots:
void editEncryption();
void switchToBrowseDataTab();
void on_buttonClearFilters_clicked();
void copyCurrentCreateStatement();
};

#endif
35 changes: 32 additions & 3 deletions src/MainWindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>311</width>
<height>531</height>
<width>294</width>
<height>444</height>
</rect>
</property>
<layout class="QFormLayout" name="formLayout">
Expand Down Expand Up @@ -810,7 +810,7 @@
<x>0</x>
<y>0</y>
<width>1000</width>
<height>25</height>
<height>19</height>
</rect>
</property>
<widget class="QMenu" name="fileMenu">
Expand Down Expand Up @@ -1621,6 +1621,18 @@
<string>&amp;Browse Table</string>
</property>
</action>
<action name="actionEditCopyCreateStatement">
<property name="icon">
<iconset resource="icons/icons.qrc">
<normaloff>:/icons/copy</normaloff>:/icons/copy</iconset>
</property>
<property name="text">
<string>Copy Create statement</string>
</property>
<property name="toolTip">
<string>Copy the CREATE statement of the item to the clipboard</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>
Expand Down Expand Up @@ -2508,6 +2520,22 @@
</hint>
</hints>
</connection>
<connection>
<sender>actionEditCopyCreateStatement</sender>
<signal>triggered()</signal>
<receiver>MainWindow</receiver>
<slot>copyCurrentCreateStatement()</slot>
<hints>
<hint type="sourcelabel">
<x>-1</x>
<y>-1</y>
</hint>
<hint type="destinationlabel">
<x>499</x>
<y>314</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>fileOpen()</slot>
Expand Down Expand Up @@ -2562,5 +2590,6 @@
<slot>editEncryption()</slot>
<slot>saveSqlFileAs()</slot>
<slot>switchToBrowseDataTab()</slot>
<slot>copyCurrentCreateStatement()</slot>
</slots>
</ui>
1 change: 1 addition & 0 deletions src/icons/icons.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,6 @@
<file alias="function">chart_curve.png</file>
<file alias="keyword">cog.png</file>
<file alias="clear_filters">clear_filters.png</file>
<file alias="copy">page_copy.png</file>
</qresource>
</RCC>
Binary file added src/icons/page_copy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 75483d0

Please sign in to comment.