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)
38 settings.value(
prefix +
"use_mcap_log_time",
false).toBool();
42 params = *default_parameters;
47 ui->radioClamp->setChecked(
true);
51 ui->radioSkip->setChecked(
true);
57 ui->radioLogTime->setChecked(
true);
61 ui->radioPubTime->setChecked(
true);
65 for (
const auto& [
id, channel] : channels)
67 auto topic = QString::fromStdString(channel->topic);
68 auto const& schema = schemas.at(channel->schemaId);
70 ui->tableWidget->setItem(row, 0,
new QTableWidgetItem(
topic));
71 ui->tableWidget->setItem(row, 1,
72 new QTableWidgetItem(QString::fromStdString(schema->name)));
73 ui->tableWidget->setItem(
74 row, 2,
new QTableWidgetItem(QString::fromStdString(schema->encoding)));
78 ui->tableWidget->selectRow(row);
82 ui->tableWidget->sortByColumn(0, Qt::SortOrder::DescendingOrder);
98 QItemSelectionModel*
select =
ui->tableWidget->selectionModel();
99 QStringList selected_topics;
100 for (QModelIndex index :
select->selectedRows())
109 bool enabled = !
ui->tableWidget->selectionModel()->selectedRows().empty();
110 ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(enabled);
116 settings.setValue(
prefix +
"geometry", saveGeometry());
118 bool clamp_checked =
ui->radioClamp->isChecked();
119 int max_array =
ui->spinBox->value();
120 bool use_timestamp =
ui->checkBoxUseTimestamp->isChecked();
121 bool use_mcap_log_time =
ui->radioLogTime->isChecked();
123 settings.setValue(
prefix +
"clamp", clamp_checked);
124 settings.setValue(
prefix +
"max_array", max_array);
125 settings.setValue(
prefix +
"use_timestamp", use_timestamp);
126 settings.setValue(
prefix +
"use_mcap_log_time", use_mcap_log_time);
128 QItemSelectionModel*
select =
ui->tableWidget->selectionModel();
129 QStringList selected_topics;
130 for (QModelIndex index :
select->selectedRows())
132 selected_topics.push_back(
ui->tableWidget->item(index.row(), 0)->text());
134 settings.setValue(
prefix +
"selected", selected_topics);