| 75 | |
| 76 | |
| 77 | QVariant ProcessListModel::data(const QModelIndex& index, int role) const |
| 78 | { |
| 79 | if (index.column() >= columnCount() || (size_t)index.row() >= m_items.size()) |
| 80 | return QVariant(); |
| 81 | |
| 82 | ProcessItem* item = static_cast<ProcessItem*>(index.internalPointer()); |
| 83 | if (!item) |
| 84 | return QVariant(); |
| 85 | |
| 86 | if ((role != Qt::DisplayRole) && (role != Qt::SizeHintRole) && (role != SortFilterRole)) |
| 87 | return QVariant(); |
| 88 | |
| 89 | switch (index.column()) |
| 90 | { |
| 91 | case ProcessListModel::PidColumn: |
| 92 | { |
| 93 | QString text = QString::asprintf("%d", item->pid()); |
| 94 | if (role == Qt::SizeHintRole) |
| 95 | return QVariant((qulonglong)text.size()); |
| 96 | |
| 97 | return QVariant(text); |
| 98 | } |
| 99 | case ProcessListModel::ProcessNameColumn: |
| 100 | { |
| 101 | QString text = QString::fromStdString(item->processName()); |
| 102 | if (role == Qt::SizeHintRole) |
| 103 | return QVariant((qulonglong)text.size()); |
| 104 | |
| 105 | return QVariant(text); |
| 106 | } |
| 107 | } |
| 108 | return QVariant(); |
| 109 | } |
| 110 | |
| 111 | |
| 112 | QVariant ProcessListModel::headerData(int column, Qt::Orientation orientation, int role) const |
no test coverage detected