Пример #1
0
void AWebservice::parseForumList (const QString& data, AForumGroupInfoList& list)
{
	list.clear();

	//
	// список групп форумов
	//

	AGroupInfoList group_list;

	int seed = 0;

	QString group_info = getNextBlock(&data, "<JanusForumGroupInfo>", "</JanusForumGroupInfo>", seed);

	while (group_info.length())
	{
		AGroupInfo info;

		info.ID        = getTextBetween(&group_info, "<forumGroupId>",   "</forumGroupId>").toInt();
		info.Name      = getTextBetween(&group_info, "<forumGroupName>", "</forumGroupName>");
		info.SortOrder = getTextBetween(&group_info, "<sortOrder>",      "</sortOrder>").toInt();

		group_list.append(info);

		group_info = getNextBlock(&data, "<JanusForumGroupInfo>", "</JanusForumGroupInfo>", seed);
	}

	//
	// список форумов
	//

	AForumInfoList forum_list;

	seed = 0;

	QString forum_info = getNextBlock(&data, "<JanusForumInfo>", "</JanusForumInfo>", seed);

	while (forum_info.length())
	{
		AForumInfo info;

		info.ID        = getTextBetween(&forum_info, "<forumId>",        "</forumId>").toInt();
		info.IDGroup   = getTextBetween(&forum_info, "<forumGroupId>",   "</forumGroupId>").toInt();
		info.ShortName = getTextBetween(&forum_info, "<shortForumName>", "</shortForumName>");
		info.Name      = getTextBetween(&forum_info, "<forumName>",      "</forumName>");
		info.Rated     = getTextBetween(&forum_info, "<rated>",          "</rated>").toInt();
		info.InTop     = getTextBetween(&forum_info, "<inTop>",          "</inTop>").toInt();
		info.RateLimit = getTextBetween(&forum_info, "<rateLimit>",      "</rateLimit>").toInt();

		forum_list.append(info);

		forum_info = getNextBlock(&data, "<JanusForumInfo>", "</JanusForumInfo>", seed);
	}

	//
	// заполнение результата
	//

	for (int group_index = 0; group_index < group_list.count(); group_index++)
	{
		AForumGroupInfo group_info;

		group_info.Group = group_list[group_index];

		for (int forum_index = 0; forum_index < forum_list.count(); forum_index++)
			if (forum_list[forum_index].IDGroup == group_info.Group.ID)
				group_info.Forums.append(forum_list[forum_index]);

		list.append(group_info);
	}
}
Пример #2
0
void AWebservice::getForumList_WebserviceParse (const QString& data, AForumGroupInfoList& list, IProgress* progress)
{
	if (progress != NULL)
		progress->onProgress(0);

	list.clear();

	//
	// список групп форумов
	//

	AGroupInfoList group_list;

	int seed = 0;

	QString group_info = getNextBlock(&data, "<JanusForumGroupInfo>", "</JanusForumGroupInfo>", seed);

	while (group_info.length())
	{
		AGroupInfo info;

		info.ID        = getTextBetween(&group_info, "<forumGroupId>",   "</forumGroupId>").toInt();
		info.Name      = getTextBetween(&group_info, "<forumGroupName>", "</forumGroupName>");
		info.SortOrder = getTextBetween(&group_info, "<sortOrder>",      "</sortOrder>").toInt();

		group_list.append(info);

		group_info = getNextBlock(&data, "<JanusForumGroupInfo>", "</JanusForumGroupInfo>", seed);
	}

	//
	// список форумов
	//

	AForumInfoList forum_list;

	seed = 0;

	QString forum_info = getNextBlock(&data, "<JanusForumInfo>", "</JanusForumInfo>", seed);

	while (forum_info.length())
	{
		AForumInfo info;

		info.ID        = getTextBetween(&forum_info, "<forumId>",        "</forumId>").toInt();
		info.IDGroup   = getTextBetween(&forum_info, "<forumGroupId>",   "</forumGroupId>").toInt();
		info.ShortName = getTextBetween(&forum_info, "<shortForumName>", "</shortForumName>");
		info.Name      = getTextBetween(&forum_info, "<forumName>",      "</forumName>");
		info.Rated     = getTextBetween(&forum_info, "<rated>",          "</rated>").toInt();
		info.InTop     = getTextBetween(&forum_info, "<inTop>",          "</inTop>").toInt();
		info.RateLimit = getTextBetween(&forum_info, "<rateLimit>",      "</rateLimit>").toInt();

		forum_list.append(info);

		forum_info = getNextBlock(&data, "<JanusForumInfo>", "</JanusForumInfo>", seed);
	}

	//
	// заполнение результата
	//

	for (int group_index = 0; group_index < group_list.count(); group_index++)
	{
		AForumGroupInfo group_info;

		group_info.Group = group_list[group_index];

		for (int forum_index = 0; forum_index < forum_list.count(); forum_index++)
			if (forum_list[forum_index].IDGroup == group_info.Group.ID)
				group_info.Forums.append(forum_list[forum_index]);

		list.append(group_info);
	}

	//
	// добавление "мусорки"
	//

	/*
	AForumGroupInfo trash_group;

	trash_group.Group.ID        = 0;
	trash_group.Group.Name      = QString::fromUtf8("Корзина");
	trash_group.Group.SortOrder = 10000;

	AForumInfo trash_forum;

	trash_forum.ID        = 0;
	trash_forum.IDGroup   = 0;
	trash_forum.ShortName = "trash";
	trash_forum.Name      = QString::fromUtf8("Удаленные");
	trash_forum.Rated     = true;
	trash_forum.InTop     = true;
	trash_forum.RateLimit = 0;

	trash_group.Forums.append(trash_forum);

	list.append(trash_group);
	*/
}