mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-30 03:20:41 +01:00
Profiles: can now disable some profiles, they still appears in the list, but they are marked as disabled
This commit is contained in:
1 parent
5b778af745
commit
deb84ca331
8 files changed
+146
-13
No files matched your search
@@ -99,6 +99,7 @@ class GeometryWindow(PamhyrWindow):
|
||||
self._profile_window = []
|
||||
|
||||
self.setup_table()
|
||||
self.setup_checkbox()
|
||||
self.setup_plots()
|
||||
self.setup_statusbar()
|
||||
self.setup_connections()
|
||||
@@ -124,6 +125,10 @@ class GeometryWindow(PamhyrWindow):
|
||||
table.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
|
||||
table.setAlternatingRowColors(True)
|
||||
|
||||
def setup_checkbox(self):
|
||||
self._checkbox = self.find(QCheckBox, "checkBox_enabled")
|
||||
self._set_checkbox_state()
|
||||
|
||||
def setup_plots(self):
|
||||
self.setup_plots_xy()
|
||||
self.setup_plots_rkc()
|
||||
@@ -223,6 +228,9 @@ class GeometryWindow(PamhyrWindow):
|
||||
.selectionChanged\
|
||||
.connect(self.select_current_profile)
|
||||
|
||||
if not self._study.is_read_only():
|
||||
self._checkbox.clicked.connect(self._set_profiles_state)
|
||||
|
||||
self._table.layoutChanged.connect(self.update_redraw)
|
||||
|
||||
def update(self):
|
||||
@@ -525,6 +533,48 @@ class GeometryWindow(PamhyrWindow):
|
||||
self._plot_ac.draw()
|
||||
|
||||
self.tableView.model().blockSignals(False)
|
||||
self._set_checkbox_state()
|
||||
|
||||
def index_selected_rows(self):
|
||||
return [
|
||||
index.row()
|
||||
for index in self.tableView.selectionModel().selectedRows()
|
||||
]
|
||||
|
||||
def _set_checkbox_state(self):
|
||||
rows = self.index_selected_rows()
|
||||
editable = not self._study.is_read_only()
|
||||
disabled_count = self._reach.number_profiles - self._reach.number_enabled_profiles
|
||||
self._checkbox.setText(
|
||||
self._trad["cross_section_enabled_count"].format(
|
||||
count=disabled_count
|
||||
)
|
||||
)
|
||||
|
||||
self._checkbox.setEnabled(editable and len(rows) > 0)
|
||||
if len(rows) == 0:
|
||||
self._checkbox.setTristate(False)
|
||||
self._checkbox.setChecked(False)
|
||||
return
|
||||
|
||||
states = {
|
||||
self._reach.profile(row).is_enabled
|
||||
for row in rows
|
||||
}
|
||||
if len(states) == 1:
|
||||
self._checkbox.setTristate(False)
|
||||
self._checkbox.setChecked(states.pop())
|
||||
else:
|
||||
self._checkbox.setTristate(True)
|
||||
self._checkbox.setCheckState(Qt.PartiallyChecked)
|
||||
|
||||
def _set_profiles_state(self, enabled):
|
||||
rows = self.index_selected_rows()
|
||||
if len(rows) == 0:
|
||||
return
|
||||
|
||||
self._checkbox.setTristate(False)
|
||||
self._table.enabled(rows, enabled)
|
||||
|
||||
def add(self):
|
||||
if len(self.tableView.selectedIndexes()) == 0:
|
||||
|
||||
Reference in new issue
Block a user