1 #include "pirselectkeysetform.h"
2 #include "ui_pirselectkeysetform.h"
3 #include "pirkeysetwidgetitem.h"
4 //#include <QListWidget>
7 extern PIRMakeMgr makeManager;
9 PIRSelectKeysetForm::PIRSelectKeysetForm(
12 ui(new Ui::PIRSelectKeysetForm),
17 // Don't want to start with the line editor visible:
18 ui->searchStringLineEdit->hide();
19 ui->searchStringLineEdit->lower();
20 ui->ssClosePushButton->hide();
22 // Set some initial flags:
23 setAttribute(Qt::WA_Maemo5StackedWindow);
24 setWindowFlags(windowFlags() | Qt::Window);
26 // push the list of makers into the make combo box:
27 makeManager.populateComboBox(ui->makeComboBox);
29 // Connection telling main window that keyset has been selected:
32 SIGNAL(itemActivated(QListWidgetItem *)),
34 SLOT(keysetSelectionChanged(QListWidgetItem *)),
35 Qt::QueuedConnection);
37 // Connection used to filter keyset list:
40 SIGNAL(currentIndexChanged(int)),
42 SLOT(filterListByMake(int)),
43 Qt::QueuedConnection);
47 PIRSelectKeysetForm::~PIRSelectKeysetForm()
54 void PIRSelectKeysetForm::addNameToList(
59 ui->keysetListWidget->addItem(new PIRKeysetWidgetItem(name, index, make));
64 void PIRSelectKeysetForm::addWidgetItem(
65 PIRKeysetWidgetItem *kwi)
67 ui->keysetListWidget->addItem(kwi);
71 QListWidget *PIRSelectKeysetForm::getKeysetListWidget()
73 return ui->keysetListWidget;
77 void PIRSelectKeysetForm::keyPressEvent(
80 ui->searchStringLineEdit->show();
81 ui->searchStringLineEdit->raise();
82 ui->ssClosePushButton->show();
84 ui->searchStringLineEdit->setText(event->text());
85 ui->searchStringLineEdit->setFocus();
89 void PIRSelectKeysetForm::on_searchStringLineEdit_textChanged(
92 filterListByString(arg1);
96 void PIRSelectKeysetForm::on_ssClosePushButton_clicked()
98 ui->searchStringLineEdit->hide();
99 ui->searchStringLineEdit->lower();
100 ui->ssClosePushButton->hide();
101 ui->searchStringLineEdit->clear();
105 void PIRSelectKeysetForm::filterListByMake(
108 currentMake = (PIRMakeName) make;
113 void PIRSelectKeysetForm::filterListByString(
116 searchString = string;
121 void PIRSelectKeysetForm::refilterList()
124 int count = ui->keysetListWidget->count();
125 PIRKeysetWidgetItem *item;
126 while (index < count)
128 item = dynamic_cast<PIRKeysetWidgetItem *>(
129 ui->keysetListWidget->item(index));
131 // Does the keylist have the required make?
132 if ((currentMake == Any_Make) || (item->getMake() == currentMake))
134 // Does this keylist match the search string?
135 if ( searchString.isEmpty()
136 || item->text().contains(searchString, Qt::CaseInsensitive))
138 // Yes, we can show this keylist:
139 item->setHidden(false);
143 item->setHidden(true);
148 item->setHidden(true);