|
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: Command setting inline methods. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <cvtlogger.h> |
|
20 |
|
21 #include "cvtuicommandmodifybase.h" |
|
22 |
|
23 // ======== LOCAL FUNCTIONS ======== |
|
24 |
|
25 static const TInt KVtUiModifierArrayGranularity = 1; |
|
26 |
|
27 // --------------------------------------------------------------------------- |
|
28 // CVtUiCommandSetting< A >::~CVtUiCommandSetting |
|
29 // --------------------------------------------------------------------------- |
|
30 // |
|
31 template < typename A > |
|
32 CVtUiCommandSetting< A >::~CVtUiCommandSetting() |
|
33 { |
|
34 iModifiers.Reset(); |
|
35 } |
|
36 |
|
37 // --------------------------------------------------------------------------- |
|
38 // CVtUiCommandSetting< A >::CVtUiCommandSetting |
|
39 // --------------------------------------------------------------------------- |
|
40 // |
|
41 template < typename A > |
|
42 CVtUiCommandSetting< A >::CVtUiCommandSetting( Type aCommandType ) : |
|
43 iModifiers( KVtUiModifierArrayGranularity ), iCommandType( aCommandType ) |
|
44 { |
|
45 } |
|
46 |
|
47 // --------------------------------------------------------------------------- |
|
48 // CVtUiCommandSetting< A >::DefineCommandsL |
|
49 // --------------------------------------------------------------------------- |
|
50 // |
|
51 template < typename A > |
|
52 void CVtUiCommandSetting< A >::DefineCommandsL( const A& aAction ) |
|
53 { |
|
54 __VTPRINTENTER( "CmdSet< A >.DefineCommandsL" ) |
|
55 iAction = &aAction; |
|
56 if ( iModifiers.Count() > 0 ) |
|
57 { |
|
58 iModifiers[ iModifiers.Count() - 1 ]->ModifyCommandsL( *this ); |
|
59 } |
|
60 else |
|
61 { |
|
62 DoDefineCommandsL(); |
|
63 } |
|
64 iAction = NULL; |
|
65 __VTPRINTEXIT( "CmdSet< A >.DefineCommandsL" ) |
|
66 } |
|
67 |
|
68 // --------------------------------------------------------------------------- |
|
69 // CVtUiCommandSetting< A >::AddModifier |
|
70 // --------------------------------------------------------------------------- |
|
71 // |
|
72 template < typename A > |
|
73 TInt CVtUiCommandSetting< A >::AddModifier( |
|
74 CVtUiCommandModifyBase& aModifier ) |
|
75 { |
|
76 __VTPRINTENTER( "CmdSet< A >.AddModifier" ) |
|
77 TInt result( KErrNone ); |
|
78 if ( aModifier.Supports( iCommandType ) ) |
|
79 { |
|
80 TInt idx( iModifiers.FindInOrder( &aModifier, |
|
81 CVtUiCommandModifyBase::PriorityOrder() ) ); |
|
82 if ( idx == KErrNotFound ) |
|
83 { |
|
84 result = iModifiers.InsertInOrder( &aModifier, |
|
85 CVtUiCommandModifyBase::PriorityOrder() ); |
|
86 } |
|
87 else |
|
88 { |
|
89 if ( iModifiers[ idx ] != &aModifier ) |
|
90 { |
|
91 // Priorities match, but instance is not same -> argument |
|
92 // is not valid |
|
93 result = KErrArgument; |
|
94 } |
|
95 } |
|
96 } |
|
97 __VTPRINTEXITR( "CmdSet< A >.AddModifier %d", result ) |
|
98 return result; |
|
99 } |
|
100 |
|
101 // --------------------------------------------------------------------------- |
|
102 // CVtUiCommandSetting< A >::RemoveModifier |
|
103 // --------------------------------------------------------------------------- |
|
104 // |
|
105 template < typename A > |
|
106 void CVtUiCommandSetting< A >::RemoveModifier( |
|
107 CVtUiCommandModifyBase& aModifier ) |
|
108 { |
|
109 __VTPRINTENTER( "CmdSet< A >.RemoveModifier" ) |
|
110 TInt idx( iModifiers.FindInOrder( &aModifier, |
|
111 CVtUiCommandModifyBase::PriorityOrder() ) ); |
|
112 |
|
113 if ( idx != KErrNotFound ) |
|
114 { |
|
115 iModifiers.Remove( idx ); |
|
116 } |
|
117 __VTPRINTEXIT( "CmdSet< A >.RemoveModifier" ) |
|
118 } |
|
119 |
|
120 // --------------------------------------------------------------------------- |
|
121 // CVtUiCommandSetting< A >::CommandType |
|
122 // --------------------------------------------------------------------------- |
|
123 // |
|
124 template < typename A > |
|
125 MVtUiCommandSetting::Type CVtUiCommandSetting< A >::CommandType() const |
|
126 { |
|
127 return iCommandType; |
|
128 } |
|
129 |
|
130 // --------------------------------------------------------------------------- |
|
131 // CVtUiCommandSetting< A >::Action |
|
132 // --------------------------------------------------------------------------- |
|
133 // |
|
134 template < typename A > |
|
135 const A& CVtUiCommandSetting< A >::Action() |
|
136 { |
|
137 return *iAction; |
|
138 } |
|
139 |