1 #include "pirselectkeysetform.h"
2 #include "ui_pirselectkeysetform.h"
3 #include "pirkeysetwidgetitem.h"
6 extern PIRMakeMgr makeManager;
7 extern PIRDeviceTypeMgr deviceManager;
9 PIRSelectKeysetForm::PIRSelectKeysetForm(
12 ui(new Ui::PIRSelectKeysetForm),
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 deviceManager.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 PIRSelectKeysetForm::~PIRSelectKeysetForm()
54 void PIRSelectKeysetForm::addNameToList(
59 ui->keysetListWidget->addItem(new PIRKeysetWidgetItem(name, index, make));
62 void PIRSelectKeysetForm::addWidgetItem(
63 PIRKeysetWidgetItem *kwi)
65 ui->keysetListWidget->addItem(kwi);
68 QListWidget *PIRSelectKeysetForm::getKeysetListWidget()
70 return ui->keysetListWidget;
73 void PIRSelectKeysetForm::filterListByMake(
76 currentMake = (PIRMakeName) make;
80 void PIRSelectKeysetForm::filterListByDeviceType(
83 currentDevice = (PIRDeviceTypeName) deviceType;
87 void PIRSelectKeysetForm::refilterList()
90 int count = ui->keysetListWidget->count();
91 PIRKeysetWidgetItem *item;
94 item = dynamic_cast<PIRKeysetWidgetItem *>(
95 ui->keysetListWidget->item(index));
97 // Does the keylist have the required make?
98 if ((currentMake == Any_Make) || (item->getMake() == currentMake))
100 // And, does the keylist have the required device type?
101 if ((currentDevice == Any_Device)
102 || (item->supportsDeviceType(currentDevice)))
104 // Yes, we can show this keylist:
105 item->setHidden(false);
109 item->setHidden(true);
114 item->setHidden(true);