1
0
mirror of https://gitee.com/drabel/LibQQt.git synced 2025-01-04 10:18:44 +08:00

update GumboQuery Functions

This commit is contained in:
tianduanrui 2018-10-01 15:31:55 +08:00
parent 6c9d9628ed
commit 7d23162e6a
10 changed files with 98 additions and 44 deletions

View File

@ -1,6 +1,8 @@
# QQt Foundation Class
# QQt应用程序框架中间件
QQt Foundation Class简称LibQQt。
中文全名 ****QQt应用程序框架中间件****。
英文全名 ****QQt Application Framework Middleware****英文曾用名QQt Foundation Class。
英文简称 ****LibQQt****。
LibQQt为基于Qt开发的App提供中间问题处理层适配桌面、嵌入式以及Android、IOS的开发。
LibQQt为用户自动生成Library SDK主动帮助用户发布App和资源文件。
2018年1月LibQQt代码变更数量已达30万主要面向初、中、高级软件相关专业、有一定App开发经验的工程师。

Binary file not shown.

View File

@ -4,6 +4,11 @@
#include <QProcess>
#include <qqt-local.h>
/**
* @brief The QQtMPlayer class
* 使mplayer为后台播放视频文件
* e-linux全屏和窗口内切换的时候有一些条件
*/
class QQTSHARED_EXPORT QQtMPlayer : public QObject
{
Q_OBJECT

View File

@ -9,7 +9,7 @@
/*
* QQtWavSoundEffect = QSoundEffect + QSound +...
* QQtWavSoundEffect支持从wav获取声音并输出QSoundEffect+QSound
*
* QQtWavSoundEffect默认使用默认输出设备
*/
class QQTSHARED_EXPORT QQtWavSoundEffect : public QObject
{
@ -79,13 +79,15 @@ QQTSHARED_EXPORT QQtWavSoundEffect* QQtWavSound ( QString localFile = "" );
/**
* @brief The QQtAudioEffect class
*
*
* QSoundQSoundEffect是不能指定输出设备的
*
*
*
*
* QQt的wav文件的44头
* QQt的QQtAudioEffect目标支持多种格式的音效文件
*
*
* lame是编码器mpg123
*/

View File

@ -37,7 +37,7 @@ private:
void reset();
private:
protected:
GumboOutput* mpOutput;
};

View File

@ -94,6 +94,11 @@ std::string GumboQueryNode::text()
return GumboQueryUtil::nodeText ( mpNode );
}
std::vector<std::string> GumboQueryNode::textList()
{
return GumboQueryUtil::nodeTextList ( mpNode );
}
std::string GumboQueryNode::ownText()
{
return GumboQueryUtil::nodeOwnText ( mpNode );
@ -103,14 +108,14 @@ size_t GumboQueryNode::startPos()
{
switch ( mpNode->type )
{
case GUMBO_NODE_ELEMENT:
return mpNode->v.element.start_pos.offset + mpNode->v.element.original_tag.length;
case GUMBO_NODE_ELEMENT:
return mpNode->v.element.start_pos.offset + mpNode->v.element.original_tag.length;
case GUMBO_NODE_TEXT:
return mpNode->v.text.start_pos.offset;
case GUMBO_NODE_TEXT:
return mpNode->v.text.start_pos.offset;
default:
return 0;
default:
return 0;
}
}
@ -118,14 +123,14 @@ size_t GumboQueryNode::endPos()
{
switch ( mpNode->type )
{
case GUMBO_NODE_ELEMENT:
return mpNode->v.element.end_pos.offset;
case GUMBO_NODE_ELEMENT:
return mpNode->v.element.end_pos.offset;
case GUMBO_NODE_TEXT:
return mpNode->v.text.original_text.length + startPos();
case GUMBO_NODE_TEXT:
return mpNode->v.text.original_text.length + startPos();
default:
return 0;
default:
return 0;
}
}
@ -133,14 +138,14 @@ size_t GumboQueryNode::startPosOuter()
{
switch ( mpNode->type )
{
case GUMBO_NODE_ELEMENT:
return mpNode->v.element.start_pos.offset;
case GUMBO_NODE_ELEMENT:
return mpNode->v.element.start_pos.offset;
case GUMBO_NODE_TEXT:
return mpNode->v.text.start_pos.offset;
case GUMBO_NODE_TEXT:
return mpNode->v.text.start_pos.offset;
default:
return 0;
default:
return 0;
}
}
@ -148,14 +153,14 @@ size_t GumboQueryNode::endPosOuter()
{
switch ( mpNode->type )
{
case GUMBO_NODE_ELEMENT:
return mpNode->v.element.end_pos.offset + mpNode->v.element.original_end_tag.length;
case GUMBO_NODE_ELEMENT:
return mpNode->v.element.end_pos.offset + mpNode->v.element.original_end_tag.length;
case GUMBO_NODE_TEXT:
return mpNode->v.text.original_text.length + startPos();
case GUMBO_NODE_TEXT:
return mpNode->v.text.original_text.length + startPos();
default:
return 0;
default:
return 0;
}
}

View File

@ -18,6 +18,7 @@
#include <gumbo.h>
#include <string>
#include <vector>
#include "GumboQueryLocal.h"
class GumboQuerySelection;
@ -48,6 +49,8 @@ public:
std::string text();
std::vector<std::string> textList();
std::string ownText();
size_t startPos();
@ -62,7 +65,7 @@ public:
GumboQuerySelection find ( std::string aSelector );
private:
protected:
GumboNode* mpNode;
};

