1 #include "pirselectdeviceform.h"
2 #include "ui_pirselectdeviceform.h"
3 #include "pirkeysetwidgetitem.h"
5 extern PIRMakeMgr makeManager;
6 extern PIRDeviceTypeMgr deviceManager;
8 PIRSelectDeviceForm::PIRSelectDeviceForm(
11 ui(new Ui::PIRSelectDeviceForm),
12 currentMake(Any_Make),
13 currentDevice(Any_Device)
17 setAttribute(Qt::WA_Maemo5StackedWindow);
18 setWindowFlags(windowFlags() | Qt::Window);
20 // push the list of makers into the make combo box:
21 makeManager.populateComboBox(ui->makeComboBox);
22 deviceManager.populateComboBox(ui->deviceComboBox);
24 // Connection telling main window that keyset has been selected:
27 SIGNAL(itemActivated(QListWidgetItem *)),
29 SLOT(keysetSelectionChanged(QListWidgetItem *)),
30 Qt::QueuedConnection);
32 // Connection used to filter keyset list:
35 SIGNAL(currentIndexChanged(int)),
37 SLOT(filterListByMake(int)),
38 Qt::QueuedConnection);
42 SIGNAL(currentIndexChanged(int)),
44 SLOT(filterListByDeviceType(int)),
45 Qt::QueuedConnection);
48 PIRSelectDeviceForm::~PIRSelectDeviceForm()
53 void PIRSelectDeviceForm::addNameToList(
58 ui->deviceListWidget->addItem(new PIRKeysetWidgetItem(name, index, make));
61 void PIRSelectDeviceForm::addWidgetItem(
62 PIRKeysetWidgetItem *kwi)
64 ui->deviceListWidget->addItem(kwi);
67 QListWidget *PIRSelectDeviceForm::getDeviceListWidget()
69 return ui->deviceListWidget;
72 void PIRSelectDeviceForm::filterListByMake(
75 currentMake = (PIRMakeName) make;
79 void PIRSelectDeviceForm::filterListByDeviceType(
82 currentDevice = (PIRDeviceTypeName) deviceType;
86 void PIRSelectDeviceForm::refilterList()
89 int count = ui->deviceListWidget->count();
90 PIRKeysetWidgetItem *item;
93 item = dynamic_cast<PIRKeysetWidgetItem *>(
94 ui->deviceListWidget->item(index));
96 // Does the keylist have the required make?
97 if ((currentMake == Any_Make) || (item->getMake() == currentMake))
99 // And does it have the required type?
100 if ( (currentDevice == Any_Device)
101 || (item->getDeviceType() == currentDevice))
103 // Yes, we can show this keylist:
104 item->setHidden(false);
108 item->setHidden(true);
113 item->setHidden(true);