Skip to content

Commit

Permalink
Rename UrlToolbar to DBEditorToolbar (#2811)
Browse files Browse the repository at this point in the history
  • Loading branch information
PiispaH authored Jun 3, 2024
1 parent 199bc27 commit 4499162
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def make_context_menu(self, index):
return None
tab = self.tab_widget.widget(index)
menu.addSeparator()
menu.addAction(tab.url_toolbar.reload_action)
menu.addAction(tab.toolbar.reload_action)
db_url_codenames = tab.db_url_codenames
menu.addAction(
QIcon(CharIconEngine("\uf24d")),
Expand Down
14 changes: 7 additions & 7 deletions spinetoolbox/spine_db_editor/widgets/spine_db_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
from .tree_view_mixin import TreeViewMixin
from .graph_view_mixin import GraphViewMixin
from .tabular_view_mixin import TabularViewMixin
from .url_toolbar import UrlToolBar
from .toolbar import DBEditorToolBar
from .metadata_editor import MetadataEditor
from .item_metadata_editor import ItemMetadataEditor
from ...widgets.notification import ChangeNotifier, Notification
Expand Down Expand Up @@ -83,13 +83,13 @@ def __init__(self, db_mngr):
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.takeCentralWidget().deleteLater()
self.url_toolbar = UrlToolBar(self)
self.addToolBar(Qt.TopToolBarArea, self.url_toolbar)
self.toolbar = DBEditorToolBar(self)
self.addToolBar(Qt.TopToolBarArea, self.toolbar)
toolbox = self.db_mngr.parent()
if toolbox is not None:
self.url_toolbar.show_toolbox_action.triggered.connect(toolbox.restore_and_activate)
self.toolbar.show_toolbox_action.triggered.connect(toolbox.restore_and_activate)
else:
self.url_toolbar.show_toolbox_action.deleteLater()
self.toolbar.show_toolbox_action.deleteLater()
self.setAttribute(Qt.WA_DeleteOnClose)
self.setWindowTitle("")
self.qsettings = self.db_mngr.qsettings
Expand Down Expand Up @@ -149,7 +149,7 @@ def load_db_urls(self, db_url_codenames, create=False, update_history=True, wind
self.ui.actionExport.setEnabled(False)
self.ui.actionMass_remove_items.setEnabled(False)
self.ui.actionVacuum.setEnabled(False)
self.url_toolbar.reload_action.setEnabled(False)
self.toolbar.reload_action.setEnabled(False)
if not db_url_codenames:
return True
if not self.tear_down():
Expand All @@ -170,7 +170,7 @@ def load_db_urls(self, db_url_codenames, create=False, update_history=True, wind
self.ui.actionExport.setEnabled(True)
self.ui.actionMass_remove_items.setEnabled(True)
self.ui.actionVacuum.setEnabled(any(url.startswith("sqlite") for url in self.db_urls))
self.url_toolbar.reload_action.setEnabled(True)
self.toolbar.reload_action.setEnabled(True)
self._change_notifiers = [
ChangeNotifier(self, self.db_mngr.undo_stack[db_map], self.qsettings, "appSettings/dbEditorShowUndo")
for db_map in self.db_maps
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# this program. If not, see <http://www.gnu.org/licenses/>.
######################################################################################################################

"""Contains the UrlToolBar class and helpers."""
"""Contains the DBEditorToolBar class and helpers."""
from PySide6.QtWidgets import (
QToolBar,
QWidget,
Expand Down Expand Up @@ -38,10 +38,10 @@
from spinetoolbox.helpers import CharIconEngine


class UrlToolBar(QToolBar):
class DBEditorToolBar(QToolBar):
def __init__(self, db_editor):
super().__init__(db_editor)
self.setObjectName("spine_db_editor_url_toolbar")
self.setObjectName("spine_db_editor_toolbar")
self._db_editor = db_editor
self.create_button_for_action(self._db_editor.ui.actionUndo)
self.create_button_for_action(self._db_editor.ui.actionRedo)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@
# this program. If not, see <http://www.gnu.org/licenses/>.
######################################################################################################################

"""Unit tests for the ``url_toolbar`` module."""
"""Unit tests for the ``toolbar`` module."""
from unittest import mock
from tempfile import TemporaryDirectory
from PySide6.QtWidgets import QApplication
from spinetoolbox.spine_db_editor.widgets.url_toolbar import UrlToolBar
from spinetoolbox.spine_db_editor.widgets.toolbar import DBEditorToolBar
from tests.spine_db_editor.widgets.spine_db_editor_test_base import DBEditorTestBase
from tests.mock_helpers import create_toolboxui_with_project, clean_up_toolbox, FakeDataStore
from tests.mock_helpers import create_toolboxui_with_project, clean_up_toolbox


class TestURLToolbar(DBEditorTestBase):
class TestDBEditorToolBar(DBEditorTestBase):
@classmethod
def setUpClass(cls):
if not QApplication.instance():
Expand All @@ -35,11 +35,11 @@ def tearDown(self):
clean_up_toolbox(self._toolbox)
self._temp_dir.cleanup()

def test_url_toolbar(self):
def test_toolbar(self):
self.db_mngr.setParent(self._toolbox)
tb = UrlToolBar(self.spine_db_editor)
tb = DBEditorToolBar(self.spine_db_editor)
self.assertEqual([{'database': 'sqlite://'}], self.spine_db_editor._history)
with mock.patch("spinetoolbox.spine_db_editor.widgets.url_toolbar._UrlFilterDialog.show") as mock_show_dialog:
with mock.patch("spinetoolbox.spine_db_editor.widgets.toolbar._UrlFilterDialog.show") as mock_show_dialog:
mock_show_dialog.show.return_value = True
tb._show_filter_menu()
mock_show_dialog.assert_called()

0 comments on commit 4499162

Please sign in to comment.