aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui/maintab.cpp
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tomaz.canabrava@intel.com>2015-07-14 19:09:37 -0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-07-14 15:22:00 -0700
commit536469107d94f265a03e44fcc755b92b9016cbca (patch)
tree1ff37a3fc654724fc917e71e5134329f256f03ea /qt-ui/maintab.cpp
parentcd3f10d5ad4124960b66112074797a16517117e9 (diff)
downloadsubsurface-536469107d94f265a03e44fcc755b92b9016cbca.tar.gz
Fix selecting the first index
The way a QCompleter works is that it grabs whatever data it has in the completerRole and sets it back on the line edit. I Bypassed the QCompleter delegate to show something other than the completerRole (so, for instance, if you write 'B', you could get 'Blue Hole' as the returned text, but in fact the QCompleter has the 'B' as internal string (because of the weird - and wrong way in which we are dealing with completion - trying to complete for something that's not inside the model yet). So I hooked up a signal that will listen to the complete's index, and if it's the first row() it's surely the special case - then we bypass QCompleter return string and use our own. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/maintab.cpp')
-rw-r--r--qt-ui/maintab.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp
index 05196254a..53d8e30b6 100644
--- a/qt-ui/maintab.cpp
+++ b/qt-ui/maintab.cpp
@@ -62,7 +62,6 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
QCompleter *completer = new QCompleter();
QListView *completerListview = new QListView();
LocationInformationModel::instance()->setFirstRowTextField(ui.location);
-
completer->setPopup(completerListview);
completer->setModel(LocationInformationModel::instance());
completer->setCompletionColumn(LocationInformationModel::NAME);
@@ -70,6 +69,8 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
completerListview->setItemDelegate(new LocationFilterDelegate());
locationManagementEditHelper = new LocationManagementEditHelper();
+ connect(locationManagementEditHelper, &LocationManagementEditHelper::setLineEditText,
+ ui.location, &QLineEdit::setText);
completerListview->installEventFilter(locationManagementEditHelper);
connect(completerListview, &QAbstractItemView::activated,
locationManagementEditHelper, &LocationManagementEditHelper::handleActivation);