|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: QT C++ based Class. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "dlgsetselector.h" |
|
19 #include <QtGui> |
|
20 |
|
21 DlgSetSelector::DlgSetSelector(QList<QString> list, QWidget* parent): |
|
22 QDialog(parent), setList(list), selectName("") |
|
23 { |
|
24 SetupUI(); |
|
25 } |
|
26 |
|
27 void DlgSetSelector::SetupUI() |
|
28 { |
|
29 QGridLayout *mainLayout = new QGridLayout(this); |
|
30 this->setLayout(mainLayout); |
|
31 this->setContextMenuPolicy(Qt::NoContextMenu); |
|
32 |
|
33 rdoNewSet = new QRadioButton(this); |
|
34 rdoNewSet->setChecked(true); |
|
35 rdoNewSet->setText(tr("Create a new Set")); |
|
36 QObject::connect(rdoNewSet, SIGNAL(clicked(bool)), this, |
|
37 SLOT(on_radio1Selection_Changed(bool))); |
|
38 rdoOldSet = new QRadioButton(this); |
|
39 rdoOldSet->setChecked(false); |
|
40 rdoOldSet->setText(tr("Select a exist set:")); |
|
41 QObject::connect(rdoOldSet, SIGNAL(clicked(bool)), this, |
|
42 SLOT(on_radio2Selection_Changed(bool))); |
|
43 |
|
44 lstSet = new QListWidget(this); |
|
45 for(int i=0;i<setList.count();i++) |
|
46 { |
|
47 lstSet->addItem(setList[i]); |
|
48 } |
|
49 lstSet->setEnabled(false); |
|
50 |
|
51 QWidget *toolWidget = new QWidget(this); |
|
52 toolWidget->setContextMenuPolicy(Qt::NoContextMenu); |
|
53 QGridLayout *toolLayout = new QGridLayout(this); |
|
54 toolWidget->setLayout(toolLayout); |
|
55 btnOk = new QPushButton(tr("Ok"), toolWidget); |
|
56 btnOk->setContextMenuPolicy(Qt::NoContextMenu); |
|
57 QObject::connect(btnOk, SIGNAL(clicked()), this, |
|
58 SLOT(on_btnOk_clicked())); |
|
59 btnCancel = new QPushButton(tr("Cancel"), toolWidget); |
|
60 btnCancel->setContextMenuPolicy(Qt::NoContextMenu); |
|
61 QObject::connect(btnCancel, SIGNAL(clicked()), this, |
|
62 SLOT(on_btnCancel_clicked())); |
|
63 toolLayout->addWidget(btnOk, 0, 0); |
|
64 toolLayout->addWidget(btnCancel, 0, 1); |
|
65 |
|
66 |
|
67 mainLayout->addWidget(rdoNewSet, 0, 0); |
|
68 mainLayout->addWidget(rdoOldSet, 1, 0); |
|
69 mainLayout->addWidget(lstSet, 2, 0); |
|
70 |
|
71 mainLayout->addWidget(toolWidget, 3, 0); |
|
72 this->showMaximized(); |
|
73 |
|
74 } |
|
75 void DlgSetSelector::on_radio1Selection_Changed(bool checked) |
|
76 { |
|
77 lstSet->setEnabled(false); |
|
78 } |
|
79 |
|
80 |
|
81 void DlgSetSelector::on_radio2Selection_Changed(bool checked) |
|
82 { |
|
83 lstSet->setEnabled(true); |
|
84 if(checked) |
|
85 { |
|
86 if(setList.count() == 0) |
|
87 { |
|
88 rdoNewSet->setChecked(true); |
|
89 } |
|
90 else |
|
91 { |
|
92 lstSet->setCurrentRow(0); |
|
93 } |
|
94 } |
|
95 |
|
96 } |
|
97 |
|
98 void DlgSetSelector::on_btnOk_clicked() |
|
99 { |
|
100 if(rdoOldSet->isChecked()) |
|
101 { |
|
102 selectName = lstSet->selectedItems()[0]->text(); |
|
103 } |
|
104 else |
|
105 { |
|
106 selectName = ""; |
|
107 } |
|
108 this->accept(); |
|
109 } |
|
110 |
|
111 void DlgSetSelector::on_btnCancel_clicked() |
|
112 { |
|
113 this->reject(); |
|
114 } |