| 5389 | } |
| 5390 | |
| 5391 | void EventBrowser::on_exportActions_clicked() |
| 5392 | { |
| 5393 | QString filename = |
| 5394 | RDDialog::getSaveFileName(this, tr("Save Event List"), QString(), tr("Text files (*.txt)")); |
| 5395 | |
| 5396 | if(!filename.isEmpty()) |
| 5397 | { |
| 5398 | ANALYTIC_SET(Export.EventBrowser, true); |
| 5399 | |
| 5400 | QDir dirinfo = QFileInfo(filename).dir(); |
| 5401 | if(dirinfo.exists()) |
| 5402 | { |
| 5403 | QFile f(filename); |
| 5404 | if(f.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text)) |
| 5405 | { |
| 5406 | QTextStream stream(&f); |
| 5407 | |
| 5408 | stream << tr("%1 - Frame #%2\n\n") |
| 5409 | .arg(m_Ctx.GetCaptureFilename()) |
| 5410 | .arg(m_Ctx.FrameInfo().frameNumber); |
| 5411 | |
| 5412 | int maxNameLength = 0; |
| 5413 | |
| 5414 | QModelIndex root = ui->events->model()->index(0, COL_NAME); |
| 5415 | |
| 5416 | // skip child 0, which is the Capture Start entry that we don't want to include |
| 5417 | for(int i = 1, rowCount = ui->events->model()->rowCount(root); i < rowCount; i++) |
| 5418 | GetMaxNameLength(maxNameLength, 0, false, ui->events->model()->index(i, COL_NAME, root)); |
| 5419 | |
| 5420 | QString line = QFormatStr(" EID | %1 | Action #").arg(lit("Event"), -maxNameLength); |
| 5421 | |
| 5422 | if(m_Model->HasTimes()) |
| 5423 | { |
| 5424 | line += QFormatStr(" | %1 (%2)").arg(tr("Duration")).arg(ToQStr(m_TimeUnit)); |
| 5425 | } |
| 5426 | |
| 5427 | stream << line << "\n"; |
| 5428 | |
| 5429 | line = QFormatStr("--------%1-----------").arg(QString(), maxNameLength, QLatin1Char('-')); |
| 5430 | |
| 5431 | if(m_Model->HasTimes()) |
| 5432 | { |
| 5433 | int maxDurationLength = 0; |
| 5434 | maxDurationLength = qMax(maxDurationLength, Formatter::Format(1.0).length()); |
| 5435 | maxDurationLength = qMax(maxDurationLength, Formatter::Format(1.2345e-200).length()); |
| 5436 | maxDurationLength = |
| 5437 | qMax(maxDurationLength, Formatter::Format(123456.7890123456789).length()); |
| 5438 | line += QString(3 + maxDurationLength, QLatin1Char('-')); // 3 extra for " | " |
| 5439 | } |
| 5440 | |
| 5441 | stream << line << "\n"; |
| 5442 | |
| 5443 | for(int i = 1, rowCount = ui->events->model()->rowCount(root); i < rowCount; i++) |
| 5444 | ExportAction(stream, maxNameLength, 0, false, |
| 5445 | ui->events->model()->index(i, COL_NAME, root)); |
| 5446 | } |
| 5447 | else |
| 5448 | { |
nothing calls this directly
no test coverage detected