summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--qt-ui/modeldelegates.cpp18
-rw-r--r--qt-ui/modeldelegates.h1
2 files changed, 18 insertions, 1 deletions
diff --git a/qt-ui/modeldelegates.cpp b/qt-ui/modeldelegates.cpp
index a4f457f79..d1e283911 100644
--- a/qt-ui/modeldelegates.cpp
+++ b/qt-ui/modeldelegates.cpp
@@ -22,6 +22,7 @@
// Gets the index of the model in the currentRow and column.
// currCombo is defined below.
#define IDX( XX ) mymodel->index(currCombo.currRow, XX)
+static bool keyboardFinished = false;
StarWidgetsDelegate::StarWidgetsDelegate(QWidget* parent):
QStyledItemDelegate(parent),
@@ -91,11 +92,12 @@ 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()));
+ connect(this, SIGNAL(closeEditor(QWidget*,QAbstractItemDelegate::EndEditHint)), this, SLOT(fixTabBehavior()));
currCombo.comboEditor = comboDelegate;
currCombo.currRow = index.row();
currCombo.model = const_cast<QAbstractItemModel*>(index.model());
+ keyboardFinished = false;
// Current display of things on Gnome3 looks like shit, so
// let`s fix that.
@@ -137,6 +139,16 @@ 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.
@@ -147,6 +159,10 @@ bool ComboBoxDelegate::eventFilter(QObject* object, QEvent* event)
currCombo.ignoreSelection = true;
currCombo.comboEditor->showPopup();
}
+ 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);
diff --git a/qt-ui/modeldelegates.h b/qt-ui/modeldelegates.h
index eb9a0aa04..1aedf1bbf 100644
--- a/qt-ui/modeldelegates.h
+++ b/qt-ui/modeldelegates.h
@@ -27,6 +27,7 @@ public slots:
void testActivation(const QString& currString = QString());
//HACK: try to get rid of this in the future.
void fakeActivation();
+ void fixTabBehavior();
virtual void revertModelData(QWidget* widget, QAbstractItemDelegate::EndEditHint hint) = 0;
protected:
QAbstractItemModel *model;