|
1 /* |
|
2 * Copyright (c) 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: Description component for retrieving place. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <evtmgmteditorui.rsg> |
|
19 #include <NpdApi.h> |
|
20 #include <StringLoader.h> |
|
21 #include <eikappui.h> |
|
22 #include <eikenv.h> |
|
23 |
|
24 #include "evtmgmteditorui.hrh" |
|
25 #include "evtmgmtuidesccomponent.h" |
|
26 |
|
27 // --------------------------------------------------------------------------- |
|
28 // CEvtEditor ::NewL() |
|
29 // --------------------------------------------------------------------------- |
|
30 // |
|
31 CEvtMgmtUiDescComponent* CEvtMgmtUiDescComponent::NewL(const TPtrC aPrevDesc) |
|
32 { |
|
33 CEvtMgmtUiDescComponent * self = CEvtMgmtUiDescComponent::NewLC(aPrevDesc); |
|
34 CleanupStack::Pop(self); |
|
35 return self; |
|
36 } |
|
37 |
|
38 // --------------------------------------------------------------------------- |
|
39 // CEvtEditor ::NewLC() |
|
40 // --------------------------------------------------------------------------- |
|
41 // |
|
42 CEvtMgmtUiDescComponent* CEvtMgmtUiDescComponent::NewLC(const TPtrC aPrevDesc) |
|
43 { |
|
44 CEvtMgmtUiDescComponent * self = new (ELeave) CEvtMgmtUiDescComponent(); |
|
45 CleanupStack::PushL(self); |
|
46 self->ConstructL(aPrevDesc); |
|
47 return self; |
|
48 } |
|
49 |
|
50 // --------------------------------------------------------------------------- |
|
51 // CEvtMgmtUiDescComponent ::~CEvtMgmtUiDescComponent() |
|
52 // --------------------------------------------------------------------------- |
|
53 // |
|
54 CEvtMgmtUiDescComponent::~CEvtMgmtUiDescComponent() |
|
55 { |
|
56 delete iNotepad; |
|
57 iNotepad = NULL; |
|
58 |
|
59 delete iDesc; |
|
60 iDesc = NULL; |
|
61 } |
|
62 |
|
63 // --------------------------------------------------------------------------- |
|
64 // CEvtMgmtUiDescComponent ::ConstructL() |
|
65 // --------------------------------------------------------------------------- |
|
66 // |
|
67 void CEvtMgmtUiDescComponent ::ConstructL(const TPtrC aPrevDesc) |
|
68 { |
|
69 iDesc = aPrevDesc.AllocL(); |
|
70 iNotepad = CNotepadApi::NewL(); |
|
71 } |
|
72 |
|
73 // --------------------------------------------------------------------------- |
|
74 // CEvtMgmtUiDescComponent ::CEvtMgmtUiDescComponent() |
|
75 // --------------------------------------------------------------------------- |
|
76 // |
|
77 CEvtMgmtUiDescComponent::CEvtMgmtUiDescComponent() |
|
78 { |
|
79 } |
|
80 |
|
81 // ----------------------------------------------------------------------------- |
|
82 // CEvtMgmtUiDescComponent::DisplayNotepadEditorL() |
|
83 // It displays notepad editor and saves in descriptor variable |
|
84 // @return KErrCancel if deleted |
|
85 // KErrAlreadyExists if not modified |
|
86 // KErrNone if modified |
|
87 // ----------------------------------------------------------------------------- |
|
88 // |
|
89 TInt CEvtMgmtUiDescComponent::DisplayNotepadEditorL() |
|
90 { |
|
91 TInt status = KErrNone; |
|
92 |
|
93 //Launch notepad application |
|
94 HBufC* desc = iNotepad->ExecTextEditorL(status,*iDesc); |
|
95 |
|
96 if(!desc) |
|
97 desc = KNullDesC().AllocL(); |
|
98 |
|
99 CleanupStack::PushL(desc); |
|
100 |
|
101 if(status != KErrNone )//if deleted |
|
102 { |
|
103 CleanupStack::PopAndDestroy(desc); |
|
104 delete iDesc; |
|
105 iDesc = NULL; |
|
106 iDesc = KNullDesC().AllocL(); |
|
107 return KErrCancel; |
|
108 } |
|
109 |
|
110 desc->Des().Trim(); |
|
111 if(desc->Length()==0) //if no text |
|
112 { |
|
113 delete iDesc; |
|
114 iDesc = NULL; |
|
115 iDesc = KNullDesC().AllocL(); |
|
116 CleanupStack::PopAndDestroy(desc); |
|
117 return KErrCancel; |
|
118 } |
|
119 |
|
120 //set text to description |
|
121 delete iDesc; |
|
122 iDesc = desc; //ownership is transfered |
|
123 CleanupStack::Pop(desc); |
|
124 return KErrNone; |
|
125 } |
|
126 |
|
127 // ----------------------------------------------------------------------------- |
|
128 // CEvtMgmtUiDescComponent::DescFromExistingNotesL() |
|
129 // It shows Memo dialog and saves in descriptor variable |
|
130 // @return KErrCancel if cancel or no note |
|
131 // KErrNone if note is selected |
|
132 // ----------------------------------------------------------------------------- |
|
133 // |
|
134 TInt CEvtMgmtUiDescComponent::DescFromExistingNotesL() |
|
135 { |
|
136 HBufC* title = StringLoader::LoadLC(R_EVTUI_EDITOR_ADDDESC_TITLE); |
|
137 |
|
138 //Display memo dialog |
|
139 HBufC* desc = iNotepad->FetchMemoL(title); |
|
140 CleanupStack::PopAndDestroy(title); |
|
141 |
|
142 if(desc) //if memo is selected |
|
143 { |
|
144 CleanupStack::PushL(desc); |
|
145 delete iDesc; |
|
146 iDesc = desc; //ownership is transferred |
|
147 CleanupStack::Pop(desc); |
|
148 return KErrNone; |
|
149 } |
|
150 return KErrCancel; |
|
151 } |
|
152 |
|
153 // ----------------------------------------------------------------------------- |
|
154 // CEvtMgmtUiDescComponent::Desc() |
|
155 // returns description value |
|
156 // ----------------------------------------------------------------------------- |
|
157 |
|
158 TPtrC CEvtMgmtUiDescComponent::Desc() const |
|
159 { |
|
160 //if description, return it, else return empty string |
|
161 if(iDesc) |
|
162 return *iDesc; |
|
163 else |
|
164 return KNullDesC(); |
|
165 } |
|
166 //end of file |