| 70 | } |
| 71 | |
| 72 | bool |
| 73 | ButtonDelegate::editorEvent( |
| 74 | QEvent *event, |
| 75 | QAbstractItemModel *, |
| 76 | const QStyleOptionViewItem &option, |
| 77 | const QModelIndex &index) |
| 78 | { |
| 79 | if (event->type() == QEvent::MouseButtonPress) { |
| 80 | this->pressed = true; |
| 81 | this->rowPressed = index.row(); |
| 82 | } else if (event->type() == QEvent::FocusOut) { |
| 83 | this->pressed = false; |
| 84 | } else if (event->type() == QEvent::MouseButtonRelease) { |
| 85 | QMouseEvent * e = static_cast<QMouseEvent *>(event); |
| 86 | int clickX = e->x(); |
| 87 | int clickY = e->y(); |
| 88 | |
| 89 | QRect r = option.rect; //getting the rect of the cell |
| 90 | int x, y, w, h; |
| 91 | |
| 92 | this->pressed = false; |
| 93 | |
| 94 | x = r.left(); |
| 95 | y = r.top(); |
| 96 | w = this->buttonWidth; |
| 97 | h = r.height(); |
| 98 | |
| 99 | if (clickX > x && clickX < x + w && clickY > y && clickY < y + h) |
| 100 | emit clicked(index); |
| 101 | } |
| 102 | |
| 103 | return true; |
| 104 | } |
| 105 | |
| 106 | QSize |
| 107 | ButtonDelegate::sizeHint( |
nothing calls this directly
no outgoing calls
no test coverage detected