| 106 | } |
| 107 | |
| 108 | void |
| 109 | SigDiggerHelpers::openSaveSamplesDialog( |
| 110 | QWidget *root, |
| 111 | const SUCOMPLEX *data, |
| 112 | size_t length, |
| 113 | qreal fs, |
| 114 | int start, |
| 115 | int end, |
| 116 | Suscan::MultitaskController *mt) |
| 117 | { |
| 118 | bool done = false; |
| 119 | |
| 120 | do { |
| 121 | QFileDialog dialog(root); |
| 122 | QStringList filters; |
| 123 | QString format; |
| 124 | |
| 125 | dialog.setFileMode(QFileDialog::FileMode::AnyFile); |
| 126 | dialog.setAcceptMode(QFileDialog::AcceptSave); |
| 127 | dialog.setWindowTitle(QString("Save capture")); |
| 128 | |
| 129 | filters << "Audio file (*.wav)" |
| 130 | << "Raw I/Q data (*.raw)" |
| 131 | << "MATLAB/Octave script (*.m)" |
| 132 | << "MATLAB 5.0 MAT-file (*.mat)"; |
| 133 | |
| 134 | dialog.setNameFilters(filters); |
| 135 | |
| 136 | if (dialog.exec()) { |
| 137 | QString path = dialog.selectedFiles().first(); |
| 138 | QString filter = dialog.selectedNameFilter(); |
| 139 | ExportSamplesTask *task; |
| 140 | |
| 141 | if (strstr(filter.toStdString().c_str(), ".mat") != nullptr) |
| 142 | format = "mat"; |
| 143 | else if (strstr(filter.toStdString().c_str(), ".m") != nullptr) |
| 144 | format = "m"; |
| 145 | else if (strstr(filter.toStdString().c_str(), ".raw") != nullptr) |
| 146 | format = "raw"; |
| 147 | else |
| 148 | format = "wav"; |
| 149 | |
| 150 | path = SuWidgetsHelpers::ensureExtension(path, format); |
| 151 | |
| 152 | task = new ExportSamplesTask(path, format, data, length, fs, start, end); |
| 153 | |
| 154 | if (!task->attemptOpen()) { |
| 155 | QMessageBox::critical( |
| 156 | root, |
| 157 | task->getLastError(), |
| 158 | "Save samples to file"); |
| 159 | delete task; |
| 160 | } else { |
| 161 | QFileInfo info(path); |
| 162 | |
| 163 | // TODO: Decide whether to send to multitask controller or to |
| 164 | // run in the current thread according to data size. |
| 165 |
nothing calls this directly
no test coverage detected