8 : QAbstractTableModel(parent),
17 if (role != Qt::DisplayRole)
20 if (orientation == Qt::Horizontal){
23 case 0:
return "#";
break;
24 case 1:
return "Time";
break;
25 case 2:
return "Severity";
break;
26 case 3:
return "Node";
break;
27 case 4:
return "Message";
break;
28 case 5:
return "Source";
break;
32 return QString(
"%1").arg(section);
59 if (index.row() >=
_logs.size())
64 if (role == Qt::DisplayRole)
66 switch( index.column() )
68 case 0:
return (
int)log.
count;
73 case DEBUG:
return "DEBUG";
74 case INFO:
return "INFO";
76 case ERROR:
return "ERROR";
79 case 3:
return ( *log.
node );
81 case 5:
return ( *log.
source );
84 else if( role== Qt::ForegroundRole){
87 case DEBUG:
return QBrush( QColor::fromRgb(50, 50 , 50)) ;
88 case INFO:
return QBrush( QColor::fromRgb(0, 0 , 255));
89 case WARNINGS:
return QBrush( QColor::fromRgb(240, 120, 0));
90 case ERROR:
return QBrush( QColor::fromRgb(255, 0 , 0));
93 else if( role == Qt::UserRole){
94 switch( index.column() )
96 case 0:
return (
int)log.
count;
99 return QVariant(usec);
102 case 3:
return *log.
node;
104 case 5:
return *log.
source;
127 QString node_name = QString::fromStdString(log.name);
131 auto inserted_ret =
_node_list.insert(node_name);
132 node_it = inserted_ret.first;
134 item.
node = &(*node_it);
136 QString source_name(log.file.c_str());
137 source_name += (
" ");
138 source_name += QString::fromStdString(log.function);
139 source_name += (
":");
140 source_name += QString::number(log.line);
147 source_it = inserted_ret.first;
149 item.
source = &(*source_it);
151 item.
message = log.msg.c_str();
166 this->beginRemoveRows( QModelIndex(), 0 , 0);
167 this->endRemoveRows();
171 this->beginInsertRows( QModelIndex(),
_logs.size() - 1 ,
_logs.size() - 1);
172 this->endInsertRows();
177 size_t old_size =
_logs.size();
178 size_t new_size = old_size + pushed_logs.size();
180 int to_add = pushed_logs.size();
190 const size_t last_row = new_size - 1;
191 const size_t first_row = new_size - pushed_logs.size() ;
193 for (
int i=0;
i < pushed_logs.size();
i++){
202 this->beginRemoveRows( QModelIndex(), 0 , 0);
203 this->endRemoveRows();
208 this->beginInsertRows( QModelIndex(), first_row , last_row);
209 this->endInsertRows();
215 return _logs[ index ].message;
220 return *(
_logs[ index ].node );
225 return _logs[ index ].level_raw;
230 std::chrono::microseconds since_epoch(
_logs[ index ].time_usec_since_epoch );
235 this->beginRemoveRows( QModelIndex(), 0 ,
_logs.size() -1);
236 this->endRemoveRows();
int columnCount(const QModelIndex &parent=QModelIndex()) const override
LogItem convertRosout(const rosgraph_msgs::Log &log)
std::chrono::high_resolution_clock::time_point TimePoint
TimePoint timestamp(int index) const
LogsTableModel(QObject *parent=0)
std::set< QString > _node_list
const QString & message(int index) const
boost::circular_buffer< LogItem > _logs
std::set< QString > _source_list
Severity severity(int index) const
int rowCount(const QModelIndex &parent=QModelIndex()) const override
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
int64_t time_usec_since_epoch
const QString & nodeName(int index) const
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
void push_back(const rosgraph_msgs::Log::ConstPtr &pushed_log)