Added a filter option to the Language Chooser

This patch adds a filter option to the Language Chooser.
if you choose filter, only the filtered options will appear.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Tomaz Canabrava 2013-12-06 17:14:50 -02:00 committed by Dirk Hohndel
parent 32264cf393
commit 7436178fe0
3 changed files with 43 additions and 5 deletions

View file

@ -4,6 +4,7 @@
#include <QDebug>
#include <QFileDialog>
#include <QMessageBox>
#include <QSortFilterProxyModel>
PreferencesDialog* PreferencesDialog::instance()
{
@ -105,7 +106,11 @@ void PreferencesDialog::setUiFromPrefs()
ui.vertical_speed_minutes->setChecked(prefs.units.vertical_speed_time == units::MINUTES);
ui.vertical_speed_seconds->setChecked(prefs.units.vertical_speed_time == units::SECONDS);
ui.languageView->setModel( LanguageModel::instance() );
QSortFilterProxyModel *filterModel = new QSortFilterProxyModel();
filterModel->setSourceModel(LanguageModel::instance());
filterModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
ui.languageView->setModel(filterModel);
connect(ui.languageFilter, SIGNAL(textChanged(QString)), filterModel, SLOT(setFilterFixedString(QString)));
QSettings s;
s.beginGroup("Language");

View file

@ -25,7 +25,6 @@ public slots:
void gflowChanged(int gf);
void gfhighChanged(int gf);
private:
explicit PreferencesDialog(QWidget* parent = 0, Qt::WindowFlags f = 0);
void setUiFromPrefs();

View file

@ -131,7 +131,7 @@
</sizepolicy>
</property>
<property name="currentIndex">
<number>0</number>
<number>3</number>
</property>
<widget class="QWidget" name="page_2">
<layout class="QVBoxLayout" name="verticalLayout_3">
@ -828,7 +828,41 @@
</layout>
</widget>
<widget class="QWidget" name="page_4">
<layout class="QHBoxLayout" name="horizontalLayout_6">
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QCheckBox" name="languageSystemDefault">
<property name="text">
<string>System Default</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_14">
<property name="text">
<string>Filter</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="languageFilter"/>
</item>
</layout>
</item>
<item>
<widget class="QListView" name="languageView"/>
</item>
@ -1112,10 +1146,10 @@
</connection>
</connections>
<buttongroups>
<buttongroup name="buttonGroup"/>
<buttongroup name="verticalSpeed"/>
<buttongroup name="buttonGroup_2"/>
<buttongroup name="buttonGroup_3"/>
<buttongroup name="buttonGroup"/>
<buttongroup name="buttonGroup_4"/>
<buttongroup name="buttonGroup_5"/>
<buttongroup name="buttonGroup_6"/>