| 212 | } |
| 213 | |
| 214 | QString AeqSelector::selection(DataFormat format, bool silent) |
| 215 | { |
| 216 | if (ui->list->selectionModel()->selectedRows().isEmpty()) |
| 217 | { |
| 218 | return QString(); |
| 219 | } |
| 220 | |
| 221 | auto item = proxyModel->data(ui->list->selectionModel()->selectedRows().first(), Qt::UserRole).value<AeqMeasurement>(); |
| 222 | |
| 223 | QString name; |
| 224 | switch(format) |
| 225 | { |
| 226 | case AeqSelector::dGraphicEq: |
| 227 | name = "graphic.txt"; |
| 228 | break; |
| 229 | case AeqSelector::dCsv: |
| 230 | name = "raw.csv"; |
| 231 | break; |
| 232 | } |
| 233 | |
| 234 | QFile file(item.path(pkgManager->databaseDirectory(), name)); |
| 235 | if(!file.exists()) |
| 236 | { |
| 237 | if(!silent) |
| 238 | { |
| 239 | QMessageBox::critical(this, tr("Error"), tr("Unable to retrieve corresponding file from database. Please update the local database as it appears to be incomplete.")); |
| 240 | } |
| 241 | return QString(); |
| 242 | } |
| 243 | |
| 244 | auto guard = qScopeGuard([&]{ file.close(); }); |
| 245 | file.open(QFile::ReadOnly); |
| 246 | return file.readAll(); |
| 247 | } |
no test coverage detected