equal
deleted
inserted
replaced
19 #include <QScopedPointer> |
19 #include <QScopedPointer> |
20 #include <HbPushButton> |
20 #include <HbPushButton> |
21 #include <HbSelectionDialog> |
21 #include <HbSelectionDialog> |
22 #include <HbLabel> |
22 #include <HbLabel> |
23 #include <HbExtendedLocale> |
23 #include <HbExtendedLocale> |
|
24 #include <HbAction> |
24 |
25 |
25 #include "nmipssettingsmultiselectionitem.h" |
26 #include "nmipssettingsmultiselectionitem.h" |
|
27 |
|
28 // CONSTANTS |
|
29 const QChar NmIpsSettingsMultiSelectionItemSpace(' '); |
26 |
30 |
27 /*! |
31 /*! |
28 \class NmIpsSettingsMultiSelectionItem |
32 \class NmIpsSettingsMultiSelectionItem |
29 \brief The class implements a custom HbDataFormViewItem for showing multi selection dialog. |
33 \brief The class implements a custom HbDataFormViewItem for showing multi selection dialog. |
30 |
34 |
33 // ======== MEMBER FUNCTIONS ======== |
37 // ======== MEMBER FUNCTIONS ======== |
34 |
38 |
35 /*! |
39 /*! |
36 Constructor of NmIpsSettingsMultiSelectionItem. |
40 Constructor of NmIpsSettingsMultiSelectionItem. |
37 */ |
41 */ |
38 |
|
39 |
|
40 NmIpsSettingsMultiSelectionItem::NmIpsSettingsMultiSelectionItem( |
42 NmIpsSettingsMultiSelectionItem::NmIpsSettingsMultiSelectionItem( |
41 QGraphicsItem *parent, Qt::WindowFlags wFlags) |
43 QGraphicsItem *parent, Qt::WindowFlags wFlags) |
42 : HbWidget(parent, wFlags), |
44 : HbWidget(parent, wFlags), |
43 mButton(0), |
45 mButton(0), |
44 mSelectionDialog(0) |
46 mSelectionDialog(0) |
173 |
175 |
174 \param action Dialog closing action. |
176 \param action Dialog closing action. |
175 */ |
177 */ |
176 void NmIpsSettingsMultiSelectionItem::selectionDialogClosed(HbAction *action) |
178 void NmIpsSettingsMultiSelectionItem::selectionDialogClosed(HbAction *action) |
177 { |
179 { |
178 if (action == mSelectionDialog->primaryAction()) { |
180 // TODO: Needs to be properly fixed when ever orbit supports |
|
181 // e.g. <code>void finished(int result)</code> type of signaling. |
|
182 // This is kind of hack but we do not want to compare button text to some string to |
|
183 // be certain which button was pressed (NOTE: Buttons are created and placed |
|
184 // by HbSelectionDialog). |
|
185 if (action == mSelectionDialog->actions().at(0)) { |
179 // Get selected items. |
186 // Get selected items. |
180 mSelectedItems = mSelectionDialog->selectedItems(); |
187 mSelectedItems = mSelectionDialog->selectedItems(); |
181 |
188 |
182 // Generate button text from selected items. |
189 // Generate button text from selected items. |
183 generateButtonText(); |
190 generateButtonText(); |
199 { |
206 { |
200 // Generate button text only if both properties are valid. |
207 // Generate button text only if both properties are valid. |
201 const int itemCount(mItems.count()); |
208 const int itemCount(mItems.count()); |
202 if (mItems.count() >= mSelectedItems.count()) { |
209 if (mItems.count() >= mSelectedItems.count()) { |
203 // Construct separator for button text. |
210 // Construct separator for button text. |
204 QChar groupSeparator = HbExtendedLocale::system().groupSeparator(); |
211 QChar groupSeparator(HbExtendedLocale::system().groupSeparator()); |
205 QString separator(" "); |
212 QString separator(groupSeparator); |
206 separator.insert(0, groupSeparator); |
213 if (!groupSeparator.isSpace()) { |
207 |
214 separator.append(NmIpsSettingsMultiSelectionItemSpace); |
|
215 } |
208 QString buttonText; |
216 QString buttonText; |
209 QListIterator<QVariant> itemIterator(mSelectedItems); |
217 QListIterator<QVariant> itemIterator(mSelectedItems); |
210 while (itemIterator.hasNext()) { |
218 while (itemIterator.hasNext()) { |
211 QVariant item(itemIterator.next()); |
219 QVariant item(itemIterator.next()); |
212 bool conversionOk(false); |
220 bool conversionOk(false); |
218 if (itemIterator.hasNext()) { |
226 if (itemIterator.hasNext()) { |
219 buttonText.append(separator); |
227 buttonText.append(separator); |
220 } |
228 } |
221 } |
229 } |
222 } |
230 } |
|
231 // If empty text is set to the button, next time when some "real" text is set to the button |
|
232 // the text is drawn from left to the center of button. Text is drawn multiple times to |
|
233 // wrong place while it travelling from left side to the center of button. |
|
234 // To prevent this feature, one space is set to button instead of real empty string. |
|
235 if (buttonText.isEmpty()) { |
|
236 buttonText = " "; |
|
237 } |
223 mButton->setText(buttonText); |
238 mButton->setText(buttonText); |
224 } |
239 } |
225 } |
240 } |