diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2020-04-04 23:02:32 +0200 |
---|---|---|
committer | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2020-04-07 00:13:35 +0200 |
commit | 7dc04b4437c7aa1788f7d85a513a246ce502dea4 (patch) | |
tree | 95b5d152f870d4be5734bc424d6e3ec28b8f6b22 /desktop-widgets | |
parent | e5c4dee7f65e8f603ad5207ee6fd8a4de28321fe (diff) | |
download | subsurface-7dc04b4437c7aa1788f7d85a513a246ce502dea4.tar.gz |
delegates: remove ComboBoxTemplate::fixTabBehavior
The comment states that Qt treats TAB as cancel when in the combobox.
However, testing shows that this use-case works without this hack.
Since it caused weird behavior (the data was set *after* the editor
was closed, leading to inconsistent state), remove it.
Note: this overrides the previous commit, which is therefore redundant
from a history point of view. However, I'll leave the previous commit
in so that if something turns out to break, we can figure out which
of the two changes it was.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets')
-rw-r--r-- | desktop-widgets/modeldelegates.cpp | 16 | ||||
-rw-r--r-- | desktop-widgets/modeldelegates.h | 2 |
2 files changed, 1 insertions, 17 deletions
diff --git a/desktop-widgets/modeldelegates.cpp b/desktop-widgets/modeldelegates.cpp index 1908cc543..5480a41db 100644 --- a/desktop-widgets/modeldelegates.cpp +++ b/desktop-widgets/modeldelegates.cpp @@ -84,7 +84,6 @@ const QSize& StarWidgetsDelegate::starSize() const ComboBoxDelegate::ComboBoxDelegate(QAbstractItemModel *model, QObject *parent, bool allowEdit) : QStyledItemDelegate(parent), model(model) { editable = allowEdit; - connect(this, &ComboBoxDelegate::closeEditor, this, &ComboBoxDelegate::fixTabBehavior); connect(this, &ComboBoxDelegate::closeEditor, this, &ComboBoxDelegate::editorClosed); } @@ -121,7 +120,6 @@ QWidget *ComboBoxDelegate::createEditor(QWidget *parent, const QStyleOptionViewI currCombo.currRow = index.row(); currCombo.model = const_cast<QAbstractItemModel *>(index.model()); currCombo.activeText = currCombo.model->data(index).toString(); - keyboardFinished = false; // Current display of things on Gnome3 looks like shit, so // let`s fix that. @@ -169,16 +167,6 @@ void ComboBoxDelegate::fakeActivation() QStyledItemDelegate::eventFilter(currCombo.comboEditor, &ev); } -// This 'reverts' the model data to what we actually choosed, -// becaus e a TAB is being understood by Qt as 'cancel' while -// we are on a QComboBox ( but not on a QLineEdit. -void ComboBoxDelegate::fixTabBehavior() -{ - if (keyboardFinished) { - setModelData(0, 0, QModelIndex()); - } -} - bool ComboBoxDelegate::eventFilter(QObject *object, QEvent *event) { // Reacts on Key_UP and Key_DOWN to show the QComboBox - list of choices. @@ -192,10 +180,8 @@ bool ComboBoxDelegate::eventFilter(QObject *object, QEvent *event) return true; } } - if (ev->key() == Qt::Key_Tab || ev->key() == Qt::Key_Enter || ev->key() == Qt::Key_Return) { + if (ev->key() == Qt::Key_Tab || ev->key() == Qt::Key_Enter || ev->key() == Qt::Key_Return) currCombo.activeText = currCombo.comboEditor->currentText(); - keyboardFinished = true; - } } else { // the 'Drop Down Menu' part. QKeyEvent *ev = static_cast<QKeyEvent *>(event); if (ev->key() == Qt::Key_Enter || ev->key() == Qt::Key_Return || diff --git a/desktop-widgets/modeldelegates.h b/desktop-widgets/modeldelegates.h index 1b4c525d0..95e9c5fef 100644 --- a/desktop-widgets/modeldelegates.h +++ b/desktop-widgets/modeldelegates.h @@ -44,11 +44,9 @@ slots: void testActivation(const QModelIndex &currIndex); //HACK: try to get rid of this in the future. void fakeActivation(); - void fixTabBehavior(); virtual void editorClosed(QWidget *widget, QAbstractItemDelegate::EndEditHint hint) = 0; private: bool editable; - mutable bool keyboardFinished; protected: QAbstractItemModel *model; mutable struct CurrSelected { |