39 |
39 |
40 /*! |
40 /*! |
41 @beta |
41 @beta |
42 @hbwidgets |
42 @hbwidgets |
43 \class HbSelectionDialog |
43 \class HbSelectionDialog |
44 \brief HbSelectionDialog class allows user create a list of options out of which one or more can be selected. |
44 \brief HbSelectionDialog class allows user to create a list of options out of which one or more can be selected. |
45 |
45 |
46 HbSelectionDialog is a modal dialog which means once it is displayed, user can not perform any action |
46 SelectionDialog is a modal dialog, for which user has to use default or custom action buttons to dismiss the dialog. |
47 untill dialog is closed. |
47 |
48 |
48 There are 2 modes of selection for SelectionDialog. SingleSelection or MultiSelection.<br> |
49 There can be 2 modes of selection. SingleSelection or MultiSelection. If it is SingleSelection, dialog is closed |
49 |
50 as soon as user clicks one of the options.In case of MultiSelection, user has to explicitly press "OK" button to |
50 <b>SingleSelection</b>: User can select one item from the list at a time and the SelectionDialog will be dismissed |
51 close it after selecting the item(s). User can anytime press "Cancel" button to close the dialog without selecting |
51 as soon as the user selects the item.<br> |
52 anything. |
52 |
|
53 <b>MultiSelection</b>: User can select multiple items from the list. To dismiss the dialog user has to explicitly press "OK/Cancel" button. |
|
54 User can anytime press "Cancel" button to close the dialog without any selection. |
53 |
55 |
54 User can provide the data for options in different forms. It can be simple list of strings, list of custom |
56 User can provide the data for options in different forms. It can be simple list of strings, list of custom |
55 items or a model itself. |
57 items or a model itself. |
56 */ |
58 |
57 |
59 Below is a snippet of code which shows SelectionDialog in a single selection mode. |
58 |
60 |
59 /*! |
61 \snippet{ultimatecodesnippet/ultimatecodesnippet.cpp,55} |
60 @beta |
62 |
|
63 slot implementation: |
|
64 |
|
65 \snippet{ultimatecodesnippet/ultimatecodesnippet.cpp,56} |
|
66 |
|
67 */ |
|
68 |
|
69 |
|
70 /*! |
61 Constructor of HbSelectionDialog |
71 Constructor of HbSelectionDialog |
62 |
72 |
63 \param parent. Parent widget |
73 \param parent Parent item to SelectionDialog. |
64 */ |
74 */ |
65 HbSelectionDialog::HbSelectionDialog(QGraphicsItem* parent): |
75 HbSelectionDialog::HbSelectionDialog(QGraphicsItem* parent): |
66 HbDialog(*new HbSelectionDialogPrivate, parent) |
76 HbDialog(*new HbSelectionDialogPrivate, parent) |
67 { |
77 { |
68 Q_D(HbSelectionDialog); |
78 Q_D(HbSelectionDialog); |
69 d->init(); |
79 d->init(); |
70 setDismissPolicy(NoDismiss); |
80 setDismissPolicy(NoDismiss); |
71 } |
81 } |
72 |
82 |
73 /*! |
83 /*! |
74 @beta |
|
75 Destructor |
84 Destructor |
76 */ |
85 */ |
77 HbSelectionDialog::~HbSelectionDialog() |
86 HbSelectionDialog::~HbSelectionDialog() |
78 { |
87 { |
79 } |
88 } |
80 |
89 |
81 /*! |
90 /*! |
82 @beta |
|
83 |
|
84 \reimp |
91 \reimp |
85 */ |
92 */ |
86 void HbSelectionDialog::showEvent(QShowEvent *event) |
93 void HbSelectionDialog::showEvent(QShowEvent *event) |
87 { |
94 { |
88 HbDialog::showEvent(event); |
95 HbDialog::showEvent(event); |
89 } |
96 } |
90 |
97 |
91 /*! |
98 /*! |
92 @beta |
|
93 Sets the \a SelectionMode of the list. |
99 Sets the \a SelectionMode of the list. |
94 |
100 |
95 \param mode. It can be SingleSelection or MultiSelection .Default value is \a NoSelection. |
101 \param mode It can be SingleSelection or MultiSelection. |
96 |
102 |
97 \sa selectionMode() |
103 \sa selectionMode() |
98 */ |
104 */ |
99 void HbSelectionDialog::setSelectionMode(HbAbstractItemView::SelectionMode mode) |
105 void HbSelectionDialog::setSelectionMode(HbAbstractItemView::SelectionMode mode) |
100 { |
106 { |
114 Q_D(const HbSelectionDialog); |
119 Q_D(const HbSelectionDialog); |
115 return d->mSelectionMode; |
120 return d->mSelectionMode; |
116 } |
121 } |
117 |
122 |
118 /*! |
123 /*! |
119 @beta |
|
120 Sets the string list items to be displayed. |
124 Sets the string list items to be displayed. |
121 |
125 |
122 \param items. A items is the list of strings |
126 \param items list of string items as input to SelectionDialog in QStringList format. |
123 \param currentIndex. A currentIndex is the index of default selection |
127 \param currentIndex index of item to be selected in the SelectionDialog by default. |
124 |
128 |
125 \sa stringItems() |
129 \sa stringItems() |
126 */ |
130 */ |
127 void HbSelectionDialog::setStringItems(const QStringList &items,int currentIndex) |
131 void HbSelectionDialog::setStringItems(const QStringList &items,int currentIndex) |
128 { |
132 { |
129 Q_D(HbSelectionDialog); |
133 Q_D(HbSelectionDialog); |
130 d->setStringItems(items,currentIndex); |
134 d->setStringItems(items,currentIndex); |
131 } |
135 } |
132 |
136 |
133 /*! |
137 /*! |
134 @beta |
|
135 Returns list of string list items earlier set by setStringItems(). |
138 Returns list of string list items earlier set by setStringItems(). |
136 |
139 |
137 \sa setStringItems() |
140 \sa setStringItems() |
138 */ |
141 */ |
139 QStringList HbSelectionDialog::stringItems() const |
142 QStringList HbSelectionDialog::stringItems() const |
141 Q_D(const HbSelectionDialog); |
144 Q_D(const HbSelectionDialog); |
142 return d->stringItems(); |
145 return d->stringItems(); |
143 } |
146 } |
144 |
147 |
145 /*! |
148 /*! |
146 @beta |
|
147 Returns list of selected indexes. List contains only one item if |
149 Returns list of selected indexes. List contains only one item if |
148 \a SelectionMode is \a NoSelection or \a SingleSelection. It may |
150 \a SelectionMode is \a NoSelection or \a SingleSelection. It may |
149 contain more items if \a SelectionMode is \a MultiSelection. |
151 contain more items if \a SelectionMode is \a MultiSelection. |
150 |
152 |
151 \sa setSelectionMode(), |
153 \sa setSelectionMode(), |
156 Q_D(const HbSelectionDialog); |
158 Q_D(const HbSelectionDialog); |
157 return d->selectedItems(); |
159 return d->selectedItems(); |
158 } |
160 } |
159 |
161 |
160 /*! |
162 /*! |
161 @beta |
|
162 set the item selected. |
163 set the item selected. |
163 It can select one item if \a Selection mode is \a SingleSelection |
164 It can select one item if \a Selection mode is \a SingleSelection |
164 it can select more item if \a SelectionMode is \a MultiSelection. |
165 it can select more item if \a SelectionMode is \a MultiSelection. |
165 |
166 |
166 \param items. |
167 \param items indices of the items to be selected in SelectionDialog. |
167 |
168 |
168 \sa selectedItems |
169 \sa selectedItems |
169 */ |
170 */ |
170 void HbSelectionDialog::setSelectedItems(const QList<QVariant> items) |
171 void HbSelectionDialog::setSelectedItems(const QList<QVariant> items) |
171 { |
172 { |
172 Q_D(HbSelectionDialog); |
173 Q_D(HbSelectionDialog); |
173 d->setSelectedItems(items); |
174 d->setSelectedItems(items); |
174 } |
175 } |
175 |
176 |
176 /*! |
177 /*! |
177 @beta |
|
178 Returns list of selected model indexes. List contains only one item if |
178 Returns list of selected model indexes. List contains only one item if |
179 \a SelectionMode is \a NoSelection or \a SingleSelection. It may |
179 \a SelectionMode is \a NoSelection or \a SingleSelection. It may |
180 contain more items if \a SelectionMode is \a MultiSelection. |
180 contain more items if \a SelectionMode is \a MultiSelection. |
181 |
181 |
182 \sa setSelectionMode(), |
182 \sa setSelectionMode(), |
187 Q_D(const HbSelectionDialog); |
187 Q_D(const HbSelectionDialog); |
188 return d->selectedModelIndexes(); |
188 return d->selectedModelIndexes(); |
189 } |
189 } |
190 |
190 |
191 /*! |
191 /*! |
192 @beta |
|
193 Sets the list of custom list items to be displayed.\a items is the |
192 Sets the list of custom list items to be displayed.\a items is the |
194 list of custom items.\a bTransferOwnership is a flag defining the owner |
193 list of custom items.\a bTransferOwnership is a flag defining the owner |
195 of the items. If \a true, items will be deleted when dialog is deleted else |
194 of the items. If \a true, items will be deleted when dialog is deleted else |
196 user is responsible for deleting the items.Default value is \a false. |
195 user is responsible for deleting the items.Default value is \a false. |
197 \a current is the index of default selection. |
196 \a current is the index of default selection. |
198 |
197 |
199 \param items. items is the list of custom items |
198 \param items list of custom items to be set as input to SelectionDialog. |
200 \param transferOwnership. true or false |
199 \param transferOwnership Transfer the ownership of items to SelectionDialog by passing true else false. |
201 \param currentIndex |
200 \param currentIndex index of the item to be selected in SelectionDialog. |
202 |
201 |
203 \sa widgetItems(); |
202 \sa widgetItems(); |
204 */ |
203 */ |
205 void HbSelectionDialog::setWidgetItems(const QList<HbListWidgetItem*> &items,bool transferOwnership,int currentIndex) |
204 void HbSelectionDialog::setWidgetItems(const QList<HbListWidgetItem*> &items,bool transferOwnership,int currentIndex) |
206 { |
205 { |
207 Q_D(HbSelectionDialog); |
206 Q_D(HbSelectionDialog); |
208 d->setWidgetItems(items,transferOwnership,currentIndex); |
207 d->setWidgetItems(items,transferOwnership,currentIndex); |
209 } |
208 } |
210 |
209 |
211 /*! |
210 /*! |
212 @beta |
|
213 Returns list of custom list items earlier set by setWidgetItems(). |
211 Returns list of custom list items earlier set by setWidgetItems(). |
214 |
212 |
215 \sa setWidgetItems(). |
213 \sa setWidgetItems(). |
216 */ |
214 */ |
217 QList<HbListWidgetItem*> HbSelectionDialog::widgetItems() const |
215 QList<HbListWidgetItem*> HbSelectionDialog::widgetItems() const |
219 Q_D(const HbSelectionDialog); |
217 Q_D(const HbSelectionDialog); |
220 return d->widgetItems(); |
218 return d->widgetItems(); |
221 } |
219 } |
222 |
220 |
223 /*! |
221 /*! |
224 @beta |
|
225 Sets the Model containing data for the list items. |
222 Sets the Model containing data for the list items. |
226 |
223 |
227 \param model. |
224 \param model which has data for items to be set as input to SelectionDialog. |
228 |
225 |
229 \sa model() |
226 \sa model() |
230 */ |
227 */ |
231 void HbSelectionDialog::setModel(QAbstractItemModel* model) |
228 void HbSelectionDialog::setModel(QAbstractItemModel* model) |
232 { |
229 { |
233 Q_D(HbSelectionDialog); |
230 Q_D(HbSelectionDialog); |
234 d->setModel(model); |
231 d->setModel(model); |
235 } |
232 } |
236 |
233 |
237 /*! |
234 /*! |
238 @beta |
|
239 Returns model eariler set by setModel(). |
235 Returns model eariler set by setModel(). |
240 |
236 |
241 \sa setModel() |
237 \sa setModel() |
242 */ |
238 */ |
243 QAbstractItemModel* HbSelectionDialog::model() const |
239 QAbstractItemModel* HbSelectionDialog::model() const |
244 { |
240 { |
245 Q_D(const HbSelectionDialog); |
241 Q_D(const HbSelectionDialog); |
246 return d->model(); |
242 return d->model(); |
247 } |
243 } |
248 |
244 |
249 |
|
250 #include "moc_hbselectiondialog.cpp" |
245 #include "moc_hbselectiondialog.cpp" |