ipsservices/nmipssettings/src/nmipssettingsmultiselectionitem.cpp
branchGCC_SURGE
changeset 55 cdd802add233
parent 53 bf7eb7911fc5
child 68 83cc6bae1de8
--- a/ipsservices/nmipssettings/src/nmipssettingsmultiselectionitem.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/ipsservices/nmipssettings/src/nmipssettingsmultiselectionitem.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -21,9 +21,13 @@
 #include <HbSelectionDialog>
 #include <HbLabel>
 #include <HbExtendedLocale>
+#include <HbAction>
 
 #include "nmipssettingsmultiselectionitem.h"
 
+// CONSTANTS
+const QChar NmIpsSettingsMultiSelectionItemSpace(' ');
+
 /*!
     \class NmIpsSettingsMultiSelectionItem
     \brief The class implements a custom HbDataFormViewItem for showing multi selection dialog.
@@ -35,8 +39,6 @@
 /*!
     Constructor of NmIpsSettingsMultiSelectionItem.
 */
-
-
 NmIpsSettingsMultiSelectionItem::NmIpsSettingsMultiSelectionItem(
     QGraphicsItem *parent, Qt::WindowFlags wFlags)
  : HbWidget(parent, wFlags),
@@ -175,7 +177,12 @@
 */
 void NmIpsSettingsMultiSelectionItem::selectionDialogClosed(HbAction *action)
 {
-    if (action == mSelectionDialog->primaryAction()) {
+    // TODO: Needs to be properly fixed when ever orbit supports
+    // e.g. <code>void finished(int result)</code> type of signaling.
+    // This is kind of hack but we do not want to compare button text to some string to
+    // be certain which button was pressed (NOTE: Buttons are created and placed
+    // by HbSelectionDialog).
+    if (action == mSelectionDialog->actions().at(0)) {
         // Get selected items.
         mSelectedItems = mSelectionDialog->selectedItems();
 
@@ -201,10 +208,11 @@
     const int itemCount(mItems.count());
     if (mItems.count() >= mSelectedItems.count()) {
         // Construct separator for button text.
-        QChar groupSeparator = HbExtendedLocale::system().groupSeparator();
-        QString separator(" ");
-        separator.insert(0, groupSeparator);
-
+        QChar groupSeparator(HbExtendedLocale::system().groupSeparator());
+        QString separator(groupSeparator);
+        if (!groupSeparator.isSpace()) {
+            separator.append(NmIpsSettingsMultiSelectionItemSpace);
+        }
         QString buttonText;
         QListIterator<QVariant> itemIterator(mSelectedItems);
         while (itemIterator.hasNext()) {
@@ -220,6 +228,13 @@
                 }
             }
         }
+        // If empty text is set to the button, next time when some "real" text is set to the button
+        // the text is drawn from left to the center of button. Text is drawn multiple times to
+        // wrong place while it travelling from left side to the center of button.
+        // To prevent this feature, one space is set to button instead of real empty string.
+        if (buttonText.isEmpty()) {
+            buttonText = " ";
+        }
         mButton->setText(buttonText);
     }
 }