|
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: Implement of class CTruiShortcutEditView |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <aknViewAppUi.h> |
|
20 #include <trui.rsg> |
|
21 #include <eikmenup.h> |
|
22 #include <eikbtgpc.h> |
|
23 #include <avkon.rsg> |
|
24 #include <akntoolbar.h> |
|
25 |
|
26 #include "truishortcuteditview.h" |
|
27 #include "truishortcuteditcontainer.h" |
|
28 #include "truiappui.h" |
|
29 #include "trui.hrh" |
|
30 #include "truishortcutsview.h" |
|
31 #include "truiapplication.h" |
|
32 #include "truiengine.h" |
|
33 #include "truishortcutedittextview.h" |
|
34 |
|
35 _LIT( KSeperatorBetweenTitle, " " ); |
|
36 |
|
37 // ======== MEMBER FUNCTIONS ======== |
|
38 |
|
39 CTruiShortcutEditView::CTruiShortcutEditView() |
|
40 { |
|
41 } |
|
42 |
|
43 void CTruiShortcutEditView::ConstructL() |
|
44 { |
|
45 BaseConstructL( R_TRUI_SHORTCUTEDITVIEW ); |
|
46 } |
|
47 |
|
48 CTruiShortcutEditView* CTruiShortcutEditView::NewL() |
|
49 { |
|
50 CTruiShortcutEditView* self = CTruiShortcutEditView::NewLC(); |
|
51 CleanupStack::Pop( self ); |
|
52 return self; |
|
53 } |
|
54 |
|
55 CTruiShortcutEditView* CTruiShortcutEditView::NewLC() |
|
56 { |
|
57 CTruiShortcutEditView* self = new( ELeave ) CTruiShortcutEditView; |
|
58 CleanupStack::PushL( self ); |
|
59 self->ConstructL(); |
|
60 return self; |
|
61 } |
|
62 |
|
63 CTruiShortcutEditView::~CTruiShortcutEditView() |
|
64 { |
|
65 } |
|
66 |
|
67 // --------------------------------------------------------------------------- |
|
68 // From class CAknView. |
|
69 // Returns views id. |
|
70 // --------------------------------------------------------------------------- |
|
71 // |
|
72 TUid CTruiShortcutEditView::Id() const |
|
73 { |
|
74 return KTruiShortcutEditViewId; |
|
75 } |
|
76 |
|
77 // --------------------------------------------------------------------------- |
|
78 // From class CAknView. |
|
79 // Command handling function. |
|
80 // --------------------------------------------------------------------------- |
|
81 // |
|
82 void CTruiShortcutEditView::HandleCommandL( TInt aCommand ) |
|
83 { |
|
84 switch ( aCommand ) |
|
85 { |
|
86 case EAknSoftkeyDone: |
|
87 { |
|
88 if ( iContainer->PrepareToExitL() ) |
|
89 { |
|
90 iContainer->SwitchToShortcutViewL(); |
|
91 } |
|
92 break; |
|
93 } |
|
94 case EAknSoftkeyBack: |
|
95 { |
|
96 iContainer->BackToPreviousViewL(); |
|
97 break; |
|
98 } |
|
99 } |
|
100 } |
|
101 |
|
102 |
|
103 // --------------------------------------------------------------------------- |
|
104 // From class CAknView. |
|
105 // Carried out when View is activated |
|
106 // --------------------------------------------------------------------------- |
|
107 // |
|
108 void CTruiShortcutEditView::DoActivateL( const TVwsViewId& aPrevViewId, |
|
109 TUid /*aCustomMessageId*/, |
|
110 const TDesC8& /*aCustomMessage*/ ) |
|
111 { |
|
112 iPreViewId = aPrevViewId; |
|
113 CTruiAppUi* appui = static_cast<CTruiAppUi*>( AppUi() ); |
|
114 CEikButtonGroupContainer* cba = Cba(); |
|
115 // Set title pane and SK1's text |
|
116 if ( aPrevViewId == TVwsViewId( KUidtruiApp, KTruiShortcutsViewId ) ) |
|
117 { |
|
118 appui->ShowTitlePaneL( appui->HwrEngine()->Shortcut() ); |
|
119 cba->SetCommandSetL( R_AVKON_SOFTKEYS_DONE_BACK ); |
|
120 } |
|
121 else if ( aPrevViewId == TVwsViewId( KUidtruiApp, KTruiShortcutEditTextViewId ) ) |
|
122 { |
|
123 HBufC* numberText = iEikonEnv->AllocReadResourceLC |
|
124 ( R_TRUI_SHORTCUTEDITTEXTVIEW_TITLEPANE_LAST_NUMBER ); |
|
125 HBufC* title = HBufC::NewLC( appui->HwrEngine()->Shortcut().Length() |
|
126 + numberText->Length() + KExtraSize ); |
|
127 TPtr titlePtr = title->Des(); |
|
128 titlePtr.Copy( *numberText ); |
|
129 titlePtr.Append( KSeperatorBetweenTitle ); |
|
130 titlePtr.Append( appui->HwrEngine()->Shortcut() ); |
|
131 appui->ShowTitlePaneL( *title ); |
|
132 CleanupStack::PopAndDestroy( title ); |
|
133 CleanupStack::PopAndDestroy( numberText ); |
|
134 cba->SetCommandSetL( R_TRUI_SHORTCUTEDITVIEW_CREATE_CBA ); |
|
135 } |
|
136 |
|
137 // Close navi pane |
|
138 appui->CloseNaviPaneL(); |
|
139 |
|
140 iContainer = CTruiShortcutEditContainer::NewL( ClientRect() ); |
|
141 iContainer->SetMopParent( this ); |
|
142 AppUi()->AddToStackL( *this, iContainer ); |
|
143 iContainer->SetView( this ); |
|
144 |
|
145 // Set toolbar |
|
146 CAknToolbar* toolbar = Toolbar(); |
|
147 if ( toolbar ) |
|
148 { |
|
149 toolbar->SetToolbarObserver( this ); |
|
150 toolbar->SetToolbarVisibility( ETrue, EFalse ); |
|
151 } |
|
152 } |
|
153 |
|
154 // --------------------------------------------------------------------------- |
|
155 // From class CAknView. |
|
156 // Carried out when View is deactivated |
|
157 // --------------------------------------------------------------------------- |
|
158 // |
|
159 void CTruiShortcutEditView::DoDeactivate() |
|
160 { |
|
161 if ( iContainer ) |
|
162 { |
|
163 AppUi()->RemoveFromStack( iContainer ); |
|
164 delete iContainer; |
|
165 iContainer = NULL; |
|
166 } |
|
167 } |
|
168 |
|
169 // --------------------------------------------------------------------------- |
|
170 // From class MAknToolbarObserver. |
|
171 // Handles toolbar events for a certain toolbar item. |
|
172 // --------------------------------------------------------------------------- |
|
173 // |
|
174 void CTruiShortcutEditView::OfferToolbarEventL( TInt aCommand ) |
|
175 { |
|
176 switch ( aCommand ) |
|
177 { |
|
178 case EShortcutEditViewDelete: |
|
179 { |
|
180 iContainer->ClearCurrentModelL(); |
|
181 break; |
|
182 } |
|
183 case EShortcutEditViewPreviewModel: |
|
184 { |
|
185 iContainer->PreviewShortcutModel(); |
|
186 break; |
|
187 } |
|
188 case EShortcutEditViewGrid: |
|
189 { |
|
190 iContainer->PopupSctDialogL(); |
|
191 break; |
|
192 } |
|
193 } |
|
194 } |
|
195 |