X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=pirselectdeviceform.cpp;fp=pirselectdeviceform.cpp;h=021cc079f46aac0e46b8695c5d361208d424e668;hb=04d45dab5c6b32e9214fa21b7ade432da95c8a98;hp=4eb5ed3f3c0272d58105eb7c63be187ebc575da5;hpb=7176298055beaf1a9ad8f9fd1099f93df3461265;p=pierogi diff --git a/pirselectdeviceform.cpp b/pirselectdeviceform.cpp index 4eb5ed3..021cc07 100644 --- a/pirselectdeviceform.cpp +++ b/pirselectdeviceform.cpp @@ -1,6 +1,7 @@ #include "pirselectdeviceform.h" #include "ui_pirselectdeviceform.h" #include "pirkeysetwidgetitem.h" +#include PIRDeviceTypeMgr deviceTypeManager; @@ -15,6 +16,12 @@ PIRSelectDeviceForm::PIRSelectDeviceForm( { ui->setupUi(this); + // Don't want to start with the line editor visible: + ui->searchStringLineEdit->hide(); + ui->searchStringLineEdit->lower(); + ui->ssClosePushButton->hide(); + + // Set some initial flags: setAttribute(Qt::WA_Maemo5StackedWindow); setWindowFlags(windowFlags() | Qt::Window); @@ -61,17 +68,47 @@ void PIRSelectDeviceForm::addNameToList( } */ + void PIRSelectDeviceForm::addWidgetItem( PIRKeysetWidgetItem *kwi) { ui->deviceListWidget->addItem(kwi); } + QListWidget *PIRSelectDeviceForm::getDeviceListWidget() { return ui->deviceListWidget; } + +void PIRSelectDeviceForm::keyPressEvent( + QKeyEvent *event) +{ + ui->searchStringLineEdit->show(); + ui->searchStringLineEdit->raise(); + ui->ssClosePushButton->show(); + + ui->searchStringLineEdit->setText(event->text()); + ui->searchStringLineEdit->setFocus(); +} + + +void PIRSelectDeviceForm::on_searchStringLineEdit_textChanged(const QString &arg1) +{ + filterListByString(arg1); +} + + +void PIRSelectDeviceForm::on_ssClosePushButton_clicked() +{ + ui->searchStringLineEdit->hide(); + ui->searchStringLineEdit->lower(); + ui->ssClosePushButton->hide(); + ui->searchStringLineEdit->clear(); +} + + void PIRSelectDeviceForm::filterListByMake( int make) { @@ -79,6 +116,7 @@ void PIRSelectDeviceForm::filterListByMake( refilterList(); } + void PIRSelectDeviceForm::filterListByDeviceType( int deviceType) { @@ -86,6 +124,15 @@ void PIRSelectDeviceForm::filterListByDeviceType( refilterList(); } + +void PIRSelectDeviceForm::filterListByString( + QString string) +{ + searchString = string; + refilterList(); +} + + void PIRSelectDeviceForm::refilterList() { int index = 0; @@ -103,8 +150,17 @@ void PIRSelectDeviceForm::refilterList() if ( (currentDevice == Any_Device) || (item->getDeviceType() == currentDevice)) { - // Yes, we can show this keylist: - item->setHidden(false); + // Does it match the search string? + if ( searchString.isEmpty() + || item->text().contains(searchString, Qt::CaseInsensitive)) + { + // Yes, we can show this keylist: + item->setHidden(false); + } + else + { + item->setHidden(true); + } } else {