34 maxNewLogLevelType = eUNDEFINED;
40 return logEntries.size();
52 const int& row =
index.row();
53 const int& column =
index.column();
59 std::unique_lock lock(logEntriesMutex);
60 if (row >= (
signed int)logEntries.size() || row < 0)
62 return QString(
"n/A");
65 const LogMessage& entry = logEntries[row];
71 if (role == Qt::ToolTipRole)
78 if (!entry.backtrace.empty())
80 whatStr = QString::fromStdString(entry.what +
"\nBacktrace:\n" +
85 whatStr = QString::fromStdString(entry.what);
97 std::unique_lock lock(logEntriesMutex);
100 if (row >= (
signed int)logEntries.size() || row < 0)
102 return QString(
"n/A");
105 const LogMessage& entry = logEntries[row];
111 IceUtil::Time time = IceUtil::Time::microSeconds(entry.time);
112 std::string timeStr = time.toDateTime();
113 timeStr = timeStr.substr(timeStr.find(
' '));
114 return QString::fromStdString(timeStr);
119 return QString::fromStdString(entry.who);
124 return QString::fromStdString(entry.tag);
129 if (entry.type != eUNDEFINED)
131 return QString::fromStdString(
142 if (role == Qt::ToolTipRole)
149 if (!entry.backtrace.empty())
151 whatStr = QString::fromStdString(entry.what +
"\nBacktrace:\n...");
155 whatStr = QString::fromStdString(entry.what);
158 int maxLinesToShow = 50;
160 for (
int i = 0; i < whatStr.length(); i++)
162 auto c = whatStr.at(i);
167 if (lines == maxLinesToShow)
173 if (lines >= maxLinesToShow)
175 whatStr.truncate(pos);
176 return whatStr +
"\n...";
183 if (role == Qt::ToolTipRole)
185 return QString::fromStdString(
186 "Double click to open file in editor: " + entry.file +
":" +
187 QString::number(entry.line).toStdString());
189 else if (!entry.file.empty())
191 return QString::fromStdString(
192 entry.file +
":" + QString::number(entry.line).toStdString());
202 return QString::fromStdString(entry.function);
207 return QString::fromStdString(entry.group);
215 case Qt::DecorationRole:
219 return QIcon(
":icons/document-open-4.ico");
225 case Qt::BackgroundColorRole:
229 if (row >= (
signed int)logEntries.size() || row < 0)
234 const LogMessage& entry = logEntries[row];
239 return QColor(200, 200, 250);
242 return QColor(50, 255, 50);
245 return QColor(216, 88, 0);
248 return QColor(255, 64, 64);
251 return QColor(176, 0, 0);
259 if (activeSearchStr.length() == 0)
265 std::unique_lock lock(logEntriesMutex);
268 if (row >= (
signed int)logEntries.size() || row < 0)
273 const LogMessage& entry = logEntries[row];
277 return QColor(255, 244, 127);
306 if (searchStr.length() == 0)
313 if (
data(createIndex(row, i), Qt::DisplayRole)
315 .contains(searchStr, Qt::CaseInsensitive))
327 if (QString(logMsg.who.c_str()).contains(searchStr, Qt::CaseInsensitive))
332 if (QString(logMsg.tag.c_str()).contains(searchStr, Qt::CaseInsensitive))
337 if (QString(logMsg.what.c_str()).contains(searchStr, Qt::CaseInsensitive))
342 if (QString(logMsg.backtrace.c_str()).contains(searchStr, Qt::CaseInsensitive))
347 if (QString(logMsg.file.c_str()).contains(searchStr, Qt::CaseInsensitive))
352 if (QString(logMsg.function.c_str()).contains(searchStr, Qt::CaseInsensitive))
357 if (QString::number(logMsg.line).contains(searchStr, Qt::CaseInsensitive))
368 if (row < 0 || row >= (
signed int)logEntries.size())
373 const LogMessage& entry = logEntries[row];
375 if (logMsg.line != entry.line)
380 if (logMsg.who != entry.who)
385 if (logMsg.tag != entry.tag)
390 if (logMsg.what != entry.what)
395 if (logMsg.file != entry.file)
400 if (logMsg.function != entry.function)
411 activeSearchStr = searchStr;
412 QModelIndex leftTop =
index(0, 0);
413 QModelIndex rightBottom =
index(logEntries.size() - 1, 6);
415 emit dataChanged(leftTop, rightBottom);
423 if (role == Qt::DisplayRole)
425 if (orientation == Qt::Horizontal)
458 else if (role == Qt::ToolTipRole)
460 if (orientation == Qt::Horizontal)
480 return QString::fromStdString(
482 std::string(
": Double click cell to open Qtcreator at that location"));
538 return Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled;
542 return Qt::ItemIsSelectable | Qt::ItemIsEnabled;
551 QModelIndex leftTop =
index(logEntries.size() - newEntryCount, 0);
552 QModelIndex rightBottom =
index(logEntries.size() - 1, 6);
554 emit dataChanged(leftTop, rightBottom);
556 maxNewLogLevelType = eUNDEFINED;
562 beginInsertRows(QModelIndex(), row, row + count - 1);
563 int newEntries = row + count - logEntries.size();
565 for (
int i = 0; i < newEntries; i++)
567 logEntries.push_back(LogMessage());
577 activeFilters.push_back(std::make_pair(columnName, filter));
585 std::unique_lock lock(logEntriesMutex);
586 std::vector<LogMessage>::iterator it = logEntries.begin();
589 for (; it != logEntries.end(); ++it)
591 const LogMessage& entry = *it;
595 beginRemoveRows(QModelIndex(), row, row);
596 it = logEntries.erase(it);
612 activeFilters.clear();
619 std::unique_lock lock(logEntriesMutex);
633 *logEntries.rbegin() = entry;
640 if (entry.type > maxNewLogLevelType)
642 maxNewLogLevelType = entry.type;
645 logEntries.push_back(entry);
659 if (entryList.size() == 0)
665 unsigned int size = entryList.size();
666 int entriesAdded = 0;
668 for (
unsigned int i = 0; i < size; i++)
675 if (entriesAdded > 0)
677 beginInsertRows(QModelIndex(), logEntries.size() - entriesAdded, logEntries.size() - 1);
687 if (columnName.empty())
692 QString qcolumnName = QString::fromStdString(columnName);
694 for (
int i = 0; i <
columnCount(QModelIndex()); i++)
696 if (
headerData(i, Qt::Horizontal, Qt::DisplayRole).toString().compare(qcolumnName) == 0)
710 beginRemoveRows(QModelIndex(), 0, logEntries.size() - 1);
711 std::unique_lock lock(logEntriesMutex);
712 size = (int)logEntries.size();
713 removeRows(0, logEntries.size() - 1);
724 return logEntries.at(row);
730 std::string columnName = filter.first;
731 QString filterStr = QString::fromStdString(filter.second);
746 if (QString(logMsg.group.c_str()).contains(filterStr, Qt::CaseSensitive))
757 if (QString(logMsg.who.c_str()).contains(filterStr, Qt::CaseInsensitive))
768 if (QString(logMsg.tag.c_str()).contains(filterStr, Qt::CaseInsensitive))
779 if (logMsg.type < QString(filterStr).
toInt())
790 if (QString(logMsg.what.c_str()).contains(filterStr, Qt::CaseInsensitive))
801 if (!QString(logMsg.file.c_str()).contains(filterStr, Qt::CaseInsensitive) &&
802 filterStr.toInt() != logMsg.line)
813 if (QString(logMsg.function.c_str()).contains(filterStr, Qt::CaseInsensitive))
834 return data(createIndex(row, column), Qt::DisplayRole)
836 .contains(QString(filter.c_str()), Qt::CaseInsensitive);
843 for (
unsigned int i = 0; i < activeFilters.size(); i++)
857 for (
unsigned int i = 0; i < activeFilters.size(); i++)