An error occurred while loading the file. Please try again.
-
Mathias Chouet authored
merged cParamsCanal and ParamsSection Structures are now only defined by their LoiDebit (no more StructureType) Session : fixed serialization of lately registered Nubs Sections are now defined by a CalculatorType and a NodeType fixed bug in findFirstSingleParameter added tests for session serialisation
7b6e5403
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# -*- coding: utf-8 -*-
from config import Config
from view.ASubWindow import ASubWindow
from view.ListedSubWindow import ListedSubWindow
from view.ConfigureAddSolverWindow import ConfigureAddSolverWindow
from PyQt5.QtCore import (
Qt, QVariant, QAbstractTableModel,
)
from PyQt5.QtWidgets import (
QDialogButtonBox, QPushButton, QLineEdit,
QFileDialog, QTableView, QAbstractItemView
)
class SolverTableModel(QAbstractTableModel):
def __init__(self, headers=[], rows=[]):
super(QAbstractTableModel, self).__init__()
self.rows = rows
self.headers = headers
def rowCount(self, parent):
return len(self.rows)
def columnCount(self, parent):
return len(self.headers)
def data(self, index, role):
if role != Qt.ItemDataRole.DisplayRole:
return QVariant()
return self.rows[index.row()][self.headers[index.column()]]
def headerData(self, section, orientation, role):
if role == Qt.ItemDataRole.DisplayRole and orientation == Qt.Orientation.Horizontal:
return self.headers[section].capitalize()
if role == Qt.ItemDataRole.DisplayRole and orientation == Qt.Orientation.Vertical:
return section
return QVariant()
def removeRow(self, index):
del self.rows[index.row()]
self.layoutChanged.emit()
def add_solver(self, solver):
self.rows.append(solver)
self.layoutChanged.emit()
def change_solver(self, solver, index):
self.rows[index.row()] = solver
self.layoutChanged.emit()
class ConfigureWindow(ASubWindow, ListedSubWindow):
def __init__(self, conf=None, title="Configure", parent=None):
super(ConfigureWindow, self).__init__(name=title, ui="ConfigureDialog", parent=parent)
self.ui.setWindowTitle(title)
if conf is None:
self.conf = Config()
else:
self.conf = conf
# Solver
self.solver_table_model = SolverTableModel(
headers = ["name", "type", "description"],
rows = conf.solvers.copy()
)
self.find(QTableView, "tableView_solver").setModel(self.solver_table_model)
self.find(QTableView, "tableView_solver")\
.setSelectionBehavior(QAbstractItemView.SelectRows)
# Mailleur
self.set_line_edit_text("lineEdit_mailleur", self.conf.mailleur)
# Const
self.set_line_edit_text("lineEdit_segment", str(self.conf.segment))
self.set_line_edit_text("lineEdit_max_listing", str(self.conf.max_listing))
# Backup
self.set_check_box("checkBox_backup", self.conf.backup_enable)
self.set_line_edit_text("lineEdit_backup_path", self.conf.backup_path)
self.set_time_edit("timeEdit_backup_frequence", self.conf.backup_frequence)
self.set_spin_box("spinBox_backup_max", self.conf.backup_max)
self.find(QTableView, "tableView_solver").resizeColumnsToContents()
self.connect()
def connect(self):
buttons = {
"pushButton_solver_add": self.add_solver,
"pushButton_solver_del": self.remove_solver,
"pushButton_solver_edit": self.edit_solver,
"pushButton_backup_path": lambda: self.file_dialog(
select_file = False,
callback = lambda f: self.set_line_edit_text(
"lineEdit_backup_path", f[0]
)
),
"pushButton_mailleur" : lambda: self.file_dialog(
select_file = True,
callback = lambda f: self.set_line_edit_text(
"lineEdit_mailleur", f[0]
)
),
}
for button in buttons:
self.find(QPushButton, button).clicked.connect(buttons[button])
def accept(self):
# Solvers
self.conf.solvers = self.solver_table_model.rows.copy()
# Mailleur
self.conf.mailleur = self.get_line_edit_text("lineEdit_mailleur")
# Const
self.conf.segment = self.get_line_edit_text("lineEdit_segment")
self.conf.max_listing = self.get_line_edit_text("lineEdit_max_listing")
# Backup
self.conf.backup_enable = self.get_check_box("checkBox_backup")
self.conf.backup_path = self.get_line_edit_text("lineEdit_backup_path")
self.conf.backup_frequence = self.get_time_edit("timeEdit_backup_frequence")
self.conf.backup_max = self.get_spin_box("spinBox_backup_max")
self.end()
def reject(self):
# Nothing todo
self.end()
def end(self):
self.conf.save()
self.close()
def edit_solver(self):
indices = self.find(QTableView, "tableView_solver").selectionModel().selectedRows()
for index in indices:
self.edit_solver = ConfigureAddSolverWindow(
data=self.solver_table_model.rows[index.row()],
parent=self
)
if self.edit_solver.exec_():
self.solver_table_model.change_solver(self.edit_solver.data, index)
def add_solver(self):
dialog_solver = ConfigureAddSolverWindow(parent=self)
if dialog_solver.exec_():
self.solver_table_model.add_solver(dialog_solver.data)
def remove_solver(self):
indices = self.find(QTableView, "tableView_solver").selectionModel().selectedRows()
for index in sorted(indices):
self.solver_table_model.removeRow(index)