#include "pirselectkeysetform.h"
#include "ui_pirselectkeysetform.h"
#include "pirkeysetwidgetitem.h"
-#include <QListWidget>
+//#include <QListWidget>
+#include <QKeyEvent>
extern PIRMakeMgr makeManager;
{
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);
Qt::QueuedConnection);
}
+
PIRSelectKeysetForm::~PIRSelectKeysetForm()
{
delete ui;
}
+
/*
void PIRSelectKeysetForm::addNameToList(
QString name,
}
*/
+
void PIRSelectKeysetForm::addWidgetItem(
PIRKeysetWidgetItem *kwi)
{
ui->keysetListWidget->addItem(kwi);
}
+
QListWidget *PIRSelectKeysetForm::getKeysetListWidget()
{
return ui->keysetListWidget;
}
+
+void PIRSelectKeysetForm::keyPressEvent(
+ QKeyEvent *event)
+{
+ ui->searchStringLineEdit->show();
+ ui->searchStringLineEdit->raise();
+ ui->ssClosePushButton->show();
+
+ ui->searchStringLineEdit->setText(event->text());
+ ui->searchStringLineEdit->setFocus();
+}
+
+
+void PIRSelectKeysetForm::on_searchStringLineEdit_textChanged(
+ const QString &arg1)
+{
+ filterListByString(arg1);
+}
+
+
+void PIRSelectKeysetForm::on_ssClosePushButton_clicked()
+{
+ ui->searchStringLineEdit->hide();
+ ui->searchStringLineEdit->lower();
+ ui->ssClosePushButton->hide();
+ ui->searchStringLineEdit->clear();
+}
+
+
void PIRSelectKeysetForm::filterListByMake(
int make)
{
refilterList();
}
+
+void PIRSelectKeysetForm::filterListByString(
+ QString string)
+{
+ searchString = string;
+ refilterList();
+}
+
+
void PIRSelectKeysetForm::refilterList()
{
int index = 0;
// Does the keylist have the required make?
if ((currentMake == Any_Make) || (item->getMake() == currentMake))
{
- // Yes, we can show this keylist:
- item->setHidden(false);
+ // Does this keylist 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
{