diff options
author | Tomaz Canabrava <tcanabrava@kde.org> | 2013-09-26 19:59:58 -0300 |
---|---|---|
committer | Tomaz Canabrava <tcanabrava@kde.org> | 2013-09-26 19:59:58 -0300 |
commit | b036a318c695ed5950b5a7c74c8fc081b81b5dab (patch) | |
tree | 020dc56d878e061a4e50c9cbbe3b196643dd2cff | |
parent | 098aa6343b7b806c5c23f6e55c52b998bbe0c388 (diff) | |
download | subsurface-b036a318c695ed5950b5a7c74c8fc081b81b5dab.tar.gz |
Fix the edition of cylinders and weigths by keypress
This patch fixes the cylinders and weigth edition
by keypress. I don`t know when I broke this and linus found,
most probably when I added the code for showing the
cylinder size and working press while moving the mouse
around the list - sorry guys.
So, now this *seems* fixed, tested for a fairly good
amount of time and everything seemed ok.
I was unable to reproduce the behavior that linus got
on two value overlapped on each other, tougth.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
-rw-r--r-- | qt-ui/modeldelegates.cpp | 10 | ||||
-rw-r--r-- | qt-ui/modeldelegates.h | 2 |
2 files changed, 9 insertions, 3 deletions
diff --git a/qt-ui/modeldelegates.cpp b/qt-ui/modeldelegates.cpp index c75485788..5a55cad3c 100644 --- a/qt-ui/modeldelegates.cpp +++ b/qt-ui/modeldelegates.cpp @@ -95,6 +95,7 @@ QWidget* ComboBoxDelegate::createEditor(QWidget* parent, const QStyleOptionViewI comboDelegate->lineEdit()->installEventFilter( const_cast<QObject*>(qobject_cast<const QObject*>(this))); comboDelegate->view()->installEventFilter( const_cast<QObject*>(qobject_cast<const QObject*>(this))); connect(comboDelegate, SIGNAL(highlighted(QString)), this, SLOT(testActivation(QString))); + connect(comboDelegate->lineEdit(), SIGNAL(editingFinished()), this, SLOT(testActivation())); connect(comboDelegate, SIGNAL(activated(QString)), this, SLOT(fakeActivation())); currCombo.comboEditor = comboDelegate; currCombo.currRow = index.row(); @@ -102,9 +103,14 @@ QWidget* ComboBoxDelegate::createEditor(QWidget* parent, const QStyleOptionViewI return comboDelegate; } -void ComboBoxDelegate::testActivation(const QString& s) +/* This Method is being called when the user *writes* something and press enter or tab, + * and it`s also called when the mouse walks over the list of choices from the ComboBox, + * One thing is important, if the user writes a *new* cylinder or weigth type, it will + * be ADDED to the list, and the user will need to fill the other data. + */ +void ComboBoxDelegate::testActivation(const QString& currText) { - currCombo.activeText = s; + currCombo.activeText = currText.isEmpty() ? currCombo.comboEditor->currentText() : currText; setModelData(currCombo.comboEditor, currCombo.model, QModelIndex()); } diff --git a/qt-ui/modeldelegates.h b/qt-ui/modeldelegates.h index 92826ba41..a873e066d 100644 --- a/qt-ui/modeldelegates.h +++ b/qt-ui/modeldelegates.h @@ -23,7 +23,7 @@ public: virtual void updateEditorGeometry(QWidget* editor, const QStyleOptionViewItem& option, const QModelIndex& index) const; virtual bool eventFilter(QObject* object, QEvent* event); public slots: - void testActivation(const QString& s); + void testActivation(const QString& currString = QString()); //HACK: try to get rid of this in the future. void fakeActivation(); virtual void revertModelData(QWidget* widget, QAbstractItemDelegate::EndEditHint hint) = 0; |