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 "selectionwindow.h"
2 #include "pirkeysetwidgetitem.h"
4 #include <QString>
6 #include "pirexception.h"
8 extern PIRMakeMgr makeManager;
10 SelectionWindow::SelectionWindow(
11   QWidget *parent)
12   : QWidget(parent)
13 {
14   // This widget will be the window holding everything else.
15   setAttribute(Qt::WA_Maemo5StackedWindow);
16   setWindowFlags(windowFlags() | Qt::Window);
17   setFixedSize(800, 445);
19   // First things first, need a QList of some sort to display the names:
20   nameListWidget = new QListWidget();
22   // Now, some filters:
23 //  deviceTypeLabel = new QLabel("Filter by Device Type:");
24 //  deviceTypeComboBox = new QComboBox();
25 //  deviceTypeComboBox->insertItem(0, QString("Any"));
26   makeLabel = new QLabel("Make:");
27 //  makeLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
28   makeComboBox = new QComboBox();
29   makeComboBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
30   makeManager.populateComboBox(makeComboBox);
31 //  makeComboBox->insertItem(0, QString("Any"));
33   layout = new QGridLayout;
34 //  layout->addWidget(deviceTypeLabel, 0, 0);
35 //  layout->addWidget(deviceTypeComboBox, 1, 0);
36   layout->addWidget(makeLabel, 0, 0);
37   layout->addWidget(makeComboBox, 0, 1);
38   layout->addWidget(nameListWidget, 1, 0, 1, 2);
40   setLayout(layout);
42   connect(
43     nameListWidget,
44     SIGNAL(itemActivated(QListWidgetItem *)),
45     parent,
46     SLOT(keysetSelectionChanged(QListWidgetItem *)),
47     Qt::QueuedConnection);
49   connect(
50     makeComboBox,
51     SIGNAL(currentIndexChanged(int)),
52     this,
53     SLOT(filterListByMake(int)),
54     Qt::QueuedConnection);
55 }
58 SelectionWindow::~SelectionWindow()
59 {
60 //  if (deviceTypeLabel) delete deviceTypeLabel;
61 //  if (deviceTypeComboBox) delete deviceTypeComboBox;
62   if (makeLabel) delete makeLabel;
63   if (makeComboBox) delete makeComboBox;
64   if (layout) delete layout;
65   if (nameListWidget) delete nameListWidget;
66 }
69 void SelectionWindow::addNameToList(
70   QString name,
71   unsigned int index,
72   PIRMakeName make)
73 {
74   nameListWidget->addItem(new PIRKeysetWidgetItem(name, index, make));
75 }
78 void SelectionWindow::filterListByMake(
79   int make)
80 {
81   int index = 0;
82   int count = nameListWidget->count();
83   PIRKeysetWidgetItem *item;
84   while (index < count)
85   {
86     item = dynamic_cast<PIRKeysetWidgetItem *>(nameListWidget->item(index));
87     if ((make == Any_Make) || (item->getMake() == make))
88     {
89       item->setHidden(false);
90     }
91     else
92     {
93       item->setHidden(true);
94     }
96     ++index;
97   }
98 }

Terms of Use    Privacy Policy    Contribution Guidelines    Feedback

Powered By GForge Collaborative Development Environment