1 #include "pirselectkeysetform.h"
2 #include "ui_pirselectkeysetform.h"
3 #include "pirkeysetwidgetitem.h"
5 extern PIRMakeMgr makeManager;
6 extern PIRDeviceTypeMgr deviceManager;
8 PIRSelectKeysetForm::PIRSelectKeysetForm(
11 ui(new Ui::PIRSelectKeysetForm),
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 PIRSelectKeysetForm::~PIRSelectKeysetForm()
53 void PIRSelectKeysetForm::addNameToList(
58 ui->keysetListWidget->addItem(new PIRKeysetWidgetItem(name, index, make));
61 QListWidget *PIRSelectKeysetForm::getKeysetListWidget()
63 return ui->keysetListWidget;
66 void PIRSelectKeysetForm::filterListByMake(
69 currentMake = (PIRMakeName) make;
73 void PIRSelectKeysetForm::filterListByDeviceType(
76 currentDevice = (PIRDeviceTypeName) deviceType;
80 void PIRSelectKeysetForm::refilterList()
83 int count = ui->keysetListWidget->count();
84 PIRKeysetWidgetItem *item;
87 item = dynamic_cast<PIRKeysetWidgetItem *>(
88 ui->keysetListWidget->item(index));
90 // Does the keylist have the required make?
91 if ((currentMake == Any_Make) || (item->getMake() == currentMake))
93 // And, does the keylist have the required device type?
94 if ((currentDevice == Any_Device)
95 || (item->supportsDeviceType(currentDevice)))
97 // Yes, we can show this keylist:
98 item->setHidden(false);
102 item->setHidden(true);
107 item->setHidden(true);