|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "cnthistoryviewitem.h" |
|
19 #include "cntdebug.h" |
|
20 |
|
21 #include <cnthistorymodel.h> |
|
22 #include <hbframedrawer.h> |
|
23 #include <hbframeitem.h> |
|
24 #include <QGraphicsWidget> |
|
25 |
|
26 #define NEW_EVENT_FRAME "qtg_fr_list_new_item" |
|
27 #define INCOMING_FOCUS_FRAME "qtg_fr_convlist_received_pressed" |
|
28 #define OUTGOING_FOCUS_FRAME "qtg_fr_convlist_sent_pressed" |
|
29 |
|
30 //--------------------------------------------------------------- |
|
31 // HbListViewItem::HbListViewItem |
|
32 // Constructor |
|
33 //--------------------------------------------------------------- |
|
34 CntHistoryViewItem::CntHistoryViewItem(QGraphicsItem* parent) |
|
35 : HbListViewItem(parent), |
|
36 mIncoming(false), |
|
37 mNewMessage(false), |
|
38 mNewItem(NULL), |
|
39 mFocusItem(NULL) |
|
40 { |
|
41 CNT_ENTRY |
|
42 |
|
43 CNT_EXIT |
|
44 } |
|
45 |
|
46 //--------------------------------------------------------------- |
|
47 // HbListViewItem::createItem |
|
48 // Create a new decorator item. |
|
49 //--------------------------------------------------------------- |
|
50 HbAbstractViewItem* CntHistoryViewItem::createItem() |
|
51 { |
|
52 return new CntHistoryViewItem(*this); |
|
53 } |
|
54 |
|
55 //--------------------------------------------------------------- |
|
56 // HbListViewItem::updateChildItems |
|
57 // |
|
58 //--------------------------------------------------------------- |
|
59 void CntHistoryViewItem::updateChildItems() |
|
60 { |
|
61 CNT_ENTRY |
|
62 |
|
63 int flags = modelIndex().data(CntFlagsRole).toInt(); |
|
64 mIncoming = flags & CntIncoming ? true : false; |
|
65 mNewMessage = flags & CntUnseen ? true : false; |
|
66 |
|
67 CNT_LOG_ARGS(mIncoming << mNewMessage) |
|
68 |
|
69 if (mNewMessage) |
|
70 { |
|
71 if (!mNewItem) |
|
72 { |
|
73 mNewItem = new HbFrameItem(NEW_EVENT_FRAME, HbFrameDrawer::ThreePiecesVertical, this); |
|
74 style()->setItemName(mNewItem, "newitem"); |
|
75 } |
|
76 } |
|
77 else |
|
78 { |
|
79 if (mNewItem) |
|
80 { |
|
81 delete mNewItem; |
|
82 mNewItem = NULL; |
|
83 } |
|
84 } |
|
85 |
|
86 HbListViewItem::updateChildItems(); |
|
87 |
|
88 repolish(); |
|
89 |
|
90 CNT_EXIT |
|
91 } |
|
92 |
|
93 //--------------------------------------------------------------- |
|
94 // HbAbstractViewItem::pressStateChanged |
|
95 // This function is called whenever item press state changes. |
|
96 //--------------------------------------------------------------- |
|
97 void CntHistoryViewItem::pressStateChanged(bool pressed, bool animate) |
|
98 { |
|
99 CNT_ENTRY |
|
100 |
|
101 Q_UNUSED(animate); |
|
102 if (pressed) |
|
103 { |
|
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 |
|
135 CNT_EXIT |
|
136 } |
|
137 |
|
138 // EOF |