ulog_parameters_dialog.cpp
Go to the documentation of this file.
2 #include "ui_ulog_parameters_dialog.h"
3 
4 #include <QTableWidget>
5 #include <QSettings>
6 #include <QHeaderView>
7 
9  : QDialog(parent), ui(new Ui::ULogParametersDialog)
10 {
11  ui->setupUi(this);
12  QTableWidget* table_info = ui->tableWidgetInfo;
13  QTableWidget* table_params = ui->tableWidgetParams;
14  QTableWidget* table_logs = ui->tableWidgetLogs;
15 
16  table_info->setRowCount(parser.getInfo().size());
17  int row = 0;
18  for (const auto& it : parser.getInfo())
19  {
20  table_info->setItem(row, 0, new QTableWidgetItem(QString::fromStdString(it.first)));
21  table_info->setItem(row, 1, new QTableWidgetItem(QString::fromStdString(it.second)));
22  row++;
23  }
24  table_info->sortItems(0);
25 
26  table_params->setRowCount(parser.getParameters().size());
27  row = 0;
28  for (const auto& param : parser.getParameters())
29  {
30  table_params->setItem(row, 0,
31  new QTableWidgetItem(QString::fromStdString(param.name)));
32  QString value_str = (param.val_type == ULogParser::FLOAT) ?
33  QString::number(param.value.val_real) :
34  QString::number(param.value.val_int);
35  table_params->setItem(row, 1, new QTableWidgetItem(value_str));
36  row++;
37  }
38  table_params->sortItems(0);
39 
40  table_logs->setRowCount(parser.getLogs().size());
41  row = 0;
42  for (const auto& log_msg : parser.getLogs())
43  {
44  QString time = QString::number(0.001 * double(log_msg.timestamp / 1000), 'f', 2);
45  table_logs->setItem(row, 0, new QTableWidgetItem(time));
46 
47  switch (log_msg.level)
48  {
49  case '0':
50  table_logs->setItem(row, 1, new QTableWidgetItem("EMERGENCY"));
51  break;
52  case '1':
53  table_logs->setItem(row, 1, new QTableWidgetItem("ALERT"));
54  break;
55  case '2':
56  table_logs->setItem(row, 1, new QTableWidgetItem("CRITICAL"));
57  break;
58  case '3':
59  table_logs->setItem(row, 1, new QTableWidgetItem("ERROR"));
60  break;
61  case '4':
62  table_logs->setItem(row, 1, new QTableWidgetItem("WARNING"));
63  break;
64  case '5':
65  table_logs->setItem(row, 1, new QTableWidgetItem("NOTICE"));
66  break;
67  case '6':
68  table_logs->setItem(row, 1, new QTableWidgetItem("INFO"));
69  break;
70  case '7':
71  table_logs->setItem(row, 1, new QTableWidgetItem("DEBUG"));
72  break;
73  default:
74  table_logs->setItem(row, 1, new QTableWidgetItem(QString::number(log_msg.level)));
75  }
76  table_logs->setItem(row, 2,
77  new QTableWidgetItem(QString::fromStdString(log_msg.msg)));
78  row++;
79  }
80 }
81 
83 {
84  QTableWidget* table_info = ui->tableWidgetInfo;
85  QTableWidget* table_params = ui->tableWidgetParams;
86 
87  QSettings settings;
88  restoreGeometry(settings.value("ULogParametersDialog/geometry").toByteArray());
89  table_info->horizontalHeader()->restoreState(
90  settings.value("ULogParametersDialog/info/state").toByteArray());
91  table_params->horizontalHeader()->restoreState(
92  settings.value("ULogParametersDialog/params/state").toByteArray());
93 
94  table_info->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Interactive);
95  table_info->horizontalHeader()->setSectionResizeMode(1, QHeaderView::Interactive);
96 
97  table_params->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Interactive);
98  table_params->horizontalHeader()->setSectionResizeMode(1, QHeaderView::Interactive);
99 }
100 
102 {
103  QTableWidget* table_info = ui->tableWidgetInfo;
104  QTableWidget* table_params = ui->tableWidgetParams;
105 
106  QSettings settings;
107  settings.setValue("ULogParametersDialog/geometry", this->saveGeometry());
108  settings.setValue("ULogParametersDialog/info/state",
109  table_info->horizontalHeader()->saveState());
110  settings.setValue("ULogParametersDialog/params/state",
111  table_params->horizontalHeader()->saveState());
112 
113  delete ui;
114 }
ULogParametersDialog::ui
Ui::ULogParametersDialog * ui
Definition: ulog_parameters_dialog.h:24
ULogParser
Definition: ulog_parser.h:14
ULogParametersDialog::~ULogParametersDialog
~ULogParametersDialog()
Definition: ulog_parameters_dialog.cpp:101
ULogParametersDialog::restoreSettings
void restoreSettings()
Definition: ulog_parameters_dialog.cpp:82
Ui
Definition: cheatsheet_dialog.h:6
ULogParametersDialog
Definition: ulog_parameters_dialog.h:12
mqtt_test.time
float time
Definition: mqtt_test.py:17
ulog_parameters_dialog.h
udp_client.parser
parser
Definition: udp_client.py:9
param
T param(const std::string &param_name, const T &default_val)
ULogParser::FLOAT
@ FLOAT
Definition: ulog_parser.h:49
ULogParametersDialog::ULogParametersDialog
ULogParametersDialog(const ULogParser &parser, QWidget *parent=nullptr)
Definition: ulog_parameters_dialog.cpp:8


plotjuggler
Author(s): Davide Faconti
autogenerated on Mon Nov 11 2024 03:23:48