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  QWidget *parent):
10  QDialog(parent),
11  ui(new Ui::ULogParametersDialog)
12 {
13  ui->setupUi(this);
14  QTableWidget* table_info = ui->tableWidgetInfo;
15  QTableWidget* table_params = ui->tableWidgetParams;
16  QTableWidget* table_logs = ui->tableWidgetLogs;
17 
18  table_info->setRowCount( parser.getInfo().size() );
19  int row = 0;
20  for(const auto& it: parser.getInfo() )
21  {
22  table_info->setItem( row, 0, new QTableWidgetItem( QString::fromStdString(it.first) ) );
23  table_info->setItem( row, 1, new QTableWidgetItem( QString::fromStdString(it.second) ) );
24  row++;
25  }
26  table_info->sortItems(0);
27 
28  table_params->setRowCount( parser.getParameters().size() );
29  row = 0;
30  for(const auto& param: parser.getParameters() )
31  {
32  table_params->setItem( row, 0, new QTableWidgetItem( QString::fromStdString(param.name) ) );
33  if( param.val_type == ULogParser::FLOAT)
34  {
35  table_params->setItem( row, 1, new QTableWidgetItem( QString::number( param.value.val_real ) ) );
36  }
37  else{
38  table_params->setItem( row, 1, new QTableWidgetItem( QString::number( param.value.val_int ) ) );
39  }
40  row++;
41  }
42  table_params->sortItems(0);
43 
44  table_logs->setRowCount( parser.getLogs().size() );
45  row = 0;
46  for(const auto& log_msg: parser.getLogs() )
47  {
48  QString time = QString::number( 0.001 * double(log_msg.timestamp /1000), 'f', 2);
49  table_logs->setItem( row, 0, new QTableWidgetItem(time) );
50 
51  switch(log_msg.level)
52  {
53  case '0': table_logs->setItem( row, 1, new QTableWidgetItem("EMERGENCY") ); break;
54  case '1': table_logs->setItem( row, 1, new QTableWidgetItem("ALERT") ); break;
55  case '2': table_logs->setItem( row, 1, new QTableWidgetItem("CRITICAL") ); break;
56  case '3': table_logs->setItem( row, 1, new QTableWidgetItem("ERROR") ); break;
57  case '4': table_logs->setItem( row, 1, new QTableWidgetItem("WARNING") ); break;
58  case '5': table_logs->setItem( row, 1, new QTableWidgetItem("NOTICE") ); break;
59  case '6': table_logs->setItem( row, 1, new QTableWidgetItem("INFO") ); break;
60  case '7': table_logs->setItem( row, 1, new QTableWidgetItem("DEBUG") ); break;
61  default:
62  table_logs->setItem( row, 1, new QTableWidgetItem( QString::number( log_msg.level )) );
63  }
64  table_logs->setItem( row, 2, new QTableWidgetItem( QString::fromStdString( log_msg.msg ) ) );
65  row++;
66  }
67 }
68 
70 {
71  QTableWidget* table_info = ui->tableWidgetInfo;
72  QTableWidget* table_params = ui->tableWidgetParams;
73 
74  QSettings settings;
75  restoreGeometry(settings.value("ULogParametersDialog/geometry").toByteArray());
76  table_info->horizontalHeader()->restoreState(settings.value("ULogParametersDialog/info/state").toByteArray());
77  table_params->horizontalHeader()->restoreState(settings.value("ULogParametersDialog/params/state").toByteArray());
78 
79  table_info->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Interactive);
80  table_info->horizontalHeader()->setSectionResizeMode(1, QHeaderView::Interactive);
81 
82  table_params->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Interactive);
83  table_params->horizontalHeader()->setSectionResizeMode(1, QHeaderView::Interactive);
84 }
85 
87 {
88  QTableWidget* table_info = ui->tableWidgetInfo;
89  QTableWidget* table_params = ui->tableWidgetParams;
90 
91  QSettings settings;
92  settings.setValue("ULogParametersDialog/geometry", this->saveGeometry() );
93  settings.setValue("ULogParametersDialog/info/state",
94  table_info->horizontalHeader()->saveState() );
95  settings.setValue("ULogParametersDialog/params/state",
96  table_params->horizontalHeader()->saveState() );
97 
98  delete ui;
99 }
const std::vector< MessageLog > & getLogs() const
bool param(const std::string &param_name, T &param_val, const T &default_val)
ULogParametersDialog(const ULogParser &parser, QWidget *parent=nullptr)
const std::vector< Parameter > & getParameters() const
Ui::ULogParametersDialog * ui
const std::map< std::string, std::string > & getInfo() const


plotjuggler
Author(s): Davide Faconti
autogenerated on Sat Jul 6 2019 03:44:18