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 "cpdataformlistentryviewitem.h" |
|
19 |
|
20 #ifdef HB_EFFECTS |
|
21 #include "hbeffect.h" |
|
22 #endif |
|
23 |
|
24 #ifdef HB_GESTURE_FW |
|
25 #include <hbtapgesture.h> |
|
26 #include <hbframeitem.h> |
|
27 #endif |
|
28 |
|
29 #include <hbdataformmodel.h> |
|
30 #include <hbdataformmodelitem.h> |
|
31 #include <hbabstractitemview.h> |
|
32 #include <cpsettingformentryitemdata.h> |
|
33 |
|
34 #define CP_DATAFORMLISTENTRYVIEWITEM QLatin1String("cpdataformlistentryviewitem") |
|
35 |
|
36 CpDataFormListEntryViewItem::CpDataFormListEntryViewItem(QGraphicsItem *parent) : |
|
37 HbDataFormViewItem(parent) |
|
38 { |
|
39 #ifdef HB_EFFECTS |
|
40 HbEffect::add(CP_DATAFORMLISTENTRYVIEWITEM + "-focus", "listviewitem_press", "pressed"); |
|
41 HbEffect::add(CP_DATAFORMLISTENTRYVIEWITEM + "-focus", "listviewitem_release", "released"); |
|
42 #endif |
|
43 } |
|
44 |
|
45 CpDataFormListEntryViewItem::~CpDataFormListEntryViewItem() |
|
46 { |
|
47 } |
|
48 |
|
49 HbAbstractViewItem* CpDataFormListEntryViewItem::createItem() |
|
50 { |
|
51 return new CpDataFormListEntryViewItem(*this); |
|
52 } |
|
53 |
|
54 bool CpDataFormListEntryViewItem::canSetModelIndex(const QModelIndex &index) const |
|
55 { |
|
56 HbDataFormModelItem::DataItemType itemType = |
|
57 static_cast<HbDataFormModelItem::DataItemType>( |
|
58 index.data(HbDataFormModelItem::ItemTypeRole).toInt()); |
|
59 |
|
60 return ( itemType == CpSettingFormEntryItemData::ListEntryItem ); |
|
61 } |
|
62 |
|
63 HbWidget* CpDataFormListEntryViewItem::createCustomWidget() |
|
64 { |
|
65 HbDataFormModelItem::DataItemType itemType = |
|
66 static_cast<HbDataFormModelItem::DataItemType> (modelIndex().data( |
|
67 HbDataFormModelItem::ItemTypeRole).toInt()); |
|
68 switch (itemType) |
|
69 { |
|
70 case CpSettingFormEntryItemData::ListEntryItem: { |
|
71 break; |
|
72 } |
|
73 default: { |
|
74 break; |
|
75 } |
|
76 } |
|
77 |
|
78 return 0; |
|
79 } |
|
80 |
|
81 void CpDataFormListEntryViewItem::pressStateChanged(bool pressed, bool animate) |
|
82 { |
|
83 #ifdef HB_EFFECTS |
|
84 QGraphicsItem *focusItem = primitive("dataItem_Background"); |
|
85 bool doAnimate = animate; |
|
86 |
|
87 if (pressed) { |
|
88 if (doAnimate) { |
|
89 HbEffect::cancel(this, "released"); |
|
90 HbEffect::cancel(focusItem, "released"); |
|
91 |
|
92 HbEffect::start(this, CP_DATAFORMLISTENTRYVIEWITEM, "pressed"); |
|
93 HbEffect::start(focusItem, CP_DATAFORMLISTENTRYVIEWITEM + QString("-focus"), "pressed"); |
|
94 } |
|
95 } else { |
|
96 if (doAnimate) { |
|
97 HbEffect::cancel(this, "pressed"); |
|
98 HbEffect::cancel(focusItem, "pressed"); |
|
99 |
|
100 HbEffect::start(this, CP_DATAFORMLISTENTRYVIEWITEM, "released"); |
|
101 HbEffect::start(focusItem, CP_DATAFORMLISTENTRYVIEWITEM + QString("-focus"), "released"); |
|
102 } else { |
|
103 HbEffect::cancel(this, "pressed"); |
|
104 HbEffect::start(this, CP_DATAFORMLISTENTRYVIEWITEM, "released"); |
|
105 if (focusItem) { |
|
106 HbEffect::cancel(focusItem, "pressed"); |
|
107 HbEffect::start(focusItem, CP_DATAFORMLISTENTRYVIEWITEM + QString("-focus"), "released", this); |
|
108 } |
|
109 } |
|
110 } |
|
111 #endif |
|
112 } |
|
113 |
|
114 #ifdef HB_GESTURE_FW |
|
115 void CpDataFormListEntryViewItem::gestureEvent(QGestureEvent *event) |
|
116 { |
|
117 HbFrameItem *backgroundItem = static_cast<HbFrameItem*> ( primitive("dataItem_Background") ); |
|
118 HbTapGesture *tap = qobject_cast<HbTapGesture *>(event->gesture(Qt::TapGesture)); |
|
119 |
|
120 if(backgroundItem && tap) { |
|
121 switch(tap->state()) { |
|
122 case Qt::GestureStarted: { |
|
123 backgroundItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_list_pressed")); |
|
124 } |
|
125 break; |
|
126 case Qt::GestureUpdated: { |
|
127 |
|
128 } |
|
129 break; |
|
130 case Qt::GestureCanceled: { |
|
131 backgroundItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_list_normal")); |
|
132 } |
|
133 break; |
|
134 case Qt::GestureFinished: { |
|
135 backgroundItem->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_list_normal")); |
|
136 } |
|
137 break; |
|
138 default: |
|
139 break; |
|
140 } |
|
141 } |
|
142 |
|
143 HbDataFormViewItem::gestureEvent( event ); |
|
144 } |
|
145 #endif |
|
146 |
|
147 |
|
148 //End of File |
|