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 void PIRSelectKeysetForm::addWidgetItem(
62 PIRKeysetWidgetItem *kwi)
64 ui->keysetListWidget->addItem(kwi);
67 QListWidget *PIRSelectKeysetForm::getKeysetListWidget()
69 return ui->keysetListWidget;
72 void PIRSelectKeysetForm::filterListByMake(
75 currentMake = (PIRMakeName) make;
79 void PIRSelectKeysetForm::filterListByDeviceType(
82 currentDevice = (PIRDeviceTypeName) deviceType;
86 void PIRSelectKeysetForm::refilterList()
89 int count = ui->keysetListWidget->count();
90 PIRKeysetWidgetItem *item;
93 item = dynamic_cast<PIRKeysetWidgetItem *>(
94 ui->keysetListWidget->item(index));
96 // Does the keylist have the required make?
97 if ((currentMake == Any_Make) || (item->getMake() == currentMake))
99 // And, does the keylist have the required device type?
100 if ((currentDevice == Any_Device)
101 || (item->supportsDeviceType(currentDevice)))
103 // Yes, we can show this keylist:
104 item->setHidden(false);
108 item->setHidden(true);
113 item->setHidden(true);