Commit 78aeaec6 authored by Valentin Valls's avatar Valentin Valls
Browse files

Sync scan styles on selected item

parent e4ee0ce6
......@@ -642,6 +642,7 @@ class _DataItem(_property_tree_helper.ScanRowItem):
class ScanItem(NamedTuple):
scan: scan_model.Scan
plotModel: plot_model.Plot
plotItem: plot_model.Item
curveWidget: qt.QWidget
......@@ -677,7 +678,7 @@ class ScanTableView(data_views.VDataTableView):
self.setColumn(
self.ScanStyleColumn,
title="Style",
delegate=delegates.StyleScanDelegate,
delegate=delegates.ScanStyleDelegate,
resizeMode=qt.QHeaderView.ResizeToContents,
)
self.setColumn(
......@@ -712,7 +713,6 @@ class ScanTableView(data_views.VDataTableView):
return qt.QModelIndex()
def selectScan(self, select: scan_model.Scan):
model = self.model()
index = self.scanIndex(select)
selectionModel = self.selectionModel()
# selectionModel.reset()
......@@ -990,6 +990,7 @@ class CurvePlotPropertyWidget(qt.QWidget):
index = item.index()
selectionModel = self.__tree.selectionModel()
selectionModel.setCurrentIndex(index, flags)
self.__syncScanModel()
def __scanSelectionChanged(self, scan: scan_model.Scan):
curveWidget = self.__focusWidget
......@@ -1091,9 +1092,12 @@ class CurvePlotPropertyWidget(qt.QWidget):
plotModel = self.__plotModel
if plotModel is None:
return
plotItem = widget.selectedPlotItem()
scans = widget.scanList()
scanList = [ScanItem(s, plotModel, widget) for s in scans]
scanList = [ScanItem(s, plotModel, plotItem, widget) for s in scans]
self.__scanListModel.setObjectList(scanList)
with qtutils.blockSignals(self.__scanListView):
self.__scanListView.selectScan(widget.selectedScan())
def __structureChanged(self):
if self.__plotModel.isInTransaction():
......
......@@ -210,7 +210,7 @@ class RemovePropertyItemDelegate(qt.QStyledItemDelegate):
pass
class StyleScanDelegate(qt.QStyledItemDelegate):
class ScanStyleDelegate(qt.QStyledItemDelegate):
"""Style delegate to display scan style.
"""
......@@ -220,7 +220,7 @@ class StyleScanDelegate(qt.QStyledItemDelegate):
def createEditor(self, parent, option, index):
if not index.isValid():
return super(StyleScanDelegate, self).createEditor(parent, option, index)
return super(ScanStyleDelegate, self).createEditor(parent, option, index)
editor = StylePropertyWidget(parent)
editor.setEditable(self.__editable)
......@@ -242,6 +242,8 @@ class StyleScanDelegate(qt.QStyledItemDelegate):
def __updateEditor(self, editor: qt.QWidget, index: qt.QModelIndex):
scanItem = index.data(ObjectRole)
plotItem = scanItem.plotItem
if plotItem is None:
plotItem = self.__getFirstItem(scanItem.plotModel)
editor.setScan(scanItem.scan)
editor.setPlotItem(plotItem)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment