|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: ?Description |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include <glxgridstate.h> |
|
21 #include <glxstatemanager.h> |
|
22 #include <glxcommandhandlers.hrh> |
|
23 #include <QDebug> |
|
24 |
|
25 GlxGridState::GlxGridState(GlxStateManager *stateManager, GlxState *preState ) : GlxState(GLX_GRIDVIEW_ID, preState) |
|
26 { |
|
27 if ( preState) |
|
28 qDebug("GlxGridState::GlxGridState() state id = %d", preState->id()); |
|
29 |
|
30 mState = ALL_ITEM_S; |
|
31 mStateManager = stateManager ; |
|
32 mIsMarkingMode = FALSE; |
|
33 mCommandId = EGlxCmdHandled; |
|
34 } |
|
35 |
|
36 void GlxGridState::eventHandler(qint32 &id) |
|
37 { |
|
38 qDebug("GlxGridState::eventHandler() action id = %d", id); |
|
39 defaultEventHandler (id ); |
|
40 if ( id == EGlxCmdHandled ) { |
|
41 return; |
|
42 } |
|
43 |
|
44 switch ( mState ) { |
|
45 case ALL_ITEM_S : |
|
46 case FETCHER_ITEM_S : |
|
47 allItemEventHandler ( id ) ; |
|
48 break; |
|
49 |
|
50 case ALBUM_ITEM_S : |
|
51 case FETCHER_ALBUM_ITEM_S : |
|
52 albumItemEventHandler ( id ) ; |
|
53 break; |
|
54 |
|
55 default : |
|
56 break; |
|
57 } |
|
58 } |
|
59 |
|
60 void GlxGridState::defaultEventHandler ( qint32 &id ) |
|
61 { |
|
62 qDebug("GlxGridState::defaultEventHandler() action id = %d", id); |
|
63 |
|
64 switch(id) { |
|
65 case EGlxCmdFetcherFullScreenOpen: |
|
66 id = EGlxCmdHandled; |
|
67 mStateManager->nextState( GLX_FULLSCREENVIEW_ID, FETCHER_S ); |
|
68 break; |
|
69 case EGlxCmdAddToAlbum : |
|
70 case EGlxCmdDelete : |
|
71 case EGlxCmdRemoveFrom : |
|
72 case EGlxCmdSend : |
|
73 mStateManager->enterMarkingMode(); |
|
74 mIsMarkingMode = TRUE; |
|
75 mCommandId = id; |
|
76 id = EGlxCmdHandled; |
|
77 break; |
|
78 |
|
79 case EGlxCmdBack : |
|
80 //here this command will be handled for only marking mode |
|
81 if (mIsMarkingMode == TRUE ) { |
|
82 mStateManager->exitMarkingMode(); |
|
83 mIsMarkingMode = FALSE; |
|
84 mCommandId = id = EGlxCmdHandled; |
|
85 } |
|
86 break; |
|
87 |
|
88 case EGlxCmdSelect: |
|
89 if ( mStateManager->executeCommand(mCommandId) ) { |
|
90 mStateManager->exitMarkingMode(); |
|
91 mIsMarkingMode = FALSE; |
|
92 mCommandId = EGlxCmdHandled; |
|
93 } |
|
94 id = EGlxCmdHandled; |
|
95 break; |
|
96 |
|
97 case EGlxCmdCancel : |
|
98 mStateManager->exitMarkingMode(); |
|
99 mIsMarkingMode = FALSE; |
|
100 mCommandId = id = EGlxCmdHandled; |
|
101 break; |
|
102 |
|
103 default: |
|
104 break; |
|
105 } |
|
106 } |
|
107 |
|
108 void GlxGridState::allItemEventHandler ( qint32 &id ) |
|
109 { |
|
110 qDebug("GlxGridState::allItemEventHandler() action id = %d", id); |
|
111 |
|
112 switch(id) { |
|
113 case EGlxCmdAllGridOpen : |
|
114 case EGlxCmdFetcherAllGridOpen : |
|
115 id = EGlxCmdHandled; |
|
116 break ; |
|
117 case EGlxCmdFullScreenOpen : |
|
118 mStateManager->nextState( GLX_FULLSCREENVIEW_ID, ALL_FULLSCREEN_S ); |
|
119 id = EGlxCmdHandled; |
|
120 break; |
|
121 default : |
|
122 break; |
|
123 } |
|
124 } |
|
125 |
|
126 void GlxGridState::albumItemEventHandler ( qint32 &id ) |
|
127 { |
|
128 qDebug("GlxGridState::albumItemEventHandler() action id = %d", id); |
|
129 |
|
130 switch(id) { |
|
131 case EGlxCmdAllGridOpen : |
|
132 mStateManager->removeCurrentModel(); |
|
133 mStateManager->goBack( GLX_GRIDVIEW_ID, ALL_ITEM_S ); |
|
134 id = EGlxCmdHandled; |
|
135 break ; |
|
136 |
|
137 case EGlxCmdFetcherAllGridOpen : |
|
138 mStateManager->removeCurrentModel(); |
|
139 mStateManager->goBack( GLX_GRIDVIEW_ID, FETCHER_ITEM_S ); |
|
140 id = EGlxCmdHandled; |
|
141 break ; |
|
142 |
|
143 case EGlxCmdAlbumListOpen : |
|
144 case EGlxCmdFetcherAlbumListOpen: |
|
145 case EGlxCmdBack : |
|
146 mStateManager->removeCurrentModel(); |
|
147 mStateManager->previousState(); |
|
148 id = EGlxCmdHandled; |
|
149 break; |
|
150 |
|
151 case EGlxCmdFullScreenOpen : |
|
152 mStateManager->nextState( GLX_FULLSCREENVIEW_ID, ALBUM_FULLSCREEN_S ); |
|
153 id = EGlxCmdHandled; |
|
154 break; |
|
155 default : |
|
156 break; |
|
157 } |
|
158 } |
|
159 |
|
160 void GlxGridState::setTranstionParameter(NavigationDir dir, GlxEffect &effect, GlxViewEffect &viewEffect) |
|
161 { |
|
162 qDebug("GlxListState::setTranstionParameter dir = %d", dir); |
|
163 if ( dir == NO_DIR || dir == FORWARD_DIR) { |
|
164 effect = ALBUMLIST_TO_GRID ; |
|
165 viewEffect = BOTH_VIEW ; |
|
166 } |
|
167 |
|
168 if ( dir == BACKWARD_DIR){ |
|
169 effect = GRID_TO_ALBUMLIST ; |
|
170 viewEffect = BOTH_VIEW ; |
|
171 } |
|
172 } |
|
173 |