|
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 |
|
36 // ----------------------------------------------------------------------------- |
|
37 // CCalenCommonUI::FindPossibleInstanceL |
|
38 // Finds an instance with the given instance id and instance view. |
|
39 // (other items were commented in a header). |
|
40 // ----------------------------------------------------------------------------- |
|
41 // |
|
42 AgendaEntry CalenActionUiUtils::findPossibleInstanceL(const TCalenInstanceId& id, |
|
43 AgendaUtil* agendaUtil ) |
|
44 { |
|
45 TRACE_ENTRY_POINT; |
|
46 |
|
47 QList<AgendaEntry> instances = agendaUtil->createEntryIdListForDay(id.mInstanceTime, |
|
48 AgendaUtil::FilterFlags(AgendaUtil::IncludeAll)); |
|
49 AgendaEntry result; |
|
50 |
|
51 // For instances finishing the next day (now possible with unified DateTime editor), |
|
52 // we have to do our best to match the instance time exactly - otherwise we could |
|
53 // match the LocalUid to the incorrect instance in a series. |
|
54 for ( TInt i=0; i < instances.count() && (result.isNull()); ++i ) |
|
55 { |
|
56 if( instances[i].id() == id.mEntryLocalUid ) |
|
57 { |
|
58 // Check the instance time matches. |
|
59 if( instances[i].startTime() == id.mInstanceTime ) |
|
60 { |
|
61 result = instances[i]; |
|
62 instances.removeAt(i); |
|
63 } |
|
64 } |
|
65 } |
|
66 |
|
67 if( result.isNull() ) |
|
68 { |
|
69 // Couldn't match the instance time exactly - just use the instance |
|
70 // with the same LocalUid as the one we're looking for. |
|
71 for ( TInt i=0; i < instances.count() && (result.isNull()); ++i ) |
|
72 { |
|
73 if( instances[i].id() == id.mEntryLocalUid ) |
|
74 { |
|
75 result = instances[i]; |
|
76 instances.removeAt(i); |
|
77 } |
|
78 } |
|
79 } |
|
80 |
|
81 TRACE_EXIT_POINT; |
|
82 return result; |
|
83 } |
|
84 |
|
85 |
|
86 // ---------------------------------------------------------------------------- |
|
87 // CalenActionUiUtils::SetToDoCompleteStatusL |
|
88 // Mark to-do entry as completed or restore a completed to-do and save. |
|
89 // This is not in the engine layer because it shows an error mesage on failure. |
|
90 // (other items were commented in a header). |
|
91 // ---------------------------------------------------------------------------- |
|
92 // |
|
93 void CalenActionUiUtils::setToDoCompleteStatus( AgendaUtil* agendaUtil, |
|
94 AgendaEntry& entry, |
|
95 const bool status ) |
|
96 { |
|
97 TRACE_ENTRY_POINT; |
|
98 |
|
99 ASSERT( !entry.isNull() ); |
|
100 QDateTime now = QDateTime::currentDateTime(); |
|
101 |
|
102 // set as completed or restore and update the entry in the database |
|
103 agendaUtil->setCompleted(entry, status, now) |
|
104 |
|
105 TRACE_EXIT_POINT; |
|
106 } |
|
107 |
|
108 int CalenActionUiUtils::showDeleteConfirmationQueryL(const TDeleteConfirmationType type, |
|
109 const int count) |
|
110 { |
|
111 TRACE_ENTRY_POINT; |
|
112 int retStatus = 0; |
|
113 |
|
114 |
|
115 HbMessageBox popup(HbMessageBox::MessageTypeQuestion); |
|
116 popup.setIconVisible(true); |
|
117 popup.setTimeout(HbPopup::NoTimeout); |
|
118 |
|
119 QString text = 0; |
|
120 |
|
121 switch(type) |
|
122 { |
|
123 case CalenActionUiUtils::EDeleteEntry: |
|
124 { |
|
125 // TODO: Add the text id |
|
126 text.append("Delete entry?"); |
|
127 break; |
|
128 } |
|
129 case CalenActionUiUtils::EDeleteToDo: |
|
130 { |
|
131 text.append(hbTrId("txt_calendar_info_delete_todo_note")); |
|
132 break; |
|
133 } |
|
134 case CalenActionUiUtils::EDeleteToDos: |
|
135 {//"Delete %N to-do notes?" |
|
136 // TODO: Add the text id |
|
137 text.append("Delete %N to-do's?").arg(count); |
|
138 break; |
|
139 } |
|
140 case CalenActionUiUtils::EDeleteAll: |
|
141 { |
|
142 text.append(hbTrId("txt_calendar_info_delete_all_calendar_entries")); |
|
143 break; |
|
144 } |
|
145 default: |
|
146 break; |
|
147 } |
|
148 |
|
149 popup.setText(text); |
|
150 |
|
151 popup.setPrimaryAction(new HbAction( |
|
152 hbTrId("txt_calendar_button_delete"), &popup)); |
|
153 popup.setSecondaryAction(new HbAction( |
|
154 hbTrId("txt_calendar_button_cancel"), &popup)); |
|
155 HbAction *selected = popup.exec(); |
|
156 if (selected == popup.primaryAction()) { |
|
157 retStatus = 1; |
|
158 } |
|
159 |
|
160 TRACE_EXIT_POINT |
|
161 return retStatus; |
|
162 } |
|
163 |
|
164 |
|
165 |
|
166 // End of file |