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(
100 filterListByString(arg1);
104 void PIRSelectDeviceForm::on_ssClosePushButton_clicked()
106 ui->searchStringLineEdit->hide();
107 ui->searchStringLineEdit->lower();
108 ui->ssClosePushButton->hide();
109 ui->searchStringLineEdit->clear();
113 void PIRSelectDeviceForm::filterListByMake(
116 currentMake = (PIRMakeName) make;
121 void PIRSelectDeviceForm::filterListByDeviceType(
124 currentDevice = (PIRDeviceTypeName) deviceType;
129 void PIRSelectDeviceForm::filterListByString(
132 searchString = string;
137 void PIRSelectDeviceForm::refilterList()
140 int count = ui->deviceListWidget->count();
141 PIRKeysetWidgetItem *item;
142 while (index < count)
144 item = dynamic_cast<PIRKeysetWidgetItem *>(
145 ui->deviceListWidget->item(index));
147 // Does the keylist have the required make?
148 if ((currentMake == Any_Make) || (item->getMake() == currentMake))
150 // And does it have the required type?
151 if ( (currentDevice == Any_Device)
152 || (item->getDeviceType() == currentDevice))
154 // Does it match the search string?
155 if ( searchString.isEmpty()
156 || item->text().contains(searchString, Qt::CaseInsensitive))
158 // Yes, we can show this keylist:
159 item->setHidden(false);
163 item->setHidden(true);
168 item->setHidden(true);
173 item->setHidden(true);