DataFileExporter::ReturnCode DataFileExporter::
exportData(const WriteList& list, const QString& path, const std::string& formatTag)
{
- QDir dir(path);
- QFile file(path);
- QString plainName = file.fileName();
OutputFormats format;
DataFileExporter::ReturnCode ret;
DataWriterBackend* backend;
+ QDir dir(path);
+ QFile file(path);
+ QString plainName = file.fileName();
if (path.compare("") == 0) {
return ReturnCode::E_NO_OUTPUT;
}
if (dir.exists()) {
return ReturnCode::E_IS_DIRECTORY;
- }
-
- if (file.exists()) {
- int ret = QMessageBox::question(nullptr, "Data export", "The selected file already exists. Do you wish to overwrite it?");
- if (ret == QMessageBox::No)
- return ReturnCode::E_WOULD_OVERWRITE;
- else
- file.remove();
- }
+ }
format = formatTagToFormat(formatTag);
switch (format) {
else
file.setFileName(backend->filename(plainName));
+ if (file.exists()) {
+ int ret = QMessageBox::question(nullptr, "Data export", QString("The selected file \"%1\" already exists. Do you wish to overwrite it?").arg(file.fileName()));
+ if (ret == QMessageBox::No) {
+ file.close();
+ continue;
+ } else
+ file.remove();
+ }
+
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
QMessageBox::critical(nullptr, "Data export error", "Cannot open output file '" + file.fileName() + "' for writing.");
ret = ReturnCode::E_FAILED;