|
1 /* |
|
2 * Copyright (c) 2002-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: Predictive Candidate list model |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <aknlayoutscalable_avkon.cdl.h> // AknLayoutScalable_Avkon |
|
21 #include "peninputjapanesepredictivelistboxmodel.h" |
|
22 |
|
23 // ============================ MEMBER FUNCTIONS =============================== |
|
24 // ----------------------------------------------------------------------------- |
|
25 // CPredictivePopupLineInfo::~CPredictivePopupLineInfo |
|
26 // Destructor |
|
27 // ----------------------------------------------------------------------------- |
|
28 CPredictivePopupLineInfo::~CPredictivePopupLineInfo() |
|
29 { |
|
30 delete iLineText; |
|
31 delete iElementsOnLine; |
|
32 } |
|
33 |
|
34 // ----------------------------------------------------------------------------- |
|
35 // CPeninputJapanesePredictiveListBoxModel::SetLineInfoArray |
|
36 // Registering a array with candidate line information |
|
37 // ----------------------------------------------------------------------------- |
|
38 void CPeninputJapanesePredictiveListBoxModel::SetLineInfoArray( |
|
39 CPredictivePopupLineInfoArray* aLineInfoArray) |
|
40 { |
|
41 iLineInfoArray = aLineInfoArray; |
|
42 } |
|
43 |
|
44 // ----------------------------------------------------------------------------- |
|
45 // CPeninputJapanesePredictiveListBoxModel::LineInfoArray |
|
46 // Returning a arrary with candidate line information |
|
47 // ----------------------------------------------------------------------------- |
|
48 CPredictivePopupLineInfoArray* |
|
49 CPeninputJapanesePredictiveListBoxModel::LineInfoArray() |
|
50 { |
|
51 return iLineInfoArray; |
|
52 } |
|
53 |
|
54 // ----------------------------------------------------------------------------- |
|
55 // CPeninputJapanesePredictiveListBoxModel::SearchItemIndexFromCandidateNo |
|
56 // This function searches a item index as key in a candidate number |
|
57 // ----------------------------------------------------------------------------- |
|
58 TInt CPeninputJapanesePredictiveListBoxModel::SearchItemIndexFromCandidateNo( |
|
59 TInt aCandidateNo) const |
|
60 { |
|
61 TInt lineNo = -1; |
|
62 if (iLineInfoArray) |
|
63 { |
|
64 const TInt numberOfLine = iLineInfoArray->Count(); |
|
65 TInt i; |
|
66 for (i = 0; i < numberOfLine && lineNo == -1; i++) |
|
67 { |
|
68 CPredictivePopupLineInfo* lineInfo = iLineInfoArray->At(i); |
|
69 CPredictivePopupElementArray* elementArray =lineInfo->iElementsOnLine; |
|
70 |
|
71 const TInt numberOfElement = elementArray->Count(); |
|
72 TInt j; |
|
73 for (j = 0; j < numberOfElement; j++) |
|
74 { |
|
75 TPredictivePopupElement element = elementArray->At(j); |
|
76 if (aCandidateNo == element.iCandidateNo) |
|
77 { |
|
78 lineNo = i; |
|
79 break; |
|
80 } |
|
81 } |
|
82 } |
|
83 } |
|
84 return lineNo; |
|
85 } |
|
86 |
|
87 // ----------------------------------------------------------------------------- |
|
88 // CPeninputJapanesePredictiveListBoxModel::SearchElement |
|
89 // This function is that it checks whether the candidate is included in the line. |
|
90 // If including it, The displaying information is returned. |
|
91 // ----------------------------------------------------------------------------- |
|
92 TBool CPeninputJapanesePredictiveListBoxModel::SearchElement( |
|
93 TInt aLineNo, TInt aCandidateNo, TPredictivePopupElement& aElement) |
|
94 { |
|
95 TBool foundFlag = EFalse; |
|
96 |
|
97 if ( 0 <= aLineNo && iLineInfoArray && iLineInfoArray->Count() > aLineNo ) |
|
98 { |
|
99 CPredictivePopupLineInfo* lineInfo = iLineInfoArray->At(aLineNo); |
|
100 CPredictivePopupElementArray* elementArray = lineInfo->iElementsOnLine; |
|
101 |
|
102 const TInt numberOfElement = elementArray->Count(); |
|
103 TInt i; |
|
104 for (i = 0; i < numberOfElement; i++) |
|
105 { |
|
106 TPredictivePopupElement element = elementArray->At(i); |
|
107 if (aCandidateNo < element.iCandidateNo) |
|
108 { |
|
109 break; |
|
110 } |
|
111 else if (aCandidateNo == element.iCandidateNo) |
|
112 { |
|
113 aElement.iStartXPos = element.iStartXPos; |
|
114 aElement.iEndXPos = element.iEndXPos; |
|
115 aElement.iCandidateNo = element.iCandidateNo; |
|
116 foundFlag = ETrue; |
|
117 break; |
|
118 } |
|
119 } |
|
120 } |
|
121 return foundFlag; |
|
122 } |
|
123 |
|
124 // ----------------------------------------------------------------------------- |
|
125 // CPeninputJapanesePredictiveListBoxModel::SearchCandidateNoFromPosition |
|
126 // This function searches a CandidateNo from linenumber and Position |
|
127 // ----------------------------------------------------------------------------- |
|
128 TInt CPeninputJapanesePredictiveListBoxModel::SearchCandidateNoFromPosition( |
|
129 TInt aLineNo, const TPoint& aPoint) const |
|
130 { |
|
131 TInt atom = AknLayoutScalable_Avkon::list_single_choice_list_pane(0).LayoutLine().iH; |
|
132 TInt margin = atom*2/5; |
|
133 TInt candidateNo = -1; |
|
134 if ( 0 <= aLineNo && iLineInfoArray && iLineInfoArray->Count() > aLineNo ) |
|
135 { |
|
136 CPredictivePopupLineInfo* lineInfo = iLineInfoArray->At(aLineNo); |
|
137 CPredictivePopupElementArray* elementArray = lineInfo->iElementsOnLine; |
|
138 const TInt numberOfElement = elementArray->Count(); |
|
139 candidateNo = elementArray->At(numberOfElement - 1).iCandidateNo; |
|
140 for (TInt ii = 0; ii < numberOfElement; ii++) |
|
141 { |
|
142 TPredictivePopupElement element = elementArray->At(ii); |
|
143 if (aPoint.iX - margin <= element.iEndXPos) |
|
144 { |
|
145 candidateNo = element.iCandidateNo; |
|
146 break; |
|
147 } |
|
148 } |
|
149 } |
|
150 return candidateNo; |
|
151 } |
|
152 |
|
153 // ----------------------------------------------------------------------------- |
|
154 // CPeninputJapanesePredictiveListBoxModel::SetMaximumItems |
|
155 // Set total item numbers in listbox |
|
156 // ----------------------------------------------------------------------------- |
|
157 void CPeninputJapanesePredictiveListBoxModel::SetMaximumItems( |
|
158 TInt aMaximumItems) |
|
159 { |
|
160 iMaximumItems = aMaximumItems; |
|
161 } |
|
162 |
|
163 // ----------------------------------------------------------------------------- |
|
164 // CPeninputJapanesePredictiveListBoxModel::MaximumItems |
|
165 // Return total item numbers |
|
166 // ----------------------------------------------------------------------------- |
|
167 TInt CPeninputJapanesePredictiveListBoxModel::MaximumItems() const |
|
168 { |
|
169 return iMaximumItems; |
|
170 } |
|
171 |
|
172 // End of File |