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 QListWidget *PIRSelectKeysetForm::getKeysetListWidget()
62 {
63   return ui->keysetListWidget;
64 }
66 void PIRSelectKeysetForm::filterListByMake(
67   int make)
68 {
69   currentMake = (PIRMakeName) make;
70   refilterList();
71 }
73 void PIRSelectKeysetForm::filterListByDeviceType(
74   int deviceType)
75 {
76   currentDevice = (PIRDeviceTypeName) deviceType;
77   refilterList();
78 }
80 void PIRSelectKeysetForm::refilterList()
81 {
82   int index = 0;
83   int count = ui->keysetListWidget->count();
84   PIRKeysetWidgetItem *item;
85   while (index < count)
86   {
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))
92     {
93       // And, does the keylist have the required device type?
94       if ((currentDevice == Any_Device)
95           || (item->supportsDeviceType(currentDevice)))
96       {
97         // Yes, we can show this keylist:
98         item->setHidden(false);
99       }
100       else
101       {
102         item->setHidden(true);
103       }
104     }
105     else
106     {
107       item->setHidden(true);
108     }
110     ++index;
111   }

Terms of Use    Privacy Policy    Contribution Guidelines    Feedback

Powered By GForge Collaborative Development Environment