MCPcopy Create free account
hub / github.com/clementgallet/libTAS / data

Method data

src/program/ui/InputEventModel.cpp:61–103  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

59}
60
61QVariant 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
105bool InputEventModel::setData(const QModelIndex &index, const QVariant &value, int role)
106{

Callers

nothing calls this directly

Calls 3

columnMethod · 0.80
input_descriptionMethod · 0.80
c_strMethod · 0.45

Tested by

no test coverage detected