47 #include <QTextStream>
58 display_absolute_time_(false),
59 human_readable_time_(false),
60 display_logger_(false),
61 display_function_(false),
62 use_regular_expressions_(false),
63 debug_color_(Qt::gray),
64 info_color_(Qt::black),
65 warn_color_(QColor(255,127,0)),
66 error_color_(Qt::red),
67 fatal_color_(Qt::magenta),
69 failedSearchText_(
""),
72 QObject::connect(
db_, SIGNAL(databaseCleared()),
109 Q_EMIT dataChanged(index(0), index(
msg_mapping_.size()));
124 Q_EMIT dataChanged(index(0), index(
msg_mapping_.size()));
139 Q_EMIT dataChanged(index(0), index(
msg_mapping_.size()));
155 Q_EMIT dataChanged(index(0), index(
msg_mapping_.size()));
171 Q_EMIT dataChanged(index(0), index(
msg_mapping_.size()));
187 Q_EMIT dataChanged(index(0), index(
msg_mapping_.size()));
204 const QStringList &list)
213 const QStringList &list)
280 if (parent.isValid()) {
310 int searchNotFound = -1;
312 bool partialSearch =
false;
316 return searchNotFound;
337 partialSearch =
true;
346 QString tempString = item.
text.join(
"|");
347 if(tempString.toUpper().contains(searchText))
360 return searchNotFound;
363 index = index + increment;
385 const QModelIndex &index,
int role)
const
391 case Qt::DisplayRole:
392 case Qt::ToolTipRole:
395 case Qt::ForegroundRole:
403 if (index.parent().isValid() &&
404 static_cast<size_t>(index.row()) >=
msg_mapping_.size()) {
411 if (role == Qt::DisplayRole) {
413 if (item.
level == rosgraph_msgs::Log::DEBUG) {
415 }
else if (item.
level == rosgraph_msgs::Log::INFO) {
417 }
else if (item.
level == rosgraph_msgs::Log::WARN) {
419 }
else if (item.
level == rosgraph_msgs::Log::ERROR) {
421 }
else if (item.
level == rosgraph_msgs::Log::FATAL) {
429 int milliseconds = item.
stamp.
nsec / 1000000 ;
430 const time_t time =
static_cast<time_t
>(item.
stamp.
sec);
431 std::ostringstream oss;
432 oss << std::put_time(std::localtime(&time),
"%Y-%m-%d %H:%M:%S");
433 snprintf(stamp,
sizeof(stamp),
"%s::%03d",oss.str().c_str(), milliseconds);
435 snprintf(stamp,
sizeof(stamp),
443 int32_t secs = t.
sec;
444 int hours = secs / 60 / 60;
445 int minutes = (secs / 60) % 60;
446 int seconds = (secs % 60);
447 int milliseconds = t.
nsec / 1000000;
449 snprintf(stamp,
sizeof(stamp),
451 hours, minutes, seconds, milliseconds);
456 snprintf(
id,
sizeof(
id),
"%s::%s", item.
node.c_str(), item.
function.c_str());
458 snprintf(
id,
sizeof(
id),
"%s", item.
node.c_str());
460 snprintf(
id,
sizeof(
id),
"::%s", item.
function.c_str());
467 snprintf(
header,
sizeof(
header),
"%c %s [%s] ", level, stamp,
id);
469 snprintf(
header,
sizeof(
header),
"%c %s [] ", level, stamp);
470 }
else if (display_id) {
471 snprintf(
header,
sizeof(
header),
"%c [%s] ", level,
id);
482 for (
size_t i = 0; i < len; i++) {
490 switch (item.
level) {
491 case rosgraph_msgs::Log::DEBUG:
493 case rosgraph_msgs::Log::INFO:
495 case rosgraph_msgs::Log::WARN:
497 case rosgraph_msgs::Log::ERROR:
499 case rosgraph_msgs::Log::FATAL:
505 else if (role == Qt::ToolTipRole) {
507 snprintf(buffer,
sizeof(buffer),
508 "<p style='white-space:pre'>"
509 "Timestamp: %d.%09d\n"
524 QString text = (QString(buffer) +
525 item.
text.join(
"\n") +
528 return QVariant(text);
531 snprintf(buffer,
sizeof(buffer),
532 "Timestamp: %d.%09d\n"
545 QString text = (QString(buffer) +
546 item.
text.join(
"\n"));
548 return QVariant(text);
568 if (filename.endsWith(
".bag", Qt::CaseInsensitive)) {
585 rosgraph_msgs::Log log;
586 log.file = item.
file;
588 log.header.seq = item.
seq;
594 qWarning(
"Msg with seq %d had time (%d); it's less than ros::TIME_MIN, which is invalid. "
595 "Writing 'now' instead.",
598 log.header.stamp = item.
stamp;
600 log.level = item.
level;
601 log.line = item.
line;
602 log.msg = item.
text.join(
"\n").toStdString();
603 log.name = item.
node;
604 bag.
write(
"/rosout", log.header.stamp, log);
617 QFile outFile(filename);
618 outFile.open(QFile::WriteOnly);
619 QTextStream outstream(&outFile);
622 QString line =
data(index(i), Qt::DisplayRole).toString();
623 outstream << line <<
'\n';
637 std::deque<LineMap> new_items;
650 for (
int i = 0; i < item.
text.size(); i++) {
655 if (!new_items.empty()) {
656 beginInsertRows(QModelIndex(),
687 for (
int i = 0; i < item.
text.size(); i++) {
696 beginInsertRows(QModelIndex(),
779 Q_EMIT dataChanged(index(0), index(
msg_mapping_.size()));