|
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 if(AknLayoutUtils::LayoutMirrored()) |
|
102 { |
|
103 aTarget.Append(KArabicSummaryMarker); |
|
104 } |
|
105 else |
|
106 { |
|
107 aTarget.Append(KWesternSummaryMarker); |
|
108 } |
|
109 |
|
110 |
|
111 // "Summary" |
|
112 aTarget.Append( summary.Left( freeSpace ) ); |
|
113 freeSpace = max - aTarget.Length(); |
|
114 |
|
115 // If both summary and location exists, add separator ", " in between. |
|
116 if ( summary.Length() > 0 && location.Length() > 0 && freeSpace > 0 ) |
|
117 { |
|
118 if ( User::Language() == ELangArabic ) |
|
119 { |
|
120 aTarget.Append( arabicSeparator.Left( freeSpace ) ); |
|
121 } |
|
122 else |
|
123 { |
|
124 aTarget.Append( westernSeparator.Left( freeSpace ) ); |
|
125 } |
|
126 freeSpace = max - aTarget.Length(); |
|
127 } |
|
128 |
|
129 // "Location". It's added even if summary is empty |
|
130 if( freeSpace > 0 ) |
|
131 { |
|
132 aTarget.Append( location.Left( freeSpace ) ); |
|
133 } |
|
134 |
|
135 freeSpace = max - aTarget.Length(); |
|
136 |
|
137 AknTextUtils::ReplaceCharacters(aTarget, KReplaceWhitespaceChars, TChar(' ')); |
|
138 freeSpace = max - aTarget.Length(); |
|
139 |
|
140 // Take away extra whitespace |
|
141 aTarget.TrimAll(); |
|
142 freeSpace = max - aTarget.Length(); |
|
143 |
|
144 // Set "<unnamed>" string for text, if there's nothing in buffer so far |
|
145 //if ( aTarget.Length() == 0 ) |
|
146 if ( aEntry.SummaryL().Length() == 0 && location.Length() == 0 ) |
|
147 { |
|
148 HBufC* emptytext = StringLoader::LoadLC( R_CALEN_QTN_CALE_NO_SUBJECT ); |
|
149 aTarget.Copy( emptytext->Left( freeSpace ) ); |
|
150 freeSpace = max - aTarget.Length(); |
|
151 CleanupStack::PopAndDestroy(emptytext); |
|
152 } |
|
153 |
|
154 TRACE_EXIT_POINT; |
|
155 } |
|
156 |
|
157 // ---------------------------------------------------------------------------- |
|
158 // CalenNoteDataUtil::DateQueryL |
|
159 // Prompts the user for a time. Requires a title resource id, or pass 0 |
|
160 // for default title "Date:". |
|
161 // ---------------------------------------------------------------------------- |
|
162 // |
|
163 EXPORT_C TInt CalenViewUtils::DateQueryL( TTime& aDate, TInt aPromptId ) |
|
164 { |
|
165 TRACE_ENTRY_POINT; |
|
166 if ( aPromptId == 0 ) |
|
167 { |
|
168 aPromptId = R_CALEN_DATE_PROMPT; |
|
169 } |
|
170 |
|
171 CAknTimeQueryDialog* dlg = CAknTimeQueryDialog::NewL( aDate, |
|
172 CAknQueryDialog::ENoTone ); |
|
173 CleanupStack::PushL(dlg); |
|
174 |
|
175 HBufC* prompt = StringLoader::LoadLC( aPromptId, CEikonEnv::Static() ); |
|
176 dlg->SetPromptL( *prompt ); |
|
177 CleanupStack::PopAndDestroy( prompt ); |
|
178 |
|
179 CleanupStack::Pop(); // dlg |
|
180 |
|
181 TRACE_EXIT_POINT; |
|
182 return dlg->ExecuteLD( R_CALEN_DAYQUERY_NOTE ); |
|
183 } |
|
184 |
|
185 // --------------------------------------------------------------------------- |
|
186 // CalenViewUtils::IsAllDayEvent |
|
187 // Allday event is an event with a duration of n*24h. |
|
188 // --------------------------------------------------------------------------- |
|
189 // |
|
190 EXPORT_C TBool CalenViewUtils::IsAlldayEventL( const CCalInstance& aInstance ) |
|
191 { |
|
192 |
|
193 TRACE_ENTRY_POINT; |
|
194 |
|
195 TBool allDayEvent( EFalse ); |
|
196 CCalEntry& entry = aInstance.Entry(); |
|
197 if ( CCalEntry::EAppt == entry.EntryTypeL() |
|
198 ||CCalEntry::EEvent == entry.EntryTypeL() ) |
|
199 { |
|
200 TCalTime startTime = entry.StartTimeL(); |
|
201 TCalTime stopTime = entry.EndTimeL(); |
|
202 |
|
203 TTime startLocalTime = startTime.TimeLocalL(); |
|
204 TTime stopLocalTime = stopTime.TimeLocalL(); |
|
205 if( startLocalTime != stopLocalTime && |
|
206 startLocalTime == CalenDateUtils::BeginningOfDay( startLocalTime ) && |
|
207 stopLocalTime == CalenDateUtils::BeginningOfDay( stopLocalTime ) && |
|
208 startLocalTime != stopLocalTime ) |
|
209 { |
|
210 allDayEvent = ETrue; |
|
211 } |
|
212 else |
|
213 { |
|
214 allDayEvent = EFalse; |
|
215 } |
|
216 } |
|
217 |
|
218 TRACE_EXIT_POINT; |
|
219 return allDayEvent; |
|
220 } |
|
221 |
|
222 // End of file. |