1 #include "pirselectkeysetform.h"
2 #include "ui_pirselectkeysetform.h"
4 //#include <QListWidget>
5 //#include <QListWidgetItem>
8 #include "mainwindow.h"
9 #include "pirkeysetwidgetitem.h"
10 #include "dialogs/pireditkeysetdialog.h"
12 extern PIRMakeMgr makeManager;
14 PIRSelectKeysetForm::PIRSelectKeysetForm(
16 : QWidget(mw), // is this right?
17 ui(new Ui::PIRSelectKeysetForm),
24 // Don't want to start with the line editor visible:
25 ui->searchStringLineEdit->hide();
26 ui->searchStringLineEdit->lower();
27 ui->ssClosePushButton->hide();
29 // Set some initial flags:
30 setAttribute(Qt::WA_Maemo5StackedWindow);
31 setWindowFlags(windowFlags() | Qt::Window);
33 // push the list of makers into the make combo box:
34 makeManager.populateComboBox(ui->makeComboBox);
36 // Connection telling main window that keyset has been selected:
39 SIGNAL(itemActivated(QListWidgetItem *)),
41 SLOT(keysetSelectionChanged(QListWidgetItem *)),
42 Qt::QueuedConnection);
44 // Connection used to filter keyset list:
47 SIGNAL(currentIndexChanged(int)),
49 SLOT(filterListByMake(int)),
50 Qt::QueuedConnection);
52 // Open editor dialog for indivual keysets:
55 SIGNAL(itemClicked(QListWidgetItem *)),
57 SLOT(openKeysetDialog(QListWidgetItem *)),
58 Qt::QueuedConnection);
60 // Go ahead and construct the dialog window right now:
61 editDialog = new PIREditKeysetDialog(mainWindow);
65 PIRSelectKeysetForm::~PIRSelectKeysetForm()
72 void PIRSelectKeysetForm::addNameToList(
77 ui->keysetListWidget->addItem(new PIRKeysetWidgetItem(name, index, make));
82 void PIRSelectKeysetForm::addWidgetItem(
83 PIRKeysetWidgetItem *kwi)
85 ui->keysetListWidget->addItem(kwi);
89 QListWidget *PIRSelectKeysetForm::getKeysetListWidget()
91 return ui->keysetListWidget;
95 void PIRSelectKeysetForm::keyPressEvent(
98 ui->searchStringLineEdit->show();
99 ui->searchStringLineEdit->raise();
100 ui->ssClosePushButton->show();
102 ui->searchStringLineEdit->setText(event->text());
103 ui->searchStringLineEdit->setFocus();
107 void PIRSelectKeysetForm::on_searchStringLineEdit_textChanged(
110 filterListByString(arg1);
114 void PIRSelectKeysetForm::on_ssClosePushButton_clicked()
116 ui->searchStringLineEdit->hide();
117 ui->searchStringLineEdit->lower();
118 ui->ssClosePushButton->hide();
119 ui->searchStringLineEdit->clear();
123 void PIRSelectKeysetForm::filterListByMake(
126 currentMake = (PIRMakeName) make;
131 void PIRSelectKeysetForm::filterListByString(
134 searchString = string;
139 void PIRSelectKeysetForm::refilterList()
142 int count = ui->keysetListWidget->count();
143 PIRKeysetWidgetItem *item;
144 while (index < count)
146 item = dynamic_cast<PIRKeysetWidgetItem *>(
147 ui->keysetListWidget->item(index));
149 // Does the keylist have the required make?
150 if ((currentMake == Any_Make) || (item->getMake() == currentMake))
152 // Does this keylist match the search string?
153 if ( searchString.isEmpty()
154 || item->text().contains(searchString, Qt::CaseInsensitive))
156 // Yes, we can show this keylist:
157 item->setHidden(false);
161 item->setHidden(true);
166 item->setHidden(true);
174 void PIRSelectKeysetForm::openKeysetDialog(
175 QListWidgetItem *item)
177 PIRKeysetWidgetItem *kwi = dynamic_cast<PIRKeysetWidgetItem *>(item);
179 editDialog->setupDialog(kwi);