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

BC: Fix delete elements.

Showing with 18 additions and 8 deletions
+18 -8
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from tools import trace, timer
from Model.Except import NotImplementedMethodeError from Model.Except import NotImplementedMethodeError
class BoundaryCondition(object): class BoundaryCondition(object):
...@@ -88,6 +90,7 @@ class BoundaryCondition(object): ...@@ -88,6 +90,7 @@ class BoundaryCondition(object):
def set_i_1(self, index:int, value): def set_i_1(self, index:int, value):
self._set_i_c_v(index, 1, value) self._set_i_c_v(index, 1, value)
@timer
def convert(self, cls): def convert(self, cls):
new = cls(name = self.name) new = cls(name = self.name)
for i, _ in self.data: for i, _ in self.data:
......
...@@ -25,16 +25,16 @@ class BoundaryConditionList(list): ...@@ -25,16 +25,16 @@ class BoundaryConditionList(list):
self.remove(bc) self.remove(bc)
def delete_i(self, indexes): def delete_i(self, indexes):
bcs = map( bcs = list(
lambda x: x[1], map(
filter( lambda x: x[1],
lambda x: x[0] in indexes, filter(
enumerate(self) lambda x: x[0] in indexes,
enumerate(self)
)
) )
) )
self.delete(bcs)
for bc in bcs:
self.remove(bc)
def move_up(self, index): def move_up(self, index):
if index < len(self): if index < len(self):
......
...@@ -301,6 +301,10 @@ class BoundaryConditionWindow(ASubMainWindow, ListedSubWindow): ...@@ -301,6 +301,10 @@ class BoundaryConditionWindow(ASubMainWindow, ListedSubWindow):
2, self._delegate_node 2, self._delegate_node
) )
table.setSelectionBehavior(QAbstractItemView.SelectRows)
table.setAlternatingRowColors(True)
def setup_connections(self): def setup_connections(self):
self.find(QAction, "action_add").triggered.connect(self.add) self.find(QAction, "action_add").triggered.connect(self.add)
self.find(QAction, "action_del").triggered.connect(self.delete) self.find(QAction, "action_del").triggered.connect(self.delete)
...@@ -339,6 +343,9 @@ class BoundaryConditionWindow(ASubMainWindow, ListedSubWindow): ...@@ -339,6 +343,9 @@ class BoundaryConditionWindow(ASubMainWindow, ListedSubWindow):
def delete(self): def delete(self):
rows = self.index_selected_rows() rows = self.index_selected_rows()
if len(rows) == 0:
return
self._table.delete(rows) self._table.delete(rows)
def sort(self): def sort(self):
......
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