No overwrite confirm for saving fit parameter needed
This commit is contained in:
parent
89a3313e74
commit
34ebaf34bd
@ -50,12 +50,12 @@ class FileDialog(QtWidgets.QFileDialog):
|
|||||||
def is_valid(filename: str):
|
def is_valid(filename: str):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
bad_character = r'/*<>\|:"'
|
# bad_character = r'/*<>\|:"'
|
||||||
for c in bad_character:
|
# for c in bad_character:
|
||||||
if c in filename:
|
# if c in filename:
|
||||||
return False
|
# return False
|
||||||
|
#
|
||||||
return True
|
# return True
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
FileDialog.last_path = self.directory()
|
FileDialog.last_path = self.directory()
|
||||||
|
@ -18,7 +18,7 @@ from ..fit.result import QFitResult
|
|||||||
from ..graphs.graphwindow import QGraphWindow
|
from ..graphs.graphwindow import QGraphWindow
|
||||||
from ..graphs.movedialog import QMover
|
from ..graphs.movedialog import QMover
|
||||||
from ..io.fcbatchreader import QFCReader
|
from ..io.fcbatchreader import QFCReader
|
||||||
from ..io.filedialog import OpenFileDialog, SaveDirectoryDialog
|
from ..io.filedialog import *
|
||||||
from ..lib import get_icon, make_action_icons
|
from ..lib import get_icon, make_action_icons
|
||||||
from ..lib.pg_objects import RegionItem
|
from ..lib.pg_objects import RegionItem
|
||||||
from ..math.evaluation import QEvalDialog
|
from ..math.evaluation import QEvalDialog
|
||||||
@ -277,8 +277,10 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow):
|
|||||||
@QtCore.pyqtSlot()
|
@QtCore.pyqtSlot()
|
||||||
@QtCore.pyqtSlot(list)
|
@QtCore.pyqtSlot(list)
|
||||||
def save_fit_parameter(self, fit_sets: list[str] = None):
|
def save_fit_parameter(self, fit_sets: list[str] = None):
|
||||||
save_dialog = SaveDirectoryDialog(parent=self, caption='Save fit parameter', directory=str(self.path),
|
save_dialog = FileDialog(parent=self, caption='Save fit parameter', directory=str(self.path),
|
||||||
filter='All files(*, *);;Text files(*.dat *.txt)')
|
filter='All files(*, *);;Text files(*.dat *.txt)')
|
||||||
|
save_dialog.setAcceptMode(FileDialog.AcceptSave)
|
||||||
|
save_dialog.setOption(QtWidgets.QFileDialog.DontConfirmOverwrite, True)
|
||||||
|
|
||||||
mode = save_dialog.exec()
|
mode = save_dialog.exec()
|
||||||
if mode == QtWidgets.QDialog.Accepted:
|
if mode == QtWidgets.QDialog.Accepted:
|
||||||
|
@ -3,7 +3,6 @@ from __future__ import annotations
|
|||||||
import pathlib
|
import pathlib
|
||||||
import re
|
import re
|
||||||
import uuid
|
import uuid
|
||||||
from typing import List
|
|
||||||
|
|
||||||
from nmreval.fit import data as fit_d
|
from nmreval.fit import data as fit_d
|
||||||
from nmreval.fit.model import Model
|
from nmreval.fit.model import Model
|
||||||
@ -154,7 +153,7 @@ class UpperManagement(QtCore.QObject):
|
|||||||
|
|
||||||
return _id
|
return _id
|
||||||
|
|
||||||
def load_files(self, fname: List[str], new_plot: str = None):
|
def load_files(self, fname: list[str], new_plot: str = None):
|
||||||
if self._filereader is None:
|
if self._filereader is None:
|
||||||
self._filereader = QFileReader(manager=self)
|
self._filereader = QFileReader(manager=self)
|
||||||
ret_dic = self._filereader.readfiles(fname)
|
ret_dic = self._filereader.readfiles(fname)
|
||||||
@ -546,7 +545,7 @@ class UpperManagement(QtCore.QObject):
|
|||||||
|
|
||||||
self.newData.emit(f_id_list, gid)
|
self.newData.emit(f_id_list, gid)
|
||||||
|
|
||||||
def make_fit_parameter(self, fit_sets: List[str | FitResult], graph_id: str = None):
|
def make_fit_parameter(self, fit_sets: list[str | FitResult], graph_id: str = None):
|
||||||
fit_dict = self._collect_fit_parameter(fit_sets)
|
fit_dict = self._collect_fit_parameter(fit_sets)
|
||||||
|
|
||||||
if fit_dict:
|
if fit_dict:
|
||||||
@ -560,7 +559,7 @@ class UpperManagement(QtCore.QObject):
|
|||||||
|
|
||||||
self.newData.emit(p_id_list, graph_id)
|
self.newData.emit(p_id_list, graph_id)
|
||||||
|
|
||||||
def save_fit_parameter(self, fname: str | pathlib.Path, fit_sets: List[str] = None):
|
def save_fit_parameter(self, fname: str | pathlib.Path, fit_sets: list[str] = None):
|
||||||
if fit_sets is None:
|
if fit_sets is None:
|
||||||
fit_sets = [s for (s, _) in self.active_sets]
|
fit_sets = [s for (s, _) in self.active_sets]
|
||||||
|
|
||||||
@ -571,7 +570,7 @@ class UpperManagement(QtCore.QObject):
|
|||||||
|
|
||||||
data.data.save_parameter(fname)
|
data.data.save_parameter(fname)
|
||||||
|
|
||||||
def _collect_fit_parameter(self, fit_sets: List[str | FitResult]) -> dict:
|
def _collect_fit_parameter(self, fit_sets: list[str | FitResult]) -> dict:
|
||||||
fit_dict = {}
|
fit_dict = {}
|
||||||
|
|
||||||
for set_id in fit_sets:
|
for set_id in fit_sets:
|
||||||
|
Loading…
Reference in New Issue
Block a user