| 93 | |
| 94 | |
| 95 | QVariant DebugModulesListModel::data(const QModelIndex& index, int role) const |
| 96 | { |
| 97 | if (index.column() >= columnCount() || (size_t)index.row() >= m_items.size()) |
| 98 | return QVariant(); |
| 99 | |
| 100 | ModuleItem* item = static_cast<ModuleItem*>(index.internalPointer()); |
| 101 | if (!item) |
| 102 | return QVariant(); |
| 103 | |
| 104 | if ((role != Qt::DisplayRole) && (role != Qt::SizeHintRole) && (role != SortFilterRole)) |
| 105 | return QVariant(); |
| 106 | |
| 107 | switch (index.column()) |
| 108 | { |
| 109 | case DebugModulesListModel::AddressColumn: |
| 110 | { |
| 111 | QString text = QString::asprintf("0x%" PRIx64, item->address()); |
| 112 | if (role == Qt::SizeHintRole) |
| 113 | return QVariant((qulonglong)text.size()); |
| 114 | |
| 115 | return QVariant(text); |
| 116 | } |
| 117 | case DebugModulesListModel::EndAddressColumn: |
| 118 | { |
| 119 | QString text = QString::asprintf("0x%" PRIx64, item->endAddress()); |
| 120 | if (role == Qt::SizeHintRole) |
| 121 | return QVariant((qulonglong)text.size()); |
| 122 | |
| 123 | return QVariant(text); |
| 124 | } |
| 125 | case DebugModulesListModel::SizeColumn: |
| 126 | { |
| 127 | QString text = QString::asprintf("0x%" PRIx64, (uint64_t)item->size()); |
| 128 | if (role == Qt::SizeHintRole) |
| 129 | return QVariant((qulonglong)text.size()); |
| 130 | |
| 131 | return QVariant(text); |
| 132 | } |
| 133 | case DebugModulesListModel::NameColumn: |
| 134 | { |
| 135 | QString text = QString::fromStdString(item->name()); |
| 136 | if (role == Qt::SizeHintRole) |
| 137 | return QVariant((qulonglong)text.size()); |
| 138 | |
| 139 | return QVariant(text); |
| 140 | } |
| 141 | case DebugModulesListModel::PathColumn: |
| 142 | { |
| 143 | QString text = QString::fromStdString(item->path()); |
| 144 | if (role == Qt::SizeHintRole) |
| 145 | return QVariant((qulonglong)text.size()); |
| 146 | |
| 147 | return QVariant(text); |
| 148 | } |
| 149 | } |
| 150 | return QVariant(); |
| 151 | } |
| 152 | |