| 179 | } |
| 180 | |
| 181 | bool eventFilter(QObject* watched, QEvent* event) override { |
| 182 | if (watched == edit_ && edit_active_) { |
| 183 | if (event->type() == QEvent::FocusOut) { |
| 184 | // Reverting on focus loss is the user-requested behaviour; |
| 185 | // explicit commit only happens on Enter. |
| 186 | cancelEdit(); |
| 187 | } else if (event->type() == QEvent::KeyPress) { |
| 188 | if (static_cast<QKeyEvent*>(event)->key() == Qt::Key_Escape) { |
| 189 | cancelEdit(); |
| 190 | return true; |
| 191 | } |
| 192 | } |
| 193 | } |
| 194 | return QFrame::eventFilter(watched, event); |
| 195 | } |
| 196 | |
| 197 | private slots: |
| 198 | void commitEdit() { |