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: ?Description |
14 * Description: ?Description |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 //-------------------------------------------------------------------------------------------------------------------------------------------- |
18 //-------------------------------------------------------------------------------------------------------------------------------------------- |
19 |
|
20 #include <QModelIndex> |
19 #include <QModelIndex> |
21 #include <qdatetime.h> |
20 #include <qdatetime.h> |
22 |
21 |
23 //-------------------------------------------------------------------------------------------------------------------------------------------- |
22 //-------------------------------------------------------------------------------------------------------------------------------------------- |
24 |
23 #include <hblabel.h> |
25 #include <hbdataform.h> |
24 #include <hbdataform.h> |
26 #include <hblabel.h> |
|
27 #include <hbinstance.h> |
25 #include <hbinstance.h> |
28 #include <hbiconitem.h> |
26 #include <hbiconitem.h> |
29 #include <hblineedit.h> |
27 #include <hblineedit.h> |
30 #include <hbdataformmodel.h> |
28 #include <hbdataformmodel.h> |
31 #include <hbdataformmodelitem.h> |
29 #include <hbdataformmodelitem.h> |
32 #include <hbdataformviewitem.h> |
30 #include <hbdataformviewitem.h> |
33 |
31 |
34 //-------------------------------------------------------------------------------------------------------------------------------------------- |
32 //-------------------------------------------------------------------------------------------------------------------------------------------- |
35 |
33 #include "glxviewids.h" |
36 #include <glxmediamodel.h> |
34 #include "glxicondefs.h" //Contains the icon names/Ids |
|
35 #include "glxmodelparm.h" |
|
36 #include "glxmediamodel.h" |
37 #include "glxdetailsview.h" |
37 #include "glxdetailsview.h" |
38 #include "glxmodelparm.h" |
38 #include "glxfavmediamodel.h" |
|
39 #include <glxcommandhandlers.hrh> |
|
40 #include "glxdetailscustomicon.h" |
39 #include "glxdetailscustomwidgets.h" |
41 #include "glxdetailscustomwidgets.h" |
40 #include "glxviewids.h" |
42 #include <glxcollectionpluginalbums.hrh> |
41 #include <glxcommandhandlers.hrh> |
43 |
42 |
44 |
43 #include "OstTraceDefinitions.h" |
45 #include "OstTraceDefinitions.h" |
44 #ifdef OST_TRACE_COMPILER_IN_USE |
46 #ifdef OST_TRACE_COMPILER_IN_USE |
45 #include "glxdetailsviewTraces.h" |
47 #include "glxdetailsviewTraces.h" |
46 #endif |
48 #endif |
47 |
49 |
48 |
50 |
|
51 //SIZE OF THE IMAGE , LAYOUTS TEAM NEED TO GIVER THE SIZE IN UNITS |
|
52 #define GLX_IMAGE_SIZE 215 |
|
53 |
49 //-------------------------------------------------------------------------------------------------------------------------------------------- |
54 //-------------------------------------------------------------------------------------------------------------------------------------------- |
50 //GlxDetailsView |
55 //GlxDetailsView |
51 //-------------------------------------------------------------------------------------------------------------------------------------------- |
56 //-------------------------------------------------------------------------------------------------------------------------------------------- |
52 GlxDetailsView::GlxDetailsView(HbMainWindow *window) : GlxView ( GLX_DETAILSVIEW_ID), |
57 GlxDetailsView::GlxDetailsView(HbMainWindow *window) : |
53 mDetailsIcon(NULL), |
58 GlxView ( GLX_DETAILSVIEW_ID), |
54 mModel(NULL), |
59 mDetailsIcon(NULL), |
|
60 mFavIcon(NULL), |
|
61 mModel(NULL), |
|
62 mFavModel(NULL), |
|
63 mDetailModel(NULL), |
55 mWindow(window), |
64 mWindow(window), |
56 mDataForm(NULL), |
65 mDataForm(NULL), |
57 mDetailModel(NULL), |
|
58 mCustomPrototype(NULL), |
66 mCustomPrototype(NULL), |
59 mSelIndex (0) |
67 mSelIndex(0), |
60 { |
68 mDateLabelItem(NULL), |
61 OstTraceFunctionEntry0( GLXDETAILSVIEW_GLXDETAILSVIEW_ENTRY ); |
69 mImageLabelitem(NULL), |
62 |
70 mCommentsLabelitem(NULL) |
|
71 { |
|
72 OstTraceFunctionEntry0( GLXDETAILSVIEW_GLXDETAILSVIEW_ENTRY ); |
63 setContentFullScreen( true );//for smooth transtion between grid to full screen and vice versa |
73 setContentFullScreen( true );//for smooth transtion between grid to full screen and vice versa |
64 OstTraceFunctionExit0( GLXDETAILSVIEW_GLXDETAILSVIEW_EXIT ); |
74 OstTraceFunctionExit0( GLXDETAILSVIEW_GLXDETAILSVIEW_EXIT ); |
65 } |
75 } |
|
76 |
|
77 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
78 //activate |
|
79 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
80 void GlxDetailsView::activate() |
|
81 { |
|
82 OstTraceFunctionEntry0( GLXDETAILSVIEW_ACTIVATE_ENTRY ); |
|
83 setFormData(); |
|
84 connect(mWindow, SIGNAL(orientationChanged(Qt::Orientation)), this, SLOT(updateLayout(Qt::Orientation))); |
|
85 connect(mFavIcon,SIGNAL(updateFavourites()),this ,SLOT(updateFavourites())); |
|
86 OstTraceFunctionExit0( GLXDETAILSVIEW_ACTIVATE_EXIT ); |
|
87 } |
|
88 |
|
89 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
90 //initializeView |
|
91 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
92 void GlxDetailsView::initializeView(QAbstractItemModel *model) |
|
93 { |
|
94 OstTraceFunctionEntry0( GLXDETAILSVIEW_INITIALIZEVIEW_ENTRY ); |
|
95 |
|
96 //To show the thumbnail |
|
97 if ( mDataForm == NULL) { |
|
98 mDataForm = new HbDataForm(this); |
|
99 mDetailModel = new HbDataFormModel(); |
|
100 |
|
101 //custom prototype |
|
102 mCustomPrototype = new GlxDetailsCustomWidgets(mDataForm); |
|
103 QList <HbAbstractViewItem*> protos = mDataForm->itemPrototypes(); |
|
104 protos.append(mCustomPrototype); |
|
105 mDataForm->setItemPrototypes(protos); |
|
106 |
|
107 //Add the Widgets according to the mime type |
|
108 addWidgets(); |
|
109 } |
|
110 |
|
111 if( mDetailsIcon == NULL) { |
|
112 mDetailsIcon = new HbIconItem(this); |
|
113 mFavIcon = new GlxDetailsCustomIcon(this); |
|
114 } |
|
115 |
|
116 //Set the Model |
|
117 mModel = model; |
|
118 initializeNewModel(); |
|
119 |
|
120 //Set the Layout Correspondingly. |
|
121 updateLayout(mWindow->orientation()); |
|
122 |
|
123 //Shows the Image |
|
124 showImage(); |
|
125 OstTraceFunctionExit0( GLXDETAILSVIEW_INITIALIZEVIEW_EXIT ); |
|
126 } |
|
127 |
|
128 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
129 //resetView |
|
130 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
131 void GlxDetailsView::resetView() |
|
132 { |
|
133 OstTrace0( TRACE_NORMAL, GLXDETAILSVIEW_RESETVIEW, "GlxDetailsView::resetView" ); |
|
134 } |
|
135 |
|
136 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
137 //deActivate |
|
138 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
139 void GlxDetailsView::deActivate() |
|
140 { |
|
141 OstTraceFunctionEntry0( GLXDETAILSVIEW_DEACTIVATE_ENTRY ); |
|
142 cleanUp(); |
|
143 OstTraceFunctionExit0( GLXDETAILSVIEW_DEACTIVATE_EXIT ); |
|
144 } |
|
145 |
|
146 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
147 //cleanUp |
|
148 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
149 void GlxDetailsView::cleanUp() |
|
150 { |
|
151 clearCurrentModel(); |
|
152 |
|
153 //clear the connections |
|
154 if(mWindow) { |
|
155 disconnect(mWindow, SIGNAL(orientationChanged(Qt::Orientation)), this, SLOT(updateLayout(Qt::Orientation))); |
|
156 } |
|
157 |
|
158 if(mFavModel) { |
|
159 disconnect( mFavModel, SIGNAL( dataChanged(QModelIndex,QModelIndex) ), this, SLOT( dataChanged(QModelIndex,QModelIndex) ) ); |
|
160 } |
|
161 |
|
162 if(mFavIcon) { |
|
163 disconnect(mFavIcon,SIGNAL(updateFavourites()),this ,SLOT(updateFavourites())); |
|
164 } |
|
165 |
|
166 delete mFavModel; |
|
167 mFavModel = NULL; |
|
168 |
|
169 delete mFavIcon; |
|
170 mFavIcon = NULL; |
|
171 |
|
172 delete mDetailsIcon; |
|
173 mDetailsIcon = NULL; |
|
174 } |
66 |
175 |
67 //-------------------------------------------------------------------------------------------------------------------------------------------- |
176 //-------------------------------------------------------------------------------------------------------------------------------------------- |
68 //~GlxDetailsView |
177 //~GlxDetailsView |
69 //-------------------------------------------------------------------------------------------------------------------------------------------- |
178 //-------------------------------------------------------------------------------------------------------------------------------------------- |
70 GlxDetailsView::~GlxDetailsView() |
179 GlxDetailsView::~GlxDetailsView() |
71 { |
180 { |
72 OstTrace0( TRACE_IMPORTANT, GLXDETAILSVIEW_GLXDETAILSVIEW, "GlxDetailsView::~GlxDetailsView" ); |
181 OstTrace0( TRACE_IMPORTANT, GLXDETAILSVIEW_GLXDETAILSVIEW, "GlxDetailsView::~GlxDetailsView" ); |
73 |
182 |
74 if(mDetailsIcon) { |
183 cleanUp(); |
75 delete mDetailsIcon; |
184 |
76 mDetailsIcon = NULL; |
185 if(mDetailModel) { |
77 } |
186 delete mDetailModel; |
78 |
187 mDataForm->setModel(0); |
79 if(mDataForm && mDataForm->model()) { |
|
80 delete mDataForm->model(); |
|
81 mDataForm->setModel(0); |
|
82 } |
188 } |
83 |
189 |
84 if(mDataForm) { |
190 if(mDataForm) { |
85 delete mDataForm; |
191 delete mDataForm; |
86 mDataForm = NULL; |
192 mDataForm = NULL; |
87 } |
193 } |
88 |
194 } |
89 |
|
90 |
|
91 clearCurrentModel(); |
|
92 disconnect(mWindow, SIGNAL(orientationChanged(Qt::Orientation)), this, SLOT(updateLayout(Qt::Orientation))); |
|
93 } |
|
94 |
|
95 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
96 //activate |
|
97 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
98 void GlxDetailsView::activate() |
|
99 { |
|
100 OstTraceFunctionEntry0( GLXDETAILSVIEW_ACTIVATE_ENTRY ); |
|
101 |
|
102 setFormData(); |
|
103 connect(mWindow, SIGNAL(orientationChanged(Qt::Orientation)), this, SLOT(updateLayout(Qt::Orientation))); |
|
104 OstTraceFunctionExit0( GLXDETAILSVIEW_ACTIVATE_EXIT ); |
|
105 } |
|
106 |
|
107 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
108 //initializeView |
|
109 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
110 void GlxDetailsView::initializeView(QAbstractItemModel *model) |
|
111 { |
|
112 OstTraceFunctionEntry0( GLXDETAILSVIEW_INITIALIZEVIEW_ENTRY ); |
|
113 |
|
114 //To show the thumbnail |
|
115 if ( mDataForm == NULL) { |
|
116 mDetailsIcon = new HbIconItem(this); |
|
117 |
|
118 //Create the form and the model for the data form |
|
119 mDataForm = new HbDataForm(this); |
|
120 mDetailModel = new HbDataFormModel(); |
|
121 |
|
122 //custom prototype |
|
123 mCustomPrototype = new GlxDetailsCustomWidgets(mDataForm); |
|
124 QList <HbAbstractViewItem*> protos = mDataForm->itemPrototypes(); |
|
125 protos.append(mCustomPrototype); |
|
126 mDataForm->setItemPrototypes(protos); |
|
127 |
|
128 //Add the Widgets according to the mime type |
|
129 addWidgets(); |
|
130 } |
|
131 |
|
132 //Set the Model |
|
133 mModel = model; |
|
134 initializeNewModel(); |
|
135 |
|
136 //Set the Layout Correspondingly. |
|
137 updateLayout(mWindow->orientation()); |
|
138 |
|
139 //Shows the Image |
|
140 showImage(); |
|
141 |
|
142 OstTraceFunctionExit0( GLXDETAILSVIEW_INITIALIZEVIEW_EXIT ); |
|
143 } |
|
144 |
|
145 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
146 //resetView |
|
147 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
148 void GlxDetailsView::resetView() |
|
149 { |
|
150 OstTrace0( TRACE_NORMAL, GLXDETAILSVIEW_RESETVIEW, "GlxDetailsView::resetView" ); |
|
151 |
|
152 //Do Nothing here |
|
153 } |
|
154 |
|
155 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
156 //deActivate |
|
157 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
158 void GlxDetailsView::deActivate() |
|
159 { |
|
160 OstTraceFunctionEntry0( GLXDETAILSVIEW_DEACTIVATE_ENTRY ); |
|
161 clearCurrentModel(); |
|
162 disconnect(mWindow, SIGNAL(orientationChanged(Qt::Orientation)), this, SLOT(updateLayout(Qt::Orientation))); |
|
163 OstTraceFunctionExit0( GLXDETAILSVIEW_DEACTIVATE_EXIT ); |
|
164 } |
|
165 |
195 |
166 //-------------------------------------------------------------------------------------------------------------------------------------------- |
196 //-------------------------------------------------------------------------------------------------------------------------------------------- |
167 //addWidgets |
197 //addWidgets |
168 //-------------------------------------------------------------------------------------------------------------------------------------------- |
198 //-------------------------------------------------------------------------------------------------------------------------------------------- |
169 void GlxDetailsView::addWidgets() |
199 void GlxDetailsView::addWidgets() |
170 { |
200 { |
171 OstTrace0( TRACE_NORMAL, GLXDETAILSVIEW_ADDWIDGETS, "GlxDetailsView::addWidgets create Form" ); |
201 OstTrace0( TRACE_NORMAL, GLXDETAILSVIEW_ADDWIDGETS, "GlxDetailsView::addWidgets create Form" ); |
172 |
202 |
173 //----------------------------START OF CREATION OF WIDGETS---------------------------------// |
203 //----------------------------START OF CREATION OF WIDGETS---------------------------------// |
174 // To add new widgets in the details view, add it here. |
204 // To add new widgets in the details view, add it here. |
175 |
205 |
176 //---------------------------IMAGE NAME LABEL --------------------------------------------// |
206 //---------------------------IMAGE NAME LABEL --------------------------------------------// |
177 OstTrace0( TRACE_NORMAL, DUP1_GLXDETAILSVIEW_ADDWIDGETS, "GlxDetailsView::addWidgets create Image Label" ); |
207 OstTrace0( TRACE_NORMAL, DUP1_GLXDETAILSVIEW_ADDWIDGETS, "GlxDetailsView::addWidgets create Image Label" ); |
178 |
208 mImageLabelitem = mDetailModel->appendDataFormItem(HbDataFormModelItem::TextItem, QString("Name"), NULL); |
179 HbDataFormModelItem *imageLabelitem = |
209 |
180 mDetailModel->appendDataFormItem(HbDataFormModelItem::TextItem, QString("Name"), mDetailModel->invisibleRootItem()); |
|
181 imageLabelitem->setData(HbDataFormModelItem::KeyRole, QString("")); |
|
182 imageLabelitem->setContentWidgetData(QString("text"),QString("")); |
|
183 |
|
184 //---------------------------DATE LABEL --------------------------------------------// |
210 //---------------------------DATE LABEL --------------------------------------------// |
185 OstTrace0( TRACE_NORMAL, DUP2_GLXDETAILSVIEW_ADDWIDGETS, "GlxDetailsView::addWidgets date label" ); |
211 OstTrace0( TRACE_NORMAL, DUP2_GLXDETAILSVIEW_ADDWIDGETS, "GlxDetailsView::addWidgets date label" ); |
186 HbDataFormModelItem *dateLabelItem = mDetailModel->appendDataFormItem((HbDataFormModelItem::DataItemType)(DateLabelItem), QString("Date"), mDetailModel->invisibleRootItem()); |
212 mDateLabelItem = mDetailModel->appendDataFormItem((HbDataFormModelItem::DataItemType)(DateLabelItem), QString("Date"), NULL); |
187 dateLabelItem->setData(HbDataFormModelItem::KeyRole,QString("")); |
213 |
188 |
214 |
189 //----------------------------COMMENTS TEXT ITEM---------------------------------------------// |
215 //----------------------------COMMENTS TEXT ITEM---------------------------------------------// |
190 OstTrace0( TRACE_NORMAL, DUP5_GLXDETAILSVIEW_ADDWIDGETS, "GlxDetailsView::addWidgets comment text" ); |
216 OstTrace0( TRACE_NORMAL, DUP5_GLXDETAILSVIEW_ADDWIDGETS, "GlxDetailsView::addWidgets comment text" ); |
191 HbDataFormModelItem *commentsLabelItem = mDetailModel->appendDataFormItem((HbDataFormModelItem::DataItemType)(CommentsItem), QString("Comments"), mDetailModel->invisibleRootItem()); |
217 mCommentsLabelitem = mDetailModel->appendDataFormItem(HbDataFormModelItem::TextItem, QString("Description"), NULL); |
192 commentsLabelItem->setData(HbDataFormModelItem::KeyRole, QString("")); |
|
193 |
218 |
194 //----------------------------END OF CREATION OF WIDGETS-------------------------------------// |
219 //----------------------------END OF CREATION OF WIDGETS-------------------------------------// |
195 |
220 |
196 //Set the model to the Data Form |
221 //Set the model to the Data Form |
197 mDataForm->setModel(mDetailModel); |
222 mDataForm->setModel(mDetailModel); |
198 } |
223 } |
199 |
224 |
|
225 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
226 //setFavModel |
|
227 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
228 void GlxDetailsView::setFavModel() |
|
229 { |
|
230 GlxModelParm modelParm; |
|
231 |
|
232 QString imagePath = (mModel->data(mModel->index(mModel->data(mModel->index(0,0),GlxFocusIndexRole).value<int>(),0),GlxUriRole)).value<QString>(); |
|
233 |
|
234 if(mFavModel == NULL) { |
|
235 modelParm.setCollection( KGlxCollectionPluginFavoritesAlbumId ); |
|
236 modelParm.setContextMode(GlxContextFavorite); |
|
237 modelParm.setPath(imagePath); |
|
238 mFavModel = new GlxFavMediaModel( modelParm ); |
|
239 } |
|
240 QString imageName = imagePath.section('\\',-1); |
|
241 connect( mFavModel, SIGNAL( dataChanged(QModelIndex,QModelIndex) ), this, SLOT( dataChanged(QModelIndex,QModelIndex) ) ); |
|
242 } |
200 |
243 |
201 //-------------------------------------------------------------------------------------------------------------------------------------------- |
244 //-------------------------------------------------------------------------------------------------------------------------------------------- |
202 //setModel |
245 //setModel |
203 //-------------------------------------------------------------------------------------------------------------------------------------------- |
246 //-------------------------------------------------------------------------------------------------------------------------------------------- |
204 void GlxDetailsView::setModel(QAbstractItemModel *model) |
247 void GlxDetailsView::setModel(QAbstractItemModel *model) |
210 clearCurrentModel(); |
253 clearCurrentModel(); |
211 mModel = model; |
254 mModel = model; |
212 initializeNewModel(); |
255 initializeNewModel(); |
213 } |
256 } |
214 |
257 |
|
258 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
259 //getAnimationItem |
|
260 //-------------------------------------------------------------------------------------------------------------------------------------------- |
215 QGraphicsItem * GlxDetailsView::getAnimationItem(GlxEffect transtionEffect) |
261 QGraphicsItem * GlxDetailsView::getAnimationItem(GlxEffect transtionEffect) |
216 { |
262 { |
217 OstTrace0( TRACE_NORMAL, GLXDETAILSVIEW_GETANIMATIONITEM, "GlxDetailsView::getAnimationItem" ); |
263 OstTrace0( TRACE_NORMAL, GLXDETAILSVIEW_GETANIMATIONITEM, "GlxDetailsView::getAnimationItem" ); |
218 if ( transtionEffect == FULLSCREEN_TO_DETAIL |
264 if ( transtionEffect == FULLSCREEN_TO_DETAIL |
219 || transtionEffect == DETAIL_TO_FULLSCREEN ) { |
265 || transtionEffect == DETAIL_TO_FULLSCREEN ) { |
220 return this; |
266 return this; |
221 } |
267 } |
222 |
|
223 return NULL; |
268 return NULL; |
224 } |
269 } |
225 |
270 |
226 //-------------------------------------------------------------------------------------------------------------------------------------------- |
271 //-------------------------------------------------------------------------------------------------------------------------------------------- |
227 //updateLayout |
272 //updateLayout |
228 //-------------------------------------------------------------------------------------------------------------------------------------------- |
273 //-------------------------------------------------------------------------------------------------------------------------------------------- |
229 void GlxDetailsView::updateLayout(Qt::Orientation orient) |
274 void GlxDetailsView::updateLayout(Qt::Orientation orient) |
230 { |
275 { |
231 OstTrace1( TRACE_NORMAL, GLXDETAILSVIEW_UPDATELAYOUT, "GlxDetailsView::updateLayout;orient=%d", orient ); |
276 OstTrace1( TRACE_NORMAL, GLXDETAILSVIEW_UPDATELAYOUT, "GlxDetailsView::updateLayout;orient=%d", orient ); |
232 |
277 |
233 QRect screen_rect = mWindow->geometry(); |
278 qreal IconPosX = 0.0; |
234 setGeometry(screen_rect); |
279 qreal IconPosY = 0.0; |
|
280 qreal FavIconPosX = 0.0; |
|
281 qreal FavIconPosY = 0.0; |
|
282 qreal DataFormX = 0.0; |
|
283 qreal DataFormY = 0.0; |
|
284 qreal DataFormWidth = 0.0; |
|
285 qreal DataFormHeight = 0.0; |
|
286 |
|
287 |
|
288 qreal screenWidth = 0.0; |
|
289 qreal screenHeight = 0.0; |
|
290 qreal leftMargin = 0.0; |
|
291 qreal bottomMargin = 0.0; |
|
292 qreal screenMargin = 0.0; |
|
293 qreal favIconSize = 0.0; |
|
294 qreal chromeHeight = 0.0; |
|
295 qreal middleVerticalMargin = 0.0; |
|
296 |
|
297 style()->parameter("hb-param-screen-width", screenWidth); |
|
298 style()->parameter("hb-param-screen-height", screenHeight); |
|
299 |
|
300 style()->parameter("hb-param-margin-gene-middle-vertical", middleVerticalMargin); |
|
301 style()->parameter("hb-param-margin-gene-left", leftMargin); |
|
302 style()->parameter("hb-param-margin-gene-bottom", bottomMargin); |
|
303 style()->parameter("hb-param-margin-gene-screen", screenMargin); |
|
304 |
|
305 style()->parameter("hb-param-graphic-size-primary-small", favIconSize); |
|
306 style()->parameter("hb-param-widget-chrome-height", chromeHeight); |
|
307 |
235 |
308 |
236 if(orient == Qt::Horizontal) |
309 if(orient == Qt::Horizontal) |
237 { |
310 { |
238 OstTrace0( TRACE_NORMAL, DUP1_GLXDETAILSVIEW_UPDATELAYOUT, "GlxDetailsView::updateLayout HORIZONTAL" ); |
311 OstTrace0( TRACE_NORMAL, DUP1_GLXDETAILSVIEW_UPDATELAYOUT, "GlxDetailsView::updateLayout HORIZONTAL" ); |
239 mDetailsIcon->setPos(15,75); |
312 setGeometry(0,0,640,360); |
240 mDataForm->setGeometry(301,60,335,300); |
313 IconPosX = screenMargin; |
|
314 IconPosY = (screenMargin + chromeHeight); |
|
315 FavIconPosX = (IconPosX + GLX_IMAGE_SIZE - (favIconSize +10)); |
|
316 FavIconPosY = (IconPosY + GLX_IMAGE_SIZE - (favIconSize + 10)); |
|
317 DataFormX = screenMargin + GLX_IMAGE_SIZE + leftMargin ; |
|
318 DataFormY = screenMargin + chromeHeight ; |
|
319 |
|
320 //This Commented code should be un commented , once the screen width and height size issue is solved and also |
|
321 //the dataform issue of wrapping issue is solved |
|
322 // DataFormWidth = screenWidth(640) - DataFormX - screenMargin ; |
|
323 // DataFormHeight = screenHeight(360) - DataFormY - screenMargin ; |
|
324 DataFormWidth = screenWidth - (screenMargin + screenMargin) ; |
|
325 DataFormHeight = screenHeight - DataFormY; |
241 |
326 |
242 } |
327 } |
243 else |
328 else |
244 { |
329 { |
245 OstTrace0( TRACE_NORMAL, DUP2_GLXDETAILSVIEW_UPDATELAYOUT, "GlxDetailsView::updateLayout VERTICAL" ); |
330 OstTrace0( TRACE_NORMAL, DUP2_GLXDETAILSVIEW_UPDATELAYOUT, "GlxDetailsView::updateLayout VERTICAL" ); |
246 mDetailsIcon->setPos(25,75); |
331 setGeometry(0,0,screenWidth,screenHeight); |
247 mDataForm->setGeometry(5,351,335,300); |
332 IconPosX = (screenWidth/2) - (GLX_IMAGE_SIZE/2); |
248 mDataForm->setMaximumWidth(340); |
333 IconPosY = (screenMargin + chromeHeight); |
|
334 FavIconPosX = (IconPosX + GLX_IMAGE_SIZE - (favIconSize +10)); |
|
335 FavIconPosY = (IconPosY + GLX_IMAGE_SIZE - (favIconSize +10)); |
|
336 DataFormX = screenMargin; |
|
337 DataFormY = IconPosY + GLX_IMAGE_SIZE + middleVerticalMargin + bottomMargin ; |
|
338 DataFormWidth = screenWidth - (screenMargin + screenMargin) ; |
|
339 DataFormHeight = screenHeight - DataFormY; |
249 } |
340 } |
250 } |
341 |
251 |
342 mDetailsIcon->setPos(IconPosX,IconPosY); |
|
343 //The Numerical should be updated once we get the parameters size from the layouts. |
|
344 mFavIcon->setItemGeometry(QRect(FavIconPosX-2 ,FavIconPosY-2 ,favIconSize+12,favIconSize + 12)) ; |
|
345 //Place the FavIcon with respect to the Widget. |
|
346 mFavIcon->setItemPos(2 ,2 ); |
|
347 mDataForm->setGeometry(DataFormX,DataFormY,DataFormWidth,DataFormHeight); |
|
348 } |
|
349 |
|
350 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
351 //rowsRemoved |
|
352 //-------------------------------------------------------------------------------------------------------------------------------------------- |
252 void GlxDetailsView::rowsRemoved(const QModelIndex &parent, int start, int end) |
353 void GlxDetailsView::rowsRemoved(const QModelIndex &parent, int start, int end) |
253 { |
354 { |
254 Q_UNUSED(parent); |
355 Q_UNUSED(parent); |
255 Q_UNUSED(start); |
356 Q_UNUSED(start); |
256 Q_UNUSED(end); |
357 Q_UNUSED(end); |
269 //showImage |
370 //showImage |
270 //-------------------------------------------------------------------------------------------------------------------------------------------- |
371 //-------------------------------------------------------------------------------------------------------------------------------------------- |
271 void GlxDetailsView::showImage() |
372 void GlxDetailsView::showImage() |
272 { |
373 { |
273 OstTrace0( TRACE_NORMAL, GLXDETAILSVIEW_SHOWIMAGE, "GlxDetailsView::showImage" ); |
374 OstTrace0( TRACE_NORMAL, GLXDETAILSVIEW_SHOWIMAGE, "GlxDetailsView::showImage" ); |
274 |
375 |
275 QVariant variant = mModel->data( mModel->index(0,0), GlxFocusIndexRole ); |
376 QVariant variant = mModel->data( mModel->index(0,0), GlxFocusIndexRole ); |
276 if ( variant.isValid() && variant.canConvert<int> () ) { |
377 if ( variant.isValid() && variant.canConvert<int> () ) { |
277 mSelIndex = variant.value<int>(); |
378 mSelIndex = variant.value<int>(); |
278 } |
379 } |
279 |
380 |
280 variant = mModel->data( mModel->index( mSelIndex ,0), GlxFsImageRole); |
381 variant = mModel->data( mModel->index( mSelIndex ,0), GlxFsImageRole); |
281 if ( variant.isValid() && variant.canConvert<HbIcon> () ) |
382 if ( variant.isValid() && variant.canConvert<HbIcon> () ) |
282 { |
383 { |
283 if(mWindow->orientation() == Qt::Horizontal) |
384 QIcon itemIcon = variant.value<HbIcon>().qicon(); |
284 { |
385 QPixmap itemPixmap = itemIcon.pixmap(GLX_IMAGE_SIZE,GLX_IMAGE_SIZE); |
285 OstTrace0( TRACE_NORMAL, DUP1_GLXDETAILSVIEW_SHOWIMAGE, "GlxDetailsView::showImage HORIZONTAL" ); |
386 QSize sz(GLX_IMAGE_SIZE,GLX_IMAGE_SIZE); |
286 |
387 itemPixmap = itemPixmap.scaled(sz, Qt::IgnoreAspectRatio ); |
287 mDetailsIcon->resize(QSize(270, 270)); |
388 |
288 mDetailsIcon->setIcon(variant.value<HbIcon>()); |
389 |
289 } |
390 HbIcon tmp = HbIcon( QIcon(itemPixmap)) ; |
290 else |
391 mDetailsIcon->setSize(QSize(GLX_IMAGE_SIZE, GLX_IMAGE_SIZE)); |
291 { |
392 mDetailsIcon->setIcon(tmp); |
292 OstTrace0( TRACE_NORMAL, DUP2_GLXDETAILSVIEW_SHOWIMAGE, "GlxDetailsView::showImage VERTICAL" ); |
393 mFavIcon->setItemIcon(HbIcon("qtg_graf_ratingslider_unrated")); |
293 mDetailsIcon->resize(QSize(310, 260)); |
394 |
294 mDetailsIcon->setIcon(variant.value<HbIcon>()); |
395 qreal favIconSize = 0.0; |
295 } |
396 style()->parameter("hb-param-graphic-size-primary-small", favIconSize); |
296 } |
397 mFavIcon->setItemSize(QSize(favIconSize+10, favIconSize+10)); |
|
398 } |
297 } |
399 } |
298 |
400 |
299 //-------------------------------------------------------------------------------------------------------------------------------------------- |
401 //-------------------------------------------------------------------------------------------------------------------------------------------- |
300 //FillData |
402 //FillData |
301 //-------------------------------------------------------------------------------------------------------------------------------------------- |
403 //-------------------------------------------------------------------------------------------------------------------------------------------- |
302 void GlxDetailsView::setFormData() |
404 void GlxDetailsView::setFormData() |
303 { |
405 { |
304 OstTrace0( TRACE_NORMAL, GLXDETAILSVIEW_SETFORMDATA, "GlxDetailsView::setFormData" ); |
406 OstTrace0( TRACE_NORMAL, GLXDETAILSVIEW_SETFORMDATA, "GlxDetailsView::setFormData" ); |
305 |
407 |
|
408 //create and set the Favourite Model |
|
409 setFavModel(); |
|
410 |
306 //Call to set the Image Name |
411 //Call to set the Image Name |
307 setImageName(); |
412 setImageName(); |
|
413 |
308 //Call to set the date in the from |
414 //Call to set the date in the from |
309 setDate(); |
415 setDate(); |
310 } |
416 } |
311 |
417 |
312 //-------------------------------------------------------------------------------------------------------------------------------------------- |
418 //-------------------------------------------------------------------------------------------------------------------------------------------- |
317 OstTraceFunctionEntry0( GLXDETAILSVIEW_SETIMAGENAME_ENTRY ); |
423 OstTraceFunctionEntry0( GLXDETAILSVIEW_SETIMAGENAME_ENTRY ); |
318 |
424 |
319 QString imagePath = (mModel->data(mModel->index(mModel->data(mModel->index(0,0),GlxFocusIndexRole).value<int>(),0),GlxUriRole)).value<QString>(); |
425 QString imagePath = (mModel->data(mModel->index(mModel->data(mModel->index(0,0),GlxFocusIndexRole).value<int>(),0),GlxUriRole)).value<QString>(); |
320 QString imageName = imagePath.section('\\',-1); |
426 QString imageName = imagePath.section('\\',-1); |
321 |
427 |
322 //Fetch the text edit for displaying the Name from the Form Model |
428 mImageLabelitem->setContentWidgetData("text",imageName); |
323 GlxDetailsCustomWidgets * imageLabel = (GlxDetailsCustomWidgets *)mDataForm->itemByIndex(mDetailModel->index(0,0)); |
|
324 |
|
325 if(imageLabel) |
|
326 { |
|
327 OstTrace0( TRACE_NORMAL, GLXDETAILSVIEW_SETIMAGENAME, "GlxDetailsView::setImageName ImageLabel !=NULL" ); |
|
328 HbLineEdit* label = static_cast<HbLineEdit*>(imageLabel->dataItemContentWidget()); |
|
329 |
|
330 if(label) |
|
331 { |
|
332 OstTrace0( TRACE_NORMAL, DUP1_GLXDETAILSVIEW_SETIMAGENAME, "GlxDetailsView::setImageName SetText" ); |
|
333 label->setText(imageName); |
|
334 } |
|
335 } |
|
336 OstTraceFunctionExit0( GLXDETAILSVIEW_SETIMAGENAME_EXIT ); |
429 OstTraceFunctionExit0( GLXDETAILSVIEW_SETIMAGENAME_EXIT ); |
337 } |
430 } |
338 |
431 |
339 //-------------------------------------------------------------------------------------------------------------------------------------------- |
432 //-------------------------------------------------------------------------------------------------------------------------------------------- |
340 //setDate |
433 //setDate |
341 //-------------------------------------------------------------------------------------------------------------------------------------------- |
434 //-------------------------------------------------------------------------------------------------------------------------------------------- |
342 void GlxDetailsView::setDate() |
435 void GlxDetailsView::setDate() |
343 { |
436 { |
344 OstTraceFunctionEntry0( GLXDETAILSVIEW_SETDATE_ENTRY ); |
437 OstTraceFunctionEntry0( GLXDETAILSVIEW_SETDATE_ENTRY ); |
345 |
438 |
346 QString datestring; |
439 QString datestring; |
347 QString str("dd.MM.yyyy"); |
440 QString str("dd.MM.yyyy"); |
348 QDate date = (mModel->data(mModel->index(mModel->data(mModel->index(0,0),GlxFocusIndexRole).value<int>(),0),GlxDateRole)).value<QDate>(); |
441 QDate date = (mModel->data(mModel->index(mModel->data(mModel->index(0,0),GlxFocusIndexRole).value<int>(),0),GlxDateRole)).value<QDate>(); |
349 |
442 |
350 if(date.isNull() == FALSE ) |
443 if(date.isNull() == FALSE ) |
351 { |
444 { |
352 OstTrace0( TRACE_NORMAL, GLXDETAILSVIEW_SETDATE, "GlxDetailsView::setDate is not NULL" ); |
445 OstTrace0( TRACE_NORMAL, GLXDETAILSVIEW_SETDATE, "GlxDetailsView::setDate is not NULL" ); |
353 datestring = date.toString(str); |
446 datestring = date.toString(str); |
354 } |
447 } |
355 |
448 |
356 //Fetch the Label from the Form Model |
449 mDateLabelItem->setContentWidgetData("plainText",datestring); |
357 GlxDetailsCustomWidgets * dateLabel = (GlxDetailsCustomWidgets *)mDataForm->itemByIndex(mDetailModel->index(1,0)); |
450 |
358 |
|
359 if(dateLabel) |
|
360 { |
|
361 OstTrace0( TRACE_NORMAL, DUP1_GLXDETAILSVIEW_SETDATE, "GlxDetailsView::setDate Datelabel is not NULL" ); |
|
362 |
|
363 HbLabel* label = static_cast<HbLabel*>(dateLabel->dataItemContentWidget()); |
|
364 |
|
365 if(label) |
|
366 { |
|
367 OstTrace0( TRACE_NORMAL, DUP2_GLXDETAILSVIEW_SETDATE, "GlxDetailsView::setDate SetText" ); |
|
368 label->setPlainText(datestring); |
|
369 } |
|
370 } |
|
371 OstTraceFunctionExit0( GLXDETAILSVIEW_SETDATE_EXIT ); |
451 OstTraceFunctionExit0( GLXDETAILSVIEW_SETDATE_EXIT ); |
372 } |
452 } |
373 |
453 |
|
454 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
455 //initializeNewModel |
|
456 //-------------------------------------------------------------------------------------------------------------------------------------------- |
374 void GlxDetailsView::initializeNewModel() |
457 void GlxDetailsView::initializeNewModel() |
375 { |
458 { |
376 OstTrace0( TRACE_NORMAL, GLXDETAILSVIEW_INITIALIZENEWMODEL, "GlxDetailsView::initializeNewModel" ); |
459 OstTrace0( TRACE_NORMAL, GLXDETAILSVIEW_INITIALIZENEWMODEL, "GlxDetailsView::initializeNewModel" ); |
377 |
460 |
378 if ( mModel ) { |
461 if ( mModel ) { |
379 connect(mModel, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(rowsRemoved(QModelIndex,int,int))); |
462 connect(mModel, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(rowsRemoved(QModelIndex,int,int))); |
380 } |
463 } |
381 } |
464 } |
382 |
465 |
|
466 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
467 //clearCurrentModel |
|
468 //-------------------------------------------------------------------------------------------------------------------------------------------- |
383 void GlxDetailsView::clearCurrentModel() |
469 void GlxDetailsView::clearCurrentModel() |
384 { |
470 { |
385 OstTrace0( TRACE_NORMAL, GLXDETAILSVIEW_CLEARCURRENTMODEL, "GlxDetailsView::clearCurrentModel" ); |
471 OstTrace0( TRACE_NORMAL, GLXDETAILSVIEW_CLEARCURRENTMODEL, "GlxDetailsView::clearCurrentModel" ); |
386 |
472 |
387 if ( mModel ) { |
473 if ( mModel ) { |
388 disconnect(mModel, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(rowsRemoved(QModelIndex,int,int))); |
474 disconnect(mModel, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(rowsRemoved(QModelIndex,int,int))); |
389 mModel = NULL ; |
475 mModel = NULL ; |
390 } |
476 } |
391 } |
477 } |
|
478 |
|
479 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
480 //dataChanged |
|
481 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
482 void GlxDetailsView::dataChanged(QModelIndex startIndex, QModelIndex endIndex) |
|
483 { |
|
484 Q_UNUSED(endIndex); |
|
485 |
|
486 QVariant variant = mFavModel->data( startIndex, GlxFavorites ); |
|
487 if ( variant.isValid() && variant.canConvert<bool> () ) |
|
488 { |
|
489 if(variant.value<bool>() ) |
|
490 { |
|
491 mFavIcon->setItemIcon(HbIcon(GLXICON_ADD_TO_FAV)); |
|
492 } |
|
493 else |
|
494 { |
|
495 mFavIcon->setItemIcon(HbIcon(GLXICON_REMOVE_FAV)); |
|
496 } |
|
497 } |
|
498 } |
|
499 |
|
500 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
501 //updateFavourites |
|
502 //-------------------------------------------------------------------------------------------------------------------------------------------- |
|
503 void GlxDetailsView::updateFavourites() |
|
504 { |
|
505 QVariant variant = mFavModel->data(mFavModel->index(0,0), GlxFavorites ); |
|
506 if ( variant.isValid() && variant.canConvert<bool> ()) |
|
507 { |
|
508 if(variant.value<bool>() ) |
|
509 { |
|
510 emit actionTriggered( EGlxCmdRemoveFromFav); |
|
511 } |
|
512 else |
|
513 { |
|
514 emit actionTriggered(EGlxCmdAddToFav); |
|
515 } |
|
516 } |
|
517 } |