Log In
New Account
  
Home My Page Project Cloud Code Snippets Project Openings Pierogi
Summary Forums Tracker Lists Tasks Docs News SCM Files
1 #include "pirselectdeviceform.h"
2 #include "ui_pirselectdeviceform.h"
3 #include "pirkeysetwidgetitem.h"
5 PIRDeviceTypeMgr deviceTypeManager;
7 extern PIRMakeMgr makeManager;
9 PIRSelectDeviceForm::PIRSelectDeviceForm(
10   QWidget *parent)
11   : QWidget(parent),
12     ui(new Ui::PIRSelectDeviceForm),
13     currentMake(Any_Make),
14     currentDevice(Any_Device)
15 {
16   ui->setupUi(this);
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:
26   connect(
27     ui->deviceListWidget,
28     SIGNAL(itemActivated(QListWidgetItem *)),
29     parent,
30     SLOT(keysetSelectionChanged(QListWidgetItem *)),
31     Qt::QueuedConnection);
33   // Connection used to filter keyset list:
34   connect(
35     ui->makeComboBox,
36     SIGNAL(currentIndexChanged(int)),
37     this,
38     SLOT(filterListByMake(int)),
39     Qt::QueuedConnection);
41   connect(
42     ui->deviceComboBox,
43     SIGNAL(currentIndexChanged(int)),
44     this,
45     SLOT(filterListByDeviceType(int)),
46     Qt::QueuedConnection);
47 }
49 PIRSelectDeviceForm::~PIRSelectDeviceForm()
50 {
51   delete ui;
52 }
54 /*
55 void PIRSelectDeviceForm::addNameToList(
56   QString name,
57   unsigned int index,
58   PIRMakeName make)
59 {
60   ui->deviceListWidget->addItem(new PIRKeysetWidgetItem(name, index, make));
61 }
62 */
64 void PIRSelectDeviceForm::addWidgetItem(
65   PIRKeysetWidgetItem *kwi)
66 {
67   ui->deviceListWidget->addItem(kwi);
68 }
70 QListWidget *PIRSelectDeviceForm::getDeviceListWidget()
71 {
72   return ui->deviceListWidget;
73 }
75 void PIRSelectDeviceForm::filterListByMake(
76   int make)
77 {
78   currentMake = (PIRMakeName) make;
79   refilterList();
80 }
82 void PIRSelectDeviceForm::filterListByDeviceType(
83   int deviceType)
84 {
85   currentDevice = (PIRDeviceTypeName) deviceType;
86   refilterList();
87 }
89 void PIRSelectDeviceForm::refilterList()
90 {
91   int index = 0;
92   int count = ui->deviceListWidget->count();
93   PIRKeysetWidgetItem *item;
94   while (index < count)
95   {
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))
101     {
102       // And does it have the required type?
103       if ( (currentDevice == Any_Device)
104         || (item->getDeviceType() == currentDevice))
105      {
106         // Yes, we can show this keylist:
107         item->setHidden(false);
108       }
109       else
110       {
111         item->setHidden(true);
112       }
113     }
114     else
115     {
116       item->setHidden(true);
117     }
119     ++index;
120   }

Terms of Use    Privacy Policy    Contribution Guidelines    Feedback

Powered By GForge Collaborative Development Environment