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