33 #include "calenservices.h" |
33 #include "calenservices.h" |
34 #include "calencontext.h" |
34 #include "calencontext.h" |
35 #include "calensettingsview.h" |
35 #include "calensettingsview.h" |
36 #include "calendateutils.h" |
36 #include "calendateutils.h" |
37 #include "calenconstants.h" |
37 #include "calenconstants.h" |
|
38 #include "OstTraceDefinitions.h" |
|
39 #ifdef OST_TRACE_COMPILER_IN_USE |
|
40 #include "calennativeviewTraces.h" |
|
41 #endif |
|
42 |
38 |
43 |
39 /*! |
44 /*! |
40 \class CalenNativeView |
45 \class CalenNativeView |
41 Base class for all calendar views |
46 Base class for all calendar views |
42 */ |
47 */ |
43 |
48 |
44 /*! |
49 /*! |
45 Default constructor. |
50 Default constructor. |
46 */ |
51 */ |
47 CalenNativeView::CalenNativeView(MCalenServices &services) : |
52 CalenNativeView::CalenNativeView(MCalenServices &services) : |
48 mServices(services), mIsCapturedScreenShotValid(false) |
53 mServices(services), |
49 { |
54 mEntriesInDataBase(false), |
|
55 mIsCapturedScreenShotValid(false) |
|
56 { |
|
57 OstTraceFunctionEntry0( CALENNATIVEVIEW_CALENNATIVEVIEW_ENTRY ); |
|
58 |
50 setTitle(hbTrId("txt_calendar_title_calendar")); |
59 setTitle(hbTrId("txt_calendar_title_calendar")); |
51 |
60 |
52 // Create services API and register for notifications |
61 // Create services API and register for notifications |
53 RArray<TCalenNotification> notificationArray; |
62 RArray<TCalenNotification> notificationArray; |
54 CleanupClosePushL(notificationArray); |
63 CleanupClosePushL(notificationArray); |
58 notificationArray.Append(ECalenNotifyContextChanged); |
67 notificationArray.Append(ECalenNotifyContextChanged); |
59 |
68 |
60 mServices.RegisterForNotificationsL(this, notificationArray); |
69 mServices.RegisterForNotificationsL(this, notificationArray); |
61 |
70 |
62 CleanupStack::PopAndDestroy(¬ificationArray); |
71 CleanupStack::PopAndDestroy(¬ificationArray); |
|
72 |
|
73 OstTraceFunctionExit0( CALENNATIVEVIEW_CALENNATIVEVIEW_EXIT ); |
63 } |
74 } |
64 |
75 |
65 /*! |
76 /*! |
66 Destructor |
77 Destructor |
67 */ |
78 */ |
68 CalenNativeView::~CalenNativeView() |
79 CalenNativeView::~CalenNativeView() |
69 { |
80 { |
|
81 OstTraceFunctionEntry0( DUP1_CALENNATIVEVIEW_CALENNATIVEVIEW_ENTRY ); |
|
82 |
|
83 OstTraceFunctionExit0( DUP1_CALENNATIVEVIEW_CALENNATIVEVIEW_EXIT ); |
70 } |
84 } |
71 |
85 |
72 /*! |
86 /*! |
73 Issues populcaiton complete to the framework |
87 Issues populcaiton complete to the framework |
74 */ |
88 */ |
75 void CalenNativeView::populationComplete() |
89 void CalenNativeView::populationComplete() |
76 { |
90 { |
|
91 OstTraceFunctionEntry0( CALENNATIVEVIEW_POPULATIONCOMPLETE_ENTRY ); |
|
92 |
77 // Population is complete, issue the notification |
93 // Population is complete, issue the notification |
78 mServices.IssueNotificationL(ECalenNotifyViewPopulationComplete); |
94 mServices.IssueNotificationL(ECalenNotifyViewPopulationComplete); |
|
95 |
|
96 OstTraceFunctionExit0( CALENNATIVEVIEW_POPULATIONCOMPLETE_EXIT ); |
79 } |
97 } |
80 |
98 |
81 /*! |
99 /*! |
82 Slot for delete before date |
100 Slot for delete before date |
83 */ |
101 */ |
84 void CalenNativeView::deleteBeforeDate() |
102 void CalenNativeView::deleteBeforeDate() |
85 { |
103 { |
|
104 OstTraceFunctionEntry0( CALENNATIVEVIEW_DELETEBEFOREDATE_ENTRY ); |
|
105 |
86 mServices.IssueCommandL(ECalenDeleteEntriesBeforeDate); |
106 mServices.IssueCommandL(ECalenDeleteEntriesBeforeDate); |
|
107 |
|
108 OstTraceFunctionExit0( CALENNATIVEVIEW_DELETEBEFOREDATE_EXIT ); |
87 } |
109 } |
88 |
110 |
89 /*! |
111 /*! |
90 Slot for delete all entries |
112 Slot for delete all entries |
91 */ |
113 */ |
92 void CalenNativeView::deleteAllEntries() |
114 void CalenNativeView::deleteAllEntries() |
93 { |
115 { |
|
116 OstTraceFunctionEntry0( CALENNATIVEVIEW_DELETEALLENTRIES_ENTRY ); |
|
117 |
94 mServices.IssueCommandL(ECalenDeleteAllEntries); |
118 mServices.IssueCommandL(ECalenDeleteAllEntries); |
|
119 mEntriesInDataBase = false; |
|
120 |
|
121 OstTraceFunctionExit0( CALENNATIVEVIEW_DELETEALLENTRIES_EXIT ); |
95 } |
122 } |
96 |
123 |
97 /*! |
124 /*! |
98 Slot to handle gotodate |
125 Slot to handle gotodate |
99 */ |
126 */ |
100 void CalenNativeView::goToDate() |
127 void CalenNativeView::goToDate() |
101 { |
128 { |
|
129 OstTraceFunctionEntry0( CALENNATIVEVIEW_GOTODATE_ENTRY ); |
|
130 |
102 // Create a popup with datepicker for the user to select date. |
131 // Create a popup with datepicker for the user to select date. |
103 HbDialog *popUp = new HbDialog(); |
132 HbDialog *popUp = new HbDialog(); |
104 popUp->setDismissPolicy(HbDialog::NoDismiss); |
133 popUp->setDismissPolicy(HbDialog::NoDismiss); |
105 popUp->setTimeout(HbDialog::NoTimeout); |
134 popUp->setTimeout(HbDialog::NoTimeout); |
106 popUp->setAttribute( Qt::WA_DeleteOnClose, true ); |
135 popUp->setAttribute( Qt::WA_DeleteOnClose, true ); |
119 HbAction *okAction = new HbAction(hbTrId("txt_common_button_ok")); |
148 HbAction *okAction = new HbAction(hbTrId("txt_common_button_ok")); |
120 popUp->addAction(okAction); |
149 popUp->addAction(okAction); |
121 connect(okAction, SIGNAL(triggered()), this, SLOT(goToSelectedDate())); |
150 connect(okAction, SIGNAL(triggered()), this, SLOT(goToSelectedDate())); |
122 popUp->addAction(new HbAction(hbTrId("txt_common_button_cancel"), popUp)); |
151 popUp->addAction(new HbAction(hbTrId("txt_common_button_cancel"), popUp)); |
123 popUp->open(); |
152 popUp->open(); |
|
153 |
|
154 OstTraceFunctionExit0( CALENNATIVEVIEW_GOTODATE_EXIT ); |
124 } |
155 } |
125 |
156 |
126 /* |
157 /* |
127 Slot to handle date selected on gotodate popup |
158 Slot to handle date selected on gotodate popup |
128 */ |
159 */ |
129 void CalenNativeView::goToSelectedDate() |
160 void CalenNativeView::goToSelectedDate() |
130 { |
161 { |
|
162 OstTraceFunctionEntry0( CALENNATIVEVIEW_GOTOSELECTEDDATE_ENTRY ); |
|
163 |
131 QDate selectedDate = mDatePicker->date(); |
164 QDate selectedDate = mDatePicker->date(); |
132 |
165 |
133 // Check if the selected date is within the range. |
166 // Check if the selected date is within the range. |
134 if (selectedDate.isValid() && |
167 if (selectedDate.isValid() && |
135 selectedDate >= CalenDateUtils::minTime().date() && |
168 selectedDate >= CalenDateUtils::minTime().date() && |
140 //Set the selected date to contextDate. |
173 //Set the selected date to contextDate. |
141 contextDate.setDate(selectedDate); |
174 contextDate.setDate(selectedDate); |
142 context.setFocusDateAndTime(contextDate); |
175 context.setFocusDateAndTime(contextDate); |
143 } |
176 } |
144 refreshViewOnGoToDate(); |
177 refreshViewOnGoToDate(); |
|
178 |
|
179 OstTraceFunctionExit0( CALENNATIVEVIEW_GOTOSELECTEDDATE_EXIT ); |
145 } |
180 } |
146 |
181 |
147 /*! |
182 /*! |
148 Virtual function to refresh the current view upon selecting a date |
183 Virtual function to refresh the current view upon selecting a date |
149 from GoToDate popup |
184 from GoToDate popup |
150 */ |
185 */ |
151 void CalenNativeView::refreshViewOnGoToDate() |
186 void CalenNativeView::refreshViewOnGoToDate() |
152 { |
187 { |
|
188 OstTraceFunctionEntry0( CALENNATIVEVIEW_REFRESHVIEWONGOTODATE_ENTRY ); |
|
189 |
153 mServices.IssueCommandL(ECalenStartActiveStep); |
190 mServices.IssueCommandL(ECalenStartActiveStep); |
|
191 |
|
192 OstTraceFunctionExit0( CALENNATIVEVIEW_REFRESHVIEWONGOTODATE_EXIT ); |
154 } |
193 } |
155 |
194 |
156 /*! |
195 /*! |
157 Slot to handle setting item in options menu |
196 Slot to handle setting item in options menu |
158 */ |
197 */ |
159 void CalenNativeView::launchSettingsView() |
198 void CalenNativeView::launchSettingsView() |
160 { |
199 { |
|
200 OstTraceFunctionEntry0( CALENNATIVEVIEW_LAUNCHSETTINGSVIEW_ENTRY ); |
|
201 |
161 mServices.IssueCommandL(ECalenShowSettings); |
202 mServices.IssueCommandL(ECalenShowSettings); |
|
203 |
|
204 OstTraceFunctionExit0( CALENNATIVEVIEW_LAUNCHSETTINGSVIEW_EXIT ); |
162 } |
205 } |
163 |
206 |
164 /*! |
207 /*! |
165 Slot to handle to orientation change |
208 Slot to handle to orientation change |
166 */ |
209 */ |
167 void CalenNativeView::changeOrientation(Qt::Orientation orientation) |
210 void CalenNativeView::changeOrientation(Qt::Orientation orientation) |
168 { |
211 { |
|
212 OstTraceFunctionEntry0( CALENNATIVEVIEW_CHANGEORIENTATION_ENTRY ); |
|
213 |
169 Q_UNUSED(orientation); |
214 Q_UNUSED(orientation); |
170 // Nothing, derived classes will implement it |
215 // Nothing, derived classes will implement it |
|
216 OstTraceFunctionExit0( CALENNATIVEVIEW_CHANGEORIENTATION_EXIT ); |
171 } |
217 } |
172 |
218 |
173 /*! |
219 /*! |
174 Handles the interested notifications from the calendar framework |
220 Handles the interested notifications from the calendar framework |
175 */ |
221 */ |
176 void CalenNativeView::HandleNotification(const TCalenNotification notification) |
222 void CalenNativeView::HandleNotification(const TCalenNotification notification) |
177 { |
223 { |
|
224 OstTraceFunctionEntry0( CALENNATIVEVIEW_HANDLENOTIFICATION_ENTRY ); |
|
225 |
178 switch (notification) { |
226 switch (notification) { |
179 case ECalenNotifySystemLocaleChanged: { |
227 case ECalenNotifySystemLocaleChanged: { |
180 onLocaleChanged(EChangesLocale); |
228 onLocaleChanged(EChangesLocale); |
181 } |
229 } |
182 break; |
230 break; |
|
231 case ECalenNotifySystemTimeChanged: { |
|
232 onLocaleChanged(EChangesSystemTime); |
|
233 } |
|
234 break; |
183 case ECalenNotifyContextChanged: { |
235 case ECalenNotifyContextChanged: { |
184 onContextChanged(); |
236 onContextChanged(); |
185 } |
237 } |
186 break; |
238 break; |
187 default: |
239 default: |
188 break; |
240 break; |
189 } |
241 } |
|
242 |
|
243 OstTraceFunctionExit0( CALENNATIVEVIEW_HANDLENOTIFICATION_EXIT ); |
190 } |
244 } |
191 |
245 |
192 /*! |
246 /*! |
193 Returns true if plugin is loaded |
247 Returns true if plugin is loaded |
194 */ |
248 */ |
195 TBool CalenNativeView::pluginEnabled() |
249 TBool CalenNativeView::pluginEnabled() |
196 { |
250 { |
|
251 OstTraceFunctionEntry0( CALENNATIVEVIEW_PLUGINENABLED_ENTRY ); |
|
252 |
197 QString *pluginInfo = mServices.InfobarTextL(); |
253 QString *pluginInfo = mServices.InfobarTextL(); |
198 if (!pluginInfo) { |
254 if (!pluginInfo) { |
|
255 OstTraceFunctionExit0( CALENNATIVEVIEW_PLUGINENABLED_EXIT ); |
199 return false; |
256 return false; |
200 } else { |
257 } else { |
|
258 OstTraceFunctionExit0( DUP1_CALENNATIVEVIEW_PLUGINENABLED_EXIT ); |
201 return true; |
259 return true; |
202 } |
260 } |
203 } |
261 } |
204 |
262 |
205 QString *CalenNativeView::pluginText() |
263 QString *CalenNativeView::pluginText() |
206 { |
264 { |
|
265 OstTraceFunctionEntry0( CALENNATIVEVIEW_PLUGINTEXT_ENTRY ); |
|
266 |
|
267 OstTraceFunctionExit0( CALENNATIVEVIEW_PLUGINTEXT_EXIT ); |
207 return mServices.InfobarTextL(); |
268 return mServices.InfobarTextL(); |
|
269 |
208 } |
270 } |
209 |
271 |
210 // ---------------------------------------------------------------------------- |
272 // ---------------------------------------------------------------------------- |
211 // captureScreenshot caltures screen shot for the given viewId |
273 // captureScreenshot caltures screen shot for the given viewId |
212 // @param viewId view for which screenshot needs to be captured |
274 // @param viewId view for which screenshot needs to be captured |
213 // ---------------------------------------------------------------------------- |
275 // ---------------------------------------------------------------------------- |
214 // |
276 // |
215 void CalenNativeView::captureScreenshot(bool captureScreenShot) |
277 void CalenNativeView::captureScreenshot(bool captureScreenShot) |
216 { |
278 { |
|
279 OstTraceFunctionEntry0( CALENNATIVEVIEW_CAPTURESCREENSHOT_ENTRY ); |
|
280 |
217 // get a screenshot for saving to the activity manager. It's done for once |
281 // get a screenshot for saving to the activity manager. It's done for once |
218 // to optimize the performance |
282 // to optimize the performance |
219 if (captureScreenShot) { |
283 if (captureScreenShot) { |
220 mScreenShotMetadata.clear(); // remove any screenshot captured earlier |
284 mScreenShotMetadata.clear(); // remove any screenshot captured earlier |
221 mScreenShotMetadata.insert("screenshot", QPixmap::grabWidget(mainWindow(), mainWindow()->rect())); |
285 mScreenShotMetadata.insert("screenshot", QPixmap::grabWidget(mainWindow(), mainWindow()->rect())); |
222 } |
286 } |
223 mIsCapturedScreenShotValid = captureScreenShot; // set the validity of the screenshot captured |
287 mIsCapturedScreenShotValid = captureScreenShot; // set the validity of the screenshot captured |
|
288 |
|
289 OstTraceFunctionExit0( CALENNATIVEVIEW_CAPTURESCREENSHOT_EXIT ); |
224 } |
290 } |
225 |
291 |
226 // ---------------------------------------------------------------------------- |
292 // ---------------------------------------------------------------------------- |
227 // saveActivity saves the activity for current view |
293 // saveActivity saves the activity for current view |
228 // ---------------------------------------------------------------------------- |
294 // ---------------------------------------------------------------------------- |
229 // |
295 // |
230 void CalenNativeView::saveActivity() |
296 void CalenNativeView::saveActivity() |
231 { |
297 { |
|
298 OstTraceFunctionEntry0( CALENNATIVEVIEW_SAVEACTIVITY_ENTRY ); |
|
299 |
232 // Get a pointer to activity manager |
300 // Get a pointer to activity manager |
233 HbActivityManager* activityManager = qobject_cast<HbApplication*>(qApp)->activityManager(); |
301 HbActivityManager* activityManager = qobject_cast<HbApplication*>(qApp)->activityManager(); |
234 |
302 |
235 // check if alerady a valid screen shot is captured |
303 // check if alerady a valid screen shot is captured |
236 if (!mIsCapturedScreenShotValid) { |
304 if (!mIsCapturedScreenShotValid) { |