src/hbcore/image/hbbadgeicon.cpp
changeset 5 627c4a0fd0e7
parent 0 16d8024aca5e
child 7 923ff622b8b9
equal deleted inserted replaced
3:11d3954df52a 5:627c4a0fd0e7
    21 ** If you have questions regarding the use of this file, please contact
    21 ** If you have questions regarding the use of this file, please contact
    22 ** Nokia at developer.feedback@nokia.com.
    22 ** Nokia at developer.feedback@nokia.com.
    23 **
    23 **
    24 ****************************************************************************/
    24 ****************************************************************************/
    25 
    25 
       
    26 #include "hbbadgeicon_p.h"
    26 #include "hbicon.h"
    27 #include "hbicon.h"
    27 #include "hbbadgeiconinfo_p.h"
    28 #include "hbbadgeiconinfo_p.h"
    28 #include "hbbadgeicon_p.h"
       
    29 #include <QPainter>
    29 #include <QPainter>
    30 
    30 
    31 /*!
    31 /*!
    32   @beta
    32   @beta
    33   @hbcore
    33   @hbcore
    77 {
    77 {
    78     HbBadgeIconInfo info(icon, alignment, zValue);
    78     HbBadgeIconInfo info(icon, alignment, zValue);
    79     int size = mBadgeIcons.size();
    79     int size = mBadgeIcons.size();
    80     if (size == 0) {
    80     if (size == 0) {
    81         mBadgeIcons.append(info);
    81         mBadgeIcons.append(info);
    82     }
    82     } else {
    83     else {
       
    84         bool added = false;
    83         bool added = false;
    85         //Find a spot to insert the badgeinfo in the list.
    84         //Find a spot to insert the badgeinfo in the list.
    86         for (int i = size - 1; i >= 0; i--){
    85         for (int i = size - 1; i >= 0; i--) {
    87             if (mBadgeIcons[i].zValue() > zValue){
    86             if (mBadgeIcons[i].zValue() > zValue) {
    88                 mBadgeIcons.insert(i + 1, info);
    87                 mBadgeIcons.insert(i + 1, info);
    89                 added = true;
    88                 added = true;
    90                 break;
    89                 break;
    91             }
    90             }
    92         }
    91         }
   145 /*!
   144 /*!
   146   \internal
   145   \internal
   147   Paint all badges in z-order.
   146   Paint all badges in z-order.
   148 */
   147 */
   149 void HbBadgeIcon::paint(QPainter *painter,
   148 void HbBadgeIcon::paint(QPainter *painter,
   150                         const QRectF& rect,
   149                         const QRectF &rect,
   151                         QIcon::Mode mode,
   150                         QIcon::Mode mode,
   152                         QIcon::State state,
   151                         QIcon::State state,
   153                         bool mirror)
   152                         bool mirror)
   154 {
   153 {
   155     int count = mBadgeIcons.count();
   154     int count = mBadgeIcons.count();
   168                 absAlign |= Qt::AlignLeft;
   167                 absAlign |= Qt::AlignLeft;
   169             }
   168             }
   170         }
   169         }
   171         // ... and then draw at the specified location.
   170         // ... and then draw at the specified location.
   172         aIcon.icon().paint(painter,
   171         aIcon.icon().paint(painter,
   173                  rect,
   172                            rect,
   174                  Qt::KeepAspectRatio,
   173                            Qt::KeepAspectRatio,
   175                  absAlign,
   174                            absAlign,
   176                  mode,
   175                            mode,
   177                  state);
   176                            state);
   178     }
   177     }
   179 }
   178 }
   180 
   179 
   181 /*!
   180 /*!
   182   \internal
   181   \internal
   183  */
   182  */
   184 void HbBadgeIcon::externalize(QDataStream& stream)
   183 void HbBadgeIcon::externalize(QDataStream &stream)
   185 {
   184 {
   186     int size = mBadgeIcons.size();
   185     int size = mBadgeIcons.size();
   187     // Write out how many badges we'll save first
   186     // Write out how many badges we'll save first
   188     stream << size;
   187     stream << size;
   189     // And write each item
   188     // And write each item
   197 
   196 
   198 
   197 
   199 /*!
   198 /*!
   200 \Internal
   199 \Internal
   201 */
   200 */
   202 void HbBadgeIcon::internalize(QDataStream& stream)
   201 void HbBadgeIcon::internalize(QDataStream &stream)
   203 {
   202 {
   204     int howManyBadges;
   203     int howManyBadges;
   205     stream >> howManyBadges;
   204     stream >> howManyBadges;
   206     for (int i = 0; i<howManyBadges; ++i) {
   205     for (int i = 0; i < howManyBadges; ++i) {
   207         qint32 align;
   206         qint32 align;
   208         qint32 zValue;
   207         qint32 zValue;
   209         HbIcon icon;
   208         HbIcon icon;
   210         stream >> icon;
   209         stream >> icon;
   211         stream >> align;
   210         stream >> align;