| 59 | } |
| 60 | |
| 61 | QVariant InputEventModel::data(const QModelIndex &index, int role) const |
| 62 | { |
| 63 | const auto& event = events[index.row()]; |
| 64 | |
| 65 | if (role == Qt::DisplayRole) { |
| 66 | if (index.column() == 0) { |
| 67 | return tr(SingleInput::typeToStr(event.type)); |
| 68 | } |
| 69 | else if (index.column() == 1) { |
| 70 | switch (event.type) { |
| 71 | case SingleInput::IT_KEYBOARD: |
| 72 | return QString(context->config.km->input_description(event.which).c_str()); |
| 73 | case SingleInput::IT_POINTER_BUTTON: |
| 74 | return QString("Button %1").arg(event.which+1); |
| 75 | case SingleInput::IT_CONTROLLER1_BUTTON: |
| 76 | case SingleInput::IT_CONTROLLER2_BUTTON: |
| 77 | case SingleInput::IT_CONTROLLER3_BUTTON: |
| 78 | case SingleInput::IT_CONTROLLER4_BUTTON: |
| 79 | return tr(SingleInput::buttonToStr(event.which)); |
| 80 | case SingleInput::IT_CONTROLLER1_AXIS: |
| 81 | case SingleInput::IT_CONTROLLER2_AXIS: |
| 82 | case SingleInput::IT_CONTROLLER3_AXIS: |
| 83 | case SingleInput::IT_CONTROLLER4_AXIS: |
| 84 | return tr(SingleInput::axisToStr(event.which)); |
| 85 | } |
| 86 | } |
| 87 | else { |
| 88 | return QVariant(event.value); |
| 89 | } |
| 90 | } |
| 91 | else if (role == Qt::EditRole) { |
| 92 | if (index.column() == 0) { |
| 93 | return event.type; |
| 94 | } |
| 95 | else if (index.column() == 1) { |
| 96 | return ((unsigned long long)event.type << 32ULL) | event.which; |
| 97 | } |
| 98 | else { |
| 99 | return event.value; |
| 100 | } |
| 101 | } |
| 102 | return QVariant(); |
| 103 | } |
| 104 | |
| 105 | bool InputEventModel::setData(const QModelIndex &index, const QVariant &value, int role) |
| 106 | { |
nothing calls this directly
no test coverage detected