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: Declaration of class CCmListboxModel. |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef CMLISTBOX_LISTBOX_MODEL_H |
|
19 #define CMLISTBOX_LISTBOX_MODEL_H |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include <eikdialg.h> |
|
23 #include "cmlistitemlist.h" |
|
24 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS |
|
25 #include <commsdat.h> |
|
26 #else |
|
27 #include <commsdat.h> |
|
28 #include <commsdat_partner.h> |
|
29 #endif |
|
30 |
|
31 // CONSTANTS |
|
32 // Granularity of the model array. |
|
33 const TInt KCMGranularity = 8; |
|
34 |
|
35 //"1\tFirstLabel\tSecondLabel\t0\t0" /**/ |
|
36 _LIT( KListItemFormatCmProt, "%d\t%S\t%S\t%d" ); |
|
37 //"0\tFirstLabel\tSecondLabel" /*\t%d*/ |
|
38 _LIT( KListItemFormatCm, "%d\t%S\t%S" ); |
|
39 //"0\tFirstLabel" /*\t%d*/ |
|
40 _LIT( KListItemFormatEmbDest, "%d\t%S\t" ); |
|
41 //"0\tFirstLabel\t0\t0" /*\t%d*/ |
|
42 _LIT( KListItemFormatEmbDestProt, "%d\t%S\t\t%d" ); |
|
43 |
|
44 const TInt KCMMaxFormatSize = sizeof( KListItemFormatCm ); |
|
45 const TInt KCMMaxListItemNameLength = CommsDat::KMaxTextLength; |
|
46 const TInt KMaxCmListboxName = KCMMaxListItemNameLength+KCMMaxFormatSize; |
|
47 |
|
48 |
|
49 /** |
|
50 * Buffer size for formatting listbox text. Maximum item length |
|
51 * plus listbox internals (tabulators for icons etc.) must fit into it. |
|
52 * |
|
53 * Important note: |
|
54 * The model of the listbox is a CAknFilteredTextListBoxModel. |
|
55 * The *itemarray* of that model is this class. That is, whatever is in |
|
56 * the model (this class), it may not be visible, if it is filtered out. |
|
57 * We always must use the listbox's Model() to get visible ones. |
|
58 */ |
|
59 |
|
60 |
|
61 // CLASS DECLARATION |
|
62 |
|
63 /** |
|
64 * Model for the connection methods listbox. |
|
65 * pointers; items are owned. |
|
66 * @lib cmmanager.lib |
|
67 * @since S60 v3.2 |
|
68 */ |
|
69 NONSHARABLE_CLASS( CCmListboxModel ) : public CCmListItemList |
|
70 , public MDesCArray |
|
71 { |
|
72 public: // Construct |
|
73 |
|
74 /** |
|
75 * Constructor. |
|
76 */ |
|
77 CCmListboxModel(); |
|
78 |
|
79 /** |
|
80 * CCmListboxructor. |
|
81 */ |
|
82 virtual ~CCmListboxModel(); |
|
83 |
|
84 public: // from MDesCArray |
|
85 |
|
86 /** |
|
87 * Get number of items in the model. |
|
88 * @return number of items. |
|
89 */ |
|
90 TInt MdcaCount() const; |
|
91 |
|
92 /** |
|
93 * Text to be displayed for this item. |
|
94 * @param aIndex Index of item. |
|
95 * @return for this item text (text owned by the model). |
|
96 */ |
|
97 TPtrC MdcaPoint( TInt aIndex ) const; |
|
98 |
|
99 public: |
|
100 |
|
101 /** |
|
102 * Sets the icon offset |
|
103 * @param aOffset the offset of our icons in the iconarray |
|
104 */ |
|
105 void SetOwnIconOffset( TInt aOffset ); |
|
106 |
|
107 protected: // data |
|
108 |
|
109 /** |
|
110 * Formats the text of the listbox, calls the leaving version trapped. |
|
111 * @param aIndex Index of item. |
|
112 * @param aBuf Buffer to store formatted text. |
|
113 */ |
|
114 void FormatListboxText( TInt aIndex, TDes& aBuf ) const; |
|
115 |
|
116 /** |
|
117 * Formats the text of the listbox, leaving version. |
|
118 * @param aIndex Index of item. |
|
119 * @param aBuf Buffer to store formatted text. |
|
120 */ |
|
121 void FormatListboxTextL( TInt aIndex, TDes& aBuf ) const; |
|
122 |
|
123 /** |
|
124 * MdcaPoint() cannot leave, so this buffer is allocated |
|
125 * to allow formatting. Fortunately, doesn't have to be very |
|
126 * large. |
|
127 * We have to use MUTABLE CAST, as MdcaPoint is const (odd enough), |
|
128 * so wouldn't allow formatting the text in a member... |
|
129 */ |
|
130 __MUTABLE TBuf<KMaxCmListboxName> iBuf; |
|
131 TInt iOffset; |
|
132 }; |
|
133 |
|
134 #endif // CMLISTBOX_LISTBOX_MODEL_H |
|