ckb-next  v0.2.8 at branch master
ckb-next driver for corsair devices
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
modeselectdialog.cpp
Go to the documentation of this file.
1 #include "modeselectdialog.h"
2 #include "ui_modeselectdialog.h"
3 
4 ModeSelectDialog::ModeSelectDialog(QWidget* parent, KbMode* currentMode, QList<KbMode*> modeList, const QString& textLabel) :
5  QDialog(parent), ui(new Ui::ModeSelectDialog),
6  _modeList(modeList)
7 {
8  ui->setupUi(this);
9  _modeList.removeAll(currentMode);
10  ui->label->setText(textLabel);
11  // Populate list
12  foreach(KbMode* mode, _modeList)
13  ui->modeList->addItem(mode->name());
14 }
15 
17  delete ui;
18 }
19 
20 QList<KbMode*> ModeSelectDialog::selection(){
21  QList<KbMode*> res;
22  int count = ui->modeList->count();
23  for(int i = 0; i < count; i++){
24  if(ui->modeList->item(i)->isSelected())
25  res.append(_modeList[i]);
26  }
27  return res;
28 }
29 
31  int count = ui->modeList->count();
32  for(int i = 0; i < count; i++)
33  ui->modeList->item(i)->setSelected(true);
34 }
35 
37  int count = ui->modeList->count();
38  for(int i = 0; i < count; i++)
39  ui->modeList->item(i)->setSelected(false);
40 }
ModeSelectDialog(QWidget *parent, KbMode *currentMode, QList< KbMode * > modeList, const QString &textLabel)
Ui::ModeSelectDialog * ui
QList< KbMode * > _modeList
Definition: kbmode.h:36
const QString & name() const
Definition: kbmode.h:50
void setupUi(QDialog *ModeSelectDialog)
QList< KbMode * > selection()