| 84 | } |
| 85 | |
| 86 | QVariant PacketItemModel::data(const QModelIndex &index, int role) const |
| 87 | { |
| 88 | if (!index.isValid()) |
| 89 | return {}; |
| 90 | |
| 91 | auto item = static_cast<TreeItem *>(index.internalPointer()); |
| 92 | if (role == Qt::ForegroundRole) |
| 93 | { |
| 94 | if (item->isError()) |
| 95 | return QVariant(QBrush(QColor(255, 0, 0))); |
| 96 | return QVariant(QBrush()); |
| 97 | } |
| 98 | if (role == Qt::BackgroundRole) |
| 99 | { |
| 100 | if (!useColorCoding) |
| 101 | return QVariant(QBrush()); |
| 102 | const int idx = item->getStreamIndex(); |
| 103 | if (idx >= 0) |
| 104 | return QVariant( |
| 105 | QBrush(functionsGui::toQColor(streamIndexColors.at(idx % streamIndexColors.size())))); |
| 106 | return QVariant(QBrush()); |
| 107 | } |
| 108 | else if (role == Qt::DisplayRole || role == Qt::ToolTipRole) |
| 109 | { |
| 110 | if (index.column() == 0) |
| 111 | return QVariant(QString::fromStdString(item->getName(!showVideoOnly))); |
| 112 | else |
| 113 | return QVariant(QString::fromStdString(item->getData(index.column()))); |
| 114 | } |
| 115 | return QVariant(); |
| 116 | } |
| 117 | |
| 118 | QModelIndex PacketItemModel::index(int row, int column, const QModelIndex &parent) const |
| 119 | { |