2 #include "ui_dialog_mcap.h"
5 #include <QDialogButtonBox>
7 #include <QElapsedTimer>
12 const std::unordered_map<int, mcap::SchemaPtr>& schemas,
13 std::optional<mcap::LoadParams> default_parameters,
15 : QDialog(parent), ui(new
Ui::dialog_mcap)
19 ui->tableWidget->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
20 ui->tableWidget->horizontalHeader()->setSectionResizeMode(
21 1, QHeaderView::ResizeToContents);
22 ui->tableWidget->horizontalHeader()->setSectionResizeMode(
23 2, QHeaderView::ResizeToContents);
25 ui->tableWidget->setRowCount(channels.size());
28 restoreGeometry(settings.value(
prefix +
"geometry").toByteArray());
31 if (!default_parameters)
40 params = *default_parameters;
45 ui->radioClamp->setChecked(
true);
49 ui->radioSkip->setChecked(
true);
55 for (
const auto& [
id, channel] : channels)
57 auto topic = QString::fromStdString(channel->topic);
58 auto const& schema = schemas.at(channel->schemaId);
60 ui->tableWidget->setItem(row, 0,
new QTableWidgetItem(
topic));
61 ui->tableWidget->setItem(row, 1,
62 new QTableWidgetItem(QString::fromStdString(schema->name)));
63 ui->tableWidget->setItem(
64 row, 2,
new QTableWidgetItem(QString::fromStdString(schema->encoding)));
68 ui->tableWidget->selectRow(row);
72 ui->tableWidget->sortByColumn(0, Qt::SortOrder::DescendingOrder);
87 QItemSelectionModel*
select =
ui->tableWidget->selectionModel();
88 QStringList selected_topics;
89 for (QModelIndex index :
select->selectedRows())
98 bool enabled = !
ui->tableWidget->selectionModel()->selectedRows().empty();
99 ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(enabled);
105 settings.setValue(
prefix +
"geometry", saveGeometry());
107 bool clamp_checked =
ui->radioClamp->isChecked();
108 int max_array =
ui->spinBox->value();
109 bool use_timestamp =
ui->checkBoxUseTimestamp->isChecked();
111 settings.setValue(
prefix +
"clamp", clamp_checked);
112 settings.setValue(
prefix +
"max_array", max_array);
113 settings.setValue(
prefix +
"use_timestamp", use_timestamp);
115 QItemSelectionModel*
select =
ui->tableWidget->selectionModel();
116 QStringList selected_topics;
117 for (QModelIndex index :
select->selectedRows())
119 selected_topics.push_back(
ui->tableWidget->item(index.row(), 0)->text());
121 settings.setValue(
prefix +
"selected", selected_topics);