Skip to content

Commit

Permalink
Add Browse Table popop action to Database Structure tab
Browse files Browse the repository at this point in the history
In the Database Structure tab of the main window, add a new action to
the popup menu which open upon right clicking the tree view to allow
directly changing to the Browse Data tab with the current table being
selected automatically.

See issue sqlitebrowser#246.
  • Loading branch information
MKleusberg committed Apr 23, 2015
1 parent 4c77036 commit dd8dd48
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 3 deletions.
20 changes: 19 additions & 1 deletion src/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ void MainWindow::init()

// Create popup menus
popupTableMenu = new QMenu(this);
popupTableMenu->addAction(ui->actionEditBrowseTable);
popupTableMenu->addAction(ui->editModifyTableAction);
popupTableMenu->addAction(ui->editDeleteObjectAction);
popupTableMenu->addSeparator();
Expand Down Expand Up @@ -980,6 +981,7 @@ void MainWindow::changeTreeSelection()
// Just assume first that something's selected that can not be edited at all
ui->editDeleteObjectAction->setEnabled(false);
ui->editModifyTableAction->setEnabled(false);
ui->actionEditBrowseTable->setEnabled(false);

if(!ui->dbTreeWidget->currentIndex().isValid())
return;
Expand All @@ -1004,7 +1006,11 @@ void MainWindow::changeTreeSelection()
} else if(type == "view" || type == "trigger" || type == "index") {
ui->editDeleteObjectAction->setEnabled(true);
}
ui->actionExportCsvPopup->setEnabled(type == "table" || type == "view");
if(type == "table" || type == "view")
{
ui->actionEditBrowseTable->setEnabled(true);
ui->actionExportCsvPopup->setEnabled(true);
}
}

void MainWindow::openRecentFile()
Expand Down Expand Up @@ -2082,3 +2088,15 @@ void MainWindow::editEncryption()
}
#endif
}

void MainWindow::switchToBrowseDataTab()
{
if(!ui->dbTreeWidget->selectionModel()->hasSelection())
return;

QString tableToBrowse = ui->dbTreeWidget->model()->data(ui->dbTreeWidget->currentIndex().sibling(ui->dbTreeWidget->currentIndex().row(), 0)).toString();

ui->mainTab->setCurrentIndex(1);
ui->comboBrowseTable->setCurrentText(tableToBrowse);
ui->comboBrowseTable->activated(tableToBrowse);
}
1 change: 1 addition & 0 deletions src/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ private slots:
void fileAttach();
void updateFilter(int column, const QString& value);
void editEncryption();
void switchToBrowseDataTab();
};

#endif
30 changes: 28 additions & 2 deletions src/MainWindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>294</width>
<height>444</height>
<width>575</width>
<height>458</height>
</rect>
</property>
<layout class="QFormLayout" name="formLayout">
Expand Down Expand Up @@ -1598,6 +1598,15 @@
<string>Save SQL file</string>
</property>
</action>
<action name="actionEditBrowseTable">
<property name="icon">
<iconset resource="icons/icons.qrc">
<normaloff>:/icons/table</normaloff>:/icons/table</iconset>
</property>
<property name="text">
<string>&amp;Browse Table</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>
Expand Down Expand Up @@ -2469,6 +2478,22 @@
</hint>
</hints>
</connection>
<connection>
<sender>actionEditBrowseTable</sender>
<signal>triggered()</signal>
<receiver>MainWindow</receiver>
<slot>switchToBrowseDataTab()</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 @@ -2522,5 +2547,6 @@
<slot>fileAttach()</slot>
<slot>editEncryption()</slot>
<slot>saveSqlFileAs()</slot>
<slot>switchToBrowseDataTab()</slot>
</slots>
</ui>

0 comments on commit dd8dd48

Please sign in to comment.