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