| 326 | } |
| 327 | |
| 328 | QString MainWindow::getSaveFileName(QWidget* parent,const QString& caption,const QString& dir,const QString& filter,const QString& suffix) |
| 329 | { |
| 330 | QFileDialog dialog(parent,caption,dir,filter); |
| 331 | dialog.setDefaultSuffix(suffix); |
| 332 | dialog.setOption(QFileDialog::DontConfirmOverwrite,true); |
| 333 | dialog.setAcceptMode(QFileDialog::AcceptSave); |
| 334 | while (dialog.exec() == QDialog::Accepted) { |
| 335 | const auto& selected=dialog.selectedFiles(); |
| 336 | QString fileName=selected.first(); |
| 337 | QFileInfo info(fileName); |
| 338 | if(!info.exists()) |
| 339 | return fileName; |
| 340 | |
| 341 | auto result=QMessageBox::warning(parent,caption, |
| 342 | tr("A file named \"%1\" already exists. Do you want to replace it?").arg(info.fileName()), |
| 343 | QMessageBox::Yes|QMessageBox::No|QMessageBox::Cancel,QMessageBox::No); |
| 344 | if(result==QMessageBox::Cancel) break; |
| 345 | if(result==QMessageBox::Yes) return fileName; |
| 346 | } |
| 347 | return QString(); |
| 348 | } |
| 349 | |
| 350 | void MainWindow::exportFile(const QString& type) |
| 351 | { |
nothing calls this directly
no outgoing calls
no test coverage detected