| 269 | } |
| 270 | |
| 271 | QVariant PointerScanModel::data(const QModelIndex &index, int role) const |
| 272 | { |
| 273 | if (role == Qt::DisplayRole) { |
| 274 | const std::pair<uintptr_t, std::vector<int>> &chain = pointer_chains.at(index.row()); |
| 275 | if (index.column() == 0) { |
| 276 | /* Get file and offset */ |
| 277 | off_t offset; |
| 278 | std::string file = BaseAddresses::getFileAndOffset(chain.first, offset); |
| 279 | if (offset >= 0) |
| 280 | return QString("%1+0x%2").arg(file.c_str()).arg(offset, 0, 16); |
| 281 | else |
| 282 | return QString("%1-0x%2").arg(file.c_str()).arg(-offset, 0, 16); |
| 283 | } |
| 284 | if (index.column() > static_cast<int>(chain.second.size())) { |
| 285 | return QString(""); |
| 286 | } |
| 287 | /* Offsets are stored in reverse order */ |
| 288 | return QString("%1").arg(*(chain.second.rbegin() + (index.column() - 1)), 0, 16); |
| 289 | } |
| 290 | return QVariant(); |
| 291 | } |
no test coverage detected