13 * |
13 * |
14 * Description: List item for conference participant list. |
14 * Description: List item for conference participant list. |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 #include <QtGui> |
18 #include <QGraphicsLinearLayout> |
19 #include <hbiconitem.h> |
19 #include <hbiconitem.h> |
20 #include <hbframeitem.h> |
|
21 #include <hbtextitem.h> |
20 #include <hbtextitem.h> |
22 #include <hbiconitem.h> |
|
23 #include <hbaction.h> |
21 #include <hbaction.h> |
24 #include <hbpushbutton.h> |
22 #include <hbpushbutton.h> |
25 #include <hblabel.h> |
23 #include <hbstyleloader.h> |
|
24 #include <hbabstractitemview.h> |
|
25 #include <hblistviewitem.h> |
26 |
26 |
27 #include "bubbleparticipantlistitem.h" |
27 #include "bubbleparticipantlistitem.h" |
28 #include "bubbleprimitives.h" |
28 #include "bubblemanagerif.h" |
29 #include "bubblestyleoption.h" |
29 #include "bubbleutils.h" |
30 #include "bubblebuttonstyle.h" |
|
31 |
30 |
32 BubbleParticipantListItem::BubbleParticipantListItem( |
31 BubbleParticipantListItem::BubbleParticipantListItem( |
33 const QString& stylePluginName, |
|
34 BubbleButtonStyle& buttonStyle, |
|
35 QGraphicsItem *parent) : |
32 QGraphicsItem *parent) : |
36 HbListViewItem(parent), |
33 HbAbstractViewItem(parent), |
37 mStylePluginName(stylePluginName), |
|
38 mButtonStyle(buttonStyle), |
|
39 mBackground(0), |
|
40 mText(0), |
34 mText(0), |
41 mStatusIcon(0), |
35 mStatusIcon(0), |
42 mCipheringIcon(0), |
36 mCipheringIcon(0), |
43 mExpandIcon(0), |
37 mExpandIcon(0), |
44 mButton1(0), |
38 mButton1(0), |
45 mButton2(0), |
39 mButton2(0), |
46 mExpanded(false) |
40 mExpanded(false) |
47 { |
41 { |
48 mStylePluginBaseId = style()->registerPlugin(mStylePluginName); |
42 HbStyleLoader::registerFilePath(":/bubbleparticipantlistitem.css"); |
49 Q_ASSERT(pluginBaseId()!=-1); |
43 HbStyleLoader::registerFilePath(":/bubbleparticipantlistitem.widgetml"); |
50 } |
44 } |
51 |
45 |
52 BubbleParticipantListItem::~BubbleParticipantListItem() |
46 BubbleParticipantListItem::~BubbleParticipantListItem() |
53 { |
47 { |
54 if (prototype()==(HbAbstractViewItem*)this) { |
|
55 style()->unregisterPlugin(mStylePluginName); |
|
56 } |
|
57 } |
48 } |
58 |
49 |
59 HbAbstractViewItem* BubbleParticipantListItem::createItem() |
50 HbAbstractViewItem* BubbleParticipantListItem::createItem() |
60 { |
51 { |
61 return new BubbleParticipantListItem(*this); |
52 return new BubbleParticipantListItem(*this); |
62 } |
53 } |
63 |
54 |
64 void BubbleParticipantListItem::updateChildItems() |
55 void BubbleParticipantListItem::updateChildItems() |
65 { |
56 { |
66 setPluginBaseId(mStylePluginBaseId); |
57 HbAbstractViewItem::updateChildItems(); |
|
58 |
67 setFocusPolicy(Qt::ClickFocus); // to enable expanding |
59 setFocusPolicy(Qt::ClickFocus); // to enable expanding |
68 |
60 |
69 // create primitives |
61 // create primitives |
70 if (!mBackground) { |
|
71 mBackground = style()->createPrimitive( |
|
72 (HbStyle::Primitive)(pluginBaseId()+BP_Bubble_frame), this); |
|
73 if ( mBackground ) { |
|
74 style()->setItemName( mBackground, "background" ); |
|
75 } |
|
76 } |
|
77 |
|
78 if (!mText) { |
62 if (!mText) { |
79 mText = style()->createPrimitive( |
63 mText = new HbTextItem(this); |
80 (HbStyle::Primitive)(pluginBaseId()+BP_Text1_text), this); |
64 style()->setItemName( mText, "text" ); |
81 if ( mText ) { |
|
82 style()->setItemName( mText, "text" ); |
|
83 } |
|
84 } |
65 } |
85 |
66 |
86 if (!mCipheringIcon) { |
67 if (!mCipheringIcon) { |
87 mCipheringIcon = style()->createPrimitive( |
68 mCipheringIcon = new HbIconItem(this); |
88 (HbStyle::Primitive)(pluginBaseId()+BP_Ciphering_icon), this); |
69 style()->setItemName( mCipheringIcon, "ciphering" ); |
89 if ( mCipheringIcon ) { |
|
90 style()->setItemName( mCipheringIcon, "ciphering" ); |
|
91 } |
|
92 } |
70 } |
93 |
71 |
94 if (!mStatusIcon) { |
72 if (!mStatusIcon) { |
95 mStatusIcon = style()->createPrimitive( |
73 mStatusIcon = new HbIconItem(this); |
96 (HbStyle::Primitive)(pluginBaseId()+BP_CallStatus_icon), this); |
74 style()->setItemName( mStatusIcon, "icon" ); |
97 if ( mStatusIcon ) { |
|
98 style()->setItemName( mStatusIcon, "icon" ); |
|
99 } |
|
100 } |
75 } |
101 |
76 |
102 if (!mExpandIcon) { |
77 if (!mExpandIcon) { |
103 mExpandIcon = new HbIconItem(this); |
78 mExpandIcon = new HbIconItem(this); |
104 if ( mExpandIcon ) { |
79 style()->setItemName( mExpandIcon, "expand-indi" ); |
105 style()->setItemName( mExpandIcon, "expand-indi" ); |
80 |
|
81 // for expand/collapse controls |
|
82 if (itemView()) { |
|
83 connect( itemView()->selectionModel(), |
|
84 SIGNAL(currentChanged(QModelIndex,QModelIndex)), |
|
85 this, |
|
86 SLOT(currentIndexChanged(QModelIndex,QModelIndex)) ); |
106 } |
87 } |
107 } |
88 } |
108 |
89 |
109 BubbleParticipantListItem* p = |
90 BubbleParticipantListItem* p = |
110 static_cast<BubbleParticipantListItem*>(prototype()); |
91 static_cast<BubbleParticipantListItem*>(prototype()); |
111 |
92 |
112 if (mExpanded && !mButton1) { |
93 if (mExpanded && !mButton1) { |
113 Q_ASSERT(p->mActions.count()==2); |
94 Q_ASSERT(p->mActions.count()==2); |
114 HbAction* action = p->mActions.at(0); |
95 HbAction* action = p->mActions.at(0); |
115 mButton1 = new HbPushButton(this); |
96 mButton1 = new HbPushButton(this); |
116 mButton1->setStyle(&mButtonStyle); |
|
117 mButton1->setIcon(action->icon()); |
97 mButton1->setIcon(action->icon()); |
118 style()->setItemName( mButton1, "button-1" ); |
98 style()->setItemName( mButton1, "button-1" ); |
119 HbTextItem* label = static_cast<HbTextItem*>( |
|
120 mButton1->primitive(HbStyle::P_PushButton_text)); |
|
121 if (label) { |
|
122 label->setTextColor( Qt::white ); |
|
123 } |
|
124 |
99 |
125 // connect first action |
100 // connect first action |
126 connect(mButton1, |
101 connect(mButton1, |
127 SIGNAL(clicked()), |
102 SIGNAL(clicked()), |
128 action, |
103 action, |
156 } else { |
125 } else { |
157 delete mButton2; |
126 delete mButton2; |
158 mButton2 = 0; |
127 mButton2 = 0; |
159 } |
128 } |
160 |
129 |
161 // update primitives |
|
162 BubbleStyleOption option; |
|
163 HbWidget::initStyleOption(&option); |
|
164 |
|
165 // check canConvert() |
|
166 option.mCallState = (BubbleManagerIF::PhoneCallState) |
|
167 modelIndex().data(Qt::DecorationRole).toInt(); |
|
168 option.mText1 = modelIndex().data(Qt::DisplayRole).toString(); |
|
169 option.mCliLineNumber = 1; |
|
170 bool ciphering = modelIndex().data(Qt::StatusTipRole).toBool(); |
|
171 if (!ciphering) { |
|
172 option.mCallFlags = BubbleManagerIF::NoCiphering; |
|
173 } |
|
174 |
|
175 if (mBackground) { |
|
176 style()->updatePrimitive( |
|
177 mBackground, |
|
178 (HbStyle::Primitive)(pluginBaseId()+BP_Bubble_frame), |
|
179 &option); |
|
180 } |
|
181 |
|
182 if (mText) { |
130 if (mText) { |
183 style()->updatePrimitive( |
131 mText->setText(modelIndex().data(Qt::DisplayRole).toString()); |
184 mText, |
132 } |
185 (HbStyle::Primitive)(pluginBaseId()+BP_Text1_text), |
133 |
186 &option); |
134 int state = (BubbleManagerIF::PhoneCallState) |
187 } |
135 modelIndex().data(Qt::DecorationRole).toInt(); |
188 |
136 |
189 if (mStatusIcon) { |
137 if (mStatusIcon) { |
190 style()->updatePrimitive( |
138 BubbleUtils::setCallStatusIcon(state,0,*mStatusIcon); |
191 mStatusIcon, |
|
192 (HbStyle::Primitive)(pluginBaseId()+BP_CallStatus_icon), |
|
193 &option ); |
|
194 } |
139 } |
195 |
140 |
196 if (mCipheringIcon) { |
141 if (mCipheringIcon) { |
197 style()->updatePrimitive( |
142 int flags = !modelIndex().data(Qt::StatusTipRole).toBool() ? |
198 mCipheringIcon, |
143 BubbleManagerIF::NoCiphering : 0; |
199 (HbStyle::Primitive)(pluginBaseId()+BP_Ciphering_icon), |
144 |
200 &option ); |
145 BubbleUtils::setCipheringIcon(state,flags,*mCipheringIcon); |
201 } |
146 } |
202 |
147 |
203 if (mExpandIcon) { |
148 if (mExpandIcon) { |
204 if (mExpanded) { |
149 if (mExpanded) { |
|
150 mExpandIcon->setIcon(HbIcon("qtg_small_collapse")); |
|
151 } else { |
205 mExpandIcon->setIcon(HbIcon("qtg_small_expand")); |
152 mExpandIcon->setIcon(HbIcon("qtg_small_expand")); |
206 } else { |
|
207 mExpandIcon->setIcon(HbIcon("qtg_small_collapse")); |
|
208 } |
153 } |
209 } |
154 } |
210 |
155 |
211 repolish(); |
156 repolish(); |
212 } |
157 } |