19
|
1 |
/*
|
|
2 |
* Copyright (c) 2010 Kanrikogaku Kenkyusho, Ltd.
|
|
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 |
* Kanrikogaku Kenkyusho, Ltd. - Initial contribution
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
* {Description of the file}
|
|
16 |
*
|
|
17 |
*/
|
|
18 |
|
|
19 |
// System include files
|
|
20 |
#include <stringloader.h>
|
|
21 |
#include <aknqueryvaluetext.h>
|
|
22 |
#include <aknpopupsettingpage.h>
|
|
23 |
#include <badesca.h>
|
|
24 |
#include <DirectPrintApp.rsg>
|
|
25 |
|
|
26 |
#include "directprintlistcapability.h"
|
|
27 |
#include "tprinter.h"
|
|
28 |
#include "directprintcapabilitycodes.h"
|
|
29 |
|
|
30 |
const TInt KArrayGranularity( 4 );
|
|
31 |
|
|
32 |
CDirectPrintListCapability::CDirectPrintListCapability()
|
|
33 |
{
|
|
34 |
}
|
|
35 |
|
|
36 |
// Destructor
|
|
37 |
CDirectPrintListCapability::~CDirectPrintListCapability()
|
|
38 |
{
|
|
39 |
iEnumIDs.Close();
|
|
40 |
iTexts.ResetAndDestroy();
|
|
41 |
}
|
|
42 |
|
|
43 |
// Creates text string for the settings list box
|
|
44 |
HBufC* CDirectPrintListCapability::ListBoxTextL()
|
|
45 |
{
|
|
46 |
CDesCArrayFlat* strings =
|
|
47 |
new ( ELeave ) CDesCArrayFlat( KArrayGranularity );
|
|
48 |
CleanupStack::PushL( strings );
|
|
49 |
strings->AppendL( iTitle );
|
|
50 |
|
|
51 |
TInt i( 0 );
|
|
52 |
TInt num( iEnumIDs.Count() );
|
|
53 |
TBool found( EFalse );
|
|
54 |
// Find the matching text based on the enumeration value
|
|
55 |
for ( i = 0; i < num && !found; i++ )
|
|
56 |
{
|
|
57 |
if ( iEnumIDs[i] == iValue )
|
|
58 |
{
|
|
59 |
strings->AppendL( iTexts[i]->Des() );
|
|
60 |
found = ETrue;
|
|
61 |
}
|
|
62 |
}
|
|
63 |
|
|
64 |
if ( !found )
|
|
65 |
{
|
|
66 |
User::Leave( KErrNotFound );
|
|
67 |
}
|
|
68 |
|
|
69 |
HBufC* buf = StringLoader::LoadL( R_QTN_LBOX_FORMAT, *strings );
|
|
70 |
CleanupStack::PopAndDestroy(); // strings
|
|
71 |
|
|
72 |
return buf;
|
|
73 |
}
|
|
74 |
|
|
75 |
// Clones itself
|
|
76 |
CDirectPrintBaseCapability* CDirectPrintListCapability::CloneL()
|
|
77 |
{
|
|
78 |
CDirectPrintListCapability* clone = new ( ELeave ) CDirectPrintListCapability();
|
|
79 |
CleanupStack::PushL( clone );
|
|
80 |
|
|
81 |
clone->iValue = iValue;
|
|
82 |
clone->iIndexOnList = iIndexOnList;
|
|
83 |
clone->iTitle = iTitle;
|
|
84 |
clone->iUid = iUid;
|
|
85 |
|
|
86 |
TInt num( iEnumIDs.Count() );
|
|
87 |
if ( iUid != EDirectPrintCapabLayout )
|
|
88 |
{
|
|
89 |
for ( TInt j = 0; j < num; j++ )
|
|
90 |
{
|
|
91 |
User::LeaveIfError( clone->iEnumIDs.Append( iEnumIDs[j] ) );
|
|
92 |
User::LeaveIfError( clone->iTexts.Append( iTexts[j]->AllocLC() ) );
|
|
93 |
CleanupStack::Pop(); // clone->iTexts
|
|
94 |
}
|
|
95 |
}
|
|
96 |
|
|
97 |
CleanupStack::Pop(); // clone
|
|
98 |
return clone;
|
|
99 |
}
|
|
100 |
|
|
101 |
// Creates setting item for the settings list box
|
|
102 |
CAknSettingItem* CDirectPrintListCapability::SettingItemLC(TInt aIndex)
|
|
103 |
{
|
|
104 |
CAknEnumeratedTextPopupSettingItem* item = new (ELeave) CAknEnumeratedTextPopupSettingItem(aIndex, iEnumIndex);
|
|
105 |
CleanupStack::PushL(item);
|
|
106 |
item->ConstructL(EFalse, aIndex, iTitle, NULL, R_DIRECTPRINT_PRINTERSETTING_POPUP_SETTING_PAGE, -1, 0, R_DIRECTPRINT_PRINTERSETTING_POPUP_SETTING_TEXTS);
|
|
107 |
|
|
108 |
TInt count = iTexts.Count();
|
|
109 |
if (count > 0)
|
|
110 |
{
|
|
111 |
item->EnumeratedTextArray()->ResetAndDestroy();
|
|
112 |
}
|
|
113 |
for (TInt i=0; i<count; i++ )
|
|
114 |
{
|
|
115 |
CAknEnumeratedText* enumText;
|
|
116 |
enumText = new (ELeave) CAknEnumeratedText(i, iTexts[i]->AllocLC());
|
|
117 |
CleanupStack::Pop();
|
|
118 |
CleanupStack::PushL(enumText);
|
|
119 |
item->EnumeratedTextArray()->AppendL(enumText);
|
|
120 |
CleanupStack::Pop();
|
|
121 |
|
|
122 |
if (iValue == iEnumIDs[i])
|
|
123 |
{
|
|
124 |
iEnumIndex = i;
|
|
125 |
}
|
|
126 |
}
|
|
127 |
|
|
128 |
return item;
|
|
129 |
}
|
|
130 |
|
|
131 |
// End of File
|