| 86 | |
| 87 | |
| 88 | QVariant DebugBreakpointsListModel::data(const QModelIndex& index, int role) const |
| 89 | { |
| 90 | if (index.column() >= columnCount() || (size_t)index.row() >= m_items.size()) |
| 91 | return QVariant(); |
| 92 | |
| 93 | BreakpointItem* item = static_cast<BreakpointItem*>(index.internalPointer()); |
| 94 | if (!item) |
| 95 | return QVariant(); |
| 96 | |
| 97 | if ((role != Qt::DisplayRole) && (role != Qt::SizeHintRole)) |
| 98 | return QVariant(); |
| 99 | |
| 100 | switch (index.column()) |
| 101 | { |
| 102 | // case DebugBreakpointsListModel::EnabledColumn: |
| 103 | // { |
| 104 | // QString text = item->enabled() ? "true" : "false"; |
| 105 | // return QVariant(text); |
| 106 | // } |
| 107 | case DebugBreakpointsListModel::LocationColumn: |
| 108 | { |
| 109 | QString text; |
| 110 | if (item->location().module == "") |
| 111 | { |
| 112 | text = QString::fromStdString(fmt::format("0x{:x}", item->location().offset)); |
| 113 | } |
| 114 | else |
| 115 | { |
| 116 | // TODO: This should probably be done at the API level, e.g., also returning a short name of the module |
| 117 | QFileInfo fileInfo(QString::fromStdString(item->location().module)); |
| 118 | auto fileName = fileInfo.fileName(); |
| 119 | text = QString::fromStdString(fmt::format("{} + 0x{:x}", fileName.toStdString(), item->location().offset)); |
| 120 | } |
| 121 | |
| 122 | if (role == Qt::SizeHintRole) |
| 123 | return QVariant((qulonglong)text.size()); |
| 124 | |
| 125 | return QVariant(text); |
| 126 | } |
| 127 | case DebugBreakpointsListModel::AddressColumn: |
| 128 | { |
| 129 | QString text = QString::fromStdString(fmt::format("0x{:x}", item->address())); |
| 130 | if (role == Qt::SizeHintRole) |
| 131 | return QVariant((qulonglong)text.size()); |
| 132 | |
| 133 | return QVariant(text); |
| 134 | } |
| 135 | } |
| 136 | return QVariant(); |
| 137 | } |
| 138 | |
| 139 | |
| 140 | QVariant DebugBreakpointsListModel::headerData(int column, Qt::Orientation orientation, int role) const |