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 "pirselectkeysetform.h"
2 #include "ui_pirselectkeysetform.h"
3 #include "pirkeysetwidgetitem.h"
5 extern PIRMakeMgr makeManager;
6 extern PIRDeviceTypeMgr deviceManager;
8 PIRSelectKeysetForm::PIRSelectKeysetForm(
9   QWidget *parent)
10   : QWidget(parent),
11     ui(new Ui::PIRSelectKeysetForm),
12     currentMake(Any_Make),
13     currentDevice(Any_Device)
14 {
15   ui->setupUi(this);
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:
25   connect(
26     ui->keysetListWidget,
27     SIGNAL(itemActivated(QListWidgetItem *)),
28     parent,
29     SLOT(keysetSelectionChanged(QListWidgetItem *)),
30     Qt::QueuedConnection);
32   // Connection used to filter keyset list:
33   connect(
34     ui->makeComboBox,
35     SIGNAL(currentIndexChanged(int)),
36     this,
37     SLOT(filterListByMake(int)),
38     Qt::QueuedConnection);
40   connect(
41     ui->deviceComboBox,
42     SIGNAL(currentIndexChanged(int)),
43     this,
44     SLOT(filterListByDeviceType(int)),
45     Qt::QueuedConnection);
46 }
48 PIRSelectKeysetForm::~PIRSelectKeysetForm()
49 {
50   delete ui;
51 }
53 void PIRSelectKeysetForm::addNameToList(
54   QString name,
55   unsigned int index,
56   PIRMakeName make)
57 {
58   ui->keysetListWidget->addItem(new PIRKeysetWidgetItem(name, index, make));
59 }
61 void PIRSelectKeysetForm::addWidgetItem(
62   PIRKeysetWidgetItem *kwi)
63 {
64   ui->keysetListWidget->addItem(kwi);
65 }
67 QListWidget *PIRSelectKeysetForm::getKeysetListWidget()
68 {
69   return ui->keysetListWidget;
70 }
72 void PIRSelectKeysetForm::filterListByMake(
73   int make)
74 {
75   currentMake = (PIRMakeName) make;
76   refilterList();
77 }
79 void PIRSelectKeysetForm::filterListByDeviceType(
80   int deviceType)
81 {
82   currentDevice = (PIRDeviceTypeName) deviceType;
83   refilterList();
84 }
86 void PIRSelectKeysetForm::refilterList()
87 {
88   int index = 0;
89   int count = ui->keysetListWidget->count();
90   PIRKeysetWidgetItem *item;
91   while (index < count)
92   {
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))
98     {
99       // And, does the keylist have the required device type?
100       if ((currentDevice == Any_Device)
101           || (item->supportsDeviceType(currentDevice)))
102       {
103         // Yes, we can show this keylist:
104         item->setHidden(false);
105       }
106       else
107       {
108         item->setHidden(true);
109       }
110     }
111     else
112     {
113       item->setHidden(true);
114     }
116     ++index;
117   }

Terms of Use    Privacy Policy    Contribution Guidelines    Feedback

Powered By GForge Collaborative Development Environment