16 */ |
16 */ |
17 |
17 |
18 |
18 |
19 |
19 |
20 //Includes |
20 //Includes |
21 #include <QDebug> |
|
22 #include <hbmenu.h> |
|
23 #include <hbaction.h> |
|
24 #include <hbtoolbar.h> |
|
25 #include <hbgridview.h> |
|
26 #include <hbmainwindow.h> |
21 #include <hbmainwindow.h> |
27 #include <shareuidialog.h> |
22 #include <hggrid.h> |
28 #include <hbdocumentloader.h> |
23 #include <glxmodelwrapper.h> |
29 #include <QAbstractItemModel> |
24 #include <hbpushbutton.h> |
30 #include <hbabstractviewitem.h> |
25 #include <HbToolBar> // Temp |
|
26 #include <hbiconitem.h> |
|
27 #include <hbicon.h> |
31 #include <xqserviceutil.h> |
28 #include <xqserviceutil.h> |
32 |
29 |
33 //User Includes |
30 //User Includes |
34 #include "glxuistd.h" |
|
35 #include "glxviewids.h" |
31 #include "glxviewids.h" |
36 #include "glxgridview.h" |
32 #include "glxgridview.h" |
37 #include "glxmodelparm.h" |
33 #include "glxmodelparm.h" |
38 #include "glxloggerenabler.h" |
|
39 #include "glxdocloaderdefs.h" |
|
40 #include "glxcommandhandlers.hrh" |
34 #include "glxcommandhandlers.hrh" |
|
35 |
|
36 |
41 #include "OstTraceDefinitions.h" |
37 #include "OstTraceDefinitions.h" |
42 #ifdef OST_TRACE_COMPILER_IN_USE |
38 #ifdef OST_TRACE_COMPILER_IN_USE |
43 #include "glxgridviewTraces.h" |
39 #include "glxgridviewTraces.h" |
44 #endif |
40 #endif |
45 |
41 |
46 GlxGridView::GlxGridView(HbMainWindow *window) |
42 GlxGridView::GlxGridView(HbMainWindow *window) |
47 : GlxView ( GLX_GRIDVIEW_ID ), |
43 : GlxView ( GLX_GRIDVIEW_ID ), |
48 mGridView(NULL), |
|
49 mView(NULL), |
|
50 mWindow(window), |
44 mWindow(window), |
51 mModel ( NULL), |
45 mModel ( NULL), |
52 mVisualIndex(0), |
46 mWidget(NULL), |
53 mItem(NULL), |
47 mSelectionModel(NULL), |
54 mIsLongPress (false) |
48 mModelWrapper(NULL), |
|
49 mUiOnButton(NULL), |
|
50 mScrolling(FALSE), |
|
51 mIconItem(NULL) |
55 { |
52 { |
56 OstTraceFunctionEntry0( GLXGRIDVIEW_GLXGRIDVIEW_ENTRY ); |
53 OstTraceFunctionEntry0( GLXGRIDVIEW_GLXGRIDVIEW_ENTRY ); |
57 mDocLoader = new HbDocumentLoader(); |
54 mModelWrapper = new GlxModelWrapper(); |
|
55 mModelWrapper->setRoles(GlxQImageSmall); |
|
56 mIconItem = new HbIconItem(this); |
58 OstTraceFunctionExit0( GLXGRIDVIEW_GLXGRIDVIEW_EXIT ); |
57 OstTraceFunctionExit0( GLXGRIDVIEW_GLXGRIDVIEW_EXIT ); |
59 setContentFullScreen( true ); |
|
60 } |
58 } |
61 |
59 |
62 void GlxGridView::activate() |
60 void GlxGridView::activate() |
63 { |
61 { |
64 OstTraceFunctionEntry0( GLXGRIDVIEW_ACTIVATE_ENTRY ); |
62 OstTraceFunctionEntry0( GLXGRIDVIEW_ACTIVATE_ENTRY ); |
65 loadGridView(mWindow->orientation()); |
63 if(mUiOnButton == NULL) { |
66 addViewConnection(); |
64 mUiOnButton = new HbPushButton("UI",this); |
67 mGridView->resetTransform(); //to reset the transition effect (reset transform matrix) |
65 connect(mUiOnButton, SIGNAL(clicked(bool)), this, SLOT(uiButtonClicked(bool))); |
68 mGridView->setOpacity( 1); |
66 mUiOnButton->setGeometry(QRectF(610,0,15,15)); |
69 resetItemTransform(); |
67 mUiOnButton->setZValue(1); |
|
68 mUiOnButton->hide(); |
|
69 } |
|
70 loadGridView(); |
70 OstTraceFunctionExit0( GLXGRIDVIEW_ACTIVATE_EXIT ); |
71 OstTraceFunctionExit0( GLXGRIDVIEW_ACTIVATE_EXIT ); |
71 } |
72 } |
72 |
73 |
73 void GlxGridView::deActivate() |
74 void GlxGridView::deActivate() |
74 { |
75 { |
75 OstTraceFunctionEntry0( GLXGRIDVIEW_DEACTIVATE_ENTRY ); |
76 OstTraceFunctionEntry0( GLXGRIDVIEW_DEACTIVATE_ENTRY ); |
76 removeViewConnection(); |
77 if (mUiOnButton && mUiOnButton->isVisible()) |
77 mModel = NULL; |
78 { |
|
79 mUiOnButton->hide(); |
|
80 } |
|
81 if(mIconItem) |
|
82 { |
|
83 mIconItem->hide(); |
|
84 mIconItem->resetTransform(); |
|
85 mIconItem->setOpacity(0); |
|
86 mIconItem->setZValue(mIconItem->zValue()-20); |
|
87 } |
78 OstTraceFunctionExit0( GLXGRIDVIEW_DEACTIVATE_EXIT ); |
88 OstTraceFunctionExit0( GLXGRIDVIEW_DEACTIVATE_EXIT ); |
79 } |
89 } |
80 |
90 |
81 void GlxGridView::initializeView(QAbstractItemModel *model) |
91 void GlxGridView::initializeView(QAbstractItemModel *model) |
82 { |
92 { |
83 resetItemTransform(); |
93 activate(); |
84 mGridView->setModel(model); |
94 setModel(model); |
85 mModel = model; |
|
86 loadGridView(mWindow->orientation()); |
|
87 QVariant variant = model->data( model->index(0,0), GlxFocusIndexRole ); |
|
88 if ( variant.isValid() && variant.canConvert<int> () ) { |
|
89 mGridView->scrollTo( model->index( variant.value<int>(),0), HbGridView::EnsureVisible ); |
|
90 } |
|
91 } |
95 } |
92 |
96 |
93 void GlxGridView::setModel(QAbstractItemModel *model) |
97 void GlxGridView::setModel(QAbstractItemModel *model) |
94 { |
98 { |
95 OstTraceFunctionEntry0( GLXGRIDVIEW_SETMODEL_ENTRY ); |
99 OstTraceFunctionEntry0( GLXGRIDVIEW_SETMODEL_ENTRY ); |
96 mModel = model ; |
100 if(model) |
97 mGridView->setModel(mModel); |
101 { |
98 QVariant variant = mModel->data( mModel->index(0,0), GlxFocusIndexRole ); |
102 mModel = model; |
99 if ( variant.isValid() && variant.canConvert<int> () ) { |
103 QVariant variantimage = mModel->data(mModel->index(0,0),GlxDefaultImage); |
100 mGridView->scrollTo( mModel->index( variant.value<int>(),0), HbGridView::EnsureVisible ); |
104 if (mWidget && variantimage.isValid() && variantimage.canConvert<QImage> () ) |
101 } |
105 { |
|
106 mWidget->setDefaultImage(variantimage.value<QImage>()); |
|
107 } |
|
108 mModelWrapper->setModel(mModel); |
|
109 mWidget->setModel(mModelWrapper); |
|
110 if(!mSelectionModel) |
|
111 { |
|
112 mSelectionModel = new QItemSelectionModel(mModelWrapper, this); |
|
113 connect(mSelectionModel, SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)), this, SLOT(visibleIndexChanged(const QModelIndex &, const QModelIndex &))); |
|
114 mWidget->setSelectionModel(mSelectionModel); |
|
115 } |
|
116 scrolltofocus(); // Need to do it here ? |
|
117 } |
102 OstTraceFunctionExit0( GLXGRIDVIEW_SETMODEL_EXIT ); |
118 OstTraceFunctionExit0( GLXGRIDVIEW_SETMODEL_EXIT ); |
103 } |
119 } |
104 |
120 |
|
121 void GlxGridView::visibleIndexChanged(const QModelIndex& current, const QModelIndex& previous) |
|
122 { |
|
123 if(mScrolling) |
|
124 { |
|
125 Q_UNUSED(previous); |
|
126 if(current.row() >= 0 || current.row() < mModel->rowCount()) |
|
127 { |
|
128 mModel->setData(mModel->index(0,0),current.row(),GlxVisualWindowIndex); |
|
129 } |
|
130 } |
|
131 } |
|
132 |
105 void GlxGridView::addToolBar( HbToolBar *toolBar ) |
133 void GlxGridView::addToolBar( HbToolBar *toolBar ) |
106 { |
134 { |
107 OstTraceFunctionEntry0( GLXGRIDVIEW_ADDTOOLBAR_ENTRY ); |
135 OstTraceFunctionEntry0( GLXGRIDVIEW_ADDTOOLBAR_ENTRY ); |
108 setToolBar(toolBar) ; |
136 setToolBar(toolBar); |
|
137 hideorshowitems(mWindow->orientation()); |
109 OstTraceFunctionExit0( GLXGRIDVIEW_ADDTOOLBAR_EXIT ); |
138 OstTraceFunctionExit0( GLXGRIDVIEW_ADDTOOLBAR_EXIT ); |
110 } |
139 } |
111 |
140 |
112 void GlxGridView::enableMarking() |
141 void GlxGridView::enableMarking() |
113 { |
142 { |
114 OstTrace0( TRACE_NORMAL, GLXGRIDVIEW_ENABLEMARKING, "GlxGridView::enableMarking" ); |
143 OstTrace0( TRACE_NORMAL, GLXGRIDVIEW_ENABLEMARKING, "GlxGridView::enableMarking" ); |
115 mGridView->setSelectionMode(HbGridView::MultiSelection); |
144 mWidget->setSelectionMode(HgWidget::MultiSelection); |
116 } |
145 } |
117 |
146 |
118 void GlxGridView::disableMarking() |
147 void GlxGridView::disableMarking() |
119 { |
148 { |
120 OstTrace0( TRACE_NORMAL, GLXGRIDVIEW_DISABLEMARKING, "GlxGridView::disableMarking" ); |
149 OstTrace0( TRACE_NORMAL, GLXGRIDVIEW_DISABLEMARKING, "GlxGridView::disableMarking" ); |
121 mGridView->setSelectionMode(HbGridView::NoSelection); |
150 mWidget->setSelectionMode(HgWidget::NoSelection); |
122 } |
151 } |
123 |
152 |
124 void GlxGridView::handleUserAction(qint32 commandId) |
153 void GlxGridView::handleUserAction(qint32 commandId) |
125 { |
154 { |
126 OstTrace0( TRACE_NORMAL, GLXGRIDVIEW_HANDLEUSERACTION, "GlxGridView::handleUserAction" ); |
155 OstTrace0( TRACE_NORMAL, GLXGRIDVIEW_HANDLEUSERACTION, "GlxGridView::handleUserAction" ); |
127 switch( commandId ){ |
156 switch( commandId ) { |
128 case EGlxCmdMarkAll : |
157 case EGlxCmdMarkAll : |
129 mGridView->selectAll(); |
158 mWidget->selectAll(); |
130 break; |
159 break; |
131 |
160 |
132 case EGlxCmdUnMarkAll : |
161 case EGlxCmdUnMarkAll : |
133 mGridView->clearSelection(); |
162 mWidget->clearSelection(); |
134 break; |
163 break; |
135 |
|
136 |
|
137 |
164 |
138 default : |
165 default : |
139 break; |
166 break; |
140 } |
167 } |
141 } |
168 } |
142 |
169 |
143 QItemSelectionModel * GlxGridView::getSelectionModel() |
170 QItemSelectionModel * GlxGridView::getSelectionModel() |
144 { |
171 { |
145 OstTrace0( TRACE_NORMAL, GLXGRIDVIEW_GETSELECTIONMODEL, "GlxGridView::getSelectionModel" ); |
172 OstTrace0( TRACE_NORMAL, GLXGRIDVIEW_GETSELECTIONMODEL, "GlxGridView::getSelectionModel" ); |
146 return mGridView->selectionModel(); |
173 return mWidget->selectionModel(); |
147 } |
174 } |
148 |
175 |
149 QGraphicsItem * GlxGridView::getAnimationItem(GlxEffect transitionEffect) |
176 QGraphicsItem * GlxGridView::getAnimationItem(GlxEffect transitionEffect) |
150 { |
177 { |
151 OstTraceFunctionEntry0( GLXGRIDVIEW_GETANIMATIONITEM_ENTRY ); |
178 OstTraceFunctionEntry0( GLXGRIDVIEW_GETANIMATIONITEM_ENTRY ); |
152 int selIndex = -1; |
179 int selIndex = -1; |
153 |
180 |
154 if ( transitionEffect == FULLSCREEN_TO_GRID ) { |
181 if ( transitionEffect == FULLSCREEN_TO_GRID ) { |
155 return mGridView; |
182 return mWidget; |
156 } |
183 } |
157 |
184 |
158 if ( transitionEffect == GRID_TO_FULLSCREEN ) { |
185 if ( transitionEffect == GRID_TO_FULLSCREEN ) |
|
186 { |
159 QVariant variant = mModel->data( mModel->index(0,0), GlxFocusIndexRole ); |
187 QVariant variant = mModel->data( mModel->index(0,0), GlxFocusIndexRole ); |
160 if ( variant.isValid() && variant.canConvert<int> () ) { |
188 if ( variant.isValid() && variant.canConvert<int> () ) |
|
189 { |
161 selIndex = variant.value<int>(); |
190 selIndex = variant.value<int>(); |
162 } |
191 } |
163 |
192 else |
164 mItem = mGridView->itemByIndex( mModel->index(selIndex,0) ); |
193 { |
165 connect(mItem, SIGNAL(destroyed()), this, SLOT( itemDestroyed())); |
194 return mWidget; |
166 mItem->setZValue( mItem->zValue() + 20); |
195 } |
167 return mItem; |
196 QVariant variantimage = mModel->data(mModel->index(selIndex,0),Qt::DecorationRole); |
168 } |
197 if ( variantimage.isValid() && variantimage.canConvert<HbIcon> () ) |
|
198 { |
|
199 QPolygonF poly; |
|
200 if (mModelWrapper && !mWidget->getItemOutline(mModelWrapper->index(selIndex,0), poly)) |
|
201 { |
|
202 return mWidget; |
|
203 } |
|
204 QRectF itemRect = poly.boundingRect(); |
|
205 |
|
206 mIconItem->setSize(QSize(120,120)); |
|
207 HbIcon tempIcon = variantimage.value<HbIcon>(); |
|
208 QPixmap tempPixmap = tempIcon.qicon().pixmap(120, 120); |
|
209 QSize sz = QSize ( 120, 120); |
|
210 tempPixmap = tempPixmap.scaled(sz, Qt::IgnoreAspectRatio ); |
|
211 HbIcon tmp = HbIcon( QIcon(tempPixmap)) ; |
|
212 mIconItem->setIcon(tmp); |
|
213 mIconItem->setPos(itemRect.topLeft()); |
|
214 mIconItem->setZValue(mIconItem->zValue() + 20); |
|
215 mIconItem->show(); |
|
216 return mIconItem; |
|
217 } |
|
218 else |
|
219 { |
|
220 return mWidget; |
|
221 } |
|
222 } |
169 |
223 |
170 if ( transitionEffect == GRID_TO_ALBUMLIST || transitionEffect == ALBUMLIST_TO_GRID ){ |
224 if ( transitionEffect == GRID_TO_ALBUMLIST || transitionEffect == ALBUMLIST_TO_GRID ){ |
171 return mGridView; |
225 return mWidget; |
172 } |
226 } |
173 OstTraceFunctionExit0( GLXGRIDVIEW_GETANIMATIONITEM_EXIT ); |
227 OstTraceFunctionExit0( GLXGRIDVIEW_GETANIMATIONITEM_EXIT ); |
174 return NULL; |
228 return NULL; |
175 } |
229 } |
176 |
230 |
177 void GlxGridView::loadGridView(Qt::Orientation orient) |
231 void GlxGridView::loadGridView() |
178 { |
232 { |
179 OstTraceFunctionEntry0( GLXGRIDVIEW_LOADGRIDVIEW_ENTRY ); |
233 OstTraceFunctionEntry0( GLXGRIDVIEW_LOADGRIDVIEW_ENTRY ); |
180 bool loaded = false; |
234 if(mWidget == NULL) { |
181 QString section; |
235 Qt::Orientation orient = mWindow->orientation(); |
182 GlxContextMode mode ; |
236 mWindow->viewport()->grabGesture(Qt::PanGesture); |
183 |
237 mWindow->viewport()->grabGesture(Qt::TapGesture); |
184 //Load the widgets accroding to the current Orientation |
238 mWindow->viewport()->grabGesture(Qt::TapAndHoldGesture); |
185 if(orient == Qt::Horizontal) { |
239 mWidget = new HgGrid(orient); |
186 section = GLX_GRIDVIEW_LSSECTION ; |
240 mWidget->setLongPressEnabled(true); |
187 mode = GlxContextLsGrid ; |
241 mWidget->setScrollBarPolicy(HgWidget::ScrollBarAutoHide); |
188 } |
242 //mWidget->setItemSize(QSizeF(120,120)); |
189 else { |
243 setWidget( mWidget ); |
190 section = GLX_GRIDVIEW_PTSECTION ; |
244 addViewConnection(); |
191 mode = GlxContextPtGrid ; |
245 //hideorshowitems(orient); |
192 } |
|
193 |
|
194 if (mGridView == NULL ) { |
|
195 mDocLoader->load(GLX_GRIDVIEW_DOCMLPATH,&loaded); |
|
196 if(loaded) { |
|
197 //retrieve the widgets |
|
198 mView = static_cast<HbView*>(mDocLoader->findWidget(QString(GLX_GRIDVIEW_VIEW))); |
|
199 mGridView = static_cast<HbGridView*>(mDocLoader->findWidget(GLX_GRIDVIEW_GRID)); |
|
200 setWidget( mView ); |
|
201 mGridView->setLayoutName( QString( "GridView" ) ); |
|
202 } |
|
203 } |
|
204 //Load the Sections |
|
205 mDocLoader->load(GLX_GRIDVIEW_DOCMLPATH,section,&loaded); |
|
206 |
|
207 if ( mModel ) { |
|
208 mModel->setData(QModelIndex(), (int)mode, GlxContextRole ); |
|
209 } |
246 } |
210 OstTraceFunctionExit0( GLXGRIDVIEW_LOADGRIDVIEW_EXIT ); |
247 OstTraceFunctionExit0( GLXGRIDVIEW_LOADGRIDVIEW_EXIT ); |
211 } |
248 } |
212 |
249 |
213 void GlxGridView::itemDestroyed() |
250 void GlxGridView::orientationchanged(Qt::Orientation orient) |
214 { |
251 { |
215 OstTrace0( TRACE_NORMAL, GLXGRIDVIEW_ITEMDESTROYED, "GlxGridView::itemDestroyed" ); |
252 hideorshowitems(orient); |
216 disconnect( mItem, SIGNAL( destroyed() ), this, SLOT( itemDestroyed() ) ); |
253 } |
217 mItem = NULL; |
254 void GlxGridView::hideorshowitems(Qt::Orientation orient) |
|
255 { |
|
256 if(orient == Qt::Horizontal) |
|
257 { |
|
258 if (mUiOnButton) |
|
259 { |
|
260 mUiOnButton->show(); |
|
261 } |
|
262 setItemVisible(Hb::AllItems, FALSE) ; |
|
263 } |
|
264 else |
|
265 { |
|
266 if (mUiOnButton) |
|
267 { |
|
268 mUiOnButton->hide(); |
|
269 } |
|
270 setItemVisible(Hb::AllItems, TRUE) ; |
|
271 } |
|
272 } |
|
273 |
|
274 void GlxGridView::scrolltofocus() |
|
275 { |
|
276 if(mModelWrapper && mWidget) |
|
277 { |
|
278 QVariant variant = mModelWrapper->data( mModelWrapper->index(0,0), GlxFocusIndexRole ); |
|
279 if ( variant.isValid() && variant.canConvert<int> () ) |
|
280 { |
|
281 mWidget->scrollTo( mModelWrapper->index( variant.value<int>(),0) ); |
|
282 mModel->setData(mModel->index(0,0),variant.value<int>(),GlxVisualWindowIndex); |
|
283 } |
|
284 } |
218 } |
285 } |
219 |
286 |
220 QVariant GlxGridView::itemChange (GraphicsItemChange change, const QVariant &value) |
287 QVariant GlxGridView::itemChange (GraphicsItemChange change, const QVariant &value) |
221 { |
288 { |
222 OstTrace0( TRACE_NORMAL, GLXGRIDVIEW_ITEMCHANGE, "GlxGridView::itemChange" ); |
289 OstTrace0( TRACE_NORMAL, GLXGRIDVIEW_ITEMCHANGE, "GlxGridView::itemChange" ); |
223 |
|
224 static bool isEmit = true; |
290 static bool isEmit = true; |
225 |
|
226 if ( isEmit && change == QGraphicsItem::ItemVisibleHasChanged && value.toBool() ) { |
291 if ( isEmit && change == QGraphicsItem::ItemVisibleHasChanged && value.toBool() ) { |
227 emit actionTriggered( EGlxCmdSetupItem ); |
292 emit actionTriggered( EGlxCmdSetupItem ); |
228 isEmit = false; |
293 isEmit = false; |
229 } |
294 } |
230 return HbWidget::itemChange(change, value); |
295 return HbWidget::itemChange(change, value); |
231 } |
296 } |
232 |
297 |
233 void GlxGridView::addViewConnection () |
298 void GlxGridView::addViewConnection() |
234 { |
299 { |
235 OstTrace0( TRACE_NORMAL, GLXGRIDVIEW_ADDVIEWCONNECTION, "GlxGridView::addViewConnection" ); |
300 OstTrace0( TRACE_NORMAL, GLXGRIDVIEW_ADDVIEWCONNECTION, "GlxGridView::addViewConnection" ); |
236 connect(mWindow, SIGNAL(orientationChanged(Qt::Orientation)), this, SLOT(loadGridView(Qt::Orientation))); |
301 connect(mWindow, SIGNAL(orientationChanged(Qt::Orientation)), this, SLOT(orientationchanged(Qt::Orientation))); |
237 connect(mGridView, SIGNAL(activated(const QModelIndex &)), this, SLOT( itemSelected(const QModelIndex &))); |
302 //connect(mWindow, SIGNAL(aboutToChangeOrientation()), mWidget, SLOT(aboutToChangeOrientation())); |
238 connect( mGridView, SIGNAL( scrollingEnded() ), this, SLOT( setVisvalWindowIndex() ) ); |
303 connect(mWindow, SIGNAL(orientationChanged(Qt::Orientation)), mWidget, SLOT(orientationChanged(Qt::Orientation))); |
239 connect(mGridView, SIGNAL(longPressed( HbAbstractViewItem*, QPointF )),this, SLOT( indicateLongPress( HbAbstractViewItem*, QPointF ) ) ); |
304 connect(mWidget, SIGNAL(activated(const QModelIndex &)), SLOT( itemSelected(const QModelIndex &))); |
|
305 connect(mWidget, SIGNAL( scrollingStarted() ), this, SLOT( scrollingStarted() ) ); |
|
306 connect(mWidget, SIGNAL( scrollingEnded() ), this, SLOT( scrollingEnded() ) ); |
|
307 connect(mWidget, SIGNAL(longPressed(const QModelIndex &, QPointF)), SLOT( indicateLongPress(const QModelIndex &, QPointF) ) ); |
240 } |
308 } |
241 |
309 |
242 void GlxGridView::removeViewConnection () |
310 void GlxGridView::removeViewConnection () |
243 { |
311 { |
244 OstTrace0( TRACE_NORMAL, GLXGRIDVIEW_REMOVEVIEWCONNECTION, "GlxGridView::removeViewConnection" ); |
312 OstTrace0( TRACE_NORMAL, GLXGRIDVIEW_REMOVEVIEWCONNECTION, "GlxGridView::removeViewConnection" ); |
245 disconnect(mWindow, SIGNAL(orientationChanged(Qt::Orientation)), this, SLOT(loadGridView(Qt::Orientation))); |
313 if(mWidget) |
246 disconnect(mGridView, SIGNAL(activated(const QModelIndex &)), this, SLOT( itemSelected(const QModelIndex &))); |
314 { |
247 disconnect( mGridView, SIGNAL( scrollingEnded() ), this, SLOT( setVisvalWindowIndex() ) ); |
315 disconnect(mWindow, SIGNAL(orientationChanged(Qt::Orientation)), this, SLOT(orientationchanged(Qt::Orientation))); |
248 disconnect(mGridView, SIGNAL(longPressed( HbAbstractViewItem*, QPointF )),this, SLOT( indicateLongPress( HbAbstractViewItem*, QPointF ) ) ); |
316 //disconnect(mWindow, SIGNAL(aboutToChangeOrientation()), mWidget, SLOT(aboutToChangeOrientation())); |
249 } |
317 disconnect(mWindow, SIGNAL(orientationChanged(Qt::Orientation)), mWidget, SLOT(orientationChanged(Qt::Orientation))); |
250 |
318 disconnect(mWidget, SIGNAL(activated(const QModelIndex &)),this, SLOT( itemSelected(const QModelIndex &))); |
251 void GlxGridView::resetItemTransform() |
319 disconnect(mWidget, SIGNAL( scrollingStarted() ), this, SLOT( scrollingStarted() ) ); |
252 { |
320 disconnect(mWidget, SIGNAL( scrollingEnded() ), this, SLOT( scrollingEnded() ) ); |
253 if ( mItem ) { |
321 disconnect(mWidget, SIGNAL(longPressed(const QModelIndex &, QPointF)),this, SLOT( indicateLongPress(const QModelIndex &, QPointF) ) ); |
254 mItem->resetTransform(); //to reset the transition effect (reset transform matrix) |
322 } |
255 mItem->setOpacity( 1); |
323 } |
256 mItem->setZValue( mItem->zValue() - 20); |
324 |
257 disconnect( mItem, SIGNAL( destroyed() ), this, SLOT( itemDestroyed() ) ); |
|
258 mItem = NULL; |
|
259 } |
|
260 } |
|
261 |
325 |
262 void GlxGridView::itemSelected(const QModelIndex & index) |
326 void GlxGridView::itemSelected(const QModelIndex & index) |
263 { |
327 { |
264 OstTrace1( TRACE_NORMAL, GLXGRIDVIEW_ITEMSELECTED, "GlxGridView::itemSelected;index=%d", index.row() ); |
328 OstTrace1( TRACE_NORMAL, GLXGRIDVIEW_ITEMSELECTED, "GlxGridView::itemSelected;index=%d", index.row() ); |
265 |
329 if ( mWidget->selectionMode() == HgWidget::MultiSelection ) |
266 if ( mGridView->selectionMode() == HbGridView::MultiSelection ) { //in multi selection mode no need to open the full screen |
330 { |
267 return ; |
331 return ; |
268 } |
332 } |
269 if ( mIsLongPress ) { |
333 if(XQServiceUtil::isService()){ |
270 mIsLongPress = false; |
|
271 return ; |
|
272 } |
|
273 if(XQServiceUtil::isService()){ |
|
274 emit gridItemSelected(index); |
334 emit gridItemSelected(index); |
275 return; |
335 return; |
276 } |
336 } |
277 |
337 OstTraceEventStart0( EVENT_DUP1_GLXGRIDVIEW_ITEMSELECTED_START, "Fullscreen Launch Time" ); |
278 OstTraceEventStart0( EVENT_DUP1_GLXGRIDVIEW_ITEMSELECTED_START, "Fullscreen Launch Time" ); |
338 if ( mModel ) |
279 |
339 { |
280 if ( mModel ) { |
|
281 mModel->setData( index, index.row(), GlxFocusIndexRole ); |
340 mModel->setData( index, index.row(), GlxFocusIndexRole ); |
282 } |
341 } |
283 emit actionTriggered( EGlxCmdFullScreenOpen ); |
342 setItemVisible(Hb::AllItems, FALSE); |
|
343 emit actionTriggered( EGlxCmdFullScreenOpen ); |
284 OstTraceEventStop( EVENT_DUP1_GLXGRIDVIEW_ITEMSELECTED_STOP, "Fullscreen Launch Time", EVENT_DUP1_GLXGRIDVIEW_ITEMSELECTED_START ); |
344 OstTraceEventStop( EVENT_DUP1_GLXGRIDVIEW_ITEMSELECTED_STOP, "Fullscreen Launch Time", EVENT_DUP1_GLXGRIDVIEW_ITEMSELECTED_START ); |
285 } |
345 } |
286 |
346 |
287 void GlxGridView::setVisvalWindowIndex() |
347 void GlxGridView::scrollingStarted() |
288 { |
348 { |
289 OstTrace0( TRACE_IMPORTANT, GLXGRIDVIEW_SETVISVALWINDOWINDEX, "GlxGridView::setVisvalWindowIndex" ); |
349 if ((mWindow->orientation() == Qt::Horizontal)) |
290 QList< HbAbstractViewItem * > visibleItemList = mGridView->visibleItems(); |
350 { |
291 qDebug("GlxGridView::setVisvalWindowIndex() %d", visibleItemList.count()); |
351 setItemVisible(Hb::AllItems, FALSE) ; |
292 OstTrace1( TRACE_IMPORTANT, DUP1_GLXGRIDVIEW_SETVISVALWINDOWINDEX, "GlxGridView::setVisvalWindowIndex;visibleitemindex=%d", |
352 } |
293 visibleItemList.count() ); |
353 mScrolling = TRUE; |
294 |
354 } |
295 if ( visibleItemList.count() <= 0 ) |
355 |
296 return ; |
356 void GlxGridView::scrollingEnded() |
297 |
357 { |
298 HbAbstractViewItem *item = visibleItemList.at(0); |
358 mScrolling = FALSE; |
299 if ( item == NULL ) |
359 QList<QModelIndex> visibleIndex = mWidget->getVisibleItemIndices(); |
300 return ; |
360 if (visibleIndex.count() <= 0) |
301 |
361 { |
302 OstTrace1( TRACE_IMPORTANT, DUP2_GLXGRIDVIEW_SETVISVALWINDOWINDEX, "GlxGridView::setVisvalWindowIndex item=%d", item ); |
362 return; |
303 OstTrace1( TRACE_IMPORTANT, DUP3_GLXGRIDVIEW_SETVISVALWINDOWINDEX, "GlxGridView::setVisvalWindowIndex;visual index=%d", |
363 } |
304 item->modelIndex().row() ); |
364 QModelIndex index = visibleIndex.at(0); |
305 |
365 if ( index.row() < 0 || index.row() >= mModel->rowCount() ) |
306 if ( item->modelIndex().row() < 0 || item->modelIndex().row() >= mModel->rowCount() ) |
366 { |
307 return ; |
367 return; |
308 |
368 } |
309 mModel->setData( item->modelIndex (), item->modelIndex().row(), GlxVisualWindowIndex); |
369 if(mModel) |
|
370 { |
|
371 mModel->setData( index, index.row(), GlxVisualWindowIndex); |
|
372 } |
310 } |
373 } |
311 |
374 |
312 GlxGridView::~GlxGridView() |
375 GlxGridView::~GlxGridView() |
313 { |
376 { |
314 OstTraceFunctionEntry0( DUP1_GLXGRIDVIEW_GLXGRIDVIEW_ENTRY ); |
377 OstTraceFunctionEntry0( DUP1_GLXGRIDVIEW_GLXGRIDVIEW_ENTRY ); |
315 removeViewConnection(); |
378 removeViewConnection(); |
316 delete mGridView; |
379 if(mSelectionModel) |
317 mGridView = NULL; |
380 { |
318 |
381 disconnect(mSelectionModel, SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)), this, SLOT(visibleIndexChanged(const QModelIndex &, const QModelIndex &))); |
319 delete mDocLoader; |
382 delete mSelectionModel; |
320 mDocLoader = NULL; |
383 } |
321 |
384 delete mWidget; |
|
385 delete mModelWrapper; |
|
386 if(mUiOnButton) { |
|
387 disconnect(mUiOnButton, SIGNAL(clicked(bool)), this, SLOT(uiButtonClicked(bool))); |
|
388 delete mUiOnButton; |
|
389 } |
|
390 delete mIconItem; |
322 OstTraceFunctionExit0( DUP1_GLXGRIDVIEW_GLXGRIDVIEW_EXIT ); |
391 OstTraceFunctionExit0( DUP1_GLXGRIDVIEW_GLXGRIDVIEW_EXIT ); |
323 } |
392 } |
324 |
393 |
325 void GlxGridView::indicateLongPress(HbAbstractViewItem *item, QPointF coords) |
394 void GlxGridView::indicateLongPress(const QModelIndex& index, QPointF coords) |
326 { |
395 { |
327 OstTrace0( TRACE_NORMAL, GLXGRIDVIEW_INDICATELONGPRESS, "GlxGridView::indicateLongPress" ); |
396 OstTrace0( TRACE_NORMAL, GLXGRIDVIEW_INDICATELONGPRESS, "GlxGridView::indicateLongPress" ); |
328 qDebug() << "GlxGridView:indicateLongPress Item " << item->modelIndex() << "long pressed at " |
397 |
329 << coords; |
398 if ( mWidget->selectionMode() == HgWidget::MultiSelection ) |
330 |
399 { |
331 if ( mGridView->selectionMode() == HbGridView::MultiSelection ){ //in multi selection mode no need to open the context menu |
400 return; |
332 return ; |
401 } |
333 } |
402 if ( mModel ) |
334 |
403 { |
335 if ( mModel ) { |
404 mModel->setData( index, index.row(), GlxFocusIndexRole ); |
336 mModel->setData( item->modelIndex(), item->modelIndex().row(), GlxFocusIndexRole ); |
405 } |
337 } |
406 emit itemSpecificMenuTriggered(viewId(),coords); |
338 mIsLongPress = true; |
407 } |
339 emit itemSpecificMenuTriggered(viewId(),coords); |
408 |
340 } |
409 void GlxGridView::uiButtonClicked(bool /*checked*/) |
|
410 { |
|
411 if (isItemVisible(Hb::TitleBarItem)) // W16 All item is Not Working , So Temp Fix |
|
412 { |
|
413 setItemVisible(Hb::AllItems, FALSE) ; |
|
414 } |
|
415 else |
|
416 { |
|
417 setItemVisible(Hb::AllItems, TRUE) ; |
|
418 } |
|
419 } |
|
420 |