logwidget.cpp
Go to the documentation of this file.
1 
8 /*****************************************************************************
9 ** Includes
10 *****************************************************************************/
11 
12 #include <QDebug>
13 #include <QMessageBox>
14 #include <QSettings>
15 #include <QFileDialog>
16 #include <QStringList>
17 #include <QHeaderView>
18 #include <iostream>
19 #include "logwidget.hpp"
20 
22 {
23 using namespace Qt;
24 
25 LogWidget::LogWidget(LogsTableModel& tablemodel, QWidget* parent)
26  : QWidget(parent), model(tablemodel), proxy_model(this)
27 {
28  ui.setupUi(this); // Calling this incidentally connects all ui's triggers to on_...() callbacks in this class.
29 
30  proxy_model.setSourceModel(&model);
31  ui.tableView->setModel(&proxy_model);
32  // ui.tableView->setModel( &model );
33 
34  ui.tableView->horizontalHeader()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
35  ui.tableView->horizontalHeader()->setSectionResizeMode(1, QHeaderView::ResizeToContents);
36  ui.tableView->horizontalHeader()->setSectionResizeMode(2, QHeaderView::ResizeToContents);
37  ui.tableView->horizontalHeader()->setSectionResizeMode(3, QHeaderView::Interactive);
38  ui.tableView->horizontalHeader()->setSectionResizeMode(4, QHeaderView::Stretch);
39  // ui.tableView->horizontalHeader()->setSectionResizeMode(5, QHeaderView::Stretch);
40 
41  ui.tableView->verticalHeader()->setVisible(false);
42 
43  connect(&model, &LogsTableModel::rowsInserted, this, &LogWidget::on_rowsInserted);
44 
45  proxy_model.setSeverityDebugEnabled(ui.buttonEnableDebug->isChecked());
46  proxy_model.setSeverityWarningsEnabled(ui.buttonEnableWarnings->isChecked());
47  proxy_model.setSeverityErrorEnabled(ui.buttonEnableError->isChecked());
48  proxy_model.setSeverityInfoEnabled(ui.buttonEnableInfo->isChecked());
49 
50  proxy_model.setMessageFilterEnabled(ui.checkBoxMessageFilter->isChecked());
51  proxy_model.setNodeFilterEnabled(ui.checkBoxLoggerFilter->isChecked());
52  proxy_model.setTimeFilterEnabled(true);
53 }
54 
56 {
57 }
58 
59 void LogWidget::on_lineEditMessageFilter_textEdited(const QString& filter)
60 {
61  proxy_model.messageFilterUpdated(static_cast<ModelFilter::FilterMode>(ui.comboBoxMessageFilter->currentIndex()),
62  filter);
63  ui.tableView->resizeColumnToContents(3);
64 }
65 
67 {
68  proxy_model.messageFilterUpdated(static_cast<ModelFilter::FilterMode>(mode), ui.lineEditMessageFilter->text());
69  ui.tableView->resizeColumnToContents(4);
70 }
71 
73 {
74  ui.labelMessageFilter->setEnabled(checked);
75  ui.comboBoxMessageFilter->setEnabled(checked);
76  ui.lineEditMessageFilter->setEnabled(checked);
77 
78  proxy_model.setMessageFilterEnabled(checked);
79  ui.tableView->resizeColumnToContents(4);
80 }
81 
82 void LogWidget::on_lineEditLoggerFilter_textEdited(const QString& filter)
83 {
84  proxy_model.nodeFilterUpdated(static_cast<ModelFilter::FilterMode>(ui.comboBoxLoggerFilter->currentIndex()), filter);
85  ui.tableView->resizeColumnToContents(3);
86 }
87 
89 {
90  proxy_model.nodeFilterUpdated(static_cast<ModelFilter::FilterMode>(mode), ui.lineEditLoggerFilter->text());
91  ui.tableView->resizeColumnToContents(3);
92 }
94 
95 {
96  ui.labelLoggerFilter->setEnabled(checked);
97  ui.comboBoxLoggerFilter->setEnabled(checked);
98  ui.lineEditLoggerFilter->setEnabled(checked);
99 
100  proxy_model.setNodeFilterEnabled(checked);
101  ui.tableView->resizeColumnToContents(3);
102 }
103 
104 void LogWidget::on_rowsInserted(const QModelIndex&, int first_row, int last_row)
105 {
106  ui.tableView->scrollToBottom();
107 }
108 
110 {
111  proxy_model.setSeverityDebugEnabled(checked);
112  ui.tableView->resizeColumnToContents(2);
113 }
114 
116 {
117  proxy_model.setSeverityInfoEnabled(checked);
118  ui.tableView->resizeColumnToContents(2);
119 }
120 
122 {
123  proxy_model.setSeverityWarningsEnabled(checked);
124  ui.tableView->resizeColumnToContents(2);
125 }
126 
128 {
129  proxy_model.setSeverityErrorEnabled(checked);
130  ui.tableView->resizeColumnToContents(2);
131 }
132 
133 void LogWidget::on_timeRangeChanged(TimePoint time_min, TimePoint time_max)
134 {
135  using namespace std::chrono;
136  {
137  auto msec_since_epoch_A = duration_cast<milliseconds>(time_min.time_since_epoch());
138  auto datetimeA = QDateTime::fromMSecsSinceEpoch(msec_since_epoch_A.count());
139  ui.timeRangeMin->setDateTime(datetimeA);
140  }
141 
142  {
143  auto msec_since_epoch_B = duration_cast<milliseconds>(time_max.time_since_epoch());
144  auto datetimeB = QDateTime::fromMSecsSinceEpoch(msec_since_epoch_B.count());
145  ui.timeRangeMax->setDateTime(datetimeB);
146  }
147 
148  // qDebug() << msec_since_epoch_A.count() << " " << msec_since_epoch_B.count();
149  // qDebug() << datetimeA << " " << datetimeB;
150 
151  proxy_model.timeMinMaxUpdated(time_min, time_max);
152  ui.tableView->scrollToBottom();
153  ui.tableView->resizeColumnToContents(0);
154  ui.tableView->resizeColumnToContents(1);
155 }
156 
157 } // namespace rqt_console_plus
rqt_console_plus::LogWidget::on_lineEditLoggerFilter_textEdited
void on_lineEditLoggerFilter_textEdited(const QString &arg1)
Definition: logwidget.cpp:84
TimePoint
std::chrono::high_resolution_clock::time_point TimePoint
Definition: logs_table_model.hpp:17
rqt_console_plus::LogWidget::on_timeRangeChanged
void on_timeRangeChanged(TimePoint time_min, TimePoint time_max)
Definition: logwidget.cpp:135
rqt_console_plus::LogWidget::on_checkBoxMessageFilter_toggled
void on_checkBoxMessageFilter_toggled(bool checked)
Definition: logwidget.cpp:74
rqt_console_plus::LogWidget::on_checkBoxLoggerFilter_toggled
void on_checkBoxLoggerFilter_toggled(bool checked)
Definition: logwidget.cpp:95
rqt_console_plus::LogWidget::on_comboBoxMessageFilter_currentIndexChanged
void on_comboBoxMessageFilter_currentIndexChanged(int index)
Definition: logwidget.cpp:68
ModelFilter::FilterMode
FilterMode
Definition: modelfilter.hpp:18
rqt_console_plus
Definition: logwidget.cpp:21
rqt_console_plus::LogWidget::on_buttonEnableWarnings_toggled
void on_buttonEnableWarnings_toggled(bool checked)
Definition: logwidget.cpp:123
rqt_console_plus::LogWidget::on_buttonEnableInfo_toggled
void on_buttonEnableInfo_toggled(bool checked)
Definition: logwidget.cpp:117
rqt_console_plus::LogWidget::on_comboBoxLoggerFilter_currentIndexChanged
void on_comboBoxLoggerFilter_currentIndexChanged(int index)
Definition: logwidget.cpp:90
rqt_console_plus::LogWidget::on_buttonEnableDebug_toggled
void on_buttonEnableDebug_toggled(bool checked)
Definition: logwidget.cpp:111
LogsTableModel
Definition: logs_table_model.hpp:20
rqt_console_plus::LogWidget::on_lineEditMessageFilter_textEdited
void on_lineEditMessageFilter_textEdited(const QString &filter)
Definition: logwidget.cpp:61
logwidget.hpp
rqt_console_plus::LogWidget::~LogWidget
~LogWidget()
Definition: logwidget.cpp:57
rqt_console_plus::LogWidget::on_buttonEnableError_toggled
void on_buttonEnableError_toggled(bool checked)
Definition: logwidget.cpp:129
rqt_console_plus::LogWidget::on_rowsInserted
void on_rowsInserted(const QModelIndex &parent, int first_row, int last_row)
Definition: logwidget.cpp:106
rqt_console_plus::LogWidget::LogWidget
LogWidget(LogsTableModel &tablemodel, QWidget *parent=0)
Definition: logwidget.cpp:27


plotjuggler_ros
Author(s): Davide Faconti
autogenerated on Wed Feb 21 2024 03:22:55