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

fix linux qt4 build

This commit is contained in:
tianduanrui 2017-11-22 19:22:53 +08:00
parent 70cd411dc2
commit 858c8c89d5
16 changed files with 1512 additions and 1503 deletions

10
QQt.pro
View File

@ -1,8 +1,7 @@
TEMPLATE = subdirs
CONFIG += ordered
SUBDIRS = src/qqt.pro \
examples/qqthttpdownload
SUBDIRS = src/qqt.pro
#-----------------------------------------------------------------
#basic example
@ -20,10 +19,11 @@ SUBDIRS += examples/animationframe
SUBDIRS += examples/exquisite
SUBDIRS += examples/tabwidgetexamples
SUBDIRS += examples/qrcodeexample
SUBDIRS += examples/qqtnetworkexample
greaterThan(QT_MAJOR_VERSION , 4):SUBDIRS += examples/qqtnetworkexample
SUBDIRS += examples/QtBuildTool
SUBDIRS += examples/QtSdkManager
SUBDIRS += examples/QQtInstaller
greaterThan(QT_MAJOR_VERSION, 4):SUBDIRS += examples/qqthttpdownload
#can't support ios
SUBDIRS += examples/qqtprintsupportexample
@ -58,14 +58,12 @@ SUBDIRS += examples/soapQQtOnline
#need webwork - WebSupport
#-----------------------------------------------------------------
SUBDIRS += examples/qqtftpclient
SUBDIRS += examples/qqthttpdownload
#-----------------------------------------------------------------
#some example project
#maybe demo
#-----------------------------------------------------------------
SUBDIRS += demo/VegeTablesPrice
greaterThan(QT_MAJOR_VERSION , 4):SUBDIRS += demo/VegeTablesPrice
SUBDIRS += demo/cmdwidget
#-----------------------------------------------------------------

View File

@ -33,7 +33,7 @@
- QQtSerialPort 兼容QSerialPort and QextSerialPort
- QQtSocketTcpClient、QQtSocketTcpServer、QQtSocketUdpClient、QQtSocketUdpServer
- QQtBluetoothSocket +QQtBluetoothManager
- QQtWebProtocolManager支持http、ftp等主流协议高并发传输。
- QQtWebAccessManager支持http、ftp等主流协议高并发传输。
- QQtWebSocket接口
- 协议虚类(接口类) QQtProtocol QQtWebSocketProtocol
- 报文虚类(接口类) QQtMessage

View File

@ -14,7 +14,7 @@ MainWindow::MainWindow ( QWidget* parent ) :
//ui->b0->setFixedHeight ( 50 );
//ui->b1->setFixedHeight ( 50 );
m_client = new QQtWebProtocolManager ( this );
m_client = new QQtWebAccessManager ( this );
connect ( m_client, SIGNAL ( replyFinished ( QNetworkReply* ) ),
this, SLOT ( replyFinished ( QNetworkReply* ) ) );

View File

@ -36,7 +36,7 @@ private slots:
private:
Ui::MainWindow* ui;
QQtWebProtocolManager* m_client;
QQtWebAccessManager* m_client;
QMap<QString, QString> m_mapVege;
QBarSet* m_barSet0;
QBarSet* m_barSet1;

View File

