1 #include "pirselectdeviceform.h"
2 #include "ui_pirselectdeviceform.h"
3 #include "pirkeysetwidgetitem.h"
6 PIRDeviceTypeMgr deviceTypeManager;
8 extern PIRMakeMgr makeManager;
10 PIRSelectDeviceForm::PIRSelectDeviceForm(
13 ui(new Ui::PIRSelectDeviceForm),
14 currentMake(Any_Make),
15 currentDevice(Any_Device)
19 // Don't want to start with the line editor visible:
20 ui->searchStringLineEdit->hide();
21 ui->searchStringLineEdit->lower();
22 ui->ssClosePushButton->hide();
24 // Set some initial flags:
25 setAttribute(Qt::WA_Maemo5StackedWindow);
26 setWindowFlags(windowFlags() | Qt::Window);
28 // push the list of makers into the make combo box:
29 makeManager.populateComboBox(ui->makeComboBox);
30 deviceTypeManager.populateComboBox(ui->deviceComboBox);
32 // Connection telling main window that keyset has been selected:
35 SIGNAL(itemActivated(QListWidgetItem *)),
37 SLOT(keysetSelectionChanged(QListWidgetItem *)),
38 Qt::QueuedConnection);
40 // Connection used to filter keyset list:
43 SIGNAL(currentIndexChanged(int)),
45 SLOT(filterListByMake(int)),
46 Qt::QueuedConnection);
50 SIGNAL(currentIndexChanged(int)),
52 SLOT(filterListByDeviceType(int)),
53 Qt::QueuedConnection);
56 PIRSelectDeviceForm::~PIRSelectDeviceForm()
62 void PIRSelectDeviceForm::addNameToList(
67 ui->deviceListWidget->addItem(new PIRKeysetWidgetItem(name, index, make));
72 void PIRSelectDeviceForm::addWidgetItem(
73 PIRKeysetWidgetItem *kwi)
75 ui->deviceListWidget->addItem(kwi);
79 QListWidget *PIRSelectDeviceForm::getDeviceListWidget()
81 return ui->deviceListWidget;
85 void PIRSelectDeviceForm::keyPressEvent(
88 ui->searchStringLineEdit->show();
89 ui->searchStringLineEdit->raise();
90 ui->ssClosePushButton->show();
92 ui->searchStringLineEdit->setText(event->text());
93 ui->searchStringLineEdit->setFocus();
97 void PIRSelectDeviceForm::on_searchStringLineEdit_textChanged(const QString &arg1)
99 filterListByString(arg1);
103 void PIRSelectDeviceForm::on_ssClosePushButton_clicked()
105 ui->searchStringLineEdit->hide();
106 ui->searchStringLineEdit->lower();
107 ui->ssClosePushButton->hide();
108 ui->searchStringLineEdit->clear();
112 void PIRSelectDeviceForm::filterListByMake(
115 currentMake = (PIRMakeName) make;
120 void PIRSelectDeviceForm::filterListByDeviceType(
123 currentDevice = (PIRDeviceTypeName) deviceType;
128 void PIRSelectDeviceForm::filterListByString(
131 searchString = string;
136 void PIRSelectDeviceForm::refilterList()
139 int count = ui->deviceListWidget->count();
140 PIRKeysetWidgetItem *item;
141 while (index < count)
143 item = dynamic_cast<PIRKeysetWidgetItem *>(
144 ui->deviceListWidget->item(index));
146 // Does the keylist have the required make?
147 if ((currentMake == Any_Make) || (item->getMake() == currentMake))
149 // And does it have the required type?
150 if ( (currentDevice == Any_Device)
151 || (item->getDeviceType() == currentDevice))
153 // Does it match the search string?
154 if ( searchString.isEmpty()
155 || item->text().contains(searchString, Qt::CaseInsensitive))
157 // Yes, we can show this keylist:
158 item->setHidden(false);
162 item->setHidden(true);
167 item->setHidden(true);
172 item->setHidden(true);