View File

@ -43,7 +43,7 @@ public:
size_t nodeNum();
private:
protected:
std::vector<GumboNode*> mNodes;
};

View File

@ -71,6 +71,13 @@ std::string GumboQueryUtil::nodeText ( GumboNode* apNode )
return text;
}
std::vector<std::string> GumboQueryUtil::nodeTextList ( GumboNode* apNode )
{
std::vector<std::string> textList;
writeNodeTextList ( apNode, textList );
return textList;
}
std::string GumboQueryUtil::nodeOwnText ( GumboNode* apNode )
{
std::string text;
@ -99,25 +106,51 @@ void GumboQueryUtil::writeNodeText ( GumboNode* apNode, std::string& aText )
{
switch ( apNode->type )
{
case GUMBO_NODE_TEXT:
aText.append ( apNode->v.text.text );
break;
case GUMBO_NODE_TEXT:
aText.append ( apNode->v.text.text );
break;
case GUMBO_NODE_ELEMENT:
{
GumboVector children = apNode->v.element.children;
for ( unsigned int i = 0; i < children.length; i++ )
case GUMBO_NODE_ELEMENT:
{
GumboNode* child = ( GumboNode* ) children.data[i];
writeNodeText ( child, aText );
GumboVector children = apNode->v.element.children;
for ( unsigned int i = 0; i < children.length; i++ )
{
GumboNode* child = ( GumboNode* ) children.data[i];
writeNodeText ( child, aText );
}
break;
}
break;
default:
break;
}
}
default:
break;
void GumboQueryUtil::writeNodeTextList ( GumboNode* apNode, std::vector<std::string>& aTextList )
{
switch ( apNode->type )
{
case GUMBO_NODE_TEXT:
aTextList.push_back ( apNode->v.text.text );
break;
case GUMBO_NODE_ELEMENT:
{
GumboVector children = apNode->v.element.children;
for ( unsigned int i = 0; i < children.length; i++ )
{
GumboNode* child = ( GumboNode* ) children.data[i];
writeNodeTextList ( child, aTextList );
}
break;
}
default:
break;
}
}

View File

@ -34,12 +34,16 @@ public:
static std::string nodeText ( GumboNode* apNode );
static std::vector<std::string> nodeTextList ( GumboNode* apNode );
static std::string nodeOwnText ( GumboNode* apNode );
private:
static void writeNodeText ( GumboNode* apNode, std::string& aText );
static void writeNodeTextList ( GumboNode* apNode, std::vector<std::string>& aTextList );
};