author | hgs |
Fri, 11 Jun 2010 17:53:15 +0530 | |
changeset 44 | aa2fa096cbfb |
parent 43 | 72396548277c |
child 45 | 863223ea6961 |
permissions | -rw-r--r-- |
23
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1 |
/* |
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
3 |
* All rights reserved. |
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
4 |
* This component and the accompanying materials are made available |
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
5 |
* under the terms of "Eclipse Public License v1.0" |
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
6 |
* which accompanies this distribution, and is available |
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
8 |
* |
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
9 |
* Initial Contributors: |
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
10 |
* Nokia Corporation - initial contribution. |
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
11 |
* |
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
12 |
* Contributors: |
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
13 |
* |
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
14 |
* Description: ?Description |
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
15 |
* |
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
16 |
*/ |
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
17 |
|
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
18 |
|
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
19 |
|
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
20 |
//Includes |
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
21 |
#include <hbmainwindow.h> |
40 | 22 |
#include <hggrid.h> |
23 |
#include <glxmodelwrapper.h> |
|
24 |
#include <hbpushbutton.h> |
|
25 |
#include <HbToolBar> // Temp |
|
26 |
#include <hbiconitem.h> |
|
27 |
#include <hbicon.h> |
|
23
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
28 |
#include <xqserviceutil.h> |
42 | 29 |
#include <hbcheckbox.h> |
30 |
#include <hblabel.h> |
|
31 |
#include <QString> |
|
32 |
#include <hbframeitem.h> |
|
23
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
33 |
|
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
34 |
//User Includes |
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
35 |
#include "glxviewids.h" |
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
36 |
#include "glxgridview.h" |
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
37 |
#include "glxmodelparm.h" |
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
38 |
#include "glxcommandhandlers.hrh" |
42 | 39 |
#include "glxicondefs.h" |
40 |
#include "glxlocalisationstrings.h" |
|
40 | 41 |
|
23
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
42 |
#include "OstTraceDefinitions.h" |
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
43 |
#ifdef OST_TRACE_COMPILER_IN_USE |
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
44 |
#include "glxgridviewTraces.h" |
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
45 |
#endif |
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
46 |
|
44 | 47 |
GlxGridView::GlxGridView(HbMainWindow *window) |
48 |
: GlxView ( GLX_GRIDVIEW_ID ), |
|
49 |
mWindow(window), |
|
50 |
mModel ( NULL), |
|
40 | 51 |
mWidget(NULL), |
52 |
mSelectionModel(NULL), |
|
53 |
mModelWrapper(NULL), |
|
54 |
mUiOnButton(NULL), |
|
42 | 55 |
mCameraButton(NULL), |
40 | 56 |
mScrolling(FALSE), |
42 | 57 |
mIconItem(NULL), |
58 |
mMarkCheckBox(NULL), |
|
59 |
mCountItem(NULL), |
|
60 |
mMainLabel(NULL), |
|
61 |
mCountLabel(NULL), |
|
62 |
mZeroItemLabel(NULL), |
|
63 |
mAlbumName(NULL) |
|
24
99ad1390cd33
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
64 |
{ |
23
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
65 |
OstTraceFunctionEntry0( GLXGRIDVIEW_GLXGRIDVIEW_ENTRY ); |
40 | 66 |
mModelWrapper = new GlxModelWrapper(); |
67 |
mModelWrapper->setRoles(GlxQImageSmall); |
|
68 |
mIconItem = new HbIconItem(this); |
|
23
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
69 |
OstTraceFunctionExit0( GLXGRIDVIEW_GLXGRIDVIEW_EXIT ); |
24
99ad1390cd33
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
70 |
} |
23
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
71 |
|
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
72 |
void GlxGridView::activate() |
24
99ad1390cd33
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
73 |
{ |
23
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
74 |
OstTraceFunctionEntry0( GLXGRIDVIEW_ACTIVATE_ENTRY ); |
40 | 75 |
if(mUiOnButton == NULL) { |
42 | 76 |
mUiOnButton = new HbPushButton(this); |
40 | 77 |
connect(mUiOnButton, SIGNAL(clicked(bool)), this, SLOT(uiButtonClicked(bool))); |
42 | 78 |
mUiOnButton->setGeometry(QRectF(590,0,40,40)); |
40 | 79 |
mUiOnButton->setZValue(1); |
42 | 80 |
mUiOnButton->setIcon(HbIcon(GLXICON_WALL_UI_ON)); |
40 | 81 |
mUiOnButton->hide(); |
82 |
} |
|
83 |
loadGridView(); |
|
42 | 84 |
connect(mWindow, SIGNAL(orientationChanged(Qt::Orientation)), this, SLOT(orientationchanged(Qt::Orientation)),Qt::UniqueConnection); |
85 |
if(mCountItem == NULL) { |
|
44 | 86 |
mCountItem = new HbLabel(this); |
42 | 87 |
HbFrameItem *frame = new HbFrameItem(this); //graphics for mCountItem |
88 |
frame->frameDrawer().setFrameType(HbFrameDrawer::NinePieces); |
|
89 |
frame->frameDrawer().setFrameGraphicsName("qtg_fr_multimedia_trans"); |
|
90 |
frame->graphicsItem()->setOpacity(1); |
|
91 |
mCountItem->setBackgroundItem(frame->graphicsItem(),-1); |
|
44 | 92 |
mCountItem->hide(); |
42 | 93 |
} |
23
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
94 |
OstTraceFunctionExit0( GLXGRIDVIEW_ACTIVATE_EXIT ); |
24
99ad1390cd33
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
95 |
} |
23
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
96 |
|
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
97 |
void GlxGridView::deActivate() |
24
99ad1390cd33
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
98 |
{ |
23
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
99 |
OstTraceFunctionEntry0( GLXGRIDVIEW_DEACTIVATE_ENTRY ); |
42 | 100 |
mScrolling = FALSE; |
43 | 101 |
if (mUiOnButton){ |
40 | 102 |
mUiOnButton->hide(); |
44 | 103 |
} |
43 | 104 |
if(mIconItem) { |
40 | 105 |
mIconItem->hide(); |
106 |
mIconItem->resetTransform(); |
|
107 |
mIconItem->setOpacity(0); |
|
108 |
mIconItem->setZValue(mIconItem->zValue()-20); |
|
43 | 109 |
} |
110 |
if (mCountItem) { |
|
42 | 111 |
mCountItem->hide(); |
43 | 112 |
} |
113 |
if (mAlbumName) { |
|
42 | 114 |
mAlbumName->hide(); |
43 | 115 |
} |
116 |
if(mZeroItemLabel) { |
|
42 | 117 |
mZeroItemLabel->hide(); |
43 | 118 |
} |
119 |
if(mCameraButton) { |
|
42 | 120 |
mCameraButton->hide(); |
43 | 121 |
} |
42 | 122 |
disconnect(mWindow, SIGNAL(orientationChanged(Qt::Orientation)), this, SLOT(orientationchanged(Qt::Orientation))); |
24
99ad1390cd33
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
123 |
OstTraceFunctionExit0( GLXGRIDVIEW_DEACTIVATE_EXIT ); |
99ad1390cd33
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
124 |
} |
23
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
125 |
|
24
99ad1390cd33
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
126 |
void GlxGridView::initializeView(QAbstractItemModel *model) |
99ad1390cd33
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
127 |
{ |
40 | 128 |
activate(); |
129 |
setModel(model); |
|
24
99ad1390cd33
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
130 |
} |
23
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
131 |
|
42 | 132 |
void GlxGridView::clearCurrentModel() |
133 |
{ |
|
134 |
if ( mModel ) { |
|
135 |
disconnect(mModel, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(showItemCount())); |
|
136 |
disconnect(mModel, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(showItemCount())); |
|
137 |
disconnect(mModel, SIGNAL(destroyed()), this, SLOT( clearCurrentModel())); |
|
138 |
disconnect(mModel, SIGNAL(albumTitleAvailable(QString)), this, SLOT(showAlbumTitle(QString))); |
|
139 |
disconnect(mModel, SIGNAL(populated()), this, SLOT( populated())); |
|
140 |
mModel = NULL ; |
|
141 |
} |
|
142 |
} |
|
143 |
||
144 |
void GlxGridView::initializeNewModel() |
|
145 |
{ |
|
146 |
if ( mModel ) { |
|
147 |
connect(mModel, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(showItemCount())); |
|
148 |
connect(mModel, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(showItemCount())); |
|
149 |
connect(mModel, SIGNAL(destroyed()), this, SLOT( clearCurrentModel())); |
|
150 |
connect(mModel, SIGNAL(albumTitleAvailable(QString)), this, SLOT(showAlbumTitle(QString))); |
|
151 |
connect(mModel, SIGNAL(populated()), this, SLOT( populated())); |
|
152 |
} |
|
153 |
} |
|
154 |
||
155 |
void GlxGridView::setModel(QAbstractItemModel *model) |
|
24
99ad1390cd33
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
156 |
{ |
23
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
157 |
OstTraceFunctionEntry0( GLXGRIDVIEW_SETMODEL_ENTRY ); |
40 | 158 |
if(model) |
159 |
{ |
|
42 | 160 |
clearCurrentModel(); |
161 |
mModel = model; |
|
162 |
initializeNewModel(); |
|
40 | 163 |
QVariant variantimage = mModel->data(mModel->index(0,0),GlxDefaultImage); |
164 |
if (mWidget && variantimage.isValid() && variantimage.canConvert<QImage> () ) |
|
165 |
{ |
|
166 |
mWidget->setDefaultImage(variantimage.value<QImage>()); |
|
167 |
} |
|
168 |
mModelWrapper->setModel(mModel); |
|
44 | 169 |
mWidget->setModel(mModelWrapper); |
40 | 170 |
if(!mSelectionModel) |
171 |
{ |
|
172 |
mSelectionModel = new QItemSelectionModel(mModelWrapper, this); |
|
173 |
connect(mSelectionModel, SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)), this, SLOT(visibleIndexChanged(const QModelIndex &, const QModelIndex &))); |
|
174 |
mWidget->setSelectionModel(mSelectionModel); |
|
175 |
} |
|
176 |
scrolltofocus(); // Need to do it here ? |
|
42 | 177 |
showItemCount(); |
40 | 178 |
} |
23
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
179 |
OstTraceFunctionExit0( GLXGRIDVIEW_SETMODEL_EXIT ); |
24
99ad1390cd33
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
180 |
} |
23
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
181 |
|
40 | 182 |
void GlxGridView::visibleIndexChanged(const QModelIndex& current, const QModelIndex& previous) |
183 |
{ |
|
184 |
if(mScrolling) |
|
185 |
{ |
|
186 |
Q_UNUSED(previous); |
|
187 |
if(current.row() >= 0 || current.row() < mModel->rowCount()) |
|
188 |
{ |
|
189 |
mModel->setData(mModel->index(0,0),current.row(),GlxVisualWindowIndex); |
|
190 |
} |
|
191 |
} |
|
192 |
} |
|
193 |
||
44 | 194 |
void GlxGridView::addToolBar( HbToolBar *toolBar ) |
24
99ad1390cd33
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
195 |
{ |
44 | 196 |
OstTraceFunctionEntry0( GLXGRIDVIEW_ADDTOOLBAR_ENTRY ); |
197 |
setToolBar(toolBar); |
|
40 | 198 |
hideorshowitems(mWindow->orientation()); |
23
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
199 |
OstTraceFunctionExit0( GLXGRIDVIEW_ADDTOOLBAR_EXIT ); |
24
99ad1390cd33
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
200 |
} |
23
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
201 |
|
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
202 |
void GlxGridView::enableMarking() |
24
99ad1390cd33
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
203 |
{ |
23
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
204 |
OstTrace0( TRACE_NORMAL, GLXGRIDVIEW_ENABLEMARKING, "GlxGridView::enableMarking" ); |
40 | 205 |
mWidget->setSelectionMode(HgWidget::MultiSelection); |
42 | 206 |
if (mMainLabel == NULL) { |
44 | 207 |
mMainLabel = new HbLabel("Select Photos", this); |
42 | 208 |
HbFrameItem *frame1 = new HbFrameItem(this); //graphics for mMainLabel |
209 |
frame1->frameDrawer().setFrameType(HbFrameDrawer::NinePieces); |
|
210 |
frame1->frameDrawer().setFrameGraphicsName("qtg_fr_multimedia_trans"); |
|
211 |
frame1->graphicsItem()->setOpacity(1); |
|
212 |
mMainLabel->setBackgroundItem(frame1->graphicsItem(),-1); |
|
213 |
} |
|
214 |
if (mMarkCheckBox == NULL) { |
|
44 | 215 |
mMarkCheckBox = new HbCheckBox(GLX_OPTION_MARK_ALL, this); |
42 | 216 |
HbFrameItem *frame2 = new HbFrameItem(this); //graphics for mMarkCheckBox |
217 |
frame2->frameDrawer().setFrameType(HbFrameDrawer::NinePieces); |
|
218 |
frame2->frameDrawer().setFrameGraphicsName("qtg_fr_multimedia_trans"); |
|
219 |
frame2->graphicsItem()->setOpacity(1); |
|
220 |
mMarkCheckBox->setBackgroundItem(frame2->graphicsItem(),-1); |
|
221 |
} |
|
222 |
if (mCountLabel == NULL) { |
|
44 | 223 |
mCountLabel = new HbLabel(this); |
42 | 224 |
HbFrameItem *frame3 = new HbFrameItem(this); //graphics for mCountLabel |
225 |
frame3->frameDrawer().setFrameType(HbFrameDrawer::NinePieces); |
|
226 |
frame3->frameDrawer().setFrameGraphicsName("qtg_fr_multimedia_trans"); |
|
227 |
frame3->graphicsItem()->setOpacity(1); |
|
228 |
mCountLabel->setBackgroundItem(frame3->graphicsItem(),-1); |
|
229 |
} |
|
230 |
||
231 |
hideorshowitems(mWindow->orientation()); |
|
232 |
||
233 |
connect( mWidget->selectionModel() , SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection& ) ), this, SLOT( showMarkedItemCount() ) ); |
|
234 |
connect(mMarkCheckBox, SIGNAL( stateChanged(int) ), this, SLOT( stateChanged(int))); |
|
235 |
||
24
99ad1390cd33
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
236 |
} |
23
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
237 |
|
44 | 238 |
void GlxGridView::disableMarking() |
24
99ad1390cd33
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
239 |
{ |
23
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
240 |
OstTrace0( TRACE_NORMAL, GLXGRIDVIEW_DISABLEMARKING, "GlxGridView::disableMarking" ); |
40 | 241 |
mWidget->setSelectionMode(HgWidget::NoSelection); |
42 | 242 |
disconnect( mWidget->selectionModel() , SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection& ) ), this, SLOT( showMarkedItemCount() ) ); |
243 |
disconnect(mMarkCheckBox, SIGNAL( stateChanged(int) ), this, SLOT( stateChanged(int))); |
|
244 |
if (mMainLabel) { |
|
245 |
mMainLabel->hide(); |
|
246 |
} |
|
247 |
if (mMarkCheckBox) { |
|
248 |
mMarkCheckBox->setCheckState(Qt::Unchecked); |
|
249 |
mMarkCheckBox->hide(); |
|
250 |
} |
|
251 |
if (mCountLabel) { |
|
252 |
mCountLabel->hide(); |
|
253 |
} |
|
254 |
||
255 |
hideorshowitems(mWindow->orientation()); |
|
256 |
} |
|
257 |
||
258 |
void GlxGridView::stateChanged(int state) |
|
259 |
{ |
|
260 |
if(state) |
|
261 |
handleUserAction(EGlxCmdMarkAll); |
|
262 |
else |
|
263 |
handleUserAction(EGlxCmdUnMarkAll); |
|
264 |
} |
|
265 |
||
266 |
void GlxGridView::showMarkedItemCount() |
|
267 |
{ |
|
268 |
int count = mModel->rowCount(); |
|
269 |
QModelIndexList indexList = mWidget->selectionModel()->selectedIndexes(); |
|
270 |
int markItemCount = indexList.count(); |
|
271 |
||
272 |
QString text= QString("%1 / %2").arg( markItemCount ).arg( count ); |
|
273 |
mCountLabel->setPlainText( text ); |
|
274 |
} |
|
275 |
||
276 |
void GlxGridView::showItemCount() |
|
277 |
{ |
|
278 |
int count = 0; |
|
279 |
if(mModel) { |
|
280 |
count = mModel->rowCount(); |
|
281 |
QSize deviceSize = HbDeviceProfile::current().logicalSize(); |
|
282 |
QSize screenSize = ( mWindow->orientation() == Qt::Vertical ) ? QSize( deviceSize.width(), deviceSize.height() ) |
|
283 |
: QSize( deviceSize.height(), deviceSize.width() ) ; |
|
284 |
if(count) { |
|
285 |
if(mZeroItemLabel) { |
|
286 |
mZeroItemLabel->hide(); |
|
287 |
} |
|
288 |
if(mCameraButton) { |
|
289 |
mCameraButton->hide(); |
|
290 |
} |
|
291 |
if(isItemVisible(Hb::TitleBarItem)) { |
|
292 |
QString text; |
|
44 | 293 |
if(XQServiceUtil::isService()) |
294 |
{ |
|
295 |
showAlbumTitle(GLX_FETCHER_TITLE); |
|
296 |
} |
|
297 |
else if (getSubState() == ALL_ITEM_S) { |
|
42 | 298 |
if (mAlbumName) { |
299 |
mAlbumName->hide(); |
|
300 |
} |
|
301 |
mCountItem->setGeometry(QRectF(0,0,screenSize.width(),deviceSize.height()/24)); |
|
302 |
text = QString("%1 Items").arg( count ); |
|
303 |
mCountItem->setPlainText( text ); |
|
304 |
mCountItem->setAlignment(Qt::AlignLeft); |
|
305 |
mCountItem->show(); |
|
306 |
} |
|
307 |
else if (getSubState() == ALBUM_ITEM_S) { |
|
308 |
mCountItem->hide(); |
|
309 |
QVariant variant = mModel->data(mModel->index(0,0),GlxViewTitle); |
|
310 |
if (variant.toString() != NULL) { |
|
311 |
showAlbumTitle(variant.toString()); |
|
312 |
} |
|
313 |
} |
|
314 |
} |
|
315 |
else { |
|
316 |
if (mCountItem) { |
|
317 |
mCountItem->hide(); |
|
318 |
} |
|
319 |
if (mAlbumName) { |
|
320 |
mAlbumName->hide(); |
|
321 |
} |
|
322 |
} |
|
323 |
||
324 |
} |
|
325 |
else { |
|
326 |
bool populated = FALSE; |
|
327 |
QVariant variant = mModel->data(mModel->index(0,0),GlxPopulated); |
|
328 |
if (variant.isValid() && variant.canConvert<bool>() ) |
|
329 |
{ |
|
330 |
populated = variant.value<bool>(); |
|
331 |
} |
|
332 |
if(populated) { |
|
333 |
if (mCountItem) { |
|
334 |
mCountItem->hide(); |
|
335 |
} |
|
336 |
if (mAlbumName) { |
|
337 |
mAlbumName->hide(); |
|
338 |
} |
|
44 | 339 |
|
340 |
showNoImageString(); |
|
341 |
||
342 |
if (getSubState() == ALBUM_ITEM_S) { |
|
42 | 343 |
QVariant variant = mModel->data(mModel->index(0,0),GlxViewTitle); |
344 |
if (variant.toString() != NULL) { |
|
345 |
showAlbumTitle(variant.toString()); |
|
346 |
} |
|
44 | 347 |
} |
348 |
else if(XQServiceUtil::isService()){ |
|
349 |
showAlbumTitle(GLX_FETCHER_TITLE); |
|
42 | 350 |
} |
351 |
} |
|
352 |
} |
|
353 |
} |
|
354 |
} |
|
355 |
||
356 |
void GlxGridView::showAlbumTitle(QString aTitle) |
|
357 |
{ |
|
358 |
int count = mModel->rowCount(); |
|
359 |
QSize deviceSize = HbDeviceProfile::current().logicalSize(); |
|
360 |
QSize screenSize = ( mWindow->orientation() == Qt::Vertical ) ? QSize( deviceSize.width(), deviceSize.height() ) |
|
361 |
: QSize( deviceSize.height(), deviceSize.width() ) ; |
|
362 |
if(mAlbumName == NULL) { |
|
44 | 363 |
mAlbumName = new HbLabel(this); |
42 | 364 |
HbFrameItem *frame = new HbFrameItem(this); //graphics for mAlbumName |
365 |
frame->frameDrawer().setFrameType(HbFrameDrawer::NinePieces); |
|
366 |
frame->frameDrawer().setFrameGraphicsName("qtg_fr_multimedia_trans"); |
|
367 |
frame->graphicsItem()->setOpacity(1); |
|
368 |
mAlbumName->setBackgroundItem(frame->graphicsItem(),-1); |
|
369 |
} |
|
370 |
||
44 | 371 |
//If fetcher service set only title text |
372 |
if((XQServiceUtil::isService() ) && isItemVisible(Hb::TitleBarItem)) { |
|
42 | 373 |
mAlbumName->setGeometry(QRectF(0,0,screenSize.width(),deviceSize.height()/24)); |
374 |
QString text = QString(aTitle); |
|
375 |
mAlbumName->setPlainText( text ); |
|
376 |
mAlbumName->show(); |
|
377 |
} |
|
44 | 378 |
else{ //handle album tiltle and count display logic here |
379 |
if( count && isItemVisible(Hb::TitleBarItem)) { |
|
380 |
mAlbumName->setGeometry(QRectF(0,0,screenSize.width()/2,deviceSize.height()/24)); |
|
381 |
QString text = QString(aTitle); |
|
382 |
mAlbumName->setPlainText( text ); |
|
383 |
mAlbumName->show(); |
|
384 |
mCountItem->setGeometry(QRectF(screenSize.width()/2,0,screenSize.width()/2,deviceSize.height()/24)); |
|
385 |
text = QString("(%1)").arg(count); |
|
386 |
mCountItem->setPlainText( text ); |
|
387 |
mCountItem->setAlignment(Qt::AlignRight); |
|
388 |
mCountItem->show(); |
|
389 |
} |
|
390 |
else if((!count) && isItemVisible(Hb::TitleBarItem)) { |
|
391 |
mAlbumName->setGeometry(QRectF(0,0,screenSize.width(),deviceSize.height()/24)); |
|
392 |
QString text = QString(aTitle); |
|
393 |
mAlbumName->setPlainText( text ); |
|
394 |
mAlbumName->show(); |
|
395 |
} |
|
396 |
} |
|
42 | 397 |
} |
398 |
||
399 |
void GlxGridView::showNoImageString() |
|
400 |
{ |
|
401 |
qreal chromeHeight = 0.0; |
|
402 |
QSize deviceSize = HbDeviceProfile::current().logicalSize(); |
|
403 |
QSize screenSize = ( mWindow->orientation() == Qt::Vertical ) ? QSize( deviceSize.width(), deviceSize.height() ) |
|
404 |
: QSize( deviceSize.height(), deviceSize.width() ) ; |
|
405 |
qreal midHeight = screenSize.height()/2; |
|
406 |
if (isItemVisible(Hb::TitleBarItem)) { |
|
407 |
style()->parameter("hb-param-widget-chrome-height", chromeHeight); |
|
408 |
midHeight -= chromeHeight; |
|
409 |
} |
|
44 | 410 |
if (mZeroItemLabel == NULL) { |
411 |
QString displayText(GLX_GRID_NO_IMAGE); |
|
412 |
if(!XQServiceUtil::isService()) |
|
413 |
{ |
|
414 |
displayText.append(GLX_GRID_OPEN_CAMERA); |
|
415 |
} |
|
416 |
mZeroItemLabel = new HbLabel(displayText, this); |
|
42 | 417 |
} |
418 |
mZeroItemLabel->setGeometry(QRectF(0, midHeight - deviceSize.height()/16, screenSize.width(), 3*deviceSize.height()/32)); |
|
419 |
mZeroItemLabel->setAlignment(Qt::AlignHCenter); |
|
420 |
mZeroItemLabel->show(); |
|
421 |
if (mCameraButton == NULL) { |
|
422 |
mCameraButton = new HbPushButton(this); |
|
423 |
mCameraButton->setIcon(HbIcon(GLXICON_CAMERA)); |
|
44 | 424 |
mCameraButton->hide(); |
42 | 425 |
connect(mCameraButton, SIGNAL(clicked(bool)), this, SLOT(cameraButtonClicked(bool))); |
426 |
} |
|
44 | 427 |
if(!XQServiceUtil::isService()) |
428 |
{ |
|
429 |
mCameraButton->setGeometry(QRectF(screenSize.width()/2 - 3*deviceSize.height()/64, midHeight + deviceSize.height()/32, deviceSize.height()/32, deviceSize.height()/32)); |
|
430 |
mCameraButton->show(); |
|
431 |
} |
|
42 | 432 |
} |
433 |
||
434 |
void GlxGridView::populated() |
|
435 |
{ |
|
436 |
showItemCount(); |
|
24
99ad1390cd33
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
437 |
} |
23
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
438 |
|
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
439 |
void GlxGridView::handleUserAction(qint32 commandId) |
24
99ad1390cd33
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
440 |
{ |
23
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
441 |
OstTrace0( TRACE_NORMAL, GLXGRIDVIEW_HANDLEUSERACTION, "GlxGridView::handleUserAction" ); |
40 | 442 |
switch( commandId ) { |
23
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
443 |
case EGlxCmdMarkAll : |
40 | 444 |
mWidget->selectAll(); |
23
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
445 |
break; |
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
446 |
|
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
447 |
case EGlxCmdUnMarkAll : |
40 | 448 |
mWidget->clearSelection(); |
44 | 449 |
break; |
23
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
450 |
|
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
451 |
default : |
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
452 |
break; |
44 | 453 |
} |
24
99ad1390cd33
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
454 |
} |
23
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
455 |
|
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
456 |
QItemSelectionModel * GlxGridView::getSelectionModel() |
24
99ad1390cd33
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
457 |
{ |
23
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
458 |
OstTrace0( TRACE_NORMAL, GLXGRIDVIEW_GETSELECTIONMODEL, "GlxGridView::getSelectionModel" ); |
40 | 459 |
return mWidget->selectionModel(); |
24
99ad1390cd33
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
460 |
} |
23
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
461 |
|
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
462 |
QGraphicsItem * GlxGridView::getAnimationItem(GlxEffect transitionEffect) |
24
99ad1390cd33
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
463 |
{ |
23
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
464 |
OstTraceFunctionEntry0( GLXGRIDVIEW_GETANIMATIONITEM_ENTRY ); |
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
465 |
int selIndex = -1; |
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
466 |
|
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
467 |
if ( transitionEffect == FULLSCREEN_TO_GRID ) { |
40 | 468 |
return mWidget; |
23
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
469 |
} |
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
470 |
|
40 | 471 |
if ( transitionEffect == GRID_TO_FULLSCREEN ) |
472 |
{ |
|
44 | 473 |
QVariant variant = mModel->data( mModel->index(0,0), GlxFocusIndexRole ); |
474 |
if ( variant.isValid() && variant.canConvert<int> () ) |
|
40 | 475 |
{ |
44 | 476 |
selIndex = variant.value<int>(); |
477 |
} |
|
478 |
else |
|
40 | 479 |
{ |
480 |
return mWidget; |
|
481 |
} |
|
482 |
QVariant variantimage = mModel->data(mModel->index(selIndex,0),Qt::DecorationRole); |
|
483 |
if ( variantimage.isValid() && variantimage.canConvert<HbIcon> () ) |
|
484 |
{ |
|
485 |
QPolygonF poly; |
|
486 |
if (mModelWrapper && !mWidget->getItemOutline(mModelWrapper->index(selIndex,0), poly)) |
|
487 |
{ |
|
488 |
return mWidget; |
|
489 |
} |
|
490 |
QRectF itemRect = poly.boundingRect(); |
|
491 |
||
492 |
mIconItem->setSize(QSize(120,120)); |
|
493 |
HbIcon tempIcon = variantimage.value<HbIcon>(); |
|
494 |
QPixmap tempPixmap = tempIcon.qicon().pixmap(120, 120); |
|
495 |
QSize sz = QSize ( 120, 120); |
|
496 |
tempPixmap = tempPixmap.scaled(sz, Qt::IgnoreAspectRatio ); |
|
497 |
HbIcon tmp = HbIcon( QIcon(tempPixmap)) ; |
|
498 |
mIconItem->setIcon(tmp); |
|
499 |
mIconItem->setPos(itemRect.topLeft()); |
|
500 |
mIconItem->setZValue(mIconItem->zValue() + 20); |
|
501 |
mIconItem->show(); |
|
44 | 502 |
return mIconItem; |
40 | 503 |
} |
504 |
else |
|
505 |
{ |
|
506 |
return mWidget; |
|
507 |
} |
|
508 |
} |
|
23
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
509 |
|
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
510 |
if ( transitionEffect == GRID_TO_ALBUMLIST || transitionEffect == ALBUMLIST_TO_GRID ){ |
40 | 511 |
return mWidget; |
23
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
512 |
} |
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
513 |
OstTraceFunctionExit0( GLXGRIDVIEW_GETANIMATIONITEM_EXIT ); |
44 | 514 |
return NULL; |
24
99ad1390cd33
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
515 |
} |
23
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
516 |
|
40 | 517 |
void GlxGridView::loadGridView() |
24
99ad1390cd33
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
518 |
{ |
23
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
519 |
OstTraceFunctionEntry0( GLXGRIDVIEW_LOADGRIDVIEW_ENTRY ); |
40 | 520 |
if(mWidget == NULL) { |
521 |
Qt::Orientation orient = mWindow->orientation(); |
|
522 |
mWindow->viewport()->grabGesture(Qt::PanGesture); |
|
523 |
mWindow->viewport()->grabGesture(Qt::TapGesture); |
|
524 |
mWindow->viewport()->grabGesture(Qt::TapAndHoldGesture); |
|
525 |
mWidget = new HgGrid(orient); |
|
526 |
mWidget->setLongPressEnabled(true); |
|
44 | 527 |
mWidget->setScrollBarPolicy(HgWidget::ScrollBarAutoHide); |
528 |
setWidget( mWidget ); |
|
40 | 529 |
addViewConnection(); |
42 | 530 |
hideorshowitems(orient); |
24
99ad1390cd33
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
531 |
} |
23
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
532 |
OstTraceFunctionExit0( GLXGRIDVIEW_LOADGRIDVIEW_EXIT ); |
24
99ad1390cd33
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
533 |
} |
23
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
534 |
|
40 | 535 |
void GlxGridView::orientationchanged(Qt::Orientation orient) |
536 |
{ |
|
537 |
hideorshowitems(orient); |
|
538 |
} |
|
539 |
void GlxGridView::hideorshowitems(Qt::Orientation orient) |
|
24
99ad1390cd33
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
540 |
{ |
44 | 541 |
if ( mWidget && mWidget->selectionMode() == HgWidget::NoSelection ) { |
542 |
if( orient == Qt::Horizontal ) { |
|
42 | 543 |
setItemVisible(Hb::AllItems, FALSE) ; |
544 |
setViewFlags(viewFlags() | HbView::ViewTitleBarHidden | HbView::ViewStatusBarHidden); |
|
44 | 545 |
//To:Do remove it later, currently it is solving the problem of status bar is not |
546 |
//visible when tap on the screen first time |
|
547 |
setItemVisible(Hb::AllItems, FALSE) ; |
|
548 |
setViewFlags(viewFlags() | HbView::ViewTitleBarHidden | HbView::ViewStatusBarHidden); |
|
42 | 549 |
showItemCount(); |
44 | 550 |
if (mUiOnButton) { |
42 | 551 |
mUiOnButton->show(); |
40 | 552 |
} |
44 | 553 |
} |
554 |
else { |
|
42 | 555 |
showHbItems(); |
44 | 556 |
} |
42 | 557 |
} |
44 | 558 |
else if (mWidget && mWidget->selectionMode() == HgWidget::MultiSelection) { |
42 | 559 |
setItemVisible(Hb::TitleBarItem, FALSE) ; |
560 |
if (mUiOnButton) { |
|
561 |
mUiOnButton->hide(); |
|
40 | 562 |
} |
42 | 563 |
if (mCountItem) { |
564 |
mCountItem->hide(); |
|
565 |
} |
|
566 |
if (mAlbumName) { |
|
567 |
mAlbumName->hide(); |
|
40 | 568 |
} |
42 | 569 |
QSize deviceSize = HbDeviceProfile::current().logicalSize(); |
570 |
QSize screenSize = ( mWindow->orientation() == Qt::Vertical ) ? QSize( deviceSize.width(), deviceSize.height() ) |
|
571 |
: QSize( deviceSize.height(), deviceSize.width() ) ; |
|
572 |
mMainLabel->setGeometry(QRectF(0,0,screenSize.width(),deviceSize.height()/24)); |
|
573 |
mMarkCheckBox->setGeometry(QRectF(0,deviceSize.height()/24,screenSize.width()/2,deviceSize.height()/72)); |
|
574 |
mCountLabel->setGeometry(QRectF(screenSize.width()/2,deviceSize.height()/24,screenSize.width()/2,deviceSize.height()/12 - 3)); |
|
575 |
mCountLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter); |
|
576 |
mMainLabel->show(); |
|
577 |
mMarkCheckBox->show(); |
|
578 |
mCountLabel->show(); |
|
579 |
showMarkedItemCount(); |
|
580 |
} |
|
40 | 581 |
} |
582 |
||
583 |
void GlxGridView::scrolltofocus() |
|
584 |
{ |
|
585 |
if(mModelWrapper && mWidget) |
|
586 |
{ |
|
44 | 587 |
QVariant variant = mModelWrapper->data( mModelWrapper->index(0,0), GlxFocusIndexRole ); |
588 |
if ( variant.isValid() && variant.canConvert<int> () ) |
|
40 | 589 |
{ |
590 |
mWidget->scrollTo( mModelWrapper->index( variant.value<int>(),0) ); |
|
591 |
mModel->setData(mModel->index(0,0),variant.value<int>(),GlxVisualWindowIndex); |
|
592 |
} |
|
593 |
} |
|
24
99ad1390cd33
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
594 |
} |
23
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
595 |
|
44 | 596 |
QVariant GlxGridView::itemChange (GraphicsItemChange change, const QVariant &value) |
23
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
597 |
{ |
44 | 598 |
OstTrace0( TRACE_NORMAL, GLXGRIDVIEW_ITEMCHANGE, "GlxGridView::itemChange" ); |
23
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
599 |
static bool isEmit = true; |
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
600 |
if ( isEmit && change == QGraphicsItem::ItemVisibleHasChanged && value.toBool() ) { |
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
601 |
emit actionTriggered( EGlxCmdSetupItem ); |
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
602 |
isEmit = false; |
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
603 |
} |
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
604 |
return HbWidget::itemChange(change, value); |
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
605 |
} |
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
606 |
|
40 | 607 |
void GlxGridView::addViewConnection() |
24
99ad1390cd33
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
608 |
{ |
23
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
609 |
OstTrace0( TRACE_NORMAL, GLXGRIDVIEW_ADDVIEWCONNECTION, "GlxGridView::addViewConnection" ); |
40 | 610 |
//connect(mWindow, SIGNAL(aboutToChangeOrientation()), mWidget, SLOT(aboutToChangeOrientation())); |
611 |
connect(mWindow, SIGNAL(orientationChanged(Qt::Orientation)), mWidget, SLOT(orientationChanged(Qt::Orientation))); |
|
612 |
connect(mWidget, SIGNAL(activated(const QModelIndex &)), SLOT( itemSelected(const QModelIndex &))); |
|
613 |
connect(mWidget, SIGNAL( scrollingStarted() ), this, SLOT( scrollingStarted() ) ); |
|
614 |
connect(mWidget, SIGNAL( scrollingEnded() ), this, SLOT( scrollingEnded() ) ); |
|
615 |
connect(mWidget, SIGNAL(longPressed(const QModelIndex &, QPointF)), SLOT( indicateLongPress(const QModelIndex &, QPointF) ) ); |
|
24
99ad1390cd33
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
616 |
} |
23
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
617 |
|
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
618 |
void GlxGridView::removeViewConnection () |
24
99ad1390cd33
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
619 |
{ |
23
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
620 |
OstTrace0( TRACE_NORMAL, GLXGRIDVIEW_REMOVEVIEWCONNECTION, "GlxGridView::removeViewConnection" ); |
40 | 621 |
if(mWidget) |
622 |
{ |
|
623 |
//disconnect(mWindow, SIGNAL(aboutToChangeOrientation()), mWidget, SLOT(aboutToChangeOrientation())); |
|
624 |
disconnect(mWindow, SIGNAL(orientationChanged(Qt::Orientation)), mWidget, SLOT(orientationChanged(Qt::Orientation))); |
|
625 |
disconnect(mWidget, SIGNAL(activated(const QModelIndex &)),this, SLOT( itemSelected(const QModelIndex &))); |
|
626 |
disconnect(mWidget, SIGNAL( scrollingStarted() ), this, SLOT( scrollingStarted() ) ); |
|
627 |
disconnect(mWidget, SIGNAL( scrollingEnded() ), this, SLOT( scrollingEnded() ) ); |
|
628 |
disconnect(mWidget, SIGNAL(longPressed(const QModelIndex &, QPointF)),this, SLOT( indicateLongPress(const QModelIndex &, QPointF) ) ); |
|
629 |
} |
|
24
99ad1390cd33
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
630 |
} |
99ad1390cd33
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
631 |
|
23
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
632 |
|
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
633 |
void GlxGridView::itemSelected(const QModelIndex & index) |
24
99ad1390cd33
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
634 |
{ |
23
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
635 |
OstTrace1( TRACE_NORMAL, GLXGRIDVIEW_ITEMSELECTED, "GlxGridView::itemSelected;index=%d", index.row() ); |
44 | 636 |
if ( mWidget->selectionMode() == HgWidget::MultiSelection ) { |
26
c499df2dbb33
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
637 |
return ; |
44 | 638 |
} |
639 |
if(XQServiceUtil::isService()){ |
|
26
c499df2dbb33
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
640 |
emit gridItemSelected(index); |
c499df2dbb33
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
641 |
return; |
44 | 642 |
} |
643 |
OstTraceEventStart0( EVENT_DUP1_GLXGRIDVIEW_ITEMSELECTED_START, "Fullscreen Launch Time" ); |
|
644 |
if ( mModel ) { |
|
23
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
645 |
mModel->setData( index, index.row(), GlxFocusIndexRole ); |
44 | 646 |
} |
647 |
emit actionTriggered( EGlxCmdFullScreenOpen ); |
|
23
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
648 |
OstTraceEventStop( EVENT_DUP1_GLXGRIDVIEW_ITEMSELECTED_STOP, "Fullscreen Launch Time", EVENT_DUP1_GLXGRIDVIEW_ITEMSELECTED_START ); |
24
99ad1390cd33
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
649 |
} |
23
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
650 |
|
40 | 651 |
void GlxGridView::scrollingStarted() |
24
99ad1390cd33
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
652 |
{ |
42 | 653 |
if ((mWindow->orientation() == Qt::Horizontal) && mWidget->selectionMode() == HgWidget::NoSelection) |
40 | 654 |
{ |
655 |
setItemVisible(Hb::AllItems, FALSE) ; |
|
42 | 656 |
setViewFlags(viewFlags() | HbView::ViewTitleBarHidden | HbView::ViewStatusBarHidden); |
657 |
if (mUiOnButton) |
|
658 |
{ |
|
659 |
mUiOnButton->hide(); |
|
660 |
} |
|
661 |
if (mCountItem) { |
|
662 |
mCountItem->hide(); |
|
663 |
} |
|
664 |
if (mAlbumName) { |
|
665 |
mAlbumName->hide(); |
|
666 |
} |
|
667 |
} |
|
668 |
||
40 | 669 |
mScrolling = TRUE; |
670 |
} |
|
23
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
671 |
|
40 | 672 |
void GlxGridView::scrollingEnded() |
673 |
{ |
|
674 |
mScrolling = FALSE; |
|
42 | 675 |
if (mUiOnButton && (mWindow->orientation() == Qt::Horizontal)) |
676 |
{ |
|
677 |
mUiOnButton->show(); |
|
678 |
} |
|
40 | 679 |
QList<QModelIndex> visibleIndex = mWidget->getVisibleItemIndices(); |
680 |
if (visibleIndex.count() <= 0) |
|
681 |
{ |
|
682 |
return; |
|
683 |
} |
|
684 |
QModelIndex index = visibleIndex.at(0); |
|
685 |
if ( index.row() < 0 || index.row() >= mModel->rowCount() ) |
|
686 |
{ |
|
687 |
return; |
|
44 | 688 |
} |
40 | 689 |
if(mModel) |
690 |
{ |
|
691 |
mModel->setData( index, index.row(), GlxVisualWindowIndex); |
|
42 | 692 |
mModel->setData( index, index.row(), GlxFocusIndexRole ); |
40 | 693 |
} |
24
99ad1390cd33
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
694 |
} |
23
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
695 |
|
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
696 |
GlxGridView::~GlxGridView() |
24
99ad1390cd33
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
697 |
{ |
23
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
698 |
OstTraceFunctionEntry0( DUP1_GLXGRIDVIEW_GLXGRIDVIEW_ENTRY ); |
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
699 |
removeViewConnection(); |
40 | 700 |
if(mSelectionModel) |
701 |
{ |
|
702 |
disconnect(mSelectionModel, SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)), this, SLOT(visibleIndexChanged(const QModelIndex &, const QModelIndex &))); |
|
703 |
delete mSelectionModel; |
|
704 |
} |
|
705 |
delete mWidget; |
|
706 |
delete mModelWrapper; |
|
707 |
if(mUiOnButton) { |
|
708 |
disconnect(mUiOnButton, SIGNAL(clicked(bool)), this, SLOT(uiButtonClicked(bool))); |
|
709 |
delete mUiOnButton; |
|
710 |
} |
|
42 | 711 |
if(mCameraButton) { |
712 |
disconnect(mCameraButton, SIGNAL(clicked()), this, SLOT(cameraButtonClicked())); |
|
713 |
delete mCameraButton; |
|
714 |
} |
|
40 | 715 |
delete mIconItem; |
42 | 716 |
delete mCountItem; |
717 |
delete mAlbumName; |
|
718 |
delete mMainLabel; |
|
719 |
delete mMarkCheckBox; |
|
720 |
delete mCountLabel; |
|
721 |
delete mZeroItemLabel; |
|
23
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
722 |
OstTraceFunctionExit0( DUP1_GLXGRIDVIEW_GLXGRIDVIEW_EXIT ); |
24
99ad1390cd33
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
723 |
} |
23
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
724 |
|
40 | 725 |
void GlxGridView::indicateLongPress(const QModelIndex& index, QPointF coords) |
24
99ad1390cd33
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
726 |
{ |
23
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
727 |
OstTrace0( TRACE_NORMAL, GLXGRIDVIEW_INDICATELONGPRESS, "GlxGridView::indicateLongPress" ); |
44 | 728 |
|
40 | 729 |
if ( mWidget->selectionMode() == HgWidget::MultiSelection ) |
44 | 730 |
{ |
40 | 731 |
return; |
44 | 732 |
} |
733 |
if ( mModel ) |
|
40 | 734 |
{ |
735 |
mModel->setData( index, index.row(), GlxFocusIndexRole ); |
|
44 | 736 |
} |
40 | 737 |
emit itemSpecificMenuTriggered(viewId(),coords); |
738 |
} |
|
23
74c9f037fd5d
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
739 |
|
40 | 740 |
void GlxGridView::uiButtonClicked(bool /*checked*/) |
741 |
{ |
|
42 | 742 |
showHbItems(); |
743 |
} |
|
744 |
||
745 |
void GlxGridView::showHbItems() |
|
746 |
{ |
|
747 |
setItemVisible(Hb::AllItems, TRUE) ; |
|
748 |
setViewFlags(viewFlags() &~ HbView::ViewTitleBarHidden &~ HbView::ViewStatusBarHidden); |
|
749 |
showItemCount(); |
|
750 |
toolBar()->resetTransform(); // Temp, this is for HbToolbar issue to get fixed |
|
751 |
toolBar()->show(); |
|
752 |
if (mUiOnButton) |
|
40 | 753 |
{ |
42 | 754 |
mUiOnButton->hide(); |
40 | 755 |
} |
24
99ad1390cd33
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
756 |
} |
40 | 757 |
|
42 | 758 |
void GlxGridView::cameraButtonClicked(bool /*checked*/) |
759 |
{ |
|
760 |
emit actionTriggered(EGlxCmdCameraOpen); |
|
761 |
} |
|
762 |
||
763 |
int GlxGridView::getSubState() |
|
764 |
{ |
|
765 |
int substate = NO_GRID_S; |
|
766 |
QVariant variant = mModel->data( mModel->index(0,0), GlxSubStateRole ); |
|
767 |
if ( variant.isValid() && variant.canConvert<int> () ) { |
|
768 |
substate = variant.value<int>(); |
|
769 |
} |
|
770 |
return substate; |
|
771 |
} |
|
772 |