diff --git a/src/Model/Stricklers/StricklersList.py b/src/Model/Stricklers/StricklersList.py
index ce84d740..d2647823 100644
--- a/src/Model/Stricklers/StricklersList.py
+++ b/src/Model/Stricklers/StricklersList.py
@@ -2,10 +2,13 @@
from tools import trace, timer
+from Model.Saved import SavedStatus
from Model.Stricklers.Stricklers import Stricklers
class StricklersList(object):
def __init__(self, status = None):
+ if status is None:
+ status = SavedStatus()
self._status = status
self._stricks = []
diff --git a/src/View/Configure/Window.py b/src/View/Configure/Window.py
index 659e92ed..c019ca81 100644
--- a/src/View/Configure/Window.py
+++ b/src/View/Configure/Window.py
@@ -4,8 +4,16 @@ from config import Config
from View.ASubWindow import ASubWindow
from View.ListedSubWindow import ListedSubWindow
+from View.Stricklers.Table import TableModel
+from View.Stricklers.translate import *
+from View.Stricklers.UndoCommand import *
+
from View.Configure.Solver.Window import ConfigureSolverWindow
+from PyQt5.QtGui import (
+ QKeySequence,
+)
+
from PyQt5.QtCore import (
Qt, QVariant, QAbstractTableModel,
)
@@ -13,7 +21,7 @@ from PyQt5.QtCore import (
from PyQt5.QtWidgets import (
QDialogButtonBox, QPushButton, QLineEdit,
QFileDialog, QTableView, QAbstractItemView,
- QComboBox,
+ QComboBox, QUndoStack, QShortcut, QHeaderView,
)
@@ -71,17 +79,18 @@ class ConfigureWindow(ASubWindow, ListedSubWindow):
else:
self.conf = conf
+ self.setup_sc()
+
# Solver
+ table = self.find(QTableView, "tableView_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)
- self.find(QTableView, "tableView_solver")\
- .setAlternatingRowColors(True)
+ table.setModel(self.solver_table_model)
+ table.setSelectionBehavior(QAbstractItemView.SelectRows)
+ table.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
+ table.setAlternatingRowColors(True)
# Meshing_Tool
self.set_line_edit_text("lineEdit_meshing_tool", self.conf.meshing_tool)
@@ -99,6 +108,18 @@ class ConfigureWindow(ASubWindow, ListedSubWindow):
self.find(QTableView, "tableView_solver").resizeColumnsToContents()
self.connect()
+ # Stricklers
+ table = self.find(QTableView, f"tableView_stricklers")
+ self._stricklers = self.conf.stricklers
+ self._stricklers_table = TableModel(
+ data = self._stricklers,
+ undo = self._undo_stack,
+ )
+ table.setModel(self._stricklers_table)
+ table.setSelectionBehavior(QAbstractItemView.SelectRows)
+ table.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
+ table.setAlternatingRowColors(True)
+
# Language
languages = Config.languages()
for lang in languages:
@@ -106,11 +127,25 @@ class ConfigureWindow(ASubWindow, ListedSubWindow):
if self.conf.lang == languages[lang]:
self.set_combobox_text("comboBox_language", lang)
+ def setup_sc(self):
+ self._undo_stack = QUndoStack()
+
+ self.undo_sc = QShortcut(QKeySequence.Undo, self)
+ self.redo_sc = QShortcut(QKeySequence.Redo, self)
+ self.copy_sc = QShortcut(QKeySequence.Copy, self)
+ self.paste_sc = QShortcut(QKeySequence.Paste, self)
+
def connect(self):
buttons = {
+ # Solvers
"pushButton_solver_add": self.add_solver,
"pushButton_solver_del": self.remove_solver,
"pushButton_solver_edit": self.edit_solver,
+ # Stricklers
+ "pushButton_stricklers_add": self.add_stricklers,
+ "pushButton_stricklers_del": self.del_stricklers,
+ "pushButton_stricklers_sort": self.sort_stricklers,
+ # Others
"pushButton_backup_path": lambda: self.file_dialog(
select_file = False,
callback = lambda f: self.set_line_edit_text(
@@ -158,6 +193,8 @@ class ConfigureWindow(ASubWindow, ListedSubWindow):
self.conf.save()
self.close()
+ # Solvers
+
def edit_solver(self):
indexes = self.find(QTableView, "tableView_solver").selectionModel().selectedRows()
for index in indexes:
@@ -177,3 +214,33 @@ class ConfigureWindow(ASubWindow, ListedSubWindow):
indices = self.find(QTableView, "tableView_solver").selectionModel().selectedRows()
for index in sorted(indices):
self.solver_table_model.removeRow(index)
+
+ # Stricklers
+
+ def index_selected_rows_strikclers(self):
+ table = self.find(QTableView, f"tableView_stricklers")
+ return list(
+ set(
+ map(
+ lambda i: i.row(),
+ table.selectedIndexes()
+ )
+ )
+ )
+
+ def add_stricklers(self):
+ rows = self.index_selected_rows_strikclers()
+ if len(rows) == 0:
+ self._stricklers_table.add(0)
+ else:
+ self._stricklers_table.add(rows[0])
+
+ def del_stricklers(self):
+ rows = self.index_selected_rows_strikclers()
+ if len(rows) == 0:
+ return
+
+ self._stricklers_table.delete(rows)
+
+ def sort_stricklers(self):
+ self._stricklers_table.sort(False)
diff --git a/src/View/MainWindow.py b/src/View/MainWindow.py
index 30c7de24..c1bc091d 100644
--- a/src/View/MainWindow.py
+++ b/src/View/MainWindow.py
@@ -334,7 +334,11 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
self.lateral.show()
def open_stricklers(self):
- self.strick = StricklersWindow(study = self.model, parent=self)
+ self.strick = StricklersWindow(
+ study = self.model,
+ config = self.conf,
+ parent=self
+ )
self.strick.show()
# TODO: Delete me !
diff --git a/src/View/Stricklers/Window.py b/src/View/Stricklers/Window.py
index 0c4d2bb7..d5f325ca 100644
--- a/src/View/Stricklers/Window.py
+++ b/src/View/Stricklers/Window.py
@@ -31,7 +31,7 @@ _translate = QCoreApplication.translate
class StricklersWindow(ASubMainWindow, ListedSubWindow):
- def __init__(self, title="Stricklers", study=None, parent=None):
+ def __init__(self, title="Stricklers", study=None, config=None, parent=None):
title = title + " - " + study.name
super(StricklersWindow, self).__init__(
@@ -39,6 +39,7 @@ class StricklersWindow(ASubMainWindow, ListedSubWindow):
)
self._study = study
+ self._config = config
self.setup_sc()
self.setup_table()
@@ -59,10 +60,18 @@ class StricklersWindow(ASubMainWindow, ListedSubWindow):
for t in ["app", "study"]:
table = self.find(QTableView, f"tableView_{t}")
+ if t == "study":
+ data = self._study.river.striklers
+ else:
+ data = self._config.stricklers
+
+ print(data)
+
self._table[t] = TableModel(
- data = self._study.river.striklers,
+ data = data,
undo = self._undo_stack,
)
+
table.setModel(self._table[t])
table.setSelectionBehavior(QAbstractItemView.SelectRows)
table.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
diff --git a/src/View/ui/ConfigureDialog.ui b/src/View/ui/ConfigureDialog.ui
index 5ddf767a..693971a0 100644
--- a/src/View/ui/ConfigureDialog.ui
+++ b/src/View/ui/ConfigureDialog.ui
@@ -349,6 +349,66 @@
+
+
+ Stricklers
+
+
+ -
+
+
-
+
+
+
+
+
+
+ ressources/gtk-add.pngressources/gtk-add.png
+
+
+
+ -
+
+
+
+
+
+
+ ressources/gtk-remove.pngressources/gtk-remove.png
+
+
+
+ -
+
+
+
+
+
+
+ ressources/gtk-sort-ascending.pngressources/gtk-sort-ascending.png
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+
+
+ -
+
+
+
+
Language
diff --git a/src/View/ui/Stricklers.ui b/src/View/ui/Stricklers.ui
index b6ec590b..c27f9ff0 100644
--- a/src/View/ui/Stricklers.ui
+++ b/src/View/ui/Stricklers.ui
@@ -13,6 +13,9 @@
MainWindow
+
+
+
-
diff --git a/src/config.py b/src/config.py
index 79d0da5c..046301aa 100644
--- a/src/config.py
+++ b/src/config.py
@@ -3,6 +3,8 @@
import os
import pickle
+from Model.Stricklers.StricklersList import StricklersList
+
config_dir = "/.cache/pamhyr/"
config_file = "config.pkl"
@@ -33,6 +35,9 @@ class Config(object):
# Languages
self.lang = ""
+ # Stricklers
+ self.stricklers = StricklersList()
+
@classmethod
def filename(cls):
return os.environ["HOME"] + config_dir + config_file