39 mSoftKeyAction(NULL), |
41 mSoftKeyAction(NULL), |
40 mGoToTodayAction(NULL), |
42 mGoToTodayAction(NULL), |
41 mActionTaken(false) |
43 mActionTaken(false) |
42 { |
44 { |
43 // No implementation yet |
45 // No implementation yet |
|
46 grabGesture(Qt::SwipeGesture); |
44 } |
47 } |
45 |
48 |
46 // ---------------------------------------------------------------------------- |
49 // ---------------------------------------------------------------------------- |
47 // CCalenDayView::~CalenDayView |
50 // CCalenDayView::~CalenDayView |
48 // Rest of the details are commented in the header |
51 // Rest of the details are commented in the header |
166 CalenDocLoader* CalenDayView::docLoader() |
169 CalenDocLoader* CalenDayView::docLoader() |
167 { |
170 { |
168 return mDocLoader; |
171 return mDocLoader; |
169 } |
172 } |
170 |
173 |
171 // ---------------------------------------------------------------------------- |
174 /* |
172 // CalenDayView::handleLocaleChange |
175 Function to listen for gestures |
173 // Rest of the details are commented in the header |
176 */ |
174 // ---------------------------------------------------------------------------- |
177 void CalenDayView::gestureEvent(QGestureEvent *event) |
175 // |
178 { |
176 void CalenDayView::mousePressEvent(QGraphicsSceneMouseEvent *event) |
179 if(HbSwipeGesture *gesture = qobject_cast<HbSwipeGesture *>(event->gesture(Qt::SwipeGesture))) { |
177 { |
180 if (gesture->state() == Qt::GestureStarted) { |
178 // TODO: Remove these after gestures are available |
181 if(QSwipeGesture::Left == gesture->horizontalDirection()) { |
179 mTapPoint = event->pos(); |
182 mServices.IssueCommandL(ECalenShowNextDay); |
180 event->accept(); |
183 event->accept(Qt::SwipeGesture); |
181 } |
184 } else if(QSwipeGesture::Right == gesture->horizontalDirection()) { |
182 |
185 mServices.IssueCommandL(ECalenShowPrevDay); |
183 // ---------------------------------------------------------------------------- |
186 event->accept(Qt::SwipeGesture); |
184 // CalenDayView::handleLocaleChange |
187 } |
185 // Rest of the details are commented in the header |
188 } |
186 // ---------------------------------------------------------------------------- |
189 } |
187 // |
|
188 void CalenDayView::mouseMoveEvent(QGraphicsSceneMouseEvent *event) |
|
189 { |
|
190 // TODO: Remove these after gestures are available |
|
191 QPointF curPos = event->pos(); |
|
192 if (abs(curPos.y() - mTapPoint.y()) > 20) { |
|
193 event->accept(); |
|
194 return; |
|
195 } |
|
196 if (curPos.x() - mTapPoint.x() > 50) { |
|
197 mTapPoint = QPointF(0, 0); |
|
198 mServices.IssueCommandL(ECalenShowPrevDay); |
|
199 mActionTaken = true; |
|
200 } else if (curPos.x() - mTapPoint.x() < -50) { |
|
201 mTapPoint = QPointF(0, 0); |
|
202 mServices.IssueCommandL(ECalenShowNextDay); |
|
203 mActionTaken = true; |
|
204 } |
|
205 event->accept(); |
|
206 } |
|
207 |
|
208 // ---------------------------------------------------------------------------- |
|
209 // CCalenDayView::eventFilter |
|
210 // Rest of the details are commented in the header |
|
211 // ---------------------------------------------------------------------------- |
|
212 // |
|
213 bool CalenDayView::eventFilter(QObject *source, QEvent *event) |
|
214 { |
|
215 // TODO : remove this line after gestures are available |
|
216 mActionTaken = false; |
|
217 Q_UNUSED(source) |
|
218 if (event->type() == QEvent::GraphicsSceneMousePress) { |
|
219 QGraphicsSceneMouseEvent *mouseEvent = static_cast<QGraphicsSceneMouseEvent*>(event); |
|
220 mousePressEvent(mouseEvent); |
|
221 } else if (event->type() == QEvent::GraphicsSceneMouseMove) { |
|
222 QGraphicsSceneMouseEvent *mouseEvent = static_cast<QGraphicsSceneMouseEvent*>(event); |
|
223 mouseMoveEvent(mouseEvent); |
|
224 } |
|
225 if (mActionTaken) { |
|
226 // Swipe gesture has been enforced. |
|
227 // Do not pass the event to the source |
|
228 return true; |
|
229 } |
|
230 return false; |
|
231 } |
190 } |
232 |
191 |
233 // ---------------------------------------------------------------------------- |
192 // ---------------------------------------------------------------------------- |
234 // CCalenDayView::createToolBar |
193 // CCalenDayView::createToolBar |
235 // Rest of the details are commented in the header |
194 // Rest of the details are commented in the header |