44 #include <QTextStream> 55 display_absolute_time_(false),
56 use_regular_expressions_(false),
57 debug_color_(
Qt::gray),
58 info_color_(
Qt::black),
59 warn_color_(QColor(255,127,0)),
60 error_color_(
Qt::red),
61 fatal_color_(
Qt::magenta),
63 failedSearchText_(
""),
66 QObject::connect(
db_, SIGNAL(databaseCleared()),
103 Q_EMIT dataChanged(index(0), index(
msg_mapping_.size()));
119 Q_EMIT dataChanged(index(0), index(
msg_mapping_.size()));
135 Q_EMIT dataChanged(index(0), index(
msg_mapping_.size()));
152 const QStringList &list)
161 const QStringList &list)
228 if (parent.isValid()) {
258 int searchNotFound = -1;
260 bool partialSearch =
false;
264 return searchNotFound;
285 partialSearch =
true;
294 QString tempString = item.
text.join(
"|");
295 if(tempString.toUpper().contains(searchText))
308 return searchNotFound;
311 index = index + increment;
333 const QModelIndex &index,
int role)
const 339 case Qt::DisplayRole:
340 case Qt::ToolTipRole:
343 case Qt::ForegroundRole:
351 if (index.parent().isValid() &&
352 static_cast<size_t>(index.row()) >=
msg_mapping_.size()) {
359 if (role == Qt::DisplayRole) {
361 if (item.
level == rosgraph_msgs::Log::DEBUG) {
363 }
else if (item.
level == rosgraph_msgs::Log::INFO) {
365 }
else if (item.
level == rosgraph_msgs::Log::WARN) {
367 }
else if (item.
level == rosgraph_msgs::Log::ERROR) {
369 }
else if (item.
level == rosgraph_msgs::Log::FATAL) {
375 snprintf(stamp,
sizeof(stamp),
382 int32_t secs = t.
sec;
383 int hours = secs / 60 / 60;
384 int minutes = (secs / 60) % 60;
385 int seconds = (secs % 60);
386 int milliseconds = t.
nsec / 1000000;
388 snprintf(stamp,
sizeof(stamp),
390 hours, minutes, seconds, milliseconds);
395 snprintf(header,
sizeof(header),
396 "[%c %s] ", level, stamp);
398 snprintf(header,
sizeof(header),
407 size_t len = strnlen(header,
sizeof(header));
408 for (
size_t i = 0; i < len; i++) {
413 return QVariant(QString(header) + item.
text[line_idx.
line_index]);
416 switch (item.
level) {
417 case rosgraph_msgs::Log::DEBUG:
419 case rosgraph_msgs::Log::INFO:
421 case rosgraph_msgs::Log::WARN:
423 case rosgraph_msgs::Log::ERROR:
425 case rosgraph_msgs::Log::FATAL:
431 else if (role == Qt::ToolTipRole) {
433 snprintf(buffer,
sizeof(buffer),
434 "<p style='white-space:pre'>" 435 "Timestamp: %d.%09d\n" 450 QString text = (QString(buffer) +
451 item.
text.join(
"\n") +
454 return QVariant(text);
457 snprintf(buffer,
sizeof(buffer),
458 "Timestamp: %d.%09d\n" 471 QString text = (QString(buffer) +
472 item.
text.join(
"\n"));
474 return QVariant(text);
494 if (filename.endsWith(
".bag", Qt::CaseInsensitive)) {
511 rosgraph_msgs::Log log;
512 log.file = item.
file;
514 log.header.seq = item.
seq;
520 qWarning(
"Msg with seq %d had time (%d); it's less than ros::TIME_MIN, which is invalid. " 521 "Writing 'now' instead.",
524 log.header.stamp = item.
stamp;
526 log.level = item.
level;
527 log.line = item.
line;
528 log.msg = item.
text.join(
"\n").toStdString();
529 log.name = item.
node;
530 bag.write(
"/rosout", log.header.stamp, log);
543 QFile outFile(filename);
544 outFile.open(QFile::WriteOnly);
545 QTextStream outstream(&outFile);
548 QString line =
data(index(i), Qt::DisplayRole).toString();
549 outstream << line <<
'\n';
563 std::deque<LineMap> new_items;
576 for (
int i = 0; i < item.
text.size(); i++) {
581 if (!new_items.empty()) {
582 beginInsertRows(QModelIndex(),
613 for (
int i = 0; i < item.
text.size(); i++) {
622 beginInsertRows(QModelIndex(),
705 Q_EMIT dataChanged(index(0), index(
msg_mapping_.size()));
void saveBagFile(const QString &filename) const
static const QString INFO_COLOR
bool isExcludeValid() const
bool testIncludeFilter(const LogEntry &item)
static const QString DISPLAY_TIMESTAMPS
LogDatabaseProxyModel(LogDatabase *db)
void setFatalColor(const QColor &fatal_color)
static const QString FATAL_COLOR
void setIncludeFilters(const QStringList &list)
void setDisplayTime(bool display)
std::deque< LineMap > early_mapping_
bool acceptLogEntry(const LogEntry &item)
static const QString USE_REGEXPS
void processOldMessages()
virtual QVariant data(const QModelIndex &index, int role) const
const Time TIME_MIN(0, 1)
void handleDatabaseCleared()
std::deque< LineMap > msg_mapping_
void scheduleIdleProcessing()
static const QString WARN_COLOR
void setColorizeLogs(bool colorize_logs)
std::set< std::string > names_
bool display_absolute_time_
bool use_regular_expressions_
void setUseRegularExpressions(bool useRegexps)
bool isIncludeValid() const
void setInfoColor(const QColor &info_color)
void processNewMessages()
const ros::Time & minTime() const
void setSeverityFilter(uint8_t severity_mask)
void setWarnColor(const QColor &warn_color)
void setErrorColor(const QColor &error_color)
QStringList exclude_strings_
void setExcludeFilters(const QStringList &list)
virtual int rowCount(const QModelIndex &parent) const
static const QString EXCLUDE_FILTER
static const QString DEBUG_COLOR
void saveTextFile(const QString &filename) const
void setAbsoluteTime(bool absolute)
void saveToFile(const QString &filename) const
const std::deque< LogEntry > & log()
static const QString COLORIZE_LOGS
void setNodeFilter(const std::set< std::string > &names)
int getItemIndex(const QString searchText, int index, int increment)
static const QString ABSOLUTE_TIMESTAMPS
void setDebugColor(const QColor &debug_color)
static const QString ERROR_COLOR
QString failedSearchText_
static const QString INCLUDE_FILTER
void setExcludeRegexpPattern(const QString &pattern)
size_t earliest_log_index_
QStringList include_strings_
void clearSearchFailure()
void setIncludeRegexpPattern(const QString &pattern)