Merge pull request #150 from garakmon/speedup

Improve Combobox Speed & Autocompletion
This commit is contained in:
garak 2019-08-06 21:52:57 -04:00 committed by GitHub
commit e87d669e1d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 1 deletions

1
.gitignore vendored
View file

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

View file

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

View file

@ -1,10 +1,21 @@
#include "noscrollcombobox.h"
#include <QCompleter>
NoScrollComboBox::NoScrollComboBox(QWidget *parent)
: QComboBox(parent)
{
// Don't let scrolling hijack focus.
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)