mirror of https://gitlab.com/pamhyr/pamhyr2
Compare commits
No commits in common. "e6d3564d9b744bdaef574270c5be754553b8b67d" and "0346080e16e653ae354f39b526d8d036834ad5d3" have entirely different histories.
e6d3564d9b
...
0346080e16
|
|
@ -60,9 +60,6 @@ class Scenarios(PamhyrModelDict):
|
||||||
self.set(new._id, new)
|
self.set(new._id, new)
|
||||||
return new
|
return new
|
||||||
|
|
||||||
def __len__(self):
|
|
||||||
return len(self.lst)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def lst(self):
|
def lst(self):
|
||||||
return list(
|
return list(
|
||||||
|
|
@ -73,8 +70,8 @@ class Scenarios(PamhyrModelDict):
|
||||||
)
|
)
|
||||||
|
|
||||||
def delete(self, key):
|
def delete(self, key):
|
||||||
if key not in self._dict:
|
el = self._dict.get(key)
|
||||||
|
if el is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
self._dict[key].set_as_deleted()
|
el.set_as_deleted()
|
||||||
self._status.modified()
|
|
||||||
|
|
|
||||||
|
|
@ -84,21 +84,13 @@ class StudyScenarioTestCase(unittest.TestCase):
|
||||||
self.assertNotEqual(old, new)
|
self.assertNotEqual(old, new)
|
||||||
|
|
||||||
def test_open_study(self):
|
def test_open_study(self):
|
||||||
study = Study.open(
|
study = Study.open("../tests_cases/Enlargement/Enlargement.pamhyr")
|
||||||
os.path.join(
|
|
||||||
"..", "tests_cases", "Enlargement", "Enlargement.pamhyr"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
self.assertNotEqual(study, None)
|
self.assertNotEqual(study, None)
|
||||||
self.assertEqual(study.name, "Enlargement")
|
self.assertEqual(study.name, "Enlargement")
|
||||||
self.assertEqual(study.status.scenario_id, 0)
|
self.assertEqual(study.status.scenario_id, 0)
|
||||||
|
|
||||||
def test_open_study_2(self):
|
def test_open_study_2(self):
|
||||||
study = Study.open(
|
study = Study.open("../tests_cases/MassZero/TestMultibiefs.pamhyr")
|
||||||
os.path.join(
|
|
||||||
"..", "tests_cases", "MassZero", "TestMultibiefs.pamhyr"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
self.assertNotEqual(study, None)
|
self.assertNotEqual(study, None)
|
||||||
self.assertEqual(study.name, "TestMultibiefs")
|
self.assertEqual(study.name, "TestMultibiefs")
|
||||||
self.assertEqual(study.status.scenario_id, 0)
|
self.assertEqual(study.status.scenario_id, 0)
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ from View.Tools.PamhyrTable import PamhyrTableModel
|
||||||
|
|
||||||
from PyQt5.QtCore import (
|
from PyQt5.QtCore import (
|
||||||
Qt, QRect, QVariant, QAbstractTableModel, pyqtSlot, pyqtSignal,
|
Qt, QRect, QVariant, QAbstractTableModel, pyqtSlot, pyqtSignal,
|
||||||
QEvent, QModelIndex,
|
QEvent,
|
||||||
)
|
)
|
||||||
|
|
||||||
from PyQt5.QtWidgets import (
|
from PyQt5.QtWidgets import (
|
||||||
|
|
@ -41,32 +41,20 @@ logger = logging.getLogger()
|
||||||
|
|
||||||
class ScenariosTableModel(PamhyrTableModel):
|
class ScenariosTableModel(PamhyrTableModel):
|
||||||
def _setup_lst(self):
|
def _setup_lst(self):
|
||||||
self._lst = list(
|
self._lst = self._data.scenarios.lst
|
||||||
filter(
|
|
||||||
lambda x: not x.is_deleted(),
|
|
||||||
self._data.scenarios.lst
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
def rowCount(self, parent=QModelIndex()):
|
|
||||||
self._setup_lst()
|
|
||||||
|
|
||||||
return len(self._lst)
|
|
||||||
|
|
||||||
def data(self, index, role):
|
def data(self, index, role):
|
||||||
if role != Qt.ItemDataRole.DisplayRole:
|
if role != Qt.ItemDataRole.DisplayRole:
|
||||||
return QVariant()
|
return QVariant()
|
||||||
|
|
||||||
value = self._lst[index.row()]
|
|
||||||
|
|
||||||
if self._headers[index.column()] == "parent":
|
if self._headers[index.column()] == "parent":
|
||||||
parent = value["parent"]
|
parent = self._lst[index.row()][self._headers[index.column()]]
|
||||||
if parent is None:
|
if parent is None:
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
return parent.name
|
return parent.name
|
||||||
|
|
||||||
return value[self._headers[index.column()]]
|
return self._lst[index.row()][self._headers[index.column()]]
|
||||||
|
|
||||||
@pyqtSlot()
|
@pyqtSlot()
|
||||||
def setData(self, index, value, role=Qt.EditRole):
|
def setData(self, index, value, role=Qt.EditRole):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue