|
1 /* |
|
2 * Copyright (c) 2008-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: Implementation of private wrapper class |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "glxtvoutwrapper.h" |
|
19 #include "glxtvoutwrapper_p.h" |
|
20 #include "glxtvconnectionobserver.h" |
|
21 #include "glxhdmicontroller.h" |
|
22 #include "glxmodelparm.h" |
|
23 |
|
24 // ----------------------------------------------------------------------------- |
|
25 // Static method to create the private wrapper instance |
|
26 // ----------------------------------------------------------------------------- |
|
27 GlxTvOutWrapperPrivate* GlxTvOutWrapperPrivate::Instance(GlxTvOutWrapper* aTvOutWrapper, |
|
28 QAbstractItemModel* aModel) |
|
29 { |
|
30 GlxTvOutWrapperPrivate* self = new GlxTvOutWrapperPrivate(aTvOutWrapper,aModel); |
|
31 if (self){ |
|
32 TRAPD(err,self->ConstructL()); |
|
33 if(err != KErrNone){ |
|
34 delete self; |
|
35 self = NULL; |
|
36 } |
|
37 } |
|
38 return self; |
|
39 } |
|
40 |
|
41 // ----------------------------------------------------------------------------- |
|
42 // ConstructL |
|
43 // This creates the Connection observer and the Hdmi Controller |
|
44 // ----------------------------------------------------------------------------- |
|
45 void GlxTvOutWrapperPrivate::ConstructL() |
|
46 { |
|
47 iConnectionObserver = CGlxConnectionObserver::NewL(this); |
|
48 if (!iHdmiController) { |
|
49 iHdmiController = CGlxHdmiController::NewL(); |
|
50 iHdmiConnected = iHdmiController->IsHDMIConnected(); |
|
51 } |
|
52 } |
|
53 |
|
54 // ----------------------------------------------------------------------------- |
|
55 // Constructor |
|
56 // ----------------------------------------------------------------------------- |
|
57 GlxTvOutWrapperPrivate::GlxTvOutWrapperPrivate(GlxTvOutWrapper* aTvOutWrapper, |
|
58 QAbstractItemModel* aModel):iTvOutWrapper(aTvOutWrapper), |
|
59 iModel(aModel), |
|
60 iConnectionObserver(NULL), |
|
61 iHdmiController(NULL), |
|
62 iHdmiConnected(false), |
|
63 isImageSetToHdmi(false) |
|
64 { |
|
65 // Do Nothing |
|
66 } |
|
67 |
|
68 // ----------------------------------------------------------------------------- |
|
69 // Destructor |
|
70 // ----------------------------------------------------------------------------- |
|
71 GlxTvOutWrapperPrivate::~GlxTvOutWrapperPrivate() |
|
72 { |
|
73 if (iConnectionObserver){ |
|
74 delete iConnectionObserver; |
|
75 iConnectionObserver = NULL; |
|
76 } |
|
77 if (iHdmiController){ |
|
78 delete iHdmiController; |
|
79 iHdmiController = NULL; |
|
80 } |
|
81 } |
|
82 |
|
83 // ----------------------------------------------------------------------------- |
|
84 // HandleConnectionChange |
|
85 // observes the connection change to modify the connection flag |
|
86 // ----------------------------------------------------------------------------- |
|
87 void GlxTvOutWrapperPrivate::HandleConnectionChange(bool aConnected) |
|
88 { |
|
89 iHdmiConnected = aConnected; |
|
90 // if Connection state positive and uri/bmp are not passed to HDMI already |
|
91 // then it is a new image - Set it. |
|
92 if (!isImageSetToHdmi && iHdmiConnected) |
|
93 { |
|
94 SetNewImage(); |
|
95 } |
|
96 } |
|
97 |
|
98 // ----------------------------------------------------------------------------- |
|
99 // SetImagetoHDMI |
|
100 // if the Hdmi is connected, Set the new image else do nothing |
|
101 // ----------------------------------------------------------------------------- |
|
102 void GlxTvOutWrapperPrivate::SetImagetoHDMI() |
|
103 { |
|
104 if (iHdmiConnected) |
|
105 { |
|
106 // Set the Image |
|
107 SetNewImage(); |
|
108 // Set the flag after HDMI is set for the image |
|
109 isImageSetToHdmi = true; |
|
110 } |
|
111 else |
|
112 { |
|
113 // UnSet the flag as HDMI not set |
|
114 // this would be in future use if HDMI not set for a image in FS/SS and |
|
115 // cable connected |
|
116 isImageSetToHdmi = false; |
|
117 } |
|
118 } |
|
119 |
|
120 // ----------------------------------------------------------------------------- |
|
121 // SetNewImage |
|
122 // Private implementation of setting the image to HDMI |
|
123 // ----------------------------------------------------------------------------- |
|
124 void GlxTvOutWrapperPrivate::SetNewImage() |
|
125 { |
|
126 int focusIndex = (iModel->data(iModel->index(0,0),GlxFocusIndexRole).value<int>()); |
|
127 |
|
128 // Get the image uri |
|
129 QString imagePath = (iModel->data(iModel->index(focusIndex,0),GlxUriRole)).value<QString>(); |
|
130 if(imagePath.isNull()) { |
|
131 // Null path no need to proceed |
|
132 return ; |
|
133 } |
|
134 |
|
135 TPtrC aPtr = reinterpret_cast<const TUint16*>(imagePath.utf16()); |
|
136 QVariant var = (iModel->data(iModel->index(focusIndex,0),GlxHdmiBitmap)); |
|
137 CFbsBitmap* bmp = var.value<CFbsBitmap*>(); |
|
138 iHdmiController->SetImageL(aPtr,bmp); |
|
139 } |
|
140 |
|
141 // ----------------------------------------------------------------------------- |
|
142 // setToCloningMode |
|
143 // ----------------------------------------------------------------------------- |
|
144 void GlxTvOutWrapperPrivate::SetToCloningMode() |
|
145 { |
|
146 if(iHdmiController){ |
|
147 iHdmiController->ShiftToCloningMode(); |
|
148 } |
|
149 } |
|
150 |
|
151 // ----------------------------------------------------------------------------- |
|
152 // setToNativeMode |
|
153 // ----------------------------------------------------------------------------- |
|
154 void GlxTvOutWrapperPrivate::SetToNativeMode() |
|
155 { |
|
156 if(iHdmiController){ |
|
157 iHdmiController->ShiftToPostingMode(); |
|
158 } |
|
159 } |
|
160 |
|
161 // ----------------------------------------------------------------------------- |
|
162 // itemNotSupported |
|
163 // ----------------------------------------------------------------------------- |
|
164 void GlxTvOutWrapperPrivate::ItemNotSupported() |
|
165 { |
|
166 if(iHdmiController){ |
|
167 iHdmiController->ItemNotSupported(); |
|
168 } |
|
169 } |
|
170 |
|
171 // ----------------------------------------------------------------------------- |
|
172 // activateZoom |
|
173 // ----------------------------------------------------------------------------- |
|
174 void GlxTvOutWrapperPrivate::ActivateZoom(bool autoZoomOut) |
|
175 { |
|
176 if(iHdmiController){ |
|
177 iHdmiController->ActivateZoom(autoZoomOut); |
|
178 } |
|
179 } |
|
180 |
|
181 // ----------------------------------------------------------------------------- |
|
182 // deactivateZoom |
|
183 // ----------------------------------------------------------------------------- |
|
184 void GlxTvOutWrapperPrivate::DeactivateZoom() |
|
185 { |
|
186 if(iHdmiController){ |
|
187 iHdmiController->DeactivateZoom(); |
|
188 } |
|
189 } |
|
190 |
|
191 // End of file |