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:
parent
6c9d9628ed
commit
7d23162e6a
@ -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.
@ -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
|
||||
|
@ -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
|
||||
* 未实现
|
||||
*
|
||||
* QSound、QSoundEffect是不能指定输出设备的。
|
||||
* 用于播放音效文件,接受指定输出设备。
|
||||
* 用于播放多种格式的音效文件,接收指定输出设备。
|
||||
*
|
||||
* 请不要用来播放大文件,会全部读入内存,然后逐渐删除。
|
||||
* 尝试用QQt的,需要切掉wav文件的44头。
|
||||
* 现在更新为用QQt的,QQtAudioEffect目标支持多种格式的音效文件。
|
||||
* 未实现
|
||||
*
|
||||
* lame是编码器,解码器用mpg123
|
||||
*/
|
||||
|
@ -37,7 +37,7 @@ private:
|
||||
|
||||
void reset();
|
||||
|
||||
private:
|
||||
protected:
|
||||
|
||||
GumboOutput* mpOutput;
|
||||
};
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
};
|
||||
|
@ -43,7 +43,7 @@ public:
|
||||
|
||||
size_t nodeNum();
|
||||
|
||||
private:
|
||||
protected:
|
||||
|
||||
std::vector<GumboNode*> mNodes;
|
||||
};
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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 );
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user