|
1 /* |
|
2 * Copyright (c) 2007 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 View Utils |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <calenviewutils.h> |
|
20 #include <calendateutils.h> |
|
21 #include <Calendar.rsg> |
|
22 #include <AknUtils.h> |
|
23 #include <calentry.h> |
|
24 #include <calalarm.h> |
|
25 #include <calenagendautils.h> |
|
26 #include <CalenInterimUtils2.h> |
|
27 #include <StringLoader.h> |
|
28 #include <aknnotewrappers.h> |
|
29 #include <Calendar.rsg> |
|
30 #include <AknQueryDialog.h> |
|
31 #include <calinstance.h> |
|
32 #include <calsession.h> |
|
33 #include <akntoolbar.h> |
|
34 #include <aknappui.h> |
|
35 |
|
36 #include "calendarui_debug.h" // Debug. |
|
37 #include "calendar.hrh" |
|
38 |
|
39 _LIT( KWesternSummaryMarker, "\x200E" ); |
|
40 _LIT( KArabicSummaryMarker , "\x200F" ); |
|
41 /* KReplaceWhitespaceChars contains some characters that should be replaced by |
|
42 * space in Calendar popup, day view etc. Characters are: |
|
43 * \x0009 horizontal tab |
|
44 * \x000a new line |
|
45 * \x000b line tabulation (vertical |
|
46 * \x000c form feed |
|
47 * \x000d carriage return |
|
48 * \x2028 line separator |
|
49 * \x2029 paragraph separator |
|
50 */ |
|
51 _LIT( KReplaceWhitespaceChars, "\x0009\x000A\x000B\x000C\x000D\x2028\x2029" ); |
|
52 _LIT( KWesternSummaryLocationSeparator, ", " ); |
|
53 _LIT( KArabicSummaryLocationSeparator, " \x060c" ); |
|
54 |
|
55 // ---------------------------------------------------------------------------- |
|
56 // CalenViewUtils::ShowDateErrorNoteL |
|
57 // Show Error note of out of range of date |
|
58 // (other items were commented in a header). |
|
59 // ---------------------------------------------------------------------------- |
|
60 // |
|
61 EXPORT_C void CalenViewUtils::ShowDateOutOfRangeErrorNoteL() |
|
62 { |
|
63 TRACE_ENTRY_POINT; |
|
64 |
|
65 HBufC* buf = StringLoader::LoadLC( R_QTN_CALE_INFO_YEAR_LIMIT ); |
|
66 TPtr ptr = buf->Des(); |
|
67 // Message contains year numbers, which have to be converted |
|
68 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( ptr ); |
|
69 CAknInformationNote* dialog = new( ELeave )CAknInformationNote(); |
|
70 dialog->ExecuteLD( *buf ); |
|
71 CleanupStack::PopAndDestroy( buf ); |
|
72 |
|
73 TRACE_EXIT_POINT; |
|
74 } |
|
75 |
|
76 // ---------------------------------------------------------------------------- |
|
77 // CalenViewUtils::GetSummaryLocationTextL |
|
78 // Fills a string with a more displayable text representation of the summary |
|
79 // and location fields from an entry. The number of characters to fill in the |
|
80 // target string must be specified. The function replaces problem characters |
|
81 // with spaces and trims whitespace. See KReplaceWhitespaceChars for replaced |
|
82 // characters. |
|
83 // ---------------------------------------------------------------------------- |
|
84 // |
|
85 EXPORT_C void CalenViewUtils::GetSummaryLocationTextL( |
|
86 CCalEntry& aEntry, |
|
87 TDes& aTarget, |
|
88 TInt aMaxLength ) |
|
89 { |
|
90 TRACE_ENTRY_POINT; |
|
91 |
|
92 // Every Copy and Append has to ensure that MaxLength is not exceed. |
|
93 const TInt max = aMaxLength; |
|
94 TInt freeSpace = max - 2; // freeSpace is recalculated after each update |
|
95 |
|
96 const TDesC& summary = aEntry.SummaryL(); |
|
97 //const TDesC& location = aEntry.LocationL(); |
|
98 const TDesC& westernSeparator = KWesternSummaryLocationSeparator; |
|
99 const TDesC& arabicSeparator = KArabicSummaryLocationSeparator; |
|
100 |
|
101 //location string is not available for anniversary and todo |
|
102 HBufC16* text = HBufC16::NewLC( max ); |
|
103 TPtrC location = text->Des(); |
|
104 if ( CCalEntry::ETodo != aEntry.EntryTypeL()) |
|
105 { |
|
106 location.Set(aEntry.LocationL()); |
|
107 } |
|
108 |
|
109 |
|
110 if(AknLayoutUtils::LayoutMirrored()) |
|
111 { |
|
112 aTarget.Append(KArabicSummaryMarker); |
|
113 } |
|
114 else |
|
115 { |
|
116 aTarget.Append(KWesternSummaryMarker); |
|
117 } |
|
118 |
|
119 |
|
120 // "Summary" |
|
121 aTarget.Append( summary.Left( freeSpace ) ); |
|
122 freeSpace = max - aTarget.Length(); |
|
123 |
|
124 // If both summary and location exists, add separator ", " in between. |
|
125 if ( summary.Length() > 0 && location.Length() > 0 && freeSpace > 0 ) |
|
126 { |
|
127 if ( User::Language() == ELangArabic ) |
|
128 { |
|
129 aTarget.Append( arabicSeparator.Left( freeSpace ) ); |
|
130 } |
|
131 else |
|
132 { |
|
133 aTarget.Append( westernSeparator.Left( freeSpace ) ); |
|
134 } |
|
135 freeSpace = max - aTarget.Length(); |
|
136 } |
|
137 |
|
138 // "Location". It's added even if summary is empty |
|
139 if( freeSpace > 0 ) |
|
140 { |
|
141 aTarget.Append( location.Left( freeSpace ) ); |
|
142 } |
|
143 |
|
144 freeSpace = max - aTarget.Length(); |
|
145 |
|
146 AknTextUtils::ReplaceCharacters(aTarget, KReplaceWhitespaceChars, TChar(' ')); |
|
147 freeSpace = max - aTarget.Length(); |
|
148 |
|
149 // Take away extra whitespace |
|
150 aTarget.TrimAll(); |
|
151 freeSpace = max - aTarget.Length(); |
|
152 |
|
153 // Set "<unnamed>" string for text, if there's nothing in buffer so far |
|
154 //if ( aTarget.Length() == 0 ) |
|
155 if ( aEntry.SummaryL().Length() == 0 && location.Length() == 0 ) |
|
156 { |
|
157 HBufC* emptytext = StringLoader::LoadLC( R_CALEN_QTN_CALE_NO_SUBJECT ); |
|
158 aTarget.Copy( emptytext->Left( freeSpace ) ); |
|
159 freeSpace = max - aTarget.Length(); |
|
160 CleanupStack::PopAndDestroy(emptytext); |
|
161 } |
|
162 CleanupStack::PopAndDestroy( text ); |
|
163 TRACE_EXIT_POINT; |
|
164 } |
|
165 |
|
166 // ---------------------------------------------------------------------------- |
|
167 // CalenNoteDataUtil::DateQueryL |
|
168 // Prompts the user for a time. Requires a title resource id, or pass 0 |
|
169 // for default title "Date:". |
|
170 // ---------------------------------------------------------------------------- |
|
171 // |
|
172 EXPORT_C TInt CalenViewUtils::DateQueryL( TTime& aDate, TInt aPromptId ) |
|
173 { |
|
174 TRACE_ENTRY_POINT; |
|
175 if ( aPromptId == 0 ) |
|
176 { |
|
177 aPromptId = R_CALEN_DATE_PROMPT; |
|
178 } |
|
179 |
|
180 CAknTimeQueryDialog* dlg = CAknTimeQueryDialog::NewL( aDate, |
|
181 CAknQueryDialog::ENoTone ); |
|
182 CleanupStack::PushL(dlg); |
|
183 |
|
184 HBufC* prompt = StringLoader::LoadLC( aPromptId, CEikonEnv::Static() ); |
|
185 dlg->SetPromptL( *prompt ); |
|
186 CleanupStack::PopAndDestroy( prompt ); |
|
187 |
|
188 CleanupStack::Pop(); // dlg |
|
189 |
|
190 TRACE_EXIT_POINT; |
|
191 return dlg->ExecuteLD( R_CALEN_DAYQUERY_NOTE ); |
|
192 } |
|
193 |
|
194 // --------------------------------------------------------------------------- |
|
195 // CalenViewUtils::IsAllDayEvent |
|
196 // Allday event is an event with a duration of n*24h. |
|
197 // --------------------------------------------------------------------------- |
|
198 // |
|
199 EXPORT_C TBool CalenViewUtils::IsAlldayEventL( const CCalInstance& aInstance ) |
|
200 { |
|
201 |
|
202 TRACE_ENTRY_POINT; |
|
203 |
|
204 TBool allDayEvent( EFalse ); |
|
205 CCalEntry& entry = aInstance.Entry(); |
|
206 if ( CCalEntry::EAppt == entry.EntryTypeL() |
|
207 ||CCalEntry::EEvent == entry.EntryTypeL() ) |
|
208 { |
|
209 TCalTime startTime = entry.StartTimeL(); |
|
210 TCalTime stopTime = entry.EndTimeL(); |
|
211 |
|
212 TTime startLocalTime = startTime.TimeLocalL(); |
|
213 TTime stopLocalTime = stopTime.TimeLocalL(); |
|
214 TTimeIntervalDays differenceInTime = stopLocalTime.DaysFrom(startLocalTime); // fix for AllDayEntry issue |
|
215 if( startLocalTime != stopLocalTime && |
|
216 startLocalTime == CalenDateUtils::BeginningOfDay( startLocalTime ) && |
|
217 stopLocalTime == CalenDateUtils::BeginningOfDay( stopLocalTime ) && |
|
218 startLocalTime != stopLocalTime && differenceInTime.Int() >= 1 ) // fix for AllDayEntry issue |
|
219 { |
|
220 allDayEvent = ETrue; |
|
221 } |
|
222 else |
|
223 { |
|
224 allDayEvent = EFalse; |
|
225 } |
|
226 } |
|
227 |
|
228 TRACE_EXIT_POINT; |
|
229 return allDayEvent; |
|
230 } |
|
231 |
|
232 // End of file. |