24 ****************************************************************************/ |
24 ****************************************************************************/ |
25 |
25 |
26 #include "hbgridviewitem_p.h" |
26 #include "hbgridviewitem_p.h" |
27 #include <hbgridviewitem.h> |
27 #include <hbgridviewitem.h> |
28 #include "hbgridview_p.h" |
28 #include "hbgridview_p.h" |
29 #include <hbstyleoptiongridviewitem_p.h> |
29 |
|
30 #include <hbstyletextprimitivedata.h> |
|
31 #include <hbstylerichtextprimitivedata.h> |
|
32 #include <hbstyleiconprimitivedata.h> |
30 #include <QDebug> |
33 #include <QDebug> |
31 |
34 |
32 /*! |
35 /*! |
33 @beta |
36 @beta |
34 @hbwidgets |
37 @hbwidgets |
49 |
52 |
50 If the derived grid view item has transient state information that would have no meaning if stored within the model index (for example child item cursor |
53 If the derived grid view item has transient state information that would have no meaning if stored within the model index (for example child item cursor |
51 position selection areas etc.) the view item can use the grid view's internal state model to store this information.To use this feature |
54 position selection areas etc.) the view item can use the grid view's internal state model to store this information.To use this feature |
52 implement the state() and setState() functions in the derived class. |
55 implement the state() and setState() functions in the derived class. |
53 |
56 |
54 See also HbGridView, HbAbstractItemView, HbAbstractViewItem, HbStyleOptionAbstractViewItem |
57 See also HbGridView, HbAbstractItemView, HbAbstractViewItem |
55 |
58 |
56 \primitives |
59 \primitives |
57 \primitive{icon} HbIconItem representing the icon in the HbGridViewItem. |
60 \primitive{icon} HbIconItem with item name "icon" representing the icon in the HbGridViewItem. |
58 \primitive{text} HbTextItem representing the text in the HbGridViewItem. |
61 \primitive{text} HbTextItem with item name "text" representing the text in the HbGridViewItem. |
59 |
62 |
60 */ |
63 */ |
61 |
64 |
62 /*! |
65 /*! |
63 Constructs a grid view item with the given parent. |
66 Constructs a grid view item with the given parent. |
146 d->updateIconItem(*viewPrivate); |
149 d->updateIconItem(*viewPrivate); |
147 } |
150 } |
148 HbAbstractViewItem::updateChildItems(); |
151 HbAbstractViewItem::updateChildItems(); |
149 } |
152 } |
150 |
153 |
|
154 |
|
155 /*! |
|
156 Initializes the HbGridViewItem primitive data. |
|
157 |
|
158 This function calls HbWidgetBase::initPrimitiveData(). |
|
159 \a primitiveData is data object, which is populated with data. \a primitive is the primitive. |
|
160 */ |
|
161 void HbGridViewItem::initPrimitiveData(HbStylePrimitiveData *primitiveData, |
|
162 const QGraphicsObject *primitive) |
|
163 { |
|
164 Q_ASSERT_X(primitive && primitiveData, "HbGridViewItem::initPrimitiveData" , "NULL data not permitted"); |
|
165 Q_D(HbGridViewItem); |
|
166 |
|
167 HbWidgetBase::initPrimitiveData(primitiveData, primitive); |
|
168 if (primitiveData->type == HbStylePrimitiveData::SPD_Text) { |
|
169 HbStyleTextPrimitiveData *textPrimitiveData = hbstyleprimitivedata_cast<HbStyleTextPrimitiveData*>(primitiveData); |
|
170 textPrimitiveData->text = d->mText; |
|
171 |
|
172 } else if (primitiveData->type == HbStylePrimitiveData::SPD_Icon) { |
|
173 HbStyleIconPrimitiveData *iconPrimitiveData = hbstyleprimitivedata_cast<HbStyleIconPrimitiveData*>(primitiveData); |
|
174 iconPrimitiveData->icon = d->mIcon; |
|
175 } |
|
176 } |
|
177 |
|
178 |
151 /*! |
179 /*! |
152 \reimp |
180 \reimp |
153 */ |
181 */ |
154 void HbGridViewItem::updatePrimitives() |
182 void HbGridViewItem::updatePrimitives() |
155 { |
183 { |
156 Q_D( HbGridViewItem ); |
184 Q_D( HbGridViewItem ); |
157 if (d->mTextItem || d->mIconItem) { |
185 if (d->mTextItem || d->mIconItem) { |
158 HbStyleOptionGridViewItem styleOption; |
|
159 initStyleOption(&styleOption); |
|
160 |
|
161 if (d->mTextItem) { |
186 if (d->mTextItem) { |
162 HbStylePrivate::updatePrimitive(d->mTextItem, HbStylePrivate::P_GridViewItem_text, |
187 HbStyleTextPrimitiveData textPrimitiveData; |
163 &styleOption); |
188 initPrimitiveData(&textPrimitiveData, d->mTextItem); |
|
189 style()->updatePrimitive(d->mTextItem, &textPrimitiveData,this); |
164 } |
190 } |
165 if (d->mIconItem) { |
191 if (d->mIconItem) { |
166 HbStylePrivate::updatePrimitive(d->mIconItem, HbStylePrivate::P_GridViewItem_icon, |
192 HbStyleIconPrimitiveData iconPrimitiveData; |
167 &styleOption); |
193 initPrimitiveData(&iconPrimitiveData, d->mIconItem); |
|
194 style()->updatePrimitive(d->mIconItem, &iconPrimitiveData,this); |
168 } |
195 } |
169 } |
196 } |
170 HbAbstractViewItem::updatePrimitives(); |
197 HbAbstractViewItem::updatePrimitives(); |
171 } |
|
172 |
|
173 /*! |
|
174 Populates a style option object for this widget based on its current state, and stores the output in \a option. |
|
175 */ |
|
176 void HbGridViewItem::initStyleOption(HbStyleOptionGridViewItem *option) const |
|
177 { |
|
178 Q_D( const HbGridViewItem ); |
|
179 |
|
180 HbAbstractViewItem::initStyleOption(option); |
|
181 option->icon = d->mIcon; |
|
182 option->text = d->mText; |
|
183 } |
198 } |
184 |
199 |
185 /*! |
200 /*! |
186 \reimp |
201 \reimp |
187 */ |
202 */ |