|
3 | 3 | #include "timestamp.h" |
4 | 4 |
|
5 | 5 | #include <QtCore/QMetaProperty> |
| 6 | +#include <QtGui/QColor> |
6 | 7 | #include <QtGui/QGuiApplication> |
7 | 8 | #include <QtGui/QFont> |
8 | 9 |
|
@@ -98,6 +99,41 @@ void CustomFilterProxyModel::setProgress(int progress) const |
98 | 99 | QVariant CustomFilterProxyModel::data(const QModelIndex &index, int role) const |
99 | 100 | { |
100 | 101 | QVariant ret = QSortFilterProxyModel::data(index, role); |
| 102 | + if (index.column() == GStreamerLogModel::TimestampColumn) { |
| 103 | + auto hasGap = [&](int a, int b) { |
| 104 | + const auto previousTimestamp = Timestamp::fromString(index.siblingAtRow(a).data().toString()); |
| 105 | + const auto currentTimestamp = Timestamp::fromString(index.siblingAtRow(b).data().toString()); |
| 106 | + return previousTimestamp.secsTo(currentTimestamp) > 0; |
| 107 | + }; |
| 108 | + switch (role) { |
| 109 | + case Qt::BackgroundRole: { |
| 110 | + const auto row = index.row(); |
| 111 | + if (row > 0) { |
| 112 | + if (hasGap(row - 1, row)) { |
| 113 | + ret = QColor(Qt::red); |
| 114 | + } else if (row < rowCount() - 1) { |
| 115 | + if (hasGap(row, row + 1)) { |
| 116 | + ret = QColor(Qt::red); |
| 117 | + } |
| 118 | + } |
| 119 | + } |
| 120 | + break; } |
| 121 | + case Qt::ForegroundRole: { |
| 122 | + const auto row = index.row(); |
| 123 | + if (row > 0) { |
| 124 | + if (hasGap(row - 1, row)) { |
| 125 | + ret = QColor(Qt::white); |
| 126 | + } else if (row < rowCount() - 1) { |
| 127 | + if (hasGap(row, row + 1)) { |
| 128 | + ret = QColor(Qt::white); |
| 129 | + } |
| 130 | + } |
| 131 | + } |
| 132 | + break; } |
| 133 | + default: |
| 134 | + break; |
| 135 | + } |
| 136 | + } |
101 | 137 | if (role == Qt::FontRole) { |
102 | 138 | if (!d->filter.isEmpty()) { |
103 | 139 | static const auto mo = &GStreamerLogLine::staticMetaObject; |
|
0 commit comments