65
|
1 |
/*
|
|
2 |
* Copyright (c) 2005 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 the License "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: Encapsulates a edit folder dialog.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#include <AknPopupFieldText.h>
|
|
20 |
#include <avkon.hrh>
|
|
21 |
#include <avkon.rsg>
|
|
22 |
#include <eikedwin.h>
|
|
23 |
#include <eikmenup.h>
|
|
24 |
#include <charconv.h>
|
|
25 |
#include <aknviewappui.h>
|
|
26 |
|
|
27 |
#ifdef __SERIES60_HELP
|
|
28 |
#include <hlplch.h>
|
|
29 |
#endif
|
|
30 |
|
|
31 |
#include "BrowserAppUi.h"
|
|
32 |
#include "BrowserAppViewBase.h"
|
|
33 |
#include "FeedsEditFolderDialog.h"
|
|
34 |
|
|
35 |
#include "Browser.hrh"
|
|
36 |
#include <BrowserNG.rsg>
|
|
37 |
|
|
38 |
// -----------------------------------------------------------------------------
|
|
39 |
// CFeedsEditFolderDialog::NewL
|
|
40 |
//
|
|
41 |
// Two-phased constructor.
|
|
42 |
// -----------------------------------------------------------------------------
|
|
43 |
//
|
|
44 |
CFeedsEditFolderDialog* CFeedsEditFolderDialog::NewL(MFeedsEditFolderDialogObserver& aObserver,
|
|
45 |
CAknViewAppUi* aAppUi,
|
|
46 |
const TDesC& aName)
|
|
47 |
{
|
|
48 |
CFeedsEditFolderDialog* self = new (ELeave) CFeedsEditFolderDialog(aObserver, aAppUi, aName);
|
|
49 |
CleanupStack::PushL(self);
|
|
50 |
self->ConstructL();
|
|
51 |
CleanupStack::Pop(self);
|
|
52 |
|
|
53 |
return self;
|
|
54 |
}
|
|
55 |
|
|
56 |
|
|
57 |
// -----------------------------------------------------------------------------
|
|
58 |
// CFeedsEditFolderDialog::NewL
|
|
59 |
//
|
|
60 |
// Two-phased constructor.
|
|
61 |
// -----------------------------------------------------------------------------
|
|
62 |
//
|
|
63 |
CFeedsEditFolderDialog* CFeedsEditFolderDialog::NewL(MFeedsEditFolderDialogObserver& aObserver,
|
|
64 |
CAknViewAppUi* aAppUi)
|
|
65 |
{
|
|
66 |
CFeedsEditFolderDialog* self = new (ELeave) CFeedsEditFolderDialog(aObserver, aAppUi, KNullDesC);
|
|
67 |
|
|
68 |
CleanupStack::PushL(self);
|
|
69 |
self->iIsNewFolder = ETrue;
|
|
70 |
self->ConstructL();
|
|
71 |
CleanupStack::Pop(self);
|
|
72 |
|
|
73 |
return self;
|
|
74 |
}
|
|
75 |
|
|
76 |
|
|
77 |
// -----------------------------------------------------------------------------
|
|
78 |
// CFeedsEditFolderDialog::CFeedsEditFolderDialog
|
|
79 |
//
|
|
80 |
// C++ default constructor.
|
|
81 |
// -----------------------------------------------------------------------------
|
|
82 |
//
|
|
83 |
CFeedsEditFolderDialog::CFeedsEditFolderDialog(MFeedsEditFolderDialogObserver& aObserver,
|
|
84 |
CAknViewAppUi* aAppUi,
|
|
85 |
const TDesC& aName):
|
|
86 |
iObserver(aObserver), iAppUi(aAppUi), iName(aName)
|
|
87 |
{
|
|
88 |
}
|
|
89 |
|
|
90 |
|
|
91 |
// -----------------------------------------------------------------------------
|
|
92 |
// CFeedsEditFolderDialog::~CFeedsEditFolderDialog
|
|
93 |
//
|
|
94 |
// Deconstructor.
|
|
95 |
// -----------------------------------------------------------------------------
|
|
96 |
//
|
|
97 |
CFeedsEditFolderDialog::~CFeedsEditFolderDialog()
|
|
98 |
{
|
|
99 |
}
|
|
100 |
|
|
101 |
|
|
102 |
// -----------------------------------------------------------------------------
|
|
103 |
// CFeedsEditFolderDialog::PreLayoutDynInitL
|
|
104 |
//
|
|
105 |
// Called to setup the options menu with the dialog is active.
|
|
106 |
// -----------------------------------------------------------------------------
|
|
107 |
//
|
|
108 |
void CFeedsEditFolderDialog::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane)
|
|
109 |
{
|
|
110 |
CAknForm::DynInitMenuPaneL(aResourceId, aMenuPane);
|
|
111 |
|
|
112 |
if (aResourceId == R_AVKON_FORM_MENUPANE)
|
|
113 |
{
|
|
114 |
aMenuPane->SetItemDimmed(EAknFormCmdLabel, ETrue);
|
|
115 |
aMenuPane->SetItemDimmed(EAknFormCmdAdd, ETrue);
|
|
116 |
aMenuPane->SetItemDimmed(EAknFormCmdDelete, ETrue);
|
|
117 |
|
|
118 |
aMenuPane->AddMenuItemsL(R_FEEDS_HELP_EXIT_FEED_MENU);
|
|
119 |
}
|
|
120 |
}
|
|
121 |
|
|
122 |
|
|
123 |
// -----------------------------------------------------------------------------
|
|
124 |
// CFeedsEditFolderDialog::SaveFormDataL
|
|
125 |
//
|
|
126 |
// Called by the framework whenver the 'Save' menu item is selected.
|
|
127 |
// -----------------------------------------------------------------------------
|
|
128 |
//
|
|
129 |
TBool CFeedsEditFolderDialog::SaveFormDataL()
|
|
130 |
{
|
|
131 |
CEikEdwin* textEditor;
|
|
132 |
HBufC* name = NULL;
|
|
133 |
TBool valid = EFalse;
|
|
134 |
|
|
135 |
// Extract the new name.
|
|
136 |
textEditor = static_cast<CEikEdwin*>(ControlOrNull(EFeedsEditDialogNameId));
|
|
137 |
name = textEditor->GetTextInHBufL();
|
|
138 |
CleanupStack::PushL(name);
|
|
139 |
|
|
140 |
// Notify the observer.
|
|
141 |
valid = iObserver.IsFolderNameValidL(name, !iIsNewFolder);
|
|
142 |
|
|
143 |
// If invalid force the user to reentry it.
|
|
144 |
if (!valid)
|
|
145 |
{
|
|
146 |
// Focus and select the name field.
|
|
147 |
textEditor = static_cast<CEikEdwin*>(ControlOrNull(EFeedsEditDialogNameId));
|
|
148 |
|
|
149 |
textEditor->SetFocus(ETrue);
|
|
150 |
textEditor->SelectAllL();
|
|
151 |
|
|
152 |
iExitDialog = EFalse;
|
|
153 |
}
|
|
154 |
|
|
155 |
// Otherwise pass the new values to the observer.
|
|
156 |
else
|
|
157 |
{
|
|
158 |
if (iIsNewFolder)
|
|
159 |
{
|
|
160 |
iObserver.NewFolderL(*name);
|
|
161 |
}
|
|
162 |
else
|
|
163 |
{
|
|
164 |
iObserver.UpdateFolderL(*name);
|
|
165 |
}
|
|
166 |
|
|
167 |
iExitDialog = ETrue;
|
|
168 |
}
|
|
169 |
|
|
170 |
// Clean up.
|
|
171 |
CleanupStack::PopAndDestroy(name);
|
|
172 |
|
|
173 |
return valid;
|
|
174 |
}
|
|
175 |
|
|
176 |
|
|
177 |
// -----------------------------------------------------------------------------
|
|
178 |
// CFeedsEditFolderDialog::PreLayoutDynInitL
|
|
179 |
//
|
|
180 |
// Called by the framework before the form is initialised.
|
|
181 |
// -----------------------------------------------------------------------------
|
|
182 |
//
|
|
183 |
void CFeedsEditFolderDialog::PreLayoutDynInitL()
|
|
184 |
{
|
|
185 |
CEikEdwin* textEditor = NULL;
|
|
186 |
|
|
187 |
CAknForm::PreLayoutDynInitL();
|
|
188 |
|
|
189 |
// Get the name field
|
|
190 |
textEditor = static_cast<CEikEdwin*>(ControlOrNull(EFeedsEditDialogNameId));
|
|
191 |
|
|
192 |
// If the name was set then set it.
|
|
193 |
if (iName.Length() > 0)
|
|
194 |
{
|
|
195 |
textEditor->SetTextL(&iName);
|
|
196 |
}
|
|
197 |
|
|
198 |
// Otherwise use the default name.
|
|
199 |
else
|
|
200 |
{
|
|
201 |
HBufC* text = NULL;
|
|
202 |
|
|
203 |
// Load the label
|
|
204 |
text = CCoeEnv::Static()->AllocReadResourceAsDes16L(R_FEEDS_NEW_FOLDER_ITEM);
|
|
205 |
CleanupStack::PushL(text);
|
|
206 |
|
|
207 |
textEditor->SetTextL(text);
|
|
208 |
SetFormFlag(EUnsavedEdit, ETrue);
|
|
209 |
|
|
210 |
CleanupStack::PopAndDestroy(text);
|
|
211 |
}
|
|
212 |
}
|
|
213 |
|
|
214 |
|
|
215 |
// -----------------------------------------------------------------------------
|
|
216 |
// CFeedsEditFolderDialog::ProcessCommandL
|
|
217 |
//
|
|
218 |
// Called by the framework to process the options menu.
|
|
219 |
// -----------------------------------------------------------------------------
|
|
220 |
//
|
|
221 |
void CFeedsEditFolderDialog::ProcessCommandL(TInt aCommandId)
|
|
222 |
{
|
|
223 |
switch (aCommandId)
|
|
224 |
{
|
|
225 |
case EAknCmdExit:
|
|
226 |
{
|
|
227 |
// Custom added commands. Forward to view.
|
|
228 |
// Note that we respond to EAknCmdExit, not CEikCmdExit; it's
|
|
229 |
// because we don't get it through the AppUi framework (instead,
|
|
230 |
// we forward it there now).
|
|
231 |
CBrowserAppUi::Static()->ActiveView()->ProcessCommandL( aCommandId );
|
|
232 |
break;
|
|
233 |
}
|
|
234 |
|
|
235 |
case EEikCmdExit:
|
|
236 |
break;
|
|
237 |
|
|
238 |
#ifdef __SERIES60_HELP
|
|
239 |
case EAknCmdHelp:
|
|
240 |
HlpLauncher::LaunchHelpApplicationL(iEikonEnv->WsSession(),
|
|
241 |
iAppUi->AppHelpContextL());
|
|
242 |
|
|
243 |
break;
|
|
244 |
#endif //__SERIES60_HELP
|
|
245 |
case EWmlCmdAboutProduct:
|
|
246 |
{
|
|
247 |
iAppUi->HandleCommandL( aCommandId );
|
|
248 |
break;
|
|
249 |
}
|
|
250 |
default:
|
|
251 |
// Standard form commands.
|
|
252 |
CAknForm::ProcessCommandL(aCommandId);
|
|
253 |
|
|
254 |
if (iExitDialog)
|
|
255 |
{
|
|
256 |
TryExitL(EAknSoftkeyBack);
|
|
257 |
}
|
|
258 |
break;
|
|
259 |
}
|
|
260 |
}
|