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): ...@@ -642,6 +642,7 @@ class _DataItem(_property_tree_helper.ScanRowItem):
class ScanItem(NamedTuple): class ScanItem(NamedTuple):
scan: scan_model.Scan scan: scan_model.Scan
plotModel: plot_model.Plot plotModel: plot_model.Plot
plotItem: plot_model.Item
curveWidget: qt.QWidget curveWidget: qt.QWidget
...@@ -677,7 +678,7 @@ class ScanTableView(data_views.VDataTableView): ...@@ -677,7 +678,7 @@ class ScanTableView(data_views.VDataTableView):
self.setColumn( self.setColumn(
self.ScanStyleColumn, self.ScanStyleColumn,
title="Style", title="Style",
delegate=delegates.StyleScanDelegate, delegate=delegates.ScanStyleDelegate,
resizeMode=qt.QHeaderView.ResizeToContents, resizeMode=qt.QHeaderView.ResizeToContents,
) )
self.setColumn( self.setColumn(
...@@ -712,7 +713,6 @@ class ScanTableView(data_views.VDataTableView): ...@@ -712,7 +713,6 @@ class ScanTableView(data_views.VDataTableView):
return qt.QModelIndex() return qt.QModelIndex()
def selectScan(self, select: scan_model.Scan): def selectScan(self, select: scan_model.Scan):
model = self.model()
index = self.scanIndex(select) index = self.scanIndex(select)
selectionModel = self.selectionModel() selectionModel = self.selectionModel()
# selectionModel.reset() # selectionModel.reset()
...@@ -990,6 +990,7 @@ class CurvePlotPropertyWidget(qt.QWidget): ...@@ -990,6 +990,7 @@ class CurvePlotPropertyWidget(qt.QWidget):
index = item.index() index = item.index()
selectionModel = self.__tree.selectionModel() selectionModel = self.__tree.selectionModel()
selectionModel.setCurrentIndex(index, flags) selectionModel.setCurrentIndex(index, flags)
self.__syncScanModel()
def __scanSelectionChanged(self, scan: scan_model.Scan): def __scanSelectionChanged(self, scan: scan_model.Scan):
curveWidget = self.__focusWidget curveWidget = self.__focusWidget
...@@ -1091,9 +1092,12 @@ class CurvePlotPropertyWidget(qt.QWidget): ...@@ -1091,9 +1092,12 @@ class CurvePlotPropertyWidget(qt.QWidget):
plotModel = self.__plotModel plotModel = self.__plotModel
if plotModel is None: if plotModel is None:
return return
plotItem = widget.selectedPlotItem()
scans = widget.scanList() 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) self.__scanListModel.setObjectList(scanList)
with qtutils.blockSignals(self.__scanListView):
self.__scanListView.selectScan(widget.selectedScan())
def __structureChanged(self): def __structureChanged(self):
if self.__plotModel.isInTransaction(): if self.__plotModel.isInTransaction():
......
...@@ -210,7 +210,7 @@ class RemovePropertyItemDelegate(qt.QStyledItemDelegate): ...@@ -210,7 +210,7 @@ class RemovePropertyItemDelegate(qt.QStyledItemDelegate):
pass pass
class StyleScanDelegate(qt.QStyledItemDelegate): class ScanStyleDelegate(qt.QStyledItemDelegate):
"""Style delegate to display scan style. """Style delegate to display scan style.
""" """
...@@ -220,7 +220,7 @@ class StyleScanDelegate(qt.QStyledItemDelegate): ...@@ -220,7 +220,7 @@ class StyleScanDelegate(qt.QStyledItemDelegate):
def createEditor(self, parent, option, index): def createEditor(self, parent, option, index):
if not index.isValid(): if not index.isValid():
return super(StyleScanDelegate, self).createEditor(parent, option, index) return super(ScanStyleDelegate, self).createEditor(parent, option, index)
editor = StylePropertyWidget(parent) editor = StylePropertyWidget(parent)
editor.setEditable(self.__editable) editor.setEditable(self.__editable)
...@@ -242,7 +242,9 @@ class StyleScanDelegate(qt.QStyledItemDelegate): ...@@ -242,7 +242,9 @@ class StyleScanDelegate(qt.QStyledItemDelegate):
def __updateEditor(self, editor: qt.QWidget, index: qt.QModelIndex): def __updateEditor(self, editor: qt.QWidget, index: qt.QModelIndex):
scanItem = index.data(ObjectRole) scanItem = index.data(ObjectRole)
plotItem = self.__getFirstItem(scanItem.plotModel) plotItem = scanItem.plotItem
if plotItem is None:
plotItem = self.__getFirstItem(scanItem.plotModel)
editor.setScan(scanItem.scan) editor.setScan(scanItem.scan)
editor.setPlotItem(plotItem) 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