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 
21 namespace rqt_console_plus {
22 
23 using namespace Qt;
24 
25 
26 LogWidget::LogWidget(LogsTableModel& tablemodel, QWidget *parent)
27  : QWidget(parent),
28  model(tablemodel),
29  proxy_model(this)
30 {
31  ui.setupUi(this); // Calling this incidentally connects all ui's triggers to on_...() callbacks in this class.
32 
33  proxy_model.setSourceModel(&model);
34  ui.tableView->setModel(&proxy_model);
35  // ui.tableView->setModel( &model );
36 
37  ui.tableView->horizontalHeader()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
38  ui.tableView->horizontalHeader()->setSectionResizeMode(1, QHeaderView::ResizeToContents);
39  ui.tableView->horizontalHeader()->setSectionResizeMode(2, QHeaderView::ResizeToContents);
40  ui.tableView->horizontalHeader()->setSectionResizeMode(3, QHeaderView::Interactive);
41  ui.tableView->horizontalHeader()->setSectionResizeMode(4, QHeaderView::Stretch);
42  // ui.tableView->horizontalHeader()->setSectionResizeMode(5, QHeaderView::Stretch);
43 
44  ui.tableView->verticalHeader()->setVisible(false);
45 
46  connect( &model, &LogsTableModel::rowsInserted,
48 
49  proxy_model.setSeverityDebugEnabled( ui.buttonEnableDebug->isChecked() );
50  proxy_model.setSeverityWarningsEnabled( ui.buttonEnableWarnings->isChecked() );
51  proxy_model.setSeverityErrorEnabled( ui.buttonEnableError->isChecked() );
52  proxy_model.setSeverityInfoEnabled( ui.buttonEnableInfo->isChecked() );
53 
54  proxy_model.setMessageFilterEnabled( ui.checkBoxMessageFilter->isChecked() );
55  proxy_model.setNodeFilterEnabled( ui.checkBoxLoggerFilter->isChecked() );
57 
58 }
59 
61 
62 
64 {
66  static_cast<ModelFilter::FilterMode>( ui.comboBoxMessageFilter->currentIndex() ),
67  filter );
68  ui.tableView->resizeColumnToContents(3);
69 }
70 
72 {
74  static_cast<ModelFilter::FilterMode>( mode ),
75  ui.lineEditMessageFilter->text() );
76  ui.tableView->resizeColumnToContents(4);
77 }
78 
80 {
81  ui.labelMessageFilter->setEnabled( checked );
82  ui.comboBoxMessageFilter->setEnabled( checked );
83  ui.lineEditMessageFilter->setEnabled( checked );
84 
86  ui.tableView->resizeColumnToContents(4);
87 }
88 
90 {
92  static_cast<ModelFilter::FilterMode>( ui.comboBoxLoggerFilter->currentIndex() ),
93  filter );
94  ui.tableView->resizeColumnToContents(3);
95 }
96 
98 {
100  static_cast<ModelFilter::FilterMode>( mode ),
101  ui.lineEditLoggerFilter->text() );
102  ui.tableView->resizeColumnToContents(3);
103 }
105 
106 {
107  ui.labelLoggerFilter->setEnabled( checked );
108  ui.comboBoxLoggerFilter->setEnabled( checked );
109  ui.lineEditLoggerFilter->setEnabled( checked );
110 
112  ui.tableView->resizeColumnToContents(3);
113 }
114 
115 void LogWidget::on_rowsInserted(const QModelIndex &, int first_row, int last_row)
116 {
117  ui.tableView->scrollToBottom();
118 }
119 
121 {
123  ui.tableView->resizeColumnToContents(2);
124 }
125 
127 {
129  ui.tableView->resizeColumnToContents(2);
130 }
131 
133 {
135  ui.tableView->resizeColumnToContents(2);
136 }
137 
139 {
141  ui.tableView->resizeColumnToContents(2);
142 }
143 
145 {
146  using namespace std::chrono;
147  {
148  auto msec_since_epoch_A = duration_cast<milliseconds>( time_min.time_since_epoch() );
149  auto datetimeA = QDateTime::fromMSecsSinceEpoch( msec_since_epoch_A.count());
150  ui.timeRangeMin->setDateTime( datetimeA );
151  }
152 
153  {
154  auto msec_since_epoch_B = duration_cast<milliseconds>( time_max.time_since_epoch() );
155  auto datetimeB = QDateTime::fromMSecsSinceEpoch( msec_since_epoch_B.count());
156  ui.timeRangeMax->setDateTime( datetimeB );
157  }
158 
159  // qDebug() << msec_since_epoch_A.count() << " " << msec_since_epoch_B.count();
160  // qDebug() << datetimeA << " " << datetimeB;
161 
162  proxy_model.timeMinMaxUpdated( time_min, time_max );
163  ui.tableView->scrollToBottom();
164  ui.tableView->resizeColumnToContents(0);
165  ui.tableView->resizeColumnToContents(1);
166 }
167 
168 
169 } // namespace rqt_console_plus
std::chrono::high_resolution_clock::time_point TimePoint
Ui::LogWidgetDesign ui
Definition: logwidget.hpp:66
void on_checkBoxMessageFilter_toggled(bool checked)
Definition: logwidget.cpp:79
void on_buttonEnableInfo_toggled(bool checked)
Definition: logwidget.cpp:126
void timeMinMaxUpdated(TimePoint min, TimePoint max)
Definition: modelfilter.cpp:92
void on_rowsInserted(const QModelIndex &parent, int first_row, int last_row)
Definition: logwidget.cpp:115
void on_comboBoxMessageFilter_currentIndexChanged(int index)
Definition: logwidget.cpp:71
void on_lineEditLoggerFilter_textEdited(const QString &arg1)
Definition: logwidget.cpp:89
void on_checkBoxLoggerFilter_toggled(bool checked)
Definition: logwidget.cpp:104
void on_buttonEnableDebug_toggled(bool checked)
Definition: logwidget.cpp:120
LogWidget(LogsTableModel &tablemodel, QWidget *parent=0)
Definition: logwidget.cpp:26
void setNodeFilterEnabled(bool enabled)
Definition: modelfilter.cpp:25
void messageFilterUpdated(FilterMode mode, const QString &text)
Definition: modelfilter.cpp:43
void setSeverityInfoEnabled(bool enabled)
Definition: modelfilter.cpp:99
void setSeverityErrorEnabled(bool enabled)
void on_comboBoxLoggerFilter_currentIndexChanged(int index)
Definition: logwidget.cpp:97
void on_buttonEnableWarnings_toggled(bool checked)
Definition: logwidget.cpp:132
void on_lineEditMessageFilter_textEdited(const QString &filter)
Definition: logwidget.cpp:63
void setTimeFilterEnabled(bool enabled)
Definition: modelfilter.cpp:37
void nodeFilterUpdated(FilterMode mode, const QString &text)
Definition: modelfilter.cpp:60
void setSeverityDebugEnabled(bool enabled)
void setSeverityWarningsEnabled(bool enabled)
void on_timeRangeChanged(TimePoint time_min, TimePoint time_max)
Definition: logwidget.cpp:144
void setMessageFilterEnabled(bool enabled)
Definition: modelfilter.cpp:19
void on_buttonEnableError_toggled(bool checked)
Definition: logwidget.cpp:138
LogsTableModel & model
Definition: logwidget.hpp:67


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