equal
deleted
inserted
replaced
20 ** |
20 ** |
21 ** If you have questions regarding the use of this file, please contact |
21 ** If you have questions regarding the use of this file, please contact |
22 ** Nokia at developer.feedback@nokia.com. |
22 ** Nokia at developer.feedback@nokia.com. |
23 ** |
23 ** |
24 ****************************************************************************/ |
24 ****************************************************************************/ |
|
25 #ifndef HB_BIN_CSS |
|
26 #define HB_USETHEMESERVER |
|
27 #endif |
25 |
28 |
26 #include "hbwidgetloader_p.h" |
29 #include "hbwidgetloader_p.h" |
27 #include "hbwidgetloadersyntax_p.h" |
30 #include "hbwidgetloadersyntax_p.h" |
28 #include "hbwidgetloaderactions_p.h" |
31 #include "hbwidgetloaderactions_p.h" |
29 |
32 |
30 #include "hbinstance.h" |
33 #include "hbinstance.h" |
31 #include "hbtheme_p.h" |
34 #include "hbtheme_p.h" |
|
35 #ifdef HB_USETHEMESERVER |
32 #include "hbthemeclient_p.h" |
36 #include "hbthemeclient_p.h" |
|
37 #endif |
33 |
38 |
34 #include <QtDebug> |
39 #include <QtDebug> |
35 #include <QFile> |
40 #include <QFile> |
36 #include <QStringList> |
41 #include <QStringList> |
37 #include <hbwidget.h> |
42 #include <hbwidget.h> |
49 #define HB_WIDGETLOADER_PRINT(a) qDebug() << QString(a); |
54 #define HB_WIDGETLOADER_PRINT(a) qDebug() << QString(a); |
50 #endif // HB_WIDGETLOADER_DEBUG |
55 #endif // HB_WIDGETLOADER_DEBUG |
51 |
56 |
52 #define hbInstance (HbInstance::instance()) |
57 #define hbInstance (HbInstance::instance()) |
53 |
58 |
54 // cache at the client side to store the mesh items. |
59 // cache at the client side to store the anchor items. |
55 // key used here is the filename+layoutname+sectionname. |
60 // key used here is the filename+layoutname+sectionname. |
56 |
61 |
57 typedef QHash<QString,HbWidgetLoader::LayoutDefinition*> ClientHashForLayoutDefs; |
62 typedef QHash<QString,HbWidgetLoader::LayoutDefinition*> ClientHashForLayoutDefs; |
58 Q_GLOBAL_STATIC(ClientHashForLayoutDefs, clientLayoutDefsCache) |
63 Q_GLOBAL_STATIC(ClientHashForLayoutDefs, clientLayoutDefsCache) |
59 |
64 |
61 // This reduces the check QFile::exists() at client side as well as the server side. |
66 // This reduces the check QFile::exists() at client side as well as the server side. |
62 // also no unnecessary IPC calls. |
67 // also no unnecessary IPC calls. |
63 Q_GLOBAL_STATIC(QStringList, filesNotPresent) |
68 Q_GLOBAL_STATIC(QStringList, filesNotPresent) |
64 |
69 |
65 // Layout caching |
70 // Layout caching |
66 static HbWidgetLoader::LayoutDefinition *staticCacheLayout = NULL; |
71 static HbWidgetLoader::LayoutDefinition *staticCacheLayout = 0; |
67 static QString staticCacheFileName = QString(); |
72 static QString staticCacheFileName; |
68 static QString staticCacheName = QString(); |
73 static QString staticCacheName; |
69 static QString staticCacheSection = QString(); |
74 static QString staticCacheSection; |
70 static QDateTime staticCacheModified = QDateTime(); |
75 static QDateTime staticCacheModified; |
71 |
76 |
72 class HbWidgetLoaderPrivate |
77 class HbWidgetLoaderPrivate |
73 { |
78 { |
74 Q_DECLARE_PUBLIC(HbWidgetLoader) |
79 Q_DECLARE_PUBLIC(HbWidgetLoader) |
75 |
80 |
139 } |
144 } |
140 |
145 |
141 /*! |
146 /*! |
142 Loads and processes a WidgetML file. |
147 Loads and processes a WidgetML file. |
143 |
148 |
144 If the widget already has a layout assumes it's HbMeshLayout. |
149 If the widget already has a layout assumes it's HbAnchorLayout. |
145 If the widget doesn't have a layout creates HbMeshLayout and sets it to widget. |
150 If the widget doesn't have a layout creates HbAnchorLayout and sets it to widget. |
146 Creates the anchor edge attachments based on WidgetML. |
151 Creates the anchor edge attachments based on WidgetML. |
147 |
152 |
148 \param fileName file to be processed. |
153 \param fileName file to be processed. |
149 \param name the name of the layout to be loaded. |
154 \param name the name of the layout to be loaded. |
150 \param section space separated route to section, that you want to load. |
155 \param section space separated route to section, that you want to load. |
151 \param storage specifies where to store the mesh items. |
156 \param storage specifies where to store the anchor items. |
152 \return true if file was loaded and processed successfully. |
157 \return true if file was loaded and processed successfully. |
153 */ |
158 */ |
154 bool HbWidgetLoader::load( |
159 bool HbWidgetLoader::load( |
155 HbWidget* widget, |
160 HbWidget* widget, |
156 const QString &fileName, |
161 const QString &fileName, |
235 delete mSyntax; |
240 delete mSyntax; |
236 delete mMemActions; |
241 delete mMemActions; |
237 delete mActions; |
242 delete mActions; |
238 } |
243 } |
239 |
244 |
|
245 #ifdef HB_BIN_CSS |
|
246 void HbWidgetLoaderPrivate::setWidget( HbWidget* widget ) |
|
247 { |
|
248 Q_UNUSED(widget) |
|
249 } |
|
250 #else |
240 /*! |
251 /*! |
241 \internal |
252 \internal |
242 */ |
253 */ |
243 void HbWidgetLoaderPrivate::setWidget( HbWidget* widget ) |
254 void HbWidgetLoaderPrivate::setWidget( HbWidget* widget ) |
244 { |
255 { |
245 mActions->reset(); |
256 mActions->reset(); |
246 mActions->mWidget = widget; |
257 mActions->mWidget = widget; |
247 mActions->mCurrentProfile = HbDeviceProfile::profile(widget); |
258 mActions->mCurrentProfile = HbDeviceProfile::profile(widget); |
248 } |
259 } |
|
260 #endif |
249 |
261 |
250 /*! |
262 /*! |
251 \internal |
263 \internal |
252 */ |
264 */ |
253 bool HbWidgetLoaderPrivate::getSharedLayoutDefinition( |
265 bool HbWidgetLoaderPrivate::getSharedLayoutDefinition( |
254 const QString &fileName, |
266 const QString &fileName, |
255 const QString &name, |
267 const QString &name, |
256 const QString §ion, |
268 const QString §ion, |
257 HbWidgetLoader::LayoutDefinition *&layoutDef ) |
269 HbWidgetLoader::LayoutDefinition *&layoutDef ) |
258 { |
270 { |
259 // check in the client side cache if the vector of meshitems is present. |
271 // check in the client side cache if the vector of anchor items is present. |
260 QString key (fileName + name + section); |
272 QString key (fileName + name + section); |
261 if (clientLayoutDefsCache()->contains(key)){ |
273 if (clientLayoutDefsCache()->contains(key)){ |
262 // present in the client cache. |
274 // present in the client cache. |
263 layoutDef = clientLayoutDefsCache()->value(key); |
275 layoutDef = clientLayoutDefsCache()->value(key); |
264 return true; |
276 return true; |
278 filesNotPresent()->append(fileName); |
290 filesNotPresent()->append(fileName); |
279 return false; |
291 return false; |
280 } |
292 } |
281 |
293 |
282 // get the shared layout definition address. |
294 // get the shared layout definition address. |
|
295 #ifdef HB_USETHEMESERVER |
283 layoutDef = HbThemeClient::global()->getSharedLayoutDefs(fileName, name, section); |
296 layoutDef = HbThemeClient::global()->getSharedLayoutDefs(fileName, name, section); |
284 if (layoutDef) { |
297 if (layoutDef) { |
285 clientLayoutDefsCache()->insert(key, layoutDef); |
298 clientLayoutDefsCache()->insert(key, layoutDef); |
286 } |
299 } |
|
300 #endif |
287 return true; |
301 return true; |
288 } |
302 } |
289 |
303 |
290 /*! |
304 /*! |
291 \internal |
305 \internal |