No overwrite confirm for saving fit parameter needed

This commit is contained in:
Dominik Demuth 2023-01-12 20:11:20 +01:00
parent 89a3313e74
commit 34ebaf34bd
3 changed files with 15 additions and 14 deletions

View File

@ -50,12 +50,12 @@ class FileDialog(QtWidgets.QFileDialog):
def is_valid(filename: str):
return True
bad_character = r'/*<>\|:"'
for c in bad_character:
if c in filename:
return False
return True
# bad_character = r'/*<>\|:"'
# for c in bad_character:
# if c in filename:
# return False
#
# return True
def close(self):
FileDialog.last_path = self.directory()

View File

@ -18,7 +18,7 @@ from ..fit.result import QFitResult
from ..graphs.graphwindow import QGraphWindow
from ..graphs.movedialog import QMover
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.pg_objects import RegionItem
from ..math.evaluation import QEvalDialog
@ -277,8 +277,10 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow):
@QtCore.pyqtSlot()
@QtCore.pyqtSlot(list)
def save_fit_parameter(self, fit_sets: list[str] = None):
save_dialog = SaveDirectoryDialog(parent=self, caption='Save fit parameter', directory=str(self.path),
filter='All files(*, *);;Text files(*.dat *.txt)')
save_dialog = FileDialog(parent=self, caption='Save fit parameter', directory=str(self.path),
filter='All files(*, *);;Text files(*.dat *.txt)')
save_dialog.setAcceptMode(FileDialog.AcceptSave)
save_dialog.setOption(QtWidgets.QFileDialog.DontConfirmOverwrite, True)
mode = save_dialog.exec()
if mode == QtWidgets.QDialog.Accepted:

View File

@ -3,7 +3,6 @@ from __future__ import annotations
import pathlib
import re
import uuid
from typing import List
from nmreval.fit import data as fit_d
from nmreval.fit.model import Model
@ -154,7 +153,7 @@ class UpperManagement(QtCore.QObject):
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:
self._filereader = QFileReader(manager=self)
ret_dic = self._filereader.readfiles(fname)
@ -546,7 +545,7 @@ class UpperManagement(QtCore.QObject):
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)
if fit_dict:
@ -560,7 +559,7 @@ class UpperManagement(QtCore.QObject):
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:
fit_sets = [s for (s, _) in self.active_sets]
@ -571,7 +570,7 @@ class UpperManagement(QtCore.QObject):
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 = {}
for set_id in fit_sets: