userguide/src/HelpDataProvider.cpp
changeset 26 97d7f0705d0a
parent 24 bce8d4d2cc72
child 27 0a93cba9d57a
equal deleted inserted replaced
25:57d77d90783b 26:97d7f0705d0a
   253 	}
   253 	}
   254 }
   254 }
   255 
   255 
   256 void HelpDataProvider::constructBuiltInCategoryItem(const QString& uid, const QString& title)
   256 void HelpDataProvider::constructBuiltInCategoryItem(const QString& uid, const QString& title)
   257 {
   257 {
   258 	int featureId;
       
   259 	int priority;
   258 	int priority;
   260 	parseBuiltInMetaxml(uid, featureId, priority);
   259 	parseBuiltInMetaxml(uid, priority);
   261 	
   260 	
   262 	HelpStandardItem* item = NULL;
   261 	HelpStandardItem* item = NULL;
   263 	item = new HelpStandardItem(title);
   262 	item = new HelpStandardItem(title);
   264 	item->setData(uid, UidRole);
   263 	item->setData(uid, UidRole);
   265 
   264 
   344 	}
   343 	}
   345 	if(!query.evaluateTo(&titleList))
   344 	if(!query.evaluateTo(&titleList))
   346 	{
   345 	{
   347 		return;
   346 		return;
   348 	}
   347 	}
       
   348 
       
   349 	QStringList featureIdLst;
       
   350 
       
   351 	query.setQuery("doc($inputdoc)/collections/collection/number(@FeatureId)");
       
   352 	if(!query.isValid())
       
   353 	{
       
   354 		return;
       
   355 	}
       
   356 	if(!query.evaluateTo(&featureIdLst))
       
   357 	{
       
   358 		return;
       
   359 	}
       
   360 
       
   361 	if(featureIdLst.count() != uidList.count())
       
   362 	{
       
   363 		return;
       
   364 	}
       
   365 
       
   366 	for(int i = featureIdLst.count()  - 1; i <= 0; i--)
       
   367 	{
       
   368 		int featureID = featureIdLst.at(i).toInt();
       
   369 		if(!HelpUtils::suppportFeatureID(featureID))
       
   370 		{
       
   371 			uidList.removeAt(i);
       
   372 			titleList.removeAt(i);
       
   373 		}
       
   374 	}
   349 }
   375 }
   350 
   376 
   351 void HelpDataProvider::parseCategory2IndexXml(const QString& path, QStringList& hrefList, QStringList& titleList)
   377 void HelpDataProvider::parseCategory2IndexXml(const QString& path, QStringList& hrefList, QStringList& titleList)
   352 {
   378 {
   353 	QString pathIndex(path);
   379 	QString pathIndex(path);
   359 		return;
   385 		return;
   360 	}
   386 	}
   361 
   387 
   362 	//parse index xml to a stringlist, each string include href and navtitle and seperate by "specilchar"
   388 	//parse index xml to a stringlist, each string include href and navtitle and seperate by "specilchar"
   363 	QXmlQuery query;
   389 	QXmlQuery query;
   364 	QXmlItem xmlItem(SPECIALCHAR);
       
   365 	query.bindVariable("inputdoc", &file);
   390 	query.bindVariable("inputdoc", &file);
   366 
   391 
   367 	query.setQuery("doc($inputdoc)/topics/topicref/xs:string(@href)");	
   392 	query.setQuery("doc($inputdoc)/topics/topicref/xs:string(@href)");	
   368 	if(!query.isValid())
   393 	if(!query.isValid())
   369 	{
   394 	{
   381 	}
   406 	}
   382 	if(!query.evaluateTo(&titleList))
   407 	if(!query.evaluateTo(&titleList))
   383 	{
   408 	{
   384 		return;
   409 		return;
   385 	}
   410 	}
   386 }
   411 
   387 
   412 	QStringList featureIdLst;
   388 void HelpDataProvider::parseBuiltInMetaxml(const QString& path, int& featureId, int& priority)
   413 
       
   414 	query.setQuery("doc($inputdoc)/topics/topicref/number(@FeatureId)");
       
   415 	if(!query.isValid())
       
   416 	{
       
   417 		return;
       
   418 	}
       
   419 	if(!query.evaluateTo(&featureIdLst))
       
   420 	{
       
   421 		return;
       
   422 	}
       
   423 
       
   424 	if(featureIdLst.count() != hrefList.count())
       
   425 	{
       
   426 		return;
       
   427 	}
       
   428 
       
   429 	for(int i = featureIdLst.count()  - 1; i <= 0; i--)
       
   430 	{
       
   431 		int featureID = featureIdLst.at(i).toInt();
       
   432 		if(!HelpUtils::suppportFeatureID(featureID))
       
   433 		{
       
   434 			hrefList.removeAt(i);
       
   435 			titleList.removeAt(i);
       
   436 		}
       
   437 	}
       
   438 }
       
   439 
       
   440 void HelpDataProvider::parseBuiltInMetaxml(const QString& path, int& priority)
   389 {
   441 {
   390 	QString pathMetaxml(path);
   442 	QString pathMetaxml(path);
   391 	pathMetaxml.append(BACKSLASH);
   443 	pathMetaxml.append(BACKSLASH);
   392 	pathMetaxml.append(METAXML);
   444 	pathMetaxml.append(METAXML);
   393 
   445 
   394 	featureId = -1;
       
   395 	priority = -1;
   446 	priority = -1;
   396 
   447 
   397 	QFile file(pathMetaxml);
   448 	QFile file(pathMetaxml);
   398 	if (!file.open(QIODevice::ReadOnly))
   449 	if (!file.open(QIODevice::ReadOnly))
   399 	{
   450 	{
   401 	}
   452 	}
   402 
   453 
   403 	QXmlQuery query;
   454 	QXmlQuery query;
   404 	QString str;
   455 	QString str;
   405 	query.bindVariable("inputdoc", &file);
   456 	query.bindVariable("inputdoc", &file);
   406 
       
   407 	query.setQuery("doc($inputdoc)/meta/title/number(@FeatureId)");
       
   408 	if(query.isValid() && query.evaluateTo(&str))
       
   409 	{
       
   410 		featureId = str.toInt();
       
   411 	}
       
   412 
   457 
   413 	query.setQuery("doc($inputdoc)/meta/number(priority)");	
   458 	query.setQuery("doc($inputdoc)/meta/number(priority)");	
   414 	if(query.isValid() && query.evaluateTo(&str))
   459 	if(query.isValid() && query.evaluateTo(&str))
   415 	{
   460 	{
   416 		priority = str.toInt();
   461 		priority = str.toInt();