| 103 | |
| 104 | |
| 105 | QVariant DebugStackListModel::data(const QModelIndex& index, int role) const |
| 106 | { |
| 107 | if (index.column() >= columnCount() || (size_t)index.row() >= m_items.size()) |
| 108 | return QVariant(); |
| 109 | |
| 110 | DebugStackItem* item = static_cast<DebugStackItem*>(index.internalPointer()); |
| 111 | if (!item) |
| 112 | return QVariant(); |
| 113 | |
| 114 | |
| 115 | if ((role != Qt::DisplayRole) && (role != Qt::SizeHintRole)) |
| 116 | return QVariant(); |
| 117 | |
| 118 | switch (index.column()) |
| 119 | { |
| 120 | case DebugStackListModel::OffsetColumn: |
| 121 | { |
| 122 | ptrdiff_t value = item->offset(); |
| 123 | QString valueStr; |
| 124 | if (value < 0) |
| 125 | valueStr = QString::asprintf("-%" PRIx64, (uint64_t)-value); |
| 126 | else |
| 127 | valueStr = QString::asprintf("%" PRIx64, (uint64_t)value); |
| 128 | |
| 129 | if (role == Qt::SizeHintRole) |
| 130 | return QVariant((qulonglong)valueStr.size()); |
| 131 | |
| 132 | QList<QVariant> line; |
| 133 | line.push_back(getThemeColor(WhiteStandardHighlightColor).rgba()); |
| 134 | line.push_back(valueStr); |
| 135 | return QVariant(line); |
| 136 | } |
| 137 | case DebugStackListModel::AddressColumn: |
| 138 | { |
| 139 | uint64_t value = item->address(); |
| 140 | QString valueStr = QString::asprintf("%" PRIx64, value); |
| 141 | if (role == Qt::SizeHintRole) |
| 142 | return QVariant((qulonglong)valueStr.size()); |
| 143 | |
| 144 | QList<QVariant> line; |
| 145 | line.push_back(getThemeColor(WhiteStandardHighlightColor).rgba()); |
| 146 | line.push_back(valueStr); |
| 147 | return QVariant(line); |
| 148 | } |
| 149 | case DebugStackListModel::ValueColumn: |
| 150 | { |
| 151 | uint64_t value = item->value(); |
| 152 | QString valueStr = QString::asprintf("%" PRIx64, value); |
| 153 | if (role == Qt::SizeHintRole) |
| 154 | return QVariant((qulonglong)valueStr.size()); |
| 155 | |
| 156 | QList<QVariant> line; |
| 157 | switch (item->valueStatus()) |
| 158 | { |
| 159 | case DebugStackValueNormal: |
| 160 | line.push_back(getThemeColor(WhiteStandardHighlightColor).rgba()); |
| 161 | break; |
| 162 | case DebugStackValueChanged: |
no test coverage detected