mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-30 03:20:41 +01:00
merge master
This commit is contained in:
commit
d05d1e6914
14 files changed
+410
-119
No files matched your search
@@ -38,7 +38,7 @@ from View.Frictions.UndoCommand import (
|
||||
SetNameCommand, SetBeginCommand, SetEndCommand,
|
||||
SetBeginStricklerCommand, SetEndStricklerCommand,
|
||||
AddCommand, DelCommand, SortCommand,
|
||||
MoveCommand, PasteCommand, DuplicateCommand,
|
||||
MoveCommand, PasteCommand, DuplicateCommand, ReplaceDataCommand,
|
||||
)
|
||||
|
||||
from View.Tools.PamhyrTable import PamhyrTableModel
|
||||
@@ -99,7 +99,7 @@ class ComboBoxDelegate(QItemDelegate):
|
||||
self.commitData.emit(self.sender())
|
||||
|
||||
|
||||
class TableModel(PamhyrTableModel):
|
||||
class FrictionTableModel(PamhyrTableModel):
|
||||
def _setup_lst(self):
|
||||
self._lst = self._data.frictions
|
||||
self._study = self._opt_data
|
||||
@@ -199,6 +199,18 @@ class TableModel(PamhyrTableModel):
|
||||
self.endRemoveRows()
|
||||
self.layoutChanged.emit()
|
||||
|
||||
def replace_data(self, new_data):
|
||||
self.layoutAboutToBeChanged.emit()
|
||||
|
||||
self._undo.push(
|
||||
ReplaceDataCommand(
|
||||
self._lst, new_data
|
||||
)
|
||||
)
|
||||
|
||||
self.layoutAboutToBeChanged.emit()
|
||||
self.layoutChanged.emit()
|
||||
|
||||
def sort(self, _reverse, parent=QModelIndex()):
|
||||
self.layoutAboutToBeChanged.emit()
|
||||
|
||||
@@ -252,3 +264,33 @@ class TableModel(PamhyrTableModel):
|
||||
def redo(self):
|
||||
self._undo.redo()
|
||||
self.layoutChanged.emit()
|
||||
|
||||
def read_from_file(self, file_name):
|
||||
|
||||
reach_id = self._study.river.enable_edges().index(self._data) + 1
|
||||
|
||||
logger.debug(f"Import frictions from {file_name}")
|
||||
data = []
|
||||
with open(file_name, encoding="utf-8") as rug_file:
|
||||
for line in rug_file:
|
||||
if line.upper().startswith("K"):
|
||||
line = line.split()
|
||||
if int(line[1]) == reach_id:
|
||||
data.append(line[1:])
|
||||
|
||||
new_data = []
|
||||
for d in data:
|
||||
new = None
|
||||
minor = float(d[3])
|
||||
medium = float(d[4])
|
||||
for s in self._study.river.stricklers.stricklers:
|
||||
if s.minor == minor and s.medium == medium:
|
||||
new = s
|
||||
break
|
||||
if new is None:
|
||||
new = self._study.river.stricklers.new(len(
|
||||
self._study.river.stricklers))
|
||||
new.minor = minor
|
||||
new.medium = medium
|
||||
new_data.append([self._data, float(d[1]), float(d[2]), new, new])
|
||||
self.replace_data(new_data)
|
||||
Reference in new issue
Block a user