diff --git a/mslib/msui/multiple_flightpath_dockwidget.py b/mslib/msui/multiple_flightpath_dockwidget.py index 5898c8321..8c7ddeb3d 100644 --- a/mslib/msui/multiple_flightpath_dockwidget.py +++ b/mslib/msui/multiple_flightpath_dockwidget.py @@ -115,7 +115,8 @@ class MultipleFlightpathControlWidget(QtWidgets.QWidget, ui.Ui_MultipleViewWidge signal_parent_closes = QtCore.pyqtSignal() def __init__(self, parent=None, view=None, listFlightTracks=None, - listOperationsMSC=None, category=None, activeFlightTrack=None, mscolab_server_url=None, token=None): + listOperationsMSC=None, category=None, activeFlightTrack=None, active_op_id=None, + mscolab_server_url=None, token=None): super().__init__(parent) # ToDO: Remove all patches, on closing dockwidget. self.ui = parent @@ -124,6 +125,7 @@ def __init__(self, parent=None, view=None, listFlightTracks=None, self.flight_path = None # flightpath object self.dict_flighttrack = {} # Dictionary of flighttrack data: patch,color,wp_model self.active_flight_track = activeFlightTrack + self.active_op_id = active_op_id self.msc_category = category # object of active category self.listOperationsMSC = listOperationsMSC self.listFlightTracks = listFlightTracks @@ -196,8 +198,11 @@ def login(self, url, token): self.connect_mscolab_server() def connect_mscolab_server(self): + if self.active_op_id is not None: + self.deactivate_all_flighttracks() self.operations = MultipleFlightpathOperations(self, self.mscolab_server_url, self.token, self.list_operation_track, + self.active_op_id, self.listOperationsMSC, self.view) self.obb.append(self.operations) @@ -510,10 +515,10 @@ class MultipleFlightpathOperations: on the TopView canvas. """ - def __init__(self, parent, mscolab_server_url, token, list_operation_track, listOperationsMSC, view): + def __init__(self, parent, mscolab_server_url, token, list_operation_track, active_op_id, listOperationsMSC, view): # Variables related to Mscolab Operations self.parent = parent - self.active_op_id = None + self.active_op_id = active_op_id self.mscolab_server_url = mscolab_server_url self.token = token self.view = view diff --git a/mslib/msui/topview.py b/mslib/msui/topview.py index 8af867720..577b60370 100644 --- a/mslib/msui/topview.py +++ b/mslib/msui/topview.py @@ -221,7 +221,7 @@ def __init__(self, parent=None, mainwindow=None, model=None, _id=None, self.active_flighttrack = active_flighttrack # Stores active mscolab operation id - self.active_op_id = None + self.active_op_id = mainwindow.mscolab.active_op_id # Mscolab Server Url and token self.mscolab_server_url = mscolab_server_url @@ -356,6 +356,7 @@ def openTool(self, index): listOperationsMSC=self.mainwindow_listOperationsMSC, category=self.mainwindow_filterCategoryCb, activeFlightTrack=self.active_flighttrack, + active_op_id=self.active_op_id, mscolab_server_url=self.mscolab_server_url, token=self.token) diff --git a/mslib/msui/viewwindows.py b/mslib/msui/viewwindows.py index a72c62c6d..ff36b548d 100644 --- a/mslib/msui/viewwindows.py +++ b/mslib/msui/viewwindows.py @@ -140,6 +140,7 @@ def createDockWidget(self, index, title, widget): # setWidget transfers the widget's ownership to Qt -- no setParent() # call is necessary: self.docks[index].setWidget(widget) + self.addDockWidget(QtCore.Qt.BottomDockWidgetArea, self.docks[index]) # Check if another dock widget occupies the dock area. If yes, diff --git a/tests/_test_msui/test_mscolab.py b/tests/_test_msui/test_mscolab.py index 02b280afd..f5fe1dc34 100644 --- a/tests/_test_msui/test_mscolab.py +++ b/tests/_test_msui/test_mscolab.py @@ -411,6 +411,77 @@ def assert_logout_text(): qtbot.wait_until(assert_label_text) # ToDo verify all operations disabled again without a visual check + def test_marked_bold_only_in_multiple_flight_path_operations_for_active_operation(self, qtbot): + """ + checks that when we use operations only the operations is bold marked not the flighttrack too + """ + # more operations for the user + for op_name in ["second", "third"]: + assert add_operation(op_name, "description") + assert add_user_to_operation(path=op_name, emailid=self.userdata[0]) + + self._connect_to_mscolab(qtbot) + modify_config_file({"MSS_auth": {self.url: self.userdata[0]}}) + self._login(qtbot, emailid=self.userdata[0], password=self.userdata[2]) + + # test after activating operation + self._activate_operation_at_index(0) + self.window.actionTopView.trigger() + + def assert_active_views(): + # check 1 view opened + assert len(self.window.get_active_views()) == 1 + qtbot.wait_until(assert_active_views) + + topview_0 = self.window.listViews.item(0) + assert topview_0.window.tv_window_exists is True + # open multiple flightpath first window + topview_0.window.cbTools.currentIndexChanged.emit(6) + + def assert_dock_loaded(): + assert topview_0.window.docks[5] is not None + qtbot.wait_until(assert_dock_loaded) + assert topview_0.window.active_op_id is not None + + list_flighttrack = topview_0.window.docks[5].widget().list_flighttrack + list_operation_track = topview_0.window.docks[5].widget().list_operation_track + + for i in range(list_operation_track.count()): + listItem = list_operation_track.item(i) + if self.window.mscolab.active_op_id == listItem.op_id: + assert listItem.font().bold() is True + for i in range(list_flighttrack.count()): + listItem = list_flighttrack.item(i) + assert listItem.font().bold() is False + + def test_correct_active_op_id_in_topview(self, qtbot): + """ + checks that active_op_id is set + """ + # more operations for the user + for op_name in ["second", "third"]: + assert add_operation(op_name, "description") + assert add_user_to_operation(path=op_name, emailid=self.userdata[0]) + + self._connect_to_mscolab(qtbot) + modify_config_file({"MSS_auth": {self.url: self.userdata[0]}}) + self._login(qtbot, emailid=self.userdata[0], password=self.userdata[2]) + + assert self.window.mscolab.active_op_id is None + # test after activating operation + self._activate_operation_at_index(0) + assert self.window.mscolab.active_op_id is not None + selected_op_id = self.window.mscolab.active_op_id + self.window.actionTopView.trigger() + + def assert_active_views(): + # check 1 view opened + assert len(self.window.get_active_views()) == 1 + qtbot.wait_until(assert_active_views) + topview_0 = self.window.listViews.item(0) + assert topview_0.window.active_op_id is not None + assert topview_0.window.active_op_id == selected_op_id + def test_multiple_flightpath_switching_to_flighttrack_and_logout(self, qtbot): """ checks that we can switch in topviews with the multiple flightpath dockingwidget