mirror of https://gitlab.com/pamhyr/pamhyr2
Compare commits
No commits in common. "f4d3f2b28fd65fa89a68cd619129a90ca3c127dc" and "1e2a123693fe4ae10f306165164a3ddb87b7c808" have entirely different histories.
f4d3f2b28f
...
1e2a123693
|
|
@ -47,8 +47,6 @@ class Point(SQLSubModel):
|
|||
else:
|
||||
self._sl = sl
|
||||
|
||||
self.modified()
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
return self._name
|
||||
|
|
@ -56,7 +54,7 @@ class Point(SQLSubModel):
|
|||
@name.setter
|
||||
def name(self, name):
|
||||
self._name = name
|
||||
self.modified()
|
||||
self._status.modified()
|
||||
|
||||
def point_is_named(self):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -273,22 +273,6 @@ class PointXYZ(Point):
|
|||
|
||||
return point
|
||||
|
||||
def copy(self):
|
||||
new_p = PointXYZ(
|
||||
id=-1,
|
||||
name=self.name,
|
||||
x=self.x, y=self.y, z=self.z,
|
||||
profile=self.profile,
|
||||
status=self._status
|
||||
)
|
||||
if self.is_deleted():
|
||||
new_p.set_as_deleted()
|
||||
|
||||
new_p._sl = self.sl
|
||||
|
||||
new_p.modified()
|
||||
return new_p
|
||||
|
||||
def __repr__(self):
|
||||
return f"({self._x}, {self._y}, {self._z}, {self._name})"
|
||||
|
||||
|
|
|
|||
|
|
@ -202,7 +202,7 @@ class Profile(object):
|
|||
if point in self._points:
|
||||
point.set_as_not_deleted()
|
||||
else:
|
||||
self._points.insert(index, point)
|
||||
self.points.insert(index, point)
|
||||
|
||||
self.modified()
|
||||
|
||||
|
|
|
|||
|
|
@ -369,27 +369,6 @@ class ProfileXYZ(Profile, SQLSubModel):
|
|||
|
||||
return profile
|
||||
|
||||
def copy(self):
|
||||
new_p = ProfileXYZ(
|
||||
id=-1,
|
||||
name=self.name,
|
||||
rk=self.rk,
|
||||
reach=self.reach,
|
||||
status=self._status
|
||||
)
|
||||
if self.is_deleted():
|
||||
new_p.set_as_deleted()
|
||||
|
||||
new_p._sl = self.sl
|
||||
|
||||
for point in self._points:
|
||||
p = point.copy()
|
||||
print(p)
|
||||
new_p._points.append(p)
|
||||
|
||||
new_p.modified()
|
||||
return new_p
|
||||
|
||||
def point_from_data(self, header, data):
|
||||
def float_format(s: str):
|
||||
return float(
|
||||
|
|
|
|||
|
|
@ -126,12 +126,15 @@ class Study(SQLModel):
|
|||
|
||||
is_new = False
|
||||
fname = fname + "." + str(self._old_save_id)
|
||||
if os.path.exists(self.filename):
|
||||
if os.path.exists(self.filename) and ".backup" not in self.filename:
|
||||
filename = os.path.join(fdir, "_PAMHYR_", "__old__", fname)
|
||||
logger.debug(f"Backup previous version copy: {filename}")
|
||||
shutil.copy(self.filename, filename)
|
||||
self._old_save_id += 1
|
||||
|
||||
if ".backup" in self.filename:
|
||||
is_new = True
|
||||
|
||||
if not os.path.exists(self.filename):
|
||||
is_new = True
|
||||
|
||||
|
|
|
|||
|
|
@ -241,6 +241,7 @@ class GeometryProfileTableModel(PamhyrTableModel):
|
|||
self.layoutChanged.emit()
|
||||
|
||||
def reverse(self):
|
||||
|
||||
self._undo.push(
|
||||
ReverseCommand(
|
||||
self._data
|
||||
|
|
@ -258,16 +259,15 @@ class GeometryProfileTableModel(PamhyrTableModel):
|
|||
|
||||
self.layoutAboutToBeChanged.emit()
|
||||
|
||||
points = list(
|
||||
map(
|
||||
lambda d: self._data.point_from_data(header, d),
|
||||
data
|
||||
)
|
||||
)
|
||||
|
||||
self._undo.push(
|
||||
PasteCommand(
|
||||
self._data, row, points
|
||||
self._data, row,
|
||||
list(
|
||||
map(
|
||||
lambda d: self._data.point_from_data(header, d),
|
||||
data
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -294,13 +294,13 @@ class ProfileWindow(PamhyrWindow):
|
|||
rows = table.selectionModel().selectedRows()
|
||||
|
||||
data = []
|
||||
data.append(["name", "x", "y", "z"])
|
||||
data.append(["x", "y", "z", "name"])
|
||||
|
||||
for row in rows:
|
||||
point = self._profile.point(row.row())
|
||||
data.append(
|
||||
[
|
||||
point.name, point.x, point.y, point.z
|
||||
point.x, point.y, point.z, point.name
|
||||
]
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -158,7 +158,7 @@ class PasteCommand(QUndoCommand):
|
|||
self._row = row
|
||||
self._profiles = list(
|
||||
map(
|
||||
lambda p: p.copy(),
|
||||
lambda p: deepcopy(p),
|
||||
profiles
|
||||
)
|
||||
)
|
||||
|
|
@ -180,7 +180,7 @@ class DuplicateCommand(QUndoCommand):
|
|||
self._rows = rows
|
||||
self._profiles = list(
|
||||
map(
|
||||
lambda p: p.copy(),
|
||||
lambda p: deepcopy(p),
|
||||
profiles
|
||||
)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@
|
|||
import os
|
||||
import sys
|
||||
import time
|
||||
import shutil
|
||||
import logging
|
||||
import subprocess
|
||||
from queue import Queue
|
||||
|
|
@ -785,16 +784,26 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
|||
self.conf.set_last_study(file_name)
|
||||
else:
|
||||
file_name = self._study.filename + ".backup"
|
||||
shutil.copyfile(old, file_name)
|
||||
|
||||
self._study.filename = file_name
|
||||
|
||||
try:
|
||||
# sql_request_count = self._study.sql_save_request_count()
|
||||
# progress = QProgressDialog(
|
||||
# "Backup...", None,
|
||||
# 0, sql_request_count,
|
||||
# parent=self
|
||||
# )
|
||||
# progress.setWindowModality(Qt.WindowModal)
|
||||
# progress.setValue(0)
|
||||
|
||||
status = f"Backup ({file_name})..."
|
||||
logger.info(status)
|
||||
self.statusbar.showMessage(status, 3000)
|
||||
|
||||
self._study.save()
|
||||
self._study.save(
|
||||
# progress=lambda: progress.setValue(progress.value() + 1)
|
||||
)
|
||||
|
||||
status += " Done"
|
||||
logger.info(status)
|
||||
|
|
@ -855,32 +864,12 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
|||
if os.path.exists(backup):
|
||||
file_modified_date = time.ctime(os.path.getmtime(file))
|
||||
backup_modified_date = time.ctime(os.path.getmtime(backup))
|
||||
|
||||
if backup_modified_date > file_modified_date:
|
||||
yes = self.dialog_open_backup_study()
|
||||
|
||||
if yes:
|
||||
logger.info(f"Select backup ({backup})")
|
||||
file = backup
|
||||
logger.info(f"Select backup ({backup})")
|
||||
file = backup
|
||||
|
||||
return file
|
||||
|
||||
def dialog_open_backup_study(self):
|
||||
dlg = QMessageBox(self)
|
||||
|
||||
dlg.setWindowTitle(self._trad["mb_open_backup_title"])
|
||||
dlg.setText(self._trad["mb_open_backup_msg"])
|
||||
opt = QMessageBox.No | QMessageBox.Yes
|
||||
|
||||
dlg.setStandardButtons(opt)
|
||||
dlg.setIcon(QMessageBox.Question)
|
||||
dlg.button(QMessageBox.Yes).setText(self._trad["Yes"])
|
||||
dlg.button(QMessageBox.No).setText(self._trad["No"])
|
||||
|
||||
res = dlg.exec()
|
||||
|
||||
return res == QMessageBox.Yes
|
||||
|
||||
def dialog_close(self):
|
||||
dlg = QMessageBox(self)
|
||||
|
||||
|
|
|
|||
|
|
@ -200,15 +200,6 @@ class MainTranslate(UnitTranslate):
|
|||
"Do you want to open again the last open study?"
|
||||
)
|
||||
|
||||
self._dict["mb_open_backup_title"] = _translate(
|
||||
"MainWindow", "Open backup file"
|
||||
)
|
||||
self._dict["mb_open_backup_msg"] = _translate(
|
||||
"MainWindow",
|
||||
"A more recent backup file as found for this study, "
|
||||
+ "do you want to open the backup file?"
|
||||
)
|
||||
|
||||
self._dict["mb_close_title"] = _translate(
|
||||
"MainWindow", "Close without saving study"
|
||||
)
|
||||
|
|
@ -216,7 +207,6 @@ class MainTranslate(UnitTranslate):
|
|||
"MainWindow",
|
||||
"Do you want to save current study before closing it?"
|
||||
)
|
||||
|
||||
self._dict["x"] = _translate("MainWindow", "X (m)")
|
||||
self._dict["y"] = _translate("MainWindow", "Y (m)")
|
||||
self._dict["Yes"] = _translate("MainWindow", "Yes")
|
||||
|
|
|
|||
Loading…
Reference in New Issue