1 /* |
1 /* |
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of "Eclipse Public License v1.0" |
5 * under the terms of "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
8 * |
8 * |
9 * Initial Contributors: |
9 * Initial Contributors: |
10 * Nokia Corporation - initial contribution. |
10 * Nokia Corporation - initial contribution. |
11 * |
11 * |
12 * Contributors: |
12 * Contributors: |
13 * |
13 * |
14 * Description: |
14 * Description: |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 #include "cnthistoryviewitem.h" |
18 #include "cnthistoryviewitem.h" |
|
19 #include "cnthistoryviewitemwidget.h" |
19 #include "cntdebug.h" |
20 #include "cntdebug.h" |
20 |
21 |
21 #include <cnthistorymodel.h> |
22 #include <QGraphicsLinearLayout> |
22 #include <hbframedrawer.h> |
|
23 #include <hbframeitem.h> |
|
24 #include <QGraphicsWidget> |
|
25 |
23 |
26 #define NEW_EVENT_FRAME "qtg_fr_list_new_item" |
24 /*! |
27 #define INCOMING_FOCUS_FRAME "qtg_fr_convlist_received_pressed" |
25 Constructor, initialize member variables. |
28 #define OUTGOING_FOCUS_FRAME "qtg_fr_convlist_sent_pressed" |
26 */ |
29 |
27 CntHistoryViewItem::CntHistoryViewItem(QGraphicsItem* parent) : |
30 //--------------------------------------------------------------- |
28 HbListViewItem(parent), |
31 // HbListViewItem::HbListViewItem |
29 mWidget(NULL) |
32 // Constructor |
|
33 //--------------------------------------------------------------- |
|
34 CntHistoryViewItem::CntHistoryViewItem(QGraphicsItem* parent) |
|
35 : HbListViewItem(parent), |
|
36 mIncoming(false), |
|
37 mNewMessage(false), |
|
38 mNewItem(NULL), |
|
39 mFocusItem(NULL) |
|
40 { |
30 { |
41 CNT_ENTRY |
31 CNT_ENTRY |
42 |
32 |
43 CNT_EXIT |
33 CNT_EXIT |
44 } |
34 } |
45 |
35 |
46 //--------------------------------------------------------------- |
36 /*! |
47 // HbListViewItem::createItem |
37 Factory method to the items |
48 // Create a new decorator item. |
38 */ |
49 //--------------------------------------------------------------- |
|
50 HbAbstractViewItem* CntHistoryViewItem::createItem() |
39 HbAbstractViewItem* CntHistoryViewItem::createItem() |
51 { |
40 { |
52 return new CntHistoryViewItem(*this); |
41 return new CntHistoryViewItem(*this); |
53 } |
42 } |
54 |
43 |
55 //--------------------------------------------------------------- |
44 /*! |
56 // HbListViewItem::updateChildItems |
45 Update the custom and standard parameters of this item identified by modelindex |
57 // |
46 */ |
58 //--------------------------------------------------------------- |
|
59 void CntHistoryViewItem::updateChildItems() |
47 void CntHistoryViewItem::updateChildItems() |
60 { |
48 { |
61 CNT_ENTRY |
49 CNT_ENTRY |
62 |
50 |
63 int flags = modelIndex().data(CntFlagsRole).toInt(); |
51 if (!mWidget) |
64 mIncoming = flags & CntIncoming ? true : false; |
|
65 mNewMessage = flags & CntUnseen ? true : false; |
|
66 |
|
67 CNT_LOG_ARGS(mIncoming << mNewMessage) |
|
68 |
|
69 if (mNewMessage) |
|
70 { |
52 { |
71 if (!mNewItem) |
53 mWidget = new CntHistoryViewItemWidget(this); |
72 { |
54 QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical); |
73 mNewItem = new HbFrameItem(NEW_EVENT_FRAME, HbFrameDrawer::ThreePiecesVertical, this); |
55 layout->setContentsMargins(0, 0, 0, 0); |
74 style()->setItemName(mNewItem, "newitem"); |
56 layout->addItem(mWidget); |
75 } |
57 setLayout(layout); |
76 } |
|
77 else |
|
78 { |
|
79 if (mNewItem) |
|
80 { |
|
81 delete mNewItem; |
|
82 mNewItem = NULL; |
|
83 } |
|
84 } |
58 } |
85 |
59 |
86 HbListViewItem::updateChildItems(); |
60 mWidget->setModelIndex(modelIndex()); |
87 |
|
88 repolish(); |
|
89 |
61 |
90 CNT_EXIT |
62 CNT_EXIT |
91 } |
63 } |
92 |
64 |
93 //--------------------------------------------------------------- |
65 /*! |
94 // HbAbstractViewItem::pressStateChanged |
66 This function is called whenever item press state changes. |
95 // This function is called whenever item press state changes. |
67 */ |
96 //--------------------------------------------------------------- |
|
97 void CntHistoryViewItem::pressStateChanged(bool pressed, bool animate) |
68 void CntHistoryViewItem::pressStateChanged(bool pressed, bool animate) |
98 { |
69 { |
99 CNT_ENTRY |
70 CNT_ENTRY |
100 |
71 |
101 Q_UNUSED(animate); |
72 Q_UNUSED(animate); |
102 if (pressed) |
73 |
103 { |
74 mWidget->pressStateChanged(pressed); |
104 if (!mFocusItem) |
|
105 { |
|
106 // focus frame position can't be read from widgetml, we set it manually |
|
107 QRectF frameRect = HbWidget::primitive("frame")->boundingRect(); |
|
108 QPointF framePoint = HbWidget::primitive("frame")->pos(); |
|
109 |
|
110 frameRect.moveTo(framePoint); |
|
111 |
|
112 if (mIncoming) |
|
113 { |
|
114 mFocusItem = new HbFrameItem(INCOMING_FOCUS_FRAME, HbFrameDrawer::NinePieces, this); |
|
115 } |
|
116 else |
|
117 { |
|
118 mFocusItem = new HbFrameItem(OUTGOING_FOCUS_FRAME, HbFrameDrawer::NinePieces, this); |
|
119 } |
|
120 |
|
121 mFocusItem->setGeometry(frameRect); |
|
122 mFocusItem->setZValue(-1.0); |
|
123 style()->setItemName(mFocusItem, "focusframe"); |
|
124 } |
|
125 } |
|
126 else |
|
127 { |
|
128 if (mFocusItem) |
|
129 { |
|
130 delete mFocusItem; |
|
131 mFocusItem = NULL; |
|
132 } |
|
133 } |
|
134 |
75 |
135 CNT_EXIT |
76 CNT_EXIT |
136 } |
77 } |
137 |
78 |
138 // EOF |
79 // EOF |