src/hbwidgets/itemviews/hbgridviewitem_p.cpp
changeset 34 ed14f46c0e55
parent 0 16d8024aca5e
equal deleted inserted replaced
31:7516d6d86cf5 34:ed14f46c0e55
    23 **
    23 **
    24 ****************************************************************************/
    24 ****************************************************************************/
    25 
    25 
    26 #include <hbgridviewitem.h>
    26 #include <hbgridviewitem.h>
    27 #include <hbgridviewitem_p.h>
    27 #include <hbgridviewitem_p.h>
       
    28 #include <hbiconitem.h>
       
    29 #include <hbtextitem.h>
    28 
    30 
    29 #include <hbeffect.h>
    31 #include <hbeffect.h>
    30 
    32 
    31 #include "hbgridview_p.h"
    33 #include "hbgridview_p.h"
    32 
    34 
   104     }
   106     }
   105 
   107 
   106     if (    mTextValid
   108     if (    mTextValid
   107         &&  !mTextItem) {
   109         &&  !mTextItem) {
   108         mItemsChanged = true;
   110         mItemsChanged = true;
   109         mTextItem = q->style()->createPrimitive(HbStyle::P_GridViewItem_text, q);
   111         mTextItem = q->style()->createPrimitive(HbStyle::PT_TextItem, QLatin1String("text"), q);
   110        }
   112         HbTextItem *textItem = qobject_cast<HbTextItem*>(mTextItem);
   111     else if (   !mTextValid
   113         if (textItem) {
   112              && mTextItem) {
   114             textItem->setAlignment(Qt::AlignCenter);
       
   115         }
       
   116     } else if (   !mTextValid
       
   117                && mTextItem) {
   113         mItemsChanged = true;
   118         mItemsChanged = true;
   114         delete mTextItem;
   119         delete mTextItem;
   115         mTextItem = 0;
   120         mTextItem = 0;
   116     }
   121     }
   117 }
   122 }
   138     }
   143     }
   139 
   144 
   140     if (    mIconValid
   145     if (    mIconValid
   141         &&  !mIconItem) {
   146         &&  !mIconItem) {
   142         mItemsChanged = true;
   147         mItemsChanged = true;
   143         mIconItem = q->style()->createPrimitive(HbStyle::P_GridViewItem_icon, q);
   148         mIconItem = q->style()->createPrimitive(HbStyle::PT_IconItem, QLatin1String("icon"), 0);
       
   149         mIconItem->setParentItem(q); // To enable asynchronous icon loading.
       
   150         HbIconItem *iconItem = qobject_cast<HbIconItem*>(mIconItem);
       
   151         if (iconItem) {
       
   152             iconItem->setAlignment(Qt::AlignCenter);
       
   153         }
   144     }
   154     }
   145     else if (   !mIconValid
   155     else if (   !mIconValid
   146             &&  mIconItem) {
   156             &&  mIconItem) {
   147         mItemsChanged = true;
   157         mItemsChanged = true;
   148         delete mIconItem;
   158         delete mIconItem;