| 355 | } |
| 356 | |
| 357 | void InputEditorView::mousePressEvent(QMouseEvent *event) |
| 358 | { |
| 359 | mouseColumn = -1; |
| 360 | |
| 361 | if (event->button() != Qt::LeftButton) { |
| 362 | return QTableView::mousePressEvent(event); |
| 363 | } |
| 364 | |
| 365 | /* Get the table cell under the mouse position */ |
| 366 | const QModelIndex index = indexAt(event->pos()); |
| 367 | if (!index.isValid()) { |
| 368 | return QTableView::mousePressEvent(event); |
| 369 | } |
| 370 | |
| 371 | if (index.column() == InputEditorModel::COLUMN_FRAME) { |
| 372 | return QTableView::mousePressEvent(event); |
| 373 | } |
| 374 | |
| 375 | selectionModel()->clear(); |
| 376 | mouseColumn = index.column(); |
| 377 | mouseRow = index.row(); |
| 378 | mouseMinRow = mouseRow; |
| 379 | mouseMaxRow = mouseRow; |
| 380 | |
| 381 | /* Rewind when clicking for column */ |
| 382 | if (mouseColumn == InputEditorModel::COLUMN_SAVESTATE) { |
| 383 | inputEditorModel->seekToFrame(mouseRow); |
| 384 | return; |
| 385 | } |
| 386 | |
| 387 | /* For editable items, copy the value. Else, copy the opposite value */ |
| 388 | mouseValue = inputEditorModel->data(index, Qt::EditRole).toInt(); |
| 389 | if (!inputEditorModel->isInputAnalog(mouseColumn)) { |
| 390 | if (event->modifiers() & Qt::ControlModifier) |
| 391 | mouseValue = 1; // autofire always starts with setting input |
| 392 | else |
| 393 | mouseValue = !mouseValue; |
| 394 | } |
| 395 | |
| 396 | if (event->modifiers() & Qt::ControlModifier) |
| 397 | inputEditorModel->startPaint(mouseColumn, mouseRow, mouseRow, mouseValue, (mouseRow%2)+1); |
| 398 | else |
| 399 | inputEditorModel->startPaint(mouseColumn, mouseRow, mouseRow, mouseValue, 0); |
| 400 | |
| 401 | /* Return the original function, so that double click is triggered */ |
| 402 | if (inputEditorModel->isInputAnalog(mouseColumn)) |
| 403 | return QTableView::mousePressEvent(event); |
| 404 | |
| 405 | event->accept(); |
| 406 | } |
| 407 | |
| 408 | void InputEditorView::mouseDoubleClickEvent(QMouseEvent *event) |
| 409 | { |
nothing calls this directly
no test coverage detected