Commit ccb55ff4 authored by Pierre-Antoine Rouby's avatar Pierre-Antoine Rouby
Browse files

HS: Fix pep8 and minor change.

Showing with 25 additions and 24 deletions
+25 -24
......@@ -61,15 +61,13 @@ class ComboBoxDelegate(QItemDelegate):
def createEditor(self, parent, option, index):
self.editor = QComboBox(parent)
lst = list(
map(
lambda k: self._long_types[k], BHS_types.keys()
lambda k: self._long_types[k],
BHS_types.keys()
)
)
self.editor.addItems(
lst
)
self.editor.addItems(lst)
self.editor.setCurrentText(index.data(Qt.DisplayRole))
return self.editor
......@@ -159,8 +157,8 @@ class TableModel(PamhyrTableModel):
question = QMessageBox(self._parent)
question.setWindowTitle(self._trad['msg_type_change_title'])
question.setText(self._trad['msg_type_change_msg'])
question.setStandardButtons(QMessageBox.Cancel | QMessageBox.Ok )
question.setText(self._trad['msg_type_change_text'])
question.setStandardButtons(QMessageBox.Cancel | QMessageBox.Ok)
question.setIcon(QMessageBox.Question)
res = question.exec()
......
......@@ -32,7 +32,7 @@ class BasicHydraulicStructuresTranslate(PamhyrTranslate):
"Change hydraulic structure type"
)
self._dict['msg_type_change_msg'] = _translate(
self._dict['msg_type_change_text'] = _translate(
"BasicHydraulicStructures",
"Do you want to change the hydraulic structure type and reset \
hydraulic structure values?"
......
......@@ -126,8 +126,7 @@ class PasteCommand(QUndoCommand):
self._bhs.reverse()
def undo(self):
self._hs.delete_i(range(self._row, self._row + len(self._bhs))
)
self._hs.delete_i(range(self._row, self._row + len(self._bhs)))
def redo(self):
for r in self._bhs:
......
......@@ -45,7 +45,9 @@ from View.HydraulicStructures.BasicHydraulicStructures.Table import (
)
from View.Network.GraphWidget import GraphWidget
from View.HydraulicStructures.BasicHydraulicStructures.Translate import BasicHydraulicStructuresTranslate
from View.HydraulicStructures.BasicHydraulicStructures.Translate import (
BasicHydraulicStructuresTranslate
)
_translate = QCoreApplication.translate
......@@ -150,25 +152,25 @@ class BasicHydraulicStructuresWindow(PamhyrWindow):
table = self.find(QTableView, "tableView")
table.selectionModel()\
.selectionChanged\
.connect(self.update)
.selectionChanged\
.connect(self.update)
self._table.layoutChanged.connect(self.update)
def index_selected(self):
table = self.find(QTableView, "tableView")
r = table.selectionModel()\
.selectedRows()
if len(r)>0:
r = table.selectionModel().selectedRows()
if len(r) > 0:
return r[0]
else:
return None
def index_selected_row(self):
table = self.find(QTableView, "tableView")
r = table.selectionModel()\
.selectedRows()
if len(r)>0:
r = table.selectionModel().selectedRows()
if len(r) > 0:
return r[0].row()
else:
return None
......@@ -187,6 +189,7 @@ class BasicHydraulicStructuresWindow(PamhyrWindow):
def add(self):
rows = self.index_selected_rows()
if len(self._hs) == 0 or len(rows) == 0:
self._table.add(0)
else:
......@@ -194,6 +197,7 @@ class BasicHydraulicStructuresWindow(PamhyrWindow):
def delete(self):
rows = self.index_selected_rows()
if len(rows) == 0:
return
......@@ -213,6 +217,7 @@ class BasicHydraulicStructuresWindow(PamhyrWindow):
def _set_checkbox_state(self):
row = self.index_selected_row()
if row is None:
self._checkbox.setEnabled(False)
self._checkbox.setChecked(True)
......@@ -222,6 +227,7 @@ class BasicHydraulicStructuresWindow(PamhyrWindow):
def _set_basic_structure_state(self):
row = self.index_selected_row()
if row is not None:
self._table.enabled(
row,
......@@ -230,7 +236,3 @@ class BasicHydraulicStructuresWindow(PamhyrWindow):
def update(self):
self._set_checkbox_state()
self._update_clear_plot()
def _update_clear_plot(self):
rows = self.index_selected_rows()
......@@ -48,7 +48,9 @@ from View.HydraulicStructures.Table import (
from View.Network.GraphWidget import GraphWidget
from View.HydraulicStructures.Translate import HydraulicStructuresTranslate
from View.HydraulicStructures.BasicHydraulicStructures.Window import BasicHydraulicStructuresWindow
from View.HydraulicStructures.BasicHydraulicStructures.Window import (
BasicHydraulicStructuresWindow
)
_translate = QCoreApplication.translate
......
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