An error occurred while loading the file. Please try again.
-
Pierre-Antoine Rouby authored84688482
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# -*- coding: utf-8 -*-
from copy import copy
from tools import trace, timer
from Model.Section.Section import Section
class SectionList(object):
def __init__(self, status = None):
super(SectionList, self).__init__()
self._status = status
self._sections = []
def __len__(self):
return len(self._sections)
@property
def sections(self):
return self._sections.copy()
def get(self, row):
return self._sections[row]
def set(self, row, new):
self._sections[row] = new
self._status.modified()
def new(self, index):
n = Section(status = self._status)
self._sections.insert(index, n)
self._status.modified()
return n
def insert(self, index, new):
self._sections.insert(index, new)
self._status.modified()
def delete(self, sections):
for section in sections:
self._sections.remove(section)
self._status.modified()
def delete_i(self, indexes):
sections = list(
map(
lambda x: x[1],
filter(
lambda x: x[0] in indexes,
enumerate(self._sections)
)
)
)
self.delete(sections)
def sort(self, reverse=False, key=None):
self._sections.sort(reverse=reverse, key=key)
self._status.modified()
def move_up(self, index):
if index < len(self._sections):
next = index - 1
l = self._sections
l[index], l[next] = l[next], l[index]
self._status.modified()
def move_down(self, index):
if index >= 0:
prev = index + 1
l = self._sections
l[index], l[prev] = l[prev], l[index]
self._status.modified()