diff --git a/qt/players_table_helper.cpp b/qt/players_table_helper.cpp index fd92d9e..cd51438 100644 --- a/qt/players_table_helper.cpp +++ b/qt/players_table_helper.cpp @@ -32,6 +32,7 @@ #include "players_table_helper.h" #include "custom_popup.h" +#include "misc_helpers.h" #include "qtcommon.h" @@ -142,9 +143,9 @@ void PlayersTableHelper::addPopupRemoveAction() // Install a custom event filter, to remove the selection when the // "Delete" key is pressed - PlayersEventFilter *filter = new PlayersEventFilter(this); + KeyEventFilter *filter = new KeyEventFilter(this, Qt::Key_Delete); m_tablePlayers->installEventFilter(filter); - QObject::connect(filter, SIGNAL(deletePressed()), + QObject::connect(filter, SIGNAL(keyPressed()), this, SLOT(removeSelectedRows())); } @@ -398,28 +399,3 @@ void PlayersLevelDelegate::updateEditorGeometry(QWidget *editor, editor->setGeometry(option.rect); } - - -PlayersEventFilter::PlayersEventFilter(QObject *parent) - : QObject(parent) -{ -} - - -bool PlayersEventFilter::eventFilter(QObject *obj, QEvent *event) -{ - // If the Delete key is pressed, remove the selected line, if any - if (event->type() == QEvent::KeyPress) - { - QKeyEvent *keyEvent = static_cast(event); - if (keyEvent->key() == Qt::Key_Delete) - { - emit deletePressed(); - return true; - } - } - - // Standard event processing - return QObject::eventFilter(obj, event); -} - diff --git a/qt/players_table_helper.h b/qt/players_table_helper.h index a8c3561..fc67be6 100644 --- a/qt/players_table_helper.h +++ b/qt/players_table_helper.h @@ -143,23 +143,5 @@ public: const QModelIndex &index) const; }; - -/// Event filter used for the edition of the players display -class PlayersEventFilter: public QObject -{ - Q_OBJECT; - -public: - explicit PlayersEventFilter(QObject *parent = 0); - virtual ~PlayersEventFilter() {} - -signals: - /// As its name indicates... - void deletePressed(); - -protected: - virtual bool eventFilter(QObject *obj, QEvent *event); -}; - #endif