Changeset View
Changeset View
Standalone View
Standalone View
krusader/GUI/krhistorycombobox.cpp
Show First 20 Lines • Show All 42 Lines • ▼ Show 20 Line(s) | |||||
43 | 43 | | |||
44 | protected: | 44 | protected: | ||
45 | bool eventFilter(QObject *obj, QEvent *event) override; | 45 | bool eventFilter(QObject *obj, QEvent *event) override; | ||
46 | }; | 46 | }; | ||
47 | 47 | | |||
48 | bool KHBoxEventFilter::eventFilter(QObject *obj, QEvent *event) | 48 | bool KHBoxEventFilter::eventFilter(QObject *obj, QEvent *event) | ||
49 | { | 49 | { | ||
50 | if (event->type() == QEvent::KeyPress) { | 50 | if (event->type() == QEvent::KeyPress) { | ||
51 | auto keyEvent = static_cast<QKeyEvent *>(event); | 51 | auto keyEvent = dynamic_cast<QKeyEvent *>(event); | ||
52 | if (keyEvent->modifiers() == Qt::ShiftModifier && keyEvent->key() == Qt::Key::Key_Delete) { | 52 | if (keyEvent->modifiers() == Qt::ShiftModifier && keyEvent->key() == Qt::Key::Key_Delete) { | ||
53 | auto comboBox = dynamic_cast<KHistoryComboBox *>(obj); | 53 | auto comboBox = dynamic_cast<KHistoryComboBox *>(obj); | ||
54 | if (comboBox != nullptr) { | 54 | if (comboBox != nullptr) { | ||
55 | QString entryToDelete = comboBox->currentText(); | 55 | QString entryToDelete = comboBox->currentText(); | ||
56 | // Delete the current item | 56 | // Delete the current item | ||
57 | comboBox->removeItem(comboBox->currentIndex()); | 57 | comboBox->removeItem(comboBox->currentIndex()); | ||
58 | // The item has to be deleted also from the completion list | 58 | // The item has to be deleted also from the completion list | ||
59 | comboBox->completionObject()->removeItem(entryToDelete); | 59 | comboBox->completionObject()->removeItem(entryToDelete); | ||
Show All 18 Lines | |||||
78 | 78 | | |||
79 | protected: | 79 | protected: | ||
80 | bool eventFilter(QObject *obj, QEvent *event) override; | 80 | bool eventFilter(QObject *obj, QEvent *event) override; | ||
81 | }; | 81 | }; | ||
82 | 82 | | |||
83 | bool KHBoxListEventFilter::eventFilter(QObject *obj, QEvent *event) | 83 | bool KHBoxListEventFilter::eventFilter(QObject *obj, QEvent *event) | ||
84 | { | 84 | { | ||
85 | if (event->type() == QEvent::KeyPress) { | 85 | if (event->type() == QEvent::KeyPress) { | ||
86 | auto keyEvent = static_cast<QKeyEvent *>(event); | 86 | auto keyEvent = dynamic_cast<QKeyEvent *>(event); | ||
87 | if (keyEvent->modifiers() == Qt::ShiftModifier && keyEvent->key() == Qt::Key::Key_Delete) { | 87 | if (keyEvent->modifiers() == Qt::ShiftModifier && keyEvent->key() == Qt::Key::Key_Delete) { | ||
88 | auto itemView = dynamic_cast<QAbstractItemView *>(obj); | 88 | auto itemView = dynamic_cast<QAbstractItemView *>(obj); | ||
89 | if (itemView->model() != nullptr) { | 89 | if (itemView->model() != nullptr) { | ||
90 | QString entryToDelete = itemView->currentIndex().data().toString(); | 90 | QString entryToDelete = itemView->currentIndex().data().toString(); | ||
91 | // Delete the current item from the popup list | 91 | // Delete the current item from the popup list | ||
92 | itemView->model()->removeRow(itemView->currentIndex().row()); | 92 | itemView->model()->removeRow(itemView->currentIndex().row()); | ||
93 | // The item has to be deleted also from the completion list of the KHistoryComboBox | 93 | // The item has to be deleted also from the completion list of the KHistoryComboBox | ||
94 | if (itemView->parent() != nullptr) { | 94 | if (itemView->parent() != nullptr) { | ||
Show All 24 Lines |