|
1 /* |
|
2 * Copyright (c) 2006 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: Listbox array for common container |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <mpxmedia.h> |
|
21 #include <mpxmediacontainerdefs.h> |
|
22 #include <mpxmediaarray.h> |
|
23 #include <mpxlog.h> |
|
24 |
|
25 #include <mpxcollectionpath.h> // TMPXItemId |
|
26 #include <mpxmediageneraldefs.h> |
|
27 |
|
28 #include "mpxcommonlistboxarrayobserver.h" |
|
29 #include "mpxcommonlistboxarraybase.h" |
|
30 |
|
31 // CONSTANTS |
|
32 const TInt KMPXMaxStringSize = 300; |
|
33 |
|
34 |
|
35 // ============================ MEMBER FUNCTIONS =============================== |
|
36 |
|
37 // ----------------------------------------------------------------------------- |
|
38 // CMPXCommonListBoxArrayBase::CMPXCommonListBoxArrayBase |
|
39 // C++ default constructor can NOT contain any code, that |
|
40 // might leave. |
|
41 // ----------------------------------------------------------------------------- |
|
42 // |
|
43 EXPORT_C CMPXCommonListBoxArrayBase::CMPXCommonListBoxArrayBase() : |
|
44 iPbState( EPbStateNotInitialised ), |
|
45 iIndex( KErrNotFound ) |
|
46 { |
|
47 } |
|
48 |
|
49 // ----------------------------------------------------------------------------- |
|
50 // Destructor. |
|
51 // ----------------------------------------------------------------------------- |
|
52 // |
|
53 EXPORT_C CMPXCommonListBoxArrayBase::~CMPXCommonListBoxArrayBase() |
|
54 { |
|
55 MPX_DEBUG1( "CMPXCommonListBoxArrayBase::~CMPXCommonListBoxArrayBase START" ); |
|
56 delete iItem; |
|
57 delete iContainerMedia; |
|
58 MPX_DEBUG1( "CMPXCommonListBoxArrayBase::~CMPXCommonListBoxArrayBase END" ); |
|
59 } |
|
60 |
|
61 // ----------------------------------------------------------------------------- |
|
62 // CMPXCommonListBoxArrayBase::ConstructListBoxArrayL |
|
63 // Construct the array |
|
64 // ----------------------------------------------------------------------------- |
|
65 // |
|
66 EXPORT_C void CMPXCommonListBoxArrayBase::ConstructListBoxArrayL() |
|
67 { |
|
68 MPX_FUNC( "CMPXCommonListBoxArrayBase::ConstructListBoxArrayL" ); |
|
69 delete iItem; |
|
70 iItem = NULL; |
|
71 iItem = HBufC::NewL( KMPXMaxStringSize ); |
|
72 } |
|
73 |
|
74 // ----------------------------------------------------------------------------- |
|
75 // CMPXCommonListBoxArrayBase::AppendMediaL |
|
76 // Appends media array to the current array |
|
77 // (other items were commented in a header). |
|
78 // ----------------------------------------------------------------------------- |
|
79 // |
|
80 EXPORT_C void CMPXCommonListBoxArrayBase::AppendMediaL( const CMPXMedia& aMedia ) |
|
81 { |
|
82 MPX_FUNC( "CMPXCommonListBoxArrayBase::AppendMediaL" ); |
|
83 delete iContainerMedia; |
|
84 iContainerMedia=NULL; |
|
85 iContainerMedia=CMPXMedia::NewL(aMedia); |
|
86 iMedia=const_cast<CMPXMediaArray*>(iContainerMedia->Value<CMPXMediaArray>( KMPXMediaArrayContents ) ); |
|
87 MPX_DEBUG2( "CMPXCommonListBoxArrayBase::AppendMediaL media count %d", iMedia->Count() ); |
|
88 } |
|
89 |
|
90 // ----------------------------------------------------------------------------- |
|
91 // CMPXCommonListBoxArrayBase::ResetMediaArray |
|
92 // Resets media array. |
|
93 // ----------------------------------------------------------------------------- |
|
94 // |
|
95 EXPORT_C void CMPXCommonListBoxArrayBase::ResetMediaArrayL() |
|
96 { |
|
97 MPX_FUNC( "CMPXCommonListBoxArrayBase::ResetMediaArray" ); |
|
98 delete iContainerMedia; |
|
99 iContainerMedia = NULL; |
|
100 iMedia = NULL; |
|
101 iIndex = KErrNotFound; |
|
102 iPbState = EPbStateNotInitialised; |
|
103 } |
|
104 |
|
105 // ----------------------------------------------------------------------------- |
|
106 // CMPXCommonListBoxArrayBase::MediaArray |
|
107 // Gets media array. |
|
108 // ----------------------------------------------------------------------------- |
|
109 // |
|
110 EXPORT_C const CMPXMediaArray& CMPXCommonListBoxArrayBase::MediaArray() |
|
111 { |
|
112 MPX_FUNC( "CMPXCommonListBoxArrayBase::MediaArray" ); |
|
113 ASSERT( iMedia ); |
|
114 return *iMedia; |
|
115 } |
|
116 |
|
117 // ----------------------------------------------------------------------------- |
|
118 // CMPXCommonListBoxArrayBase::MediaL |
|
119 // Get the media at index. |
|
120 // ----------------------------------------------------------------------------- |
|
121 // |
|
122 EXPORT_C const CMPXMedia& CMPXCommonListBoxArrayBase::MediaL( TInt aIndex ) |
|
123 { |
|
124 MPX_FUNC( "CMPXCommonListBoxArrayBase::MediaL" ); |
|
125 ASSERT( iMedia ); |
|
126 if ( ( iMedia->Count() < aIndex + 1 ) || ( aIndex < 0 ) ) |
|
127 { |
|
128 MPX_DEBUG3( "CMPXCommonListBoxArrayBase::MediaL KErrArgument aIndex = %d, iMedia->Count() = %d", aIndex, iMedia->Count() ); |
|
129 User::Leave( KErrArgument ); |
|
130 } |
|
131 return *( iMedia->AtL( aIndex ) ); |
|
132 } |
|
133 |
|
134 // ----------------------------------------------------------------------------- |
|
135 // CMPXCommonListBoxArrayBase::ContainerMedia |
|
136 // Get the container media. |
|
137 // ----------------------------------------------------------------------------- |
|
138 // |
|
139 EXPORT_C const CMPXMedia& CMPXCommonListBoxArrayBase::ContainerMedia() |
|
140 { |
|
141 MPX_FUNC( "CMPXCommonListBoxArrayBase::ContainerMedia" ); |
|
142 return *iContainerMedia; |
|
143 } |
|
144 |
|
145 // ----------------------------------------------------------------------------- |
|
146 // CMPXCommonListBoxArrayBase::SetObserver |
|
147 // Set observer |
|
148 // ----------------------------------------------------------------------------- |
|
149 // |
|
150 EXPORT_C void CMPXCommonListBoxArrayBase::SetObserver( |
|
151 MMPXCommonListBoxArrayObserver* aObserver) |
|
152 { |
|
153 MPX_FUNC( "CMPXCommonListBoxArrayBase::SetObserver" ); |
|
154 ASSERT( !iObserver ); |
|
155 iObserver = aObserver; |
|
156 } |
|
157 |
|
158 // ----------------------------------------------------------------------------- |
|
159 // CMPXCommonListBoxArrayBase::RemoveObserver |
|
160 // Remove observer |
|
161 // ----------------------------------------------------------------------------- |
|
162 // |
|
163 EXPORT_C void CMPXCommonListBoxArrayBase::RemoveObserver() |
|
164 { |
|
165 MPX_FUNC( "CMPXCommonListBoxArrayBase::RemoveObserver" ); |
|
166 iObserver = NULL; |
|
167 } |
|
168 |
|
169 // ----------------------------------------------------------------------------- |
|
170 // CMPXCommonListBoxArrayBase::CreateIconArrayL |
|
171 // creates icon array. |
|
172 // ----------------------------------------------------------------------------- |
|
173 // |
|
174 EXPORT_C CAknIconArray* CMPXCommonListBoxArrayBase::CreateIconArrayL() |
|
175 { |
|
176 MPX_FUNC( "CMPXCommonListBoxArrayBase::CreateIconArrayL" ); |
|
177 return NULL; |
|
178 } |
|
179 |
|
180 // ----------------------------------------------------------------------------- |
|
181 // CMPXCommonListBoxArrayBase::MdcaCount |
|
182 // Returns the number of descriptor elements in a descriptor. |
|
183 // (other items were commented in a header). |
|
184 // ----------------------------------------------------------------------------- |
|
185 // |
|
186 EXPORT_C TInt CMPXCommonListBoxArrayBase::MdcaCount() const |
|
187 { |
|
188 MPX_DEBUG2( "CMPXCommonListBoxArrayBase::MdcaCount count = %d", iMedia ? iMedia->Count() : 0 ); |
|
189 return ( iMedia ? iMedia->Count() : 0 ); |
|
190 } |
|
191 |
|
192 // End of File |