35
|
1 |
/*
|
|
2 |
* Copyright (c) 2006, 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: Show capabilities on the screen
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#include <StringLoader.h>
|
|
20 |
#include <eiklbx.h>
|
|
21 |
#include <aknradiobuttonsettingpage.h>
|
|
22 |
|
|
23 |
|
|
24 |
#include "imageprintui.hrh"
|
|
25 |
#include "settingsitems.h"
|
|
26 |
#include "settingstables.h"
|
|
27 |
#include "imageprintuidebug.h"
|
|
28 |
#include "capabilitymanager.h"
|
|
29 |
#include "notes.h"
|
|
30 |
|
|
31 |
// ---------------------------------------------------------------------------
|
|
32 |
//
|
|
33 |
// ---------------------------------------------------------------------------
|
|
34 |
//
|
|
35 |
CSettingsItems* CSettingsItems::NewL(
|
|
36 |
CCapabilityManager* aManager, CNotes* aNotes )
|
|
37 |
{
|
|
38 |
CSettingsItems* self =
|
|
39 |
CSettingsItems::NewLC( aManager, aNotes );
|
|
40 |
CleanupStack::Pop( self );
|
|
41 |
return self;
|
|
42 |
}
|
|
43 |
|
|
44 |
// ---------------------------------------------------------------------------
|
|
45 |
//
|
|
46 |
// ---------------------------------------------------------------------------
|
|
47 |
//
|
|
48 |
CSettingsItems* CSettingsItems::NewLC(
|
|
49 |
CCapabilityManager* aManager, CNotes* aNotes
|
|
50 |
)
|
|
51 |
{
|
|
52 |
CSettingsItems* self =
|
|
53 |
new ( ELeave ) CSettingsItems( aManager, aNotes );
|
|
54 |
CleanupStack::PushL( self );
|
|
55 |
self->ConstructL();
|
|
56 |
return self;
|
|
57 |
}
|
|
58 |
|
|
59 |
// ---------------------------------------------------------------------------
|
|
60 |
//
|
|
61 |
// ---------------------------------------------------------------------------
|
|
62 |
//
|
|
63 |
CSettingsItems::CSettingsItems(
|
|
64 |
CCapabilityManager* aManager, CNotes* aNotes):
|
|
65 |
iCapabilityManager( aManager ), iNotes( aNotes)
|
|
66 |
{
|
|
67 |
}
|
|
68 |
|
|
69 |
// ---------------------------------------------------------------------------
|
|
70 |
//
|
|
71 |
// ---------------------------------------------------------------------------
|
|
72 |
//
|
|
73 |
CSettingsItems::~CSettingsItems()
|
|
74 |
{
|
|
75 |
delete iBuffer;
|
|
76 |
delete iLayout;
|
|
77 |
delete iPaperSize;
|
|
78 |
delete iQuality;
|
|
79 |
}
|
|
80 |
|
|
81 |
// ---------------------------------------------------------------------------
|
|
82 |
//
|
|
83 |
// ---------------------------------------------------------------------------
|
|
84 |
//
|
|
85 |
void CSettingsItems::ConstructL()
|
|
86 |
{
|
|
87 |
iBuffer = HBufC::NewL(KSettingsMaxSize);
|
|
88 |
iLayout = StringLoader::LoadL(R_USB_PRINT_LAYOUT);
|
|
89 |
iPaperSize = StringLoader::LoadL(R_USB_PRINT_PAPER_SIZE);
|
|
90 |
iQuality = StringLoader::LoadL(R_USB_PRINT_QUALITY);
|
|
91 |
}
|
|
92 |
|
|
93 |
// ---------------------------------------------------------------------------
|
|
94 |
// From class MDesCArray.
|
|
95 |
// Return number of items in listbox
|
|
96 |
// ----------------------------------------------------------------------------
|
|
97 |
//
|
|
98 |
TInt CSettingsItems::MdcaCount() const
|
|
99 |
{
|
|
100 |
return KNumberOfSettingsViewItems;
|
|
101 |
}
|
|
102 |
|
|
103 |
// ---------------------------------------------------------------------------
|
|
104 |
// Creates the text string for the list box item and returns it
|
|
105 |
// ----------------------------------------------------------------------------
|
|
106 |
//
|
|
107 |
TPtrC CSettingsItems::MdcaPointL(
|
|
108 |
TInt aIndex ) const
|
|
109 |
{
|
|
110 |
FLOG(_L("[IMAGEPRINTUI]\t CSettingsItems::MdcaPoint"));
|
|
111 |
_LIT(KImagePrintUiEmptyFormatString, " \t \t\t ");
|
|
112 |
TPtr ptr = iBuffer->Des();
|
|
113 |
ptr.Zero();
|
|
114 |
HBufC* temp;
|
|
115 |
ptr.Append(KTab);
|
|
116 |
switch ( aIndex )
|
|
117 |
{
|
|
118 |
case ESettingsListItemLayout:
|
|
119 |
temp = StringLoader::LoadLC( R_USB_PRINT_LAYOUT );
|
|
120 |
ptr.Append(temp->Des());
|
|
121 |
CleanupStack::PopAndDestroy(temp);
|
|
122 |
GetCurrentStringL( EDpsArgLayouts, KLayoutTable, KLayoutTableCount );
|
|
123 |
break;
|
|
124 |
|
|
125 |
case ESettingsListItemPaperSize:
|
|
126 |
temp = StringLoader::LoadLC( R_USB_PRINT_PAPER_SIZE );
|
|
127 |
ptr.Append(temp->Des());
|
|
128 |
CleanupStack::PopAndDestroy(temp);
|
|
129 |
GetCurrentStringL( EDpsArgPaperSizes, KPaperSizeTable, KPaperSizeTableCount );
|
|
130 |
break;
|
|
131 |
|
|
132 |
case ESettingsListItemPrintQuality:
|
|
133 |
temp = StringLoader::LoadLC( R_USB_PRINT_QUALITY );
|
|
134 |
ptr.Append(temp->Des());
|
|
135 |
CleanupStack::PopAndDestroy(temp);
|
|
136 |
GetCurrentStringL( EDpsArgQualities, KQualityTable, KQualityTableCount );
|
|
137 |
break;
|
|
138 |
|
|
139 |
default:
|
|
140 |
ptr.Append(KImagePrintUiEmptyFormatString);
|
|
141 |
break;
|
|
142 |
}
|
|
143 |
FLOG(_L("[IMAGEPRINTUI]\t CSettingsItems::MdcaPoint complete"));
|
|
144 |
|
|
145 |
return iBuffer->Des();
|
|
146 |
}
|
|
147 |
|
|
148 |
// ---------------------------------------------------------------------------
|
|
149 |
// Creates the text string for the list box item and returns it
|
|
150 |
// ----------------------------------------------------------------------------
|
|
151 |
//
|
|
152 |
TPtrC CSettingsItems::MdcaPoint(
|
|
153 |
TInt aIndex ) const
|
|
154 |
{
|
|
155 |
FLOG(_L("[IMAGEPRINTUI]\t CSettingsItems::MdcaPoint"));
|
|
156 |
|
|
157 |
TRAPD(err, *iBuffer = MdcaPointL(aIndex));
|
|
158 |
if(err)
|
|
159 |
{
|
|
160 |
FLOG(_L("[IMAGEPRINTUI]\t CSettingsItems::MdcaPointL error"));
|
|
161 |
}
|
|
162 |
else
|
|
163 |
{
|
|
164 |
FLOG(_L("[IMAGEPRINTUI]\t CSettingsItems::MdcaPointL no error"));
|
|
165 |
}
|
|
166 |
return iBuffer->Des();
|
|
167 |
}
|
|
168 |
|
|
169 |
|
|
170 |
// ---------------------------------------------------------------------------
|
|
171 |
// Creates the text string for the list box item and returns it
|
|
172 |
// ----------------------------------------------------------------------------
|
|
173 |
//
|
|
174 |
|
|
175 |
void CSettingsItems::GetCurrentStringL( TInt aCapability,
|
|
176 |
const TConversionTable* aTable, const TInt aTableSize ) const
|
|
177 |
{
|
|
178 |
FLOG(_L("[IMAGEPRINTUI]\t CSettingsItems::GetCurrentStringL START"));
|
|
179 |
TPtr ptr = iBuffer->Des();
|
|
180 |
ptr.Append(KTab);
|
|
181 |
ptr.Append(KTab);
|
|
182 |
|
|
183 |
TInt value = iCapabilityManager->CurrentPrintSettings( aCapability );
|
|
184 |
|
|
185 |
HBufC* temp;
|
|
186 |
for ( TInt i = 0; i < aTableSize; i++ )
|
|
187 |
{
|
|
188 |
if ( value == aTable[i].iCapabilityID )
|
|
189 |
{
|
|
190 |
temp = StringLoader::LoadLC( aTable[i].iResourceID );
|
|
191 |
ptr.Append(temp->Des());
|
|
192 |
CleanupStack::PopAndDestroy(temp);
|
|
193 |
break;
|
|
194 |
}
|
|
195 |
}
|
|
196 |
FLOG(_L("[IMAGEPRINTUI]\t CSettingsItems::GetCurrentString END"));
|
|
197 |
|
|
198 |
}
|
|
199 |
|
|
200 |
// ---------------------------------------------------------------------------
|
|
201 |
// From class MEikListBoxObserver.
|
|
202 |
// Handles the list box (enter) events by launching the pop-up list
|
|
203 |
// ----------------------------------------------------------------------------
|
|
204 |
//
|
|
205 |
void CSettingsItems::HandleListBoxEventL(
|
|
206 |
CEikListBox* aListBox,
|
|
207 |
TListBoxEvent aEventType )
|
|
208 |
{
|
|
209 |
if (( aEventType == EEventEnterKeyPressed ) ||
|
|
210 |
( aEventType == EEventItemDoubleClicked )) //for touch support
|
|
211 |
{
|
|
212 |
switch( aListBox->CurrentItemIndex() )
|
|
213 |
{
|
|
214 |
case ESettingsListItemLayout:
|
|
215 |
HandleEvent(EDpsArgLayouts, KLayoutTable,
|
|
216 |
KLayoutTableCount, iLayout);
|
|
217 |
break;
|
|
218 |
case ESettingsListItemPaperSize:
|
|
219 |
HandleEvent(EDpsArgPaperSizes, KPaperSizeTable,
|
|
220 |
KPaperSizeTableCount, iPaperSize);
|
|
221 |
break;
|
|
222 |
case ESettingsListItemPrintQuality:
|
|
223 |
HandleEvent(EDpsArgQualities, KQualityTable,
|
|
224 |
KQualityTableCount, iQuality);
|
|
225 |
break;
|
|
226 |
default:
|
|
227 |
FLOG(_L("[IMAGEPRINTUI]\t CSettingsItems::HandleListBoxEventL default switch"));
|
|
228 |
break;
|
|
229 |
}
|
|
230 |
|
|
231 |
// Redraw item to the screen
|
|
232 |
//
|
|
233 |
aListBox->DrawItem( aListBox->CurrentItemIndex() );
|
|
234 |
|
|
235 |
}
|
|
236 |
}
|
|
237 |
|
|
238 |
|
|
239 |
// ---------------------------------------------------------------------------
|
|
240 |
//
|
|
241 |
// ----------------------------------------------------------------------------
|
|
242 |
//
|
|
243 |
void CSettingsItems::HandleEventL(TInt aCapability,
|
|
244 |
const TConversionTable* aTable, const TInt aTableSize, const HBufC* aTitle )
|
|
245 |
{
|
|
246 |
HBufC* item;
|
|
247 |
FLOG(_L("[IMAGEPRINTUI]\t CSettingsItems::HandleEvent START"));
|
|
248 |
RArray<TUint> capabilityArray = iCapabilityManager->GetCapabilities(aCapability);
|
|
249 |
TInt currentItemIndex(0);
|
|
250 |
CDesCArrayFlat* items = new ( ELeave ) CDesCArrayFlat( KDefaultArrayValue );
|
|
251 |
CleanupStack::PushL(items);
|
|
252 |
TInt j(0);
|
|
253 |
TInt helpValue(0);
|
|
254 |
TInt currentItem = iCapabilityManager->CurrentPrintSettings(aCapability);
|
|
255 |
|
|
256 |
for(TInt i= 0; i < capabilityArray.Count(); i++ )
|
|
257 |
{
|
|
258 |
if ( capabilityArray[i] == currentItem )
|
|
259 |
{
|
|
260 |
currentItemIndex = i;
|
|
261 |
}
|
|
262 |
for (j=0; j< aTableSize; j++ )
|
|
263 |
{
|
|
264 |
if ( capabilityArray[i] == aTable[j].iCapabilityID)
|
|
265 |
{
|
|
266 |
helpValue++;
|
|
267 |
item = StringLoader::LoadL(aTable[j].iResourceID);
|
|
268 |
CleanupStack::PushL(item);
|
|
269 |
items->AppendL(*item);
|
|
270 |
CleanupStack::PopAndDestroy(item);
|
|
271 |
break;
|
|
272 |
}
|
|
273 |
}
|
|
274 |
}
|
|
275 |
FTRACE(FPrint(_L("[IMAGEPRINTUI] CSettingsItems::HandleEventL helpValue is %x"), helpValue ));
|
|
276 |
// Show the setting page
|
|
277 |
|
|
278 |
CAknRadioButtonSettingPage* dlg =
|
|
279 |
new ( ELeave ) CAknRadioButtonSettingPage(
|
|
280 |
R_USB_PRINT_MODE_SETTING_PAGE, currentItemIndex, items );
|
|
281 |
CleanupStack::PushL(dlg);
|
|
282 |
dlg->SetSettingTextL(*aTitle);
|
|
283 |
CleanupStack::Pop(dlg);
|
|
284 |
|
|
285 |
if ( dlg->ExecuteLD( CAknSettingPage::EUpdateWhenChanged ) )
|
|
286 |
{
|
|
287 |
// User has made the selection. Now we need to save it to
|
|
288 |
// capabilityManager
|
|
289 |
iCapabilityManager->SetValue( aCapability, capabilityArray[currentItemIndex]);
|
|
290 |
}
|
|
291 |
CleanupStack::PopAndDestroy(items);
|
|
292 |
FLOG(_L("[IMAGEPRINTUI]\t CSettingsItems::HandleEvent END"));
|
|
293 |
}
|
|
294 |
|
|
295 |
|
|
296 |
// ---------------------------------------------------------------------------
|
|
297 |
//
|
|
298 |
// ---------------------------------------------------------------------------
|
|
299 |
//
|
|
300 |
void CSettingsItems::HandleEvent(TInt aCapability,
|
|
301 |
const TConversionTable* aTable, const TInt aTableSize, const HBufC* aTitle )
|
|
302 |
{
|
|
303 |
|
|
304 |
TRAPD(err, HandleEventL(aCapability, aTable, aTableSize, aTitle));
|
|
305 |
if(err)
|
|
306 |
{
|
|
307 |
FLOG(_L("[IMAGEPRINTUI]\t CSettingsItems::error in HandleEvenL"));
|
|
308 |
}
|
|
309 |
else
|
|
310 |
{
|
|
311 |
FLOG(_L("[IMAGEPRINTUI]\t CSettingsItems::HandleEvent successfull"));
|
|
312 |
}
|
|
313 |
FLOG(_L("[IMAGEPRINTUI]\t CSettingsItems::HandleEvent END"));
|
|
314 |
}
|
|
315 |
|
|
316 |
// end of file
|