Skip to content

Commit

Permalink
active_op_id needs to be shared
Browse files Browse the repository at this point in the history
store widget data corresponding to docks
  • Loading branch information
ReimarBauer committed Apr 17, 2024
1 parent e71d9f3 commit 85b40e0
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 4 deletions.
11 changes: 8 additions & 3 deletions mslib/msui/multiple_flightpath_dockwidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion mslib/msui/topview.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,9 @@ def __init__(self, parent=None, mainwindow=None, model=None, _id=None,
# Dock windows [WMS, Satellite, Trajectories, Remote Sensing, KML Overlay, Multiple Flightpath]:
self.docks = [None, None, None, None, None, None]

# Corresponding widget objects
self.widgets = [None, None, None, None, None, None]

# Initialise the GUI elements (map view, items of combo boxes etc.).
self.setup_top_view()

Expand All @@ -221,7 +224,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
Expand Down Expand Up @@ -356,6 +359,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)

Expand Down
4 changes: 4 additions & 0 deletions mslib/msui/viewwindows.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ def __init__(self, parent=None, model=None, _id=None):
# in proper size in derived classes!
self.docks = []

self.widgets = []

# # emit _id if not none
# logging.debug(_id)
# self._id = _id
Expand Down Expand Up @@ -140,6 +142,8 @@ def createDockWidget(self, index, title, widget):
# setWidget transfers the widget's ownership to Qt -- no setParent()
# call is necessary:
self.docks[index].setWidget(widget)
# store data of widget
self.widgets[index] = widget
self.addDockWidget(QtCore.Qt.BottomDockWidgetArea, self.docks[index])

# Check if another dock widget occupies the dock area. If yes,
Expand Down
71 changes: 71 additions & 0 deletions tests/_test_msui/test_mscolab.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.widgets[5].list_flighttrack
list_operation_track = topview_0.window.widgets[5].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
Expand Down

0 comments on commit 85b40e0

Please sign in to comment.