ipsservices/nmipssettings/src/nmipssettingsmultiselectionitem.cpp
changeset 53 bf7eb7911fc5
parent 30 759dc5235cdb
child 68 83cc6bae1de8
equal deleted inserted replaced
30:759dc5235cdb 53:bf7eb7911fc5
    23 #include <HbExtendedLocale>
    23 #include <HbExtendedLocale>
    24 #include <HbAction>
    24 #include <HbAction>
    25 
    25 
    26 #include "nmipssettingsmultiselectionitem.h"
    26 #include "nmipssettingsmultiselectionitem.h"
    27 
    27 
       
    28 // CONSTANTS
       
    29 const QChar NmIpsSettingsMultiSelectionItemSpace(' ');
       
    30 
    28 /*!
    31 /*!
    29     \class NmIpsSettingsMultiSelectionItem
    32     \class NmIpsSettingsMultiSelectionItem
    30     \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.
    31 
    34 
    32 */
    35 */
    34 // ======== MEMBER FUNCTIONS ========
    37 // ======== MEMBER FUNCTIONS ========
    35 
    38 
    36 /*!
    39 /*!
    37     Constructor of NmIpsSettingsMultiSelectionItem.
    40     Constructor of NmIpsSettingsMultiSelectionItem.
    38 */
    41 */
    39 
       
    40 
       
    41 NmIpsSettingsMultiSelectionItem::NmIpsSettingsMultiSelectionItem(
    42 NmIpsSettingsMultiSelectionItem::NmIpsSettingsMultiSelectionItem(
    42     QGraphicsItem *parent, Qt::WindowFlags wFlags)
    43     QGraphicsItem *parent, Qt::WindowFlags wFlags)
    43  : HbWidget(parent, wFlags),
    44  : HbWidget(parent, wFlags),
    44    mButton(0),
    45    mButton(0),
    45    mSelectionDialog(0)
    46    mSelectionDialog(0)
   205 {
   206 {
   206     // Generate button text only if both properties are valid.
   207     // Generate button text only if both properties are valid.
   207     const int itemCount(mItems.count());
   208     const int itemCount(mItems.count());
   208     if (mItems.count() >= mSelectedItems.count()) {
   209     if (mItems.count() >= mSelectedItems.count()) {
   209         // Construct separator for button text.
   210         // Construct separator for button text.
   210         QChar groupSeparator = HbExtendedLocale::system().groupSeparator();
   211         QChar groupSeparator(HbExtendedLocale::system().groupSeparator());
   211         QString separator(" ");
   212         QString separator(groupSeparator);
   212         separator.insert(0, groupSeparator);
   213         if (!groupSeparator.isSpace()) {
   213 
   214             separator.append(NmIpsSettingsMultiSelectionItemSpace);
       
   215         }
   214         QString buttonText;
   216         QString buttonText;
   215         QListIterator<QVariant> itemIterator(mSelectedItems);
   217         QListIterator<QVariant> itemIterator(mSelectedItems);
   216         while (itemIterator.hasNext()) {
   218         while (itemIterator.hasNext()) {
   217             QVariant item(itemIterator.next());
   219             QVariant item(itemIterator.next());
   218             bool conversionOk(false);
   220             bool conversionOk(false);
   224                 if (itemIterator.hasNext()) {
   226                 if (itemIterator.hasNext()) {
   225                     buttonText.append(separator);
   227                     buttonText.append(separator);
   226                 }
   228                 }
   227             }
   229             }
   228         }
   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         }
   229         mButton->setText(buttonText);
   238         mButton->setText(buttonText);
   230     }
   239     }
   231 }
   240 }