1 #include "pirselectdeviceform.h"
2 #include "ui_pirselectdeviceform.h"
3 #include "pirkeysetwidgetitem.h"
5 PIRDeviceTypeMgr deviceTypeManager;
7 extern PIRMakeMgr makeManager;
9 PIRSelectDeviceForm::PIRSelectDeviceForm(
12 ui(new Ui::PIRSelectDeviceForm),
13 currentMake(Any_Make),
14 currentDevice(Any_Device)
18 setAttribute(Qt::WA_Maemo5StackedWindow);
19 setWindowFlags(windowFlags() | Qt::Window);
21 // push the list of makers into the make combo box:
22 makeManager.populateComboBox(ui->makeComboBox);
23 deviceTypeManager.populateComboBox(ui->deviceComboBox);
25 // Connection telling main window that keyset has been selected:
28 SIGNAL(itemActivated(QListWidgetItem *)),
30 SLOT(keysetSelectionChanged(QListWidgetItem *)),
31 Qt::QueuedConnection);
33 // Connection used to filter keyset list:
36 SIGNAL(currentIndexChanged(int)),
38 SLOT(filterListByMake(int)),
39 Qt::QueuedConnection);
43 SIGNAL(currentIndexChanged(int)),
45 SLOT(filterListByDeviceType(int)),
46 Qt::QueuedConnection);
49 PIRSelectDeviceForm::~PIRSelectDeviceForm()
55 void PIRSelectDeviceForm::addNameToList(
60 ui->deviceListWidget->addItem(new PIRKeysetWidgetItem(name, index, make));
64 void PIRSelectDeviceForm::addWidgetItem(
65 PIRKeysetWidgetItem *kwi)
67 ui->deviceListWidget->addItem(kwi);
70 QListWidget *PIRSelectDeviceForm::getDeviceListWidget()
72 return ui->deviceListWidget;
75 void PIRSelectDeviceForm::filterListByMake(
78 currentMake = (PIRMakeName) make;
82 void PIRSelectDeviceForm::filterListByDeviceType(
85 currentDevice = (PIRDeviceTypeName) deviceType;
89 void PIRSelectDeviceForm::refilterList()
92 int count = ui->deviceListWidget->count();
93 PIRKeysetWidgetItem *item;
96 item = dynamic_cast<PIRKeysetWidgetItem *>(
97 ui->deviceListWidget->item(index));
99 // Does the keylist have the required make?
100 if ((currentMake == Any_Make) || (item->getMake() == currentMake))
102 // And does it have the required type?
103 if ( (currentDevice == Any_Device)
104 || (item->getDeviceType() == currentDevice))
106 // Yes, we can show this keylist:
107 item->setHidden(false);
111 item->setHidden(true);
116 item->setHidden(true);