mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-29 19:10:42 +01:00
Ensemble: Select current tree item at dialog open.
This commit is contained in:
1 parent
5c8b7290ba
commit
4bccbbac33
2 files changed
+40
-5
No files matched your search
@@ -100,6 +100,15 @@ class EnsembleEditDialog(PamhyrDialog):
|
|||||||
parent=self._tree
|
parent=self._tree
|
||||||
)
|
)
|
||||||
|
|
||||||
|
self._target_data = (
|
||||||
|
self._ensemble.data_type,
|
||||||
|
self._ensemble.target_data
|
||||||
|
)
|
||||||
|
|
||||||
|
item = stricklers.find_item_by_value(self._target_data)
|
||||||
|
if item:
|
||||||
|
self._tree.setCurrentItem(item)
|
||||||
|
|
||||||
def _init_default_values(self):
|
def _init_default_values(self):
|
||||||
self.set_line_edit_text("lineEdit_name", self._ensemble.name)
|
self.set_line_edit_text("lineEdit_name", self._ensemble.name)
|
||||||
|
|
||||||
@@ -121,11 +130,6 @@ class EnsembleEditDialog(PamhyrDialog):
|
|||||||
|
|
||||||
self._set_widget(self._ensemble.distribution)
|
self._set_widget(self._ensemble.distribution)
|
||||||
|
|
||||||
self._target_data = (
|
|
||||||
self._ensemble.data_type,
|
|
||||||
self._ensemble.target_data
|
|
||||||
)
|
|
||||||
|
|
||||||
def _init_connection(self):
|
def _init_connection(self):
|
||||||
self.find(QComboBox, "comboBox_distribution")\
|
self.find(QComboBox, "comboBox_distribution")\
|
||||||
.currentTextChanged.connect(self.update_distribution)
|
.currentTextChanged.connect(self.update_distribution)
|
||||||
|
|||||||
@@ -61,6 +61,22 @@ class PamhyrModelItem(QTreeWidgetItem):
|
|||||||
def get_value(self):
|
def get_value(self):
|
||||||
return self._data
|
return self._data
|
||||||
|
|
||||||
|
def find_item_by_value(self, data):
|
||||||
|
if self.get_value() == data:
|
||||||
|
return self
|
||||||
|
|
||||||
|
for i in range(self.childCount()):
|
||||||
|
item = self.child(i)
|
||||||
|
if item.get_value() == data:
|
||||||
|
return item
|
||||||
|
|
||||||
|
found = item.find_item_by_value(data)
|
||||||
|
if found:
|
||||||
|
return found
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
class PamhyrModelListItem(QTreeWidgetItem):
|
class PamhyrModelListItem(QTreeWidgetItem):
|
||||||
def __init__(self, name=None, lst=None,
|
def __init__(self, name=None, lst=None,
|
||||||
child_item_ctor=PamhyrModelItem,
|
child_item_ctor=PamhyrModelItem,
|
||||||
@@ -86,3 +102,18 @@ class PamhyrModelListItem(QTreeWidgetItem):
|
|||||||
|
|
||||||
def get_value(self):
|
def get_value(self):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def find_item_by_value(self, data):
|
||||||
|
if self.get_value() == data:
|
||||||
|
return self
|
||||||
|
|
||||||
|
for i in range(self.childCount()):
|
||||||
|
item = self.child(i)
|
||||||
|
if item.get_value() == data:
|
||||||
|
return item
|
||||||
|
|
||||||
|
found = item.find_item_by_value(data)
|
||||||
|
if found:
|
||||||
|
return found
|
||||||
|
|
||||||
|
return None
|
||||||
Reference in new issue
Block a user