|
1 /* |
|
2 * Copyright (c) 2007-2008 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: Implementation of UI utils |
|
15 * |
|
16 */ |
|
17 |
|
18 // System Includes |
|
19 #include <QtGui> |
|
20 #include <hblabel.h> |
|
21 #include <hbaction.h> |
|
22 #include <hbinputdialog.h> |
|
23 #include <HbMessageBox> |
|
24 #include <agendautil.h> |
|
25 #include <agendaentry.h> |
|
26 |
|
27 // User includes |
|
28 #include "calendarui_debug.h" |
|
29 #include "calenactionuiutils.h" |
|
30 #include "calendar.hrh" |
|
31 #include "hb_calencommands.hrh" |
|
32 #include "caleninstanceid.h" |
|
33 #include "CleanupResetAndDestroy.h" |
|
34 #include "calendateutils.h" |
|
35 #include "OstTraceDefinitions.h" |
|
36 #ifdef OST_TRACE_COMPILER_IN_USE |
|
37 #include "calenactionuiutilsTraces.h" |
|
38 #endif |
|
39 |
|
40 // ----------------------------------------------------------------------------- |
|
41 // CCalenCommonUI::FindPossibleInstanceL |
|
42 // Finds an instance with the given instance id and instance view. |
|
43 // (other items were commented in a header). |
|
44 // ----------------------------------------------------------------------------- |
|
45 // |
|
46 AgendaEntry CalenActionUiUtils::findPossibleInstanceL(const TCalenInstanceId& id, |
|
47 AgendaUtil* agendaUtil ) |
|
48 { |
|
49 OstTraceFunctionEntry0( CALENACTIONUIUTILS_FINDPOSSIBLEINSTANCEL_ENTRY ); |
|
50 |
|
51 AgendaUtil::FilterFlags filter = |
|
52 AgendaUtil::FilterFlags(AgendaUtil::IncludeAnniversaries | |
|
53 AgendaUtil::IncludeAppointments | |
|
54 AgendaUtil::IncludeEvents | |
|
55 AgendaUtil::IncludeReminders | |
|
56 AgendaUtil::IncludeIncompletedTodos); |
|
57 QList<AgendaEntry> instances = |
|
58 agendaUtil->createEntryIdListForDay(id.mInstanceTime, filter); |
|
59 AgendaEntry result; |
|
60 |
|
61 // For instances finishing the next day (now possible with unified DateTime editor), |
|
62 // we have to do our best to match the instance time exactly - otherwise we could |
|
63 // match the LocalUid to the incorrect instance in a series. |
|
64 for ( TInt i=0; i < instances.count() && (result.isNull()); ++i ) |
|
65 { |
|
66 if( instances[i].id() == id.mEntryLocalUid ) |
|
67 { |
|
68 // Check the instance time matches. |
|
69 if( instances[i].startTime() == id.mInstanceTime ) |
|
70 { |
|
71 result = instances[i]; |
|
72 instances.removeAt(i); |
|
73 } |
|
74 } |
|
75 } |
|
76 |
|
77 if( result.isNull() ) |
|
78 { |
|
79 // Couldn't match the instance time exactly - just use the instance |
|
80 // with the same LocalUid as the one we're looking for. |
|
81 for ( TInt i=0; i < instances.count() && (result.isNull()); ++i ) |
|
82 { |
|
83 if( instances[i].id() == id.mEntryLocalUid ) |
|
84 { |
|
85 result = instances[i]; |
|
86 instances.removeAt(i); |
|
87 } |
|
88 } |
|
89 } |
|
90 |
|
91 OstTraceFunctionExit0( CALENACTIONUIUTILS_FINDPOSSIBLEINSTANCEL_EXIT ); |
|
92 return result; |
|
93 } |
|
94 |
|
95 |
|
96 // ---------------------------------------------------------------------------- |
|
97 // CalenActionUiUtils::SetToDoCompleteStatusL |
|
98 // Mark to-do entry as completed or restore a completed to-do and save. |
|
99 // This is not in the engine layer because it shows an error mesage on failure. |
|
100 // (other items were commented in a header). |
|
101 // ---------------------------------------------------------------------------- |
|
102 // |
|
103 void CalenActionUiUtils::setToDoCompleteStatus( AgendaUtil* agendaUtil, |
|
104 AgendaEntry& entry, |
|
105 const bool status ) |
|
106 { |
|
107 OstTraceFunctionEntry0( CALENACTIONUIUTILS_SETTODOCOMPLETESTATUS_ENTRY ); |
|
108 |
|
109 ASSERT( !entry.isNull() ); |
|
110 QDateTime now = QDateTime::currentDateTime(); |
|
111 |
|
112 // set as completed or restore and update the entry in the database |
|
113 agendaUtil->setCompleted(entry, status, now); |
|
114 |
|
115 OstTraceFunctionExit0( CALENACTIONUIUTILS_SETTODOCOMPLETESTATUS_EXIT ); |
|
116 } |
|
117 |
|
118 // End of file |