33 Adds \a offsets for a \a className. \a fileInfo points to the layout css file. |
34 Adds \a offsets for a \a className. \a fileInfo points to the layout css file. |
34 \a offsets are indexed using CSSFileType - enum value. |
35 \a offsets are indexed using CSSFileType - enum value. |
35 */ |
36 */ |
36 bool HbOffsetMapBuilder::addWidgetOffsets(const QString &className, |
37 bool HbOffsetMapBuilder::addWidgetOffsets(const QString &className, |
37 const QFileInfo *fileInfo, |
38 const QFileInfo *fileInfo, |
38 int offsets[]) |
39 qptrdiff offsets[]) |
39 { |
40 { |
|
41 if (!fileInfo) { |
|
42 return true; |
|
43 } |
40 bool retValue = true; |
44 bool retValue = true; |
41 quint32 nameHash = HbSharedCache::hash(QStringRef(&className)); |
45 quint32 nameHash = HbSharedCache::hash(QStringRef(&className)); |
42 HbBinMakerOffsetItem mapItem = _mapItems.value(nameHash, HbBinMakerOffsetItem()); |
46 HbBinMakerOffsetItem mapItem = mMapItems.value(nameHash, HbBinMakerOffsetItem()); |
43 if (mapItem.isNull()) { |
47 if (mapItem.isNull()) { |
44 if (fileInfo) { |
48 if (fileInfo) { |
45 mapItem.name = fileInfo->absoluteFilePath(); |
49 mapItem.name = fileInfo->absoluteFilePath(); |
46 } |
50 } |
47 mapItem.widgetHash = nameHash; |
51 mapItem.widgetHash = nameHash; |
48 mapItem.offsetCSS = offsets[CSSFile]; |
52 mapItem.offsetCSS = offsets[CSSFile]; |
49 mapItem.offsetColorCSS = offsets[ColorCSSFile]; |
53 mapItem.offsetColorCSS = offsets[ColorCSSFile]; |
50 _mapItems.insert(nameHash, mapItem); |
54 mMapItems.insert(nameHash, mapItem); |
51 } else { |
55 } else { |
52 err << "duplicate hash value found!" << endl; |
56 err << "duplicate hash value found!" << endl; |
53 retValue = false; |
57 retValue = false; |
54 } |
58 } |
55 return retValue; |
59 return retValue; |
65 bool HbOffsetMapBuilder::addWidgetMLOffsets(const QString &filePath, |
69 bool HbOffsetMapBuilder::addWidgetMLOffsets(const QString &filePath, |
66 quint32 classNameHash, |
70 quint32 classNameHash, |
67 const QList<LayoutItem> &layoutInfoList) |
71 const QList<LayoutItem> &layoutInfoList) |
68 { |
72 { |
69 bool retValue = true; |
73 bool retValue = true; |
70 QMap<quint32, HbBinMakerOffsetItem>::iterator offsetItem = _mapItems.find(classNameHash); |
74 QMap<quint32, HbBinMakerOffsetItem>::iterator offsetItem = mMapItems.find(classNameHash); |
71 if (offsetItem != _mapItems.end()) { |
75 if (offsetItem != mMapItems.end()) { |
72 QSet<quint64> hashCheck; |
76 QSet<quint64> hashCheck; |
73 QList<HbLayoutIndexItem> &layoutIndexTable = offsetItem.value().layoutIndexItemList; |
77 QList<HbLayoutIndexItem> &layoutIndexTable = offsetItem.value().layoutIndexItemList; |
74 Q_FOREACH(const LayoutItem &layoutInfo, layoutInfoList) { |
78 Q_FOREACH(const LayoutItem &layoutInfo, layoutInfoList) { |
75 HbLayoutIndexItem item; |
79 HbLayoutIndexItem item; |
76 item.layoutNameHash = HbSharedCache::hash(QStringRef(&layoutInfo.layout->layoutname)); |
80 item.layoutNameHash = HbSharedCache::hash(QStringRef(&layoutInfo.layout->layoutname)); |
88 } |
92 } |
89 } |
93 } |
90 return retValue; |
94 return retValue; |
91 } |
95 } |
92 |
96 |
|
97 bool HbOffsetMapBuilder::addGlobalParameters(int zoomLevel, |
|
98 const QHash<QString, HbParameterValueItem> ¶meters) |
|
99 { |
|
100 Q_UNUSED(zoomLevel) |
|
101 mParameters.clear(); |
|
102 bool status = true; |
|
103 |
|
104 QHash<QString, HbParameterValueItem>::const_iterator end = parameters.end(); |
|
105 for (QHash<QString, HbParameterValueItem>::const_iterator i = parameters.begin(); i != end; ++i) { |
|
106 quint32 hash = HbSharedCache::hash(QStringRef(&i.key())); |
|
107 if (mParameters.contains(hash)) { |
|
108 err << "duplicate parameter hash found for: " << i.key(); |
|
109 status = false; |
|
110 break; |
|
111 } |
|
112 mParameters.insert(hash, qMakePair(i.key(), i.value())); |
|
113 } |
|
114 return status; |
|
115 } |
|
116 |
93 /*! |
117 /*! |
94 dumps the contents of the offset map to bytearray. |
118 dumps the contents of the offset map to bytearray. |
95 |
119 |
96 */ |
120 */ |
97 QByteArray HbOffsetMapBuilder::result() |
121 QByteArray HbOffsetMapBuilder::result() |
98 { |
122 { |
99 QByteArray dataArray; |
123 QByteArray dataArray; |
100 |
124 |
101 //first layoutindextable is locates after the offsetitem-array. |
125 //first layoutindextable is located after the offsetitem-array. |
102 int currentLayoutIndexTableOffset = _mapItems.size() * sizeof(HbOffsetItem); |
126 qint32 currentLayoutIndexTableOffset = mMapItems.size() * sizeof(HbOffsetItem); |
103 |
127 |
104 //store offsetitems, update layout index table offset |
128 //store offsetitems, update layout index table offset |
105 foreach(const HbBinMakerOffsetItem &mapItem, _mapItems) { |
129 foreach(const HbBinMakerOffsetItem &mapItem, mMapItems) { |
106 HbOffsetItem tmp(mapItem); |
130 HbOffsetItem tmp(mapItem); |
107 if (!mapItem.layoutIndexItemList.isEmpty()) { |
131 if (!mapItem.layoutIndexItemList.isEmpty()) { |
108 tmp.offsetLayoutIndexTable = currentLayoutIndexTableOffset; |
132 tmp.offsetLayoutIndexTable = currentLayoutIndexTableOffset; |
109 currentLayoutIndexTableOffset += sizeof(quint32) // space for the size of the layoutindex table |
133 currentLayoutIndexTableOffset += sizeof(quint32) // space for the size of the layoutindex table |
110 + mapItem.layoutIndexItemList.size() |
134 + mapItem.layoutIndexItemList.size() |
111 * sizeof(HbLayoutIndexItem); |
135 * sizeof(HbLayoutIndexItem); |
112 } |
136 } |
113 dataArray.append(reinterpret_cast<const char*>(&tmp), sizeof(HbOffsetItem)); |
137 dataArray.append(reinterpret_cast<const char*>(&tmp), sizeof(HbOffsetItem)); |
114 } |
138 } |
115 |
|
116 //store layout index tables |
139 //store layout index tables |
117 QMap<quint32, HbBinMakerOffsetItem>::iterator end = _mapItems.end(); |
140 QMap<quint32, HbBinMakerOffsetItem>::iterator end = mMapItems.end(); |
118 for(QMap<quint32, HbBinMakerOffsetItem>::iterator i = _mapItems.begin(); i != end; ++i) { |
141 for(QMap<quint32, HbBinMakerOffsetItem>::iterator i = mMapItems.begin(); i != end; ++i) { |
119 HbBinMakerOffsetItem &mapItem = i.value(); |
142 HbBinMakerOffsetItem &mapItem = i.value(); |
120 if (!mapItem.layoutIndexItemList.isEmpty()) { |
143 if (!mapItem.layoutIndexItemList.isEmpty()) { |
121 qSort(mapItem.layoutIndexItemList); //sort for binary search. |
144 qSort(mapItem.layoutIndexItemList); //sort for binary search. |
122 //store the table size first. |
145 //store the table size first. |
123 quint32 size = mapItem.layoutIndexItemList.size(); |
146 qint32 size = mapItem.layoutIndexItemList.size(); |
124 dataArray.append(reinterpret_cast<const char*>(&size), sizeof(quint32)); |
147 dataArray.append(reinterpret_cast<const char*>(&size), sizeof(qint32)); |
125 //store the layout-index items. |
148 //store the layout-index items. |
126 foreach(const HbLayoutIndexItem &layoutIndexItem, mapItem.layoutIndexItemList) { |
149 foreach(const HbLayoutIndexItem &layoutIndexItem, mapItem.layoutIndexItemList) { |
127 dataArray.append(reinterpret_cast<const char*>(&layoutIndexItem), |
150 dataArray.append(reinterpret_cast<const char*>(&layoutIndexItem), |
128 sizeof(HbLayoutIndexItem)); |
151 sizeof(HbLayoutIndexItem)); |
129 } |
152 } |
130 } |
153 } |
131 } |
154 } |
|
155 //store global parameters. |
|
156 mGlobalParameterOffset = dataArray.size() |
|
157 + sizeof(qint32); //for size |
|
158 qint32 parameterCount = mParameters.count(); |
|
159 |
|
160 //parameter item array is followed by the variable name strings. |
|
161 //the start address of the hbparameter-array is the base for the name (added to nameOffset) |
|
162 int nameOffset = parameterCount * sizeof(HbParameterItem); |
|
163 |
|
164 dataArray.append(reinterpret_cast<const char*>(¶meterCount), sizeof(qint32)); |
|
165 ParameterMap::const_iterator parametersEnd = mParameters.end(); |
|
166 for (ParameterMap::const_iterator i = mParameters.begin(); i != parametersEnd; ++i) { |
|
167 HbParameterItem item(i.key(), i.value().second.offset, nameOffset, i.value().second.special); |
|
168 dataArray.append(reinterpret_cast<const char*>(&item), sizeof(HbParameterItem)); |
|
169 nameOffset += i.value().first.length() + 1; // +1 for '\0'. |
|
170 } |
|
171 |
|
172 //store parameter names |
|
173 for (ParameterMap::const_iterator i = mParameters.begin(); i != parametersEnd; ++i) { |
|
174 QByteArray name(i.value().first.toLatin1()); |
|
175 dataArray.append(name.constData(), name.length() + 1); //constData will contain the '\0' |
|
176 } |
132 return dataArray; |
177 return dataArray; |
133 } |
178 } |