improve combobox speed and autocompletion

This commit is contained in:
garak 2019-08-06 21:50:03 -04:00
parent e501a92c30
commit 5470ade7bb
3 changed files with 13 additions and 1 deletions

1
.gitignore vendored
View file

@ -1,3 +1,4 @@
Makefile
porymap.pro.user porymap.pro.user
*.autosave *.autosave
*.stash *.stash

View file

@ -206,7 +206,7 @@
</widget> </widget>
</item> </item>
<item row="3" column="0" colspan="3"> <item row="3" column="0" colspan="3">
<widget class="QComboBox" name="comboBox_metatileBehaviors"/> <widget class="NoScrollComboBox" name="comboBox_metatileBehaviors"/>
</item> </item>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="label_4"> <widget class="QLabel" name="label_4">

View file

@ -1,10 +1,21 @@
#include "noscrollcombobox.h" #include "noscrollcombobox.h"
#include <QCompleter>
NoScrollComboBox::NoScrollComboBox(QWidget *parent) NoScrollComboBox::NoScrollComboBox(QWidget *parent)
: QComboBox(parent) : QComboBox(parent)
{ {
// Don't let scrolling hijack focus. // Don't let scrolling hijack focus.
setFocusPolicy(Qt::StrongFocus); setFocusPolicy(Qt::StrongFocus);
// Make speed a priority when loading comboboxes.
setMinimumContentsLength(20);// an arbitrary limit
setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLength);
// Allow items to be searched by any part of the word, displaying all matches.
setEditable(true);// can set to false manually when using
this->completer()->setCompletionMode(QCompleter::PopupCompletion);
this->completer()->setFilterMode(Qt::MatchContains);
} }
void NoScrollComboBox::wheelEvent(QWheelEvent *event) void NoScrollComboBox::wheelEvent(QWheelEvent *event)