MCPcopy Create free account
hub / github.com/BatchDrake/SigDigger / openSaveSamplesDialog

Method openSaveSamplesDialog

Misc/SigDiggerHelpers.cpp:108–173  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

106}
107
108void
109SigDiggerHelpers::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

Callers

nothing calls this directly

Calls 3

attemptOpenMethod · 0.80
pushTaskMethod · 0.80
getLastErrorMethod · 0.45

Tested by

no test coverage detected