|
1 /* |
|
2 * Copyright (c) 2002 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: |
|
15 * Implementation of TCommandVisibility. |
|
16 * |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include <eikmenup.h> |
|
23 #include "Browser.hrh" |
|
24 #include "CommandVisibility.h" |
|
25 #include "BrowserFavouritesSelectionState.h" |
|
26 #include "BrowserUtil.h" |
|
27 |
|
28 // ================= MEMBER FUNCTIONS ======================= |
|
29 |
|
30 // --------------------------------------------------------- |
|
31 // TCommandVisibility::Apply |
|
32 // --------------------------------------------------------- |
|
33 // |
|
34 void TCommandVisibility::Apply |
|
35 ( |
|
36 CEikMenuPane* aMenuPane, |
|
37 TCommandVisibilityMap aCommandInfo, |
|
38 TCommandVisibility::TIndex aIndex |
|
39 ) |
|
40 { |
|
41 // Dim commands using the command visibility array. |
|
42 TInt command; |
|
43 TInt i = 0; |
|
44 while ( ( command = aCommandInfo[i][ECommand] ) != |
|
45 /*end of list*/EWmlNoCmd ) |
|
46 { |
|
47 if ( !(aCommandInfo[i][aIndex]) ) |
|
48 { |
|
49 aMenuPane->SetItemDimmed( command, ETrue ); |
|
50 } |
|
51 i++; |
|
52 } |
|
53 } |
|
54 |
|
55 // --------------------------------------------------------- |
|
56 // TCommandVisibility::Apply |
|
57 // --------------------------------------------------------- |
|
58 // |
|
59 TBool TCommandVisibility::Apply |
|
60 ( |
|
61 const TCommandVisibilityInfo& aCommandInfo, |
|
62 TIndex aIndex |
|
63 ) |
|
64 { |
|
65 return aCommandInfo[aIndex]; |
|
66 } |
|
67 |
|
68 // --------------------------------------------------------- |
|
69 // TCommandVisibility::Index |
|
70 // --------------------------------------------------------- |
|
71 // |
|
72 TCommandVisibility::TIndex TCommandVisibility::Index |
|
73 ( |
|
74 const TBrowserFavouritesSelectionState& aSelectionState, |
|
75 TBool aMarkedOnly |
|
76 ) |
|
77 { |
|
78 TIndex index = EInvalid; |
|
79 |
|
80 if ( aMarkedOnly ) |
|
81 { |
|
82 // Consider only marked items (OK-Options menu). |
|
83 if ( aSelectionState.IsEmpty() ) |
|
84 { |
|
85 // Empty ??? |
|
86 index = ENothing; |
|
87 } |
|
88 else if ( aSelectionState.MarkedCount() == 1 ) |
|
89 { |
|
90 // One is marked. See if item or folder. |
|
91 index = aSelectionState.iMarkedItemCount ? EOneItem : EOneFolder; |
|
92 } |
|
93 else |
|
94 { |
|
95 // More is marked. See if there are any folders. |
|
96 index = aSelectionState.NoFoldersMarked() ? |
|
97 EMoreItems : EItemsFolders; |
|
98 } |
|
99 } |
|
100 else |
|
101 { |
|
102 // All items (Normal Options menu). |
|
103 if ( aSelectionState.AnyMarked() ) |
|
104 { |
|
105 if ( aSelectionState.NoFoldersMarked() ) |
|
106 { |
|
107 if ( aSelectionState.MarkedCount() == 1 ) |
|
108 { |
|
109 index = EOneItem; |
|
110 } |
|
111 else |
|
112 { |
|
113 index = EMoreItems; |
|
114 } |
|
115 } |
|
116 else |
|
117 { |
|
118 // More marked, including folders. |
|
119 index = EItemsFolders; |
|
120 } |
|
121 } |
|
122 else if ( aSelectionState.CurrentIsItem() ) |
|
123 { |
|
124 // A bookmark is highlighted. |
|
125 index = EOneItem; |
|
126 } |
|
127 else if ( aSelectionState.CurrentIsFolder() ) |
|
128 { |
|
129 // A folder is highlighted. |
|
130 index = EOneFolder; |
|
131 } |
|
132 else |
|
133 { |
|
134 __ASSERT_DEBUG( aSelectionState.IsEmpty(), \ |
|
135 Util::Panic( Util::EFavouritesInternal ) ); |
|
136 // No items at all. |
|
137 index = ENothing; |
|
138 } |
|
139 } |
|
140 |
|
141 __ASSERT_DEBUG( index != EInvalid, |
|
142 Util::Panic( Util::EUnExpected ) ); |
|
143 |
|
144 return index; |
|
145 } |
|
146 |
|
147 // End of File |