@ -3,7 +3,24 @@
# Project created by QtCreator 2016-09-30T09:34:03
#
#-------------------------------------------------
include(../qqtframe2/link_qqt_library.pri)
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = cmdwidget
TEMPLATE = app
SOURCES += main.cpp\
cmdwidget.cpp \
rlineedit.cpp
HEADERS += cmdwidget.h \
rlineedit.h
FORMS += cmdwidget.ui
include($$PWD/../../examples/qqtframe2/link_qqt_library.pri)
############
##install
@ -31,19 +48,3 @@ equals(QKIT_PRIVATE, ANDROID) {
message ($${TARGET} config $${CONFIG})
message ($${TARGET} define $${DEFINES})
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = cmdwidget
TEMPLATE = app
SOURCES += main.cpp\
cmdwidget.cpp \
rlineedit.cpp
HEADERS += cmdwidget.h \
rlineedit.h
FORMS += cmdwidget.ui

View File

@ -1,6 +1,6 @@
#include "qqthttpdownloadprotocol.h"
QQtHttpDownloadProtocol::QQtHttpDownloadProtocol ( QObject* parent ) : QQtWebSocketProtocol ( parent )
QQtHttpDownloadProtocol::QQtHttpDownloadProtocol(QObject* parent) : QQtWebAccessManager(parent)
{
}

View File

@ -1,25 +1,25 @@
#ifndef QQTHTTPDOWNLOADPROTOCOL_H
#define QQTHTTPDOWNLOADPROTOCOL_H
#include <qqtwebsocketprotocol.h>
#include <qqtwebprotocolmanager.h>
#include <qqtwebaccessmanager.h>
class QQtHttpDownloadWebWorkSession: public QQtWebWorkSession
class QQtHttpDownloadWebWorkSession: public QQtWebAccessSession
{
Q_OBJECT
public:
explicit QQtHttpDownloadWebWorkSession ( QObject* parent = 0 ) : QQtWebWorkSession ( parent ) {}
explicit QQtHttpDownloadWebWorkSession(QObject* parent = 0) : QQtWebAccessSession(parent) {}
virtual ~QQtHttpDownloadWebWorkSession() {}
};
class QQtHttpDownloadProtocol : public QQtWebSocketProtocol
class QQtHttpDownloadProtocol : public QQtWebAccessManager
{
Q_OBJECT
public:
explicit QQtHttpDownloadProtocol ( QObject* parent = nullptr );
explicit QQtHttpDownloadProtocol(QObject* parent = nullptr);
virtual ~QQtHttpDownloadProtocol() {}
void sendRequstUrl ( QString& url ) {
void sendRequstUrl(QString& url)
{
m_url = url;
}

View File

@ -2,16 +2,18 @@
#define QQTCHART_H
#include <QWidget>
#include <qqtcore.h>
#include <qqt-local.h>
class QQtChart : public QWidget
class QQTSHARED_EXPORT QQtChart : public QWidget
{
Q_OBJECT
public:
explicit QQtChart(QWidget *parent = nullptr);
explicit QQtChart(QWidget* parent = nullptr);
signals:
public slots:
};
#endif // QQTCHART_H
#endif // QQTCHART_H

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,183 @@
#include "qqtwebaccessmanager.h"
#include "qqtcore.h"
QQtWebAccessManager::QQtWebAccessManager(QObject* parent) : QNetworkAccessManager(parent)
{
m_listWebWorkSession.clear();
connect(this, SIGNAL(finished(QNetworkReply*)),
this, SLOT(finished(QNetworkReply*)));
connect(this, SIGNAL(finished(QNetworkReply*)),
this, SIGNAL(replyFinished(QNetworkReply*)));
connect(this, SIGNAL(authenticationRequired(QNetworkReply*, QAuthenticator*)),
this, SLOT(authenticationRequired(QNetworkReply*, QAuthenticator*)));
connect(this, SIGNAL(proxyAuthenticationRequired(QNetworkProxy, QAuthenticator*)),
this, SLOT(proxyAuthenticationRequired(QNetworkProxy, QAuthenticator*)));
connect(this, SIGNAL(sslErrors(QNetworkReply*, QList<QSslError>)),
this, SLOT(sslErrors(QNetworkReply*, QList<QSslError>)));
connect(this, SIGNAL(networkAccessibleChanged(QNetworkAccessManager::NetworkAccessibility)),
this, SLOT(networkAccessibleChanged(QNetworkAccessManager::NetworkAccessibility)));
connect(this, SIGNAL(networkSessionConnected()),
this, SLOT(networkSessionConnected()));
}
void QQtWebAccessManager::sendGetRequest(QString& strUrl)
{
QQtWebAccessSession* s0 = new QQtWebAccessSession(this);
s0->m_strUrl = strUrl;
s0->m_pTimer = new QTimer(this);
s0->m_pTimer->setSingleShot(true);
s0->m_pTimer->setInterval(10000);
connect(s0->m_pTimer, SIGNAL(timeout()),
this, SLOT(localReplyTimeOut())); //超时信号
QNetworkRequest netRequest;
netRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
netRequest.setUrl(QUrl(strUrl)); //地址信息
if (strUrl.toLower().startsWith("https")) //https请求需ssl支持(下载openssl拷贝libeay32.dll和ssleay32.dll文件至Qt bin目录或程序运行目录)
{
QSslConfiguration sslConfig;
sslConfig.setPeerVerifyMode(QSslSocket::VerifyNone);
sslConfig.setProtocol(QSsl::TlsV1_1);
netRequest.setSslConfiguration(sslConfig);
}
s0->m_pNetworkReply = get(netRequest); //发起get请求
m_listWebWorkSession.push_back(s0);
/*下面关联信号和槽*/
/*下载完成后开始一阵一阵堆取数据*/
connect(s0->m_pNetworkReply, SIGNAL(readyRead()),
this, SLOT(localReadyRead()));
/*有可用数据时 */
connect(s0->m_pNetworkReply, SIGNAL(downloadProgress(qint64, qint64)),
this, SLOT(localUpdateDownloadProgress(qint64, qint64)));
connect(s0->m_pNetworkReply, SIGNAL(uploadProgress(qint64, qint64)),
this, SLOT(localUpdateUploadProgress(qint64, qint64)));
//ignore
// connect ( s0->m_pNetworkReply, SIGNAL ( finished() ),
// this, SLOT ( finished(QNetworkReply*); ) ); //请求完成信号
s0->m_pTimer->start();
}
void QQtWebAccessManager::sendPostRequest(QString& strUrl)
{
//post
// QString strBody; //http body部分可封装参数信息
// QByteArray contentByteArray = strBody.toLatin1();//转成二进制
// m_pNetworkReply = m_pNetworkManager->post(netRequest,contentByteArray);//发起post请求
}
void QQtWebAccessManager::finished(QNetworkReply* reply)
{
pline() << reply;
//clear resource
QQtWebAccessSession* s0 = NULL;
QListIterator<QQtWebAccessSession*> itor(m_listWebWorkSession);
while (itor.hasNext())
{
QQtWebAccessSession* s1 = itor.next();
if (s1->m_pNetworkReply == reply)
{
s0 = s1;
break;
}
}
if (!s0)
return;
pline() << s0->m_pNetworkReply << s0->m_pTimer;
s0->m_pTimer->stop();
s0->m_pNetworkReply->deleteLater();
m_listWebWorkSession.removeOne(s0);
}
void QQtWebAccessManager::authenticationRequired(QNetworkReply* r, QAuthenticator* a)
{
pline() << r << a;
}
void QQtWebAccessManager::proxyAuthenticationRequired(QNetworkProxy p, QAuthenticator* a)
{
pline() << p.hostName() << a;
}
void QQtWebAccessManager::sslErrors(QNetworkReply* r, QList<QSslError> e)
{
pline() << r << e.size();
}
void QQtWebAccessManager::networkAccessibleChanged(QNetworkAccessManager::NetworkAccessibility a)
{
pline() << a;
}
void QQtWebAccessManager::networkSessionConnected()
{
pline();
}
void QQtWebAccessManager::localReplyTimeOut()
{
QTimer* obj = (QTimer*) sender();
pline() << obj;
QQtWebAccessSession* s0 = NULL;
QListIterator<QQtWebAccessSession*> itor(m_listWebWorkSession);
while (itor.hasNext())
{
QQtWebAccessSession* s1 = itor.next();
if (s1->m_pTimer == obj)
{
s0 = s1;
break;
}
}
if (!s0)
return;
emit replyTimeOut(s0->m_pNetworkReply); //请求失败
s0->m_pNetworkReply->deleteLater();
}
void QQtWebAccessManager::localReadyRead()
{
QNetworkReply* obj = (QNetworkReply*) sender();
pline() << obj;
emit readyRead(obj);
}
void QQtWebAccessManager::localUpdateUploadProgress(qint64 bytesSent, qint64 bytesTotal)
{
QNetworkReply* obj = (QNetworkReply*) sender();
pline() << obj;
emit updateUploadProgress(obj, bytesSent, bytesTotal);
}
void QQtWebAccessManager::localUpdateDownloadProgress(qint64 bytesReceived, qint64 bytesTotal)
{
QNetworkReply* obj = (QNetworkReply*) sender();
pline() << obj;
emit updateDownloadProgress(obj, bytesReceived, bytesTotal);
}

View File

@ -0,0 +1,78 @@
#ifndef QQTWEBWORKCLIENT_H
#define QQTWEBWORKCLIENT_H
#include <QNetworkAccessManager>
#include <QNetworkReply>
//import this struct will not build fail
#include <QNetworkProxy>
#include <QSslError>
#include <qqt-qt.h>
#include <qqt-local.h>
#include <qqtcore.h>
class QQTSHARED_EXPORT QQtWebAccessSession : public QObject
{
Q_OBJECT
public:
explicit QQtWebAccessSession(QObject* parent = 0) :
QObject(parent) {}
virtual ~QQtWebAccessSession() {}
QNetworkReply* m_pNetworkReply; //封装请求返回信息
QTimer* m_pTimer; //请求超时计时器
QString m_strUrl; //记录当前请求的url
/**
* @brief m_sessionName
* talk with whom, which protocol, req content, all represented by this name;
*/
QString m_sessionName;
} ;
/**
* @brief The QQtWebworkClient class
* One Ftp Http ...
* Multi QNetworkAccessManager
* Multi New Protocol QWebSocket
* need ssl
* Qt team supportedSchemes
*/
class QQTSHARED_EXPORT QQtWebAccessManager : public QNetworkAccessManager
{
Q_OBJECT
public:
explicit QQtWebAccessManager(QObject* parent = 0);
QNetworkReply* getReplyHandler(QString& strUrl) {}
void sendGetRequest(QString& strUrl);
void sendPostRequest(QString& strUrl);
signals:
void updateUploadProgress(QNetworkReply* reply, qint64 bytesSent, qint64 bytesTotal);
void updateDownloadProgress(QNetworkReply* reply, qint64 bytesReceived, qint64 bytesTotal);
//reply->readAll but maybe not all data once
void readyRead(QNetworkReply* reply);
//reply->readAll all data once in theory
void replyFinished(QNetworkReply* reply);
void replyTimeOut(QNetworkReply* reply);
public slots:
private slots:
void finished(QNetworkReply* reply);
void authenticationRequired(QNetworkReply*, QAuthenticator*);
void proxyAuthenticationRequired(QNetworkProxy, QAuthenticator*);
void sslErrors(QNetworkReply*, QList<QSslError>);
void networkAccessibleChanged(QNetworkAccessManager::NetworkAccessibility);
void networkSessionConnected();
void localReplyTimeOut();
void localReadyRead();
void localUpdateUploadProgress(qint64 bytesSent, qint64 bytesTotal);
void localUpdateDownloadProgress(qint64 bytesReceived, qint64 bytesTotal);
private:
QList<QQtWebAccessSession*> m_listWebWorkSession;
};
#endif // QQTWEBWORKCLIENT_H

View File

@ -1,183 +0,0 @@
#include "qqtwebprotocolmanager.h"
#include "qqtcore.h"
QQtWebProtocolManager::QQtWebProtocolManager ( QObject* parent ) : QNetworkAccessManager ( parent )
{
m_listWebWorkSession.clear();
connect ( this, SIGNAL ( finished ( QNetworkReply* ) ),
this, SLOT ( finished ( QNetworkReply* ) ) );
connect ( this, SIGNAL ( finished ( QNetworkReply* ) ),
this, SIGNAL ( replyFinished ( QNetworkReply* ) ) );
connect ( this, SIGNAL ( authenticationRequired ( QNetworkReply*, QAuthenticator* ) ),
this, SLOT ( authenticationRequired ( QNetworkReply*, QAuthenticator* ) ) );
connect ( this, SIGNAL ( proxyAuthenticationRequired ( QNetworkProxy, QAuthenticator* ) ),
this, SLOT ( proxyAuthenticationRequired ( QNetworkProxy, QAuthenticator* ) ) );
connect ( this, SIGNAL ( sslErrors ( QNetworkReply*, QList<QSslError> ) ),
this, SLOT ( sslErrors ( QNetworkReply*, QList<QSslError> ) ) );
connect ( this, SIGNAL ( networkAccessibleChanged ( QNetworkAccessManager::NetworkAccessibility ) ),
this, SLOT ( networkAccessibleChanged ( QNetworkAccessManager::NetworkAccessibility ) ) );
connect ( this, SIGNAL ( networkSessionConnected() ),
this, SLOT ( networkSessionConnected() ) );
}
void QQtWebProtocolManager::sendGetRequest ( QString& strUrl )
{
QQtWebWorkSession* s0 = new QQtWebWorkSession ( this );
s0->m_strUrl = strUrl;
s0->m_pTimer = new QTimer ( this );
s0->m_pTimer->setSingleShot ( true );
s0->m_pTimer->setInterval ( 10000 );
connect ( s0->m_pTimer, SIGNAL ( timeout() ),
this, SLOT ( localReplyTimeOut() ) ); //超时信号
QNetworkRequest netRequest;
netRequest.setHeader ( QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded" );
netRequest.setUrl ( QUrl ( strUrl ) ); //地址信息
if ( strUrl.toLower().startsWith ( "https" ) ) //https请求需ssl支持(下载openssl拷贝libeay32.dll和ssleay32.dll文件至Qt bin目录或程序运行目录)
{
QSslConfiguration sslConfig;
sslConfig.setPeerVerifyMode ( QSslSocket::VerifyNone );
sslConfig.setProtocol ( QSsl::TlsV1_1 );
netRequest.setSslConfiguration ( sslConfig );
}
s0->m_pNetworkReply = get ( netRequest ); //发起get请求
m_listWebWorkSession.push_back ( s0 );
/*下面关联信号和槽*/
/*下载完成后开始一阵一阵堆取数据*/
connect ( s0->m_pNetworkReply, SIGNAL ( readyRead() ),
this, SLOT ( localReadyRead() ) );
/*有可用数据时 */
connect ( s0->m_pNetworkReply, SIGNAL ( downloadProgress ( qint64, qint64 ) ),
this, SLOT ( localUpdateDownloadProgress ( qint64, qint64 ) ) );
connect ( s0->m_pNetworkReply, SIGNAL ( uploadProgress ( qint64, qint64 ) ),
this, SLOT ( localUpdateUploadProgress ( qint64, qint64 ) ) );
//ignore
// connect ( s0->m_pNetworkReply, SIGNAL ( finished() ),
// this, SLOT ( finished(QNetworkReply*); ) ); //请求完成信号
s0->m_pTimer->start ( );
}
void QQtWebProtocolManager::sendPostRequest ( QString& strUrl )
{
//post
// QString strBody; //http body部分可封装参数信息
// QByteArray contentByteArray = strBody.toLatin1();//转成二进制
// m_pNetworkReply = m_pNetworkManager->post(netRequest,contentByteArray);//发起post请求
}
void QQtWebProtocolManager::finished ( QNetworkReply* reply )
{
pline() << reply;
//clear resource
QQtWebWorkSession* s0 = NULL;
QListIterator<QQtWebWorkSession*> itor ( m_listWebWorkSession );
while ( itor.hasNext() )
{
QQtWebWorkSession* s1 = itor.next();
if ( s1->m_pNetworkReply == reply )
{
s0 = s1;
break;
}
}
if ( !s0 )
return;
pline() << s0->m_pNetworkReply << s0->m_pTimer;
s0->m_pTimer->stop();
s0->m_pNetworkReply->deleteLater();
m_listWebWorkSession.removeOne ( s0 );
}
void QQtWebProtocolManager::authenticationRequired ( QNetworkReply* r, QAuthenticator* a )
{
pline() << r << a;
}
void QQtWebProtocolManager::proxyAuthenticationRequired ( QNetworkProxy p, QAuthenticator* a )
{
pline() << p.hostName() << a;
}
void QQtWebProtocolManager::sslErrors ( QNetworkReply* r, QList<QSslError> e )
{
pline() << r << e.size();
}
void QQtWebProtocolManager::networkAccessibleChanged ( QNetworkAccessManager::NetworkAccessibility a )
{
pline() << a;
}
void QQtWebProtocolManager::networkSessionConnected()
{
pline();
}
void QQtWebProtocolManager::localReplyTimeOut()
{
QTimer* obj = ( QTimer* ) sender();
pline() << obj;
QQtWebWorkSession* s0 = NULL;
QListIterator<QQtWebWorkSession*> itor ( m_listWebWorkSession );
while ( itor.hasNext() )
{
QQtWebWorkSession* s1 = itor.next();
if ( s1->m_pTimer == obj )
{
s0 = s1;
break;
}
}
if ( !s0 )
return;
emit replyTimeOut ( s0->m_pNetworkReply ); //请求失败
s0->m_pNetworkReply->deleteLater();
}
void QQtWebProtocolManager::localReadyRead()
{
QNetworkReply* obj = ( QNetworkReply* ) sender();
pline() << obj;
emit readyRead ( obj );
}
void QQtWebProtocolManager::localUpdateUploadProgress ( qint64 bytesSent, qint64 bytesTotal )
{
QNetworkReply* obj = ( QNetworkReply* ) sender();
pline() << obj;
emit updateUploadProgress ( obj, bytesSent, bytesTotal );
}
void QQtWebProtocolManager::localUpdateDownloadProgress ( qint64 bytesReceived, qint64 bytesTotal )
{
QNetworkReply* obj = ( QNetworkReply* ) sender();
pline() << obj;
emit updateDownloadProgress ( obj, bytesReceived, bytesTotal );
}

View File

@ -1,80 +0,0 @@
#ifndef QQTWEBWORKCLIENT_H
#define QQTWEBWORKCLIENT_H
#include <QNetworkAccessManager>
#include <QNetworkReply>
//import this struct will not build fail
#include <QNetworkProxy>
#include <QSslError>
#include <qqt-qt.h>
#include <qqt-local.h>
/**
* @brief The QQtWebworkClient class
* One Ftp Http ...
* Multi QNetworkAccessManager
* Multi New Protocol QWebSocket
* need ssl
* Qt team supportedSchemes
*/
class QQtWebWorkSession;
class QQTSHARED_EXPORT QQtWebProtocolManager : public QNetworkAccessManager
{
Q_OBJECT
public:
explicit QQtWebProtocolManager ( QObject* parent = 0 );
QNetworkReply* getReplyHandler ( QString& strUrl ) {}
void sendGetRequest ( QString& strUrl );
void sendPostRequest ( QString& strUrl );
signals:
void updateUploadProgress ( QNetworkReply* reply, qint64 bytesSent, qint64 bytesTotal );
void updateDownloadProgress ( QNetworkReply* reply, qint64 bytesReceived, qint64 bytesTotal );
//reply->readAll but maybe not all data once
void readyRead ( QNetworkReply* reply );
//reply->readAll all data once in theory
void replyFinished ( QNetworkReply* reply );
void replyTimeOut ( QNetworkReply* reply );
public slots:
private slots:
void finished ( QNetworkReply* reply );
void authenticationRequired ( QNetworkReply*, QAuthenticator* );
void proxyAuthenticationRequired ( QNetworkProxy, QAuthenticator* );
void sslErrors ( QNetworkReply*, QList<QSslError> );
void networkAccessibleChanged ( QNetworkAccessManager::NetworkAccessibility );
void networkSessionConnected();
void localReplyTimeOut();
void localReadyRead();
void localUpdateUploadProgress ( qint64 bytesSent, qint64 bytesTotal );
void localUpdateDownloadProgress ( qint64 bytesReceived, qint64 bytesTotal );
private:
QList<QQtWebWorkSession*> m_listWebWorkSession;
};
class QQtWebWorkSession : public QObject
{
Q_OBJECT
public:
explicit QQtWebWorkSession ( QObject* parent ) :
QObject ( parent ) {}
virtual ~QQtWebWorkSession() {}
QNetworkReply* m_pNetworkReply; //封装请求返回信息
QTimer* m_pTimer; //请求超时计时器
QString m_strUrl; //记录当前请求的url
/**
* @brief m_sessionName
* talk with whom, which protocol, req content, all represented by this name;
*/
QString m_sessionName;
} ;
#endif // QQTWEBWORKCLIENT_H

View File

@ -183,9 +183,9 @@ DEFINES += __WEBSERVICESUPPORT__
#One Ftp Http 单工...
#Multi 半双工(客户端并发,服务器序列) QNetworkAccessManager
#if you use QNetworkAccessManagerSupport , open this annotation
DEFINES += __WEBPROTOCOLSUPPORT__
lessThan(QT_MAJOR_VERSION, 5): DEFINES -= __WEBPROTOCOLSUPPORT__
contains (DEFINES, __WEBPROTOCOLSUPPORT__) {
DEFINES += __WEBACCESSSUPPORT__
lessThan(QT_MAJOR_VERSION, 5): DEFINES -= __WEBACCESSSUPPORT__
contains (DEFINES, __WEBACCESSSUPPORT__) {
#QSslError not found, you need recompiler Qt4
#TODO: QT += webkit
}
@ -203,6 +203,7 @@ contains (DEFINES, __WEBSOCKETSUPPORT__) {
##################Charts Module###############################
#if you use QQtCharts, open this annotation
DEFINES += __QQTCHARTS__
lessThan(QT_MAJOR_VERSION, 5):DEFINES-=__QQTCHARTS__
#based on QtCharts, need charts module
contains(DEFINES, __QQTCHARTS__) {
QT += charts

View File

@ -252,11 +252,12 @@ contains(DEFINES, __WEBSERVICESUPPORT__) {
HEADERS += \
$$PWD/network/soap/qtsoap.h
}
contains (DEFINES, __WEBPROTOCOLSUPPORT__) {
#webaccess manager
contains (DEFINES, __WEBACCESSSUPPORT__) {
SOURCES += \
$$PWD/network/qqtwebprotocolmanager.cpp
$$PWD/network/qqtwebaccessmanager.cpp
HEADERS += \
$$PWD/network/qqtwebprotocolmanager.h
$$PWD/network/qqtwebaccessmanager.h
}
contains (DEFINES, __WEBSOCKETSUPPORT__) {

View File

@ -4,42 +4,45 @@
#include <GumboQuerySelection.h>
#include <GumboQueryNode.h>
#include "stdlib.h"
#include "stdio.h"
void test_parser()
{
std::string page ( "<h1><a>wrong link</a><a class=\"special\"\\>some link</a></h1>" );
std::string page("<h1><a>wrong link</a><a class=\"special\"\\>some link</a></h1>");
GumboQueryDocument doc;
doc.parse ( page.c_str() );
doc.parse(page.c_str());
GumboQuerySelection c = doc.find ( "h1 a.special" );
GumboQueryNode node = c.nodeAt ( 0 );
printf ( "Node: %s\n", node.text().c_str() );
std::string content = page.substr ( node.startPos(), node.endPos() - node.startPos() );
printf ( "Node: %s\n", content.c_str() );
GumboQuerySelection c = doc.find("h1 a.special");
GumboQueryNode node = c.nodeAt(0);
printf("Node: %s\n", node.text().c_str());
std::string content = page.substr(node.startPos(), node.endPos() - node.startPos());
printf("Node: %s\n", content.c_str());
}
void test_html()
{
std::string page = "<html><div><span>1\n</span>2\n</div></html>";
GumboQueryDocument doc;
doc.parse ( page.c_str() );
GumboQueryNode pNode = doc.find ( "div" ).nodeAt ( 0 );
std::string content = page.substr ( pNode.startPos(), pNode.endPos() - pNode.startPos() );
printf ( "Node: #%s#\n", content.c_str() );
doc.parse(page.c_str());
GumboQueryNode pNode = doc.find("div").nodeAt(0);
std::string content = page.substr(pNode.startPos(), pNode.endPos() - pNode.startPos());
printf("Node: #%s#\n", content.c_str());
}
void test_escape()
{
std::string page = "<html><div><span id=\"that's\">1\n</span>2\n</div></html>";
GumboQueryDocument doc;
doc.parse ( page.c_str() );
GumboQueryNode pNode = doc.find ( "span[id=\"that's\"]" ).nodeAt ( 0 );
std::string content = page.substr ( pNode.startPos(), pNode.endPos() - pNode.startPos() );
printf ( "Node: #%s#\n", content.c_str() );
doc.parse(page.c_str());
GumboQueryNode pNode = doc.find("span[id=\"that's\"]").nodeAt(0);
std::string content = page.substr(pNode.startPos(), pNode.endPos() - pNode.startPos());
printf("Node: #%s#\n", content.c_str());
}
int main ( int argc, char* argv[] )
int main(int argc, char* argv[])
{
QCoreApplication a ( argc, argv );
QCoreApplication a(argc, argv);
test_parser();
test_html();
test_escape();