本文整理汇总了C++中QWebElementCollection::append方法的典型用法代码示例。如果您正苦于以下问题:C++ QWebElementCollection::append方法的具体用法?C++ QWebElementCollection::append怎么用?C++ QWebElementCollection::append使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QWebElementCollection
的用法示例。
在下文中一共展示了QWebElementCollection::append方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: findElement
void ClickToFlash::findElement()
{
if (!loadButton_)
return;
QPoint objectPos = page_->view()->mapFromGlobal(loadButton_->mapToGlobal(loadButton_->pos()));
QWebFrame* objectFrame = page_->frameAt(objectPos);
QWebHitTestResult hitResult;
QWebElement hitElement;
if (objectFrame) {
hitResult = objectFrame->hitTestContent(objectPos);
hitElement = hitResult.element();
}
if (!hitElement.isNull() && (hitElement.tagName().compare("embed", Qt::CaseInsensitive) == 0 ||
hitElement.tagName().compare("object", Qt::CaseInsensitive) == 0)) {
element_ = hitElement;
return;
}
// HitTestResult failed, trying to find element by src
// attribute in elements at all frames on page (less accurate)
QList<QWebFrame*> frames;
frames.append(objectFrame);
frames.append(page_->mainFrame());
while (!frames.isEmpty()) {
QWebFrame* frame = frames.takeFirst();
if (!frame) {
continue;
}
QWebElement docElement = frame->documentElement();
QWebElementCollection elements;
elements.append(docElement.findAll(QLatin1String("embed")));
elements.append(docElement.findAll(QLatin1String("object")));
foreach (const QWebElement &element, elements) {
if (!checkElement(element) && !checkUrlOnElement(element)) {
continue;
}
element_ = element;
return;
}
frames += frame->childFrames();
}
}
示例2: showRSSInfo
void WebTab::showRSSInfo(const QPoint &pos)
{
QWebElementCollection col = page()->mainFrame()->findAllElements("link[type=\"application/rss+xml\"]");
col.append(page()->mainFrame()->findAllElements("link[type=\"application/atom+xml\"]"));
QMap<KUrl, QString> map;
foreach(const QWebElement &el, col)
{
QString urlString;
if (el.attribute("href").startsWith(QL1S("http")))
urlString = el.attribute("href");
else
{
KUrl u = url();
// NOTE
// cd() is probably better than setPath() here,
// for all those url sites just having a path
if (u.cd(el.attribute("href")))
urlString = u.toMimeDataString();
}
QString title = el.attribute("title");
if (title.isEmpty())
title = el.attribute("href");
map.insert(KUrl(urlString), title);
}
示例3: hasRSSInfo
bool WebTab::hasRSSInfo()
{
QWebElementCollection col = page()->mainFrame()->findAllElements("link[type=\"application/rss+xml\"]");
col.append(page()->mainFrame()->findAllElements("link[type=\"application/atom+xml\"]"));
if (col.count() != 0)
return true;
return false;
}
示例4: sipNoMethod
static PyObject *meth_QWebElementCollection_append(PyObject *sipSelf, PyObject *sipArgs)
{
PyObject *sipParseErr = NULL;
{
const QWebElementCollection * a0;
QWebElementCollection *sipCpp;
if (sipParseArgs(&sipParseErr, sipArgs, "BJ9", &sipSelf, sipType_QWebElementCollection, &sipCpp, sipType_QWebElementCollection, &a0))
{
Py_BEGIN_ALLOW_THREADS
sipCpp->append(*a0);
Py_END_ALLOW_THREADS
Py_INCREF(Py_None);
return Py_None;
}
}
/* Raise an exception if the arguments couldn't be parsed. */
sipNoMethod(sipParseErr, sipName_QWebElementCollection, sipName_append, NULL);
return NULL;
}
示例5: parseMarkdown
void tdRenderer::parseMarkdown(int at, int removed, int added)
{
QTextCursor cursor = m_editor->textCursor();
cursor.beginEditBlock();
int steps = m_editor->document()->availableUndoSteps();
bool undoStepsChanged = (steps != m_undoSteps);
m_undoSteps = steps;
if (undoStepsChanged && !m_isUndoRedo)
m_undoStack->push(new tdRendererCursorCommand(this, at, removed, added));
m_isUndoRedo = false;
int start;
int end;
if (m_sizes.isEmpty()) {
start = end = 0;
} else {
int i = 0, n = 0;
while (i < m_fframe)
n += m_sizes.at(i++);
start = n;
while (i <= m_lframe)
n += m_sizes.at(i++);
end = n;
}
int diff = added - removed;
m_count += diff;
if (m_sizes.isEmpty()) end = m_count;
else end += diff;
cursor.setPosition(start);
cursor.setPosition(qMin(end, m_count), QTextCursor::KeepAnchor);
int c = m_fframe;
int klass = 0;
QWebElementCollection collection;
while (c++ <= m_lframe && !m_sizes.isEmpty()) {
m_sizes.takeAt(m_fframe);
klass = m_indices.takeAt(m_fframe);
collection.append(m_body.findAll(".__" % QString::number(klass) % "__"));
}
QList<QWebElement> list = collection.toList();
QWebElement element;
if (klass) {
QString k = "__" % QString::number(klass) % "__";
element = list.last();
while (element.parent().hasClass(k))
element = element.parent();
list.removeAll(element);
element.setOuterXml("<div class=\"__tmp__\"></div>");
QList<QWebElement>::iterator i = list.begin();
for (; i != list.end(); ++i)
i->takeFromDocument();
} else {
m_body.prependInside("<div class=\"__tmp__\"></div>");
}
render(cursor.selection().toPlainText().toAscii());
cursor.endEditBlock();
updateFrameInterval();
emit parsingDone();
}
示例6: post
void AutoFillModel::post(const QNetworkRequest &request, const QByteArray &outgoingData)
{
//Dont save in private browsing
if (mApp->webSettings()->testAttribute(QWebSettings::PrivateBrowsingEnabled)) {
return;
}
m_lastOutgoingData = outgoingData;
QVariant v = request.attribute((QNetworkRequest::Attribute)(QNetworkRequest::User + 100));
WebPage* webPage = static_cast<WebPage*>(v.value<void*>());
if (!webPage) {
return;
}
WebView* webView = qobject_cast<WebView*>(webPage->view());
if (!webView) {
return;
}
v = request.attribute((QNetworkRequest::Attribute)(QNetworkRequest::User + 101));
QWebPage::NavigationType type = (QWebPage::NavigationType)v.toInt();
if (type != QWebPage::NavigationTypeFormSubmitted) {
return;
}
QString usernameName;
QString usernameValue;
QString passwordName;
QString passwordValue;
QUrl siteUrl = webPage->url();
if (!isStoringEnabled(siteUrl)) {
return;
}
QWebElementCollection allForms; // All form elements on page
QWebElement foundForm; // Sent form element
QList<QWebFrame*> frames;
frames.append(webPage->mainFrame()); // Find all form elements
while (!frames.isEmpty()) {
QWebFrame* frame = frames.takeFirst();
allForms.append(frame->findAllElements("form"));
frames += frame->childFrames();
}
foreach(const QWebElement & formElement, allForms) {
foreach(const QWebElement &inputElement, formElement.findAll("input[type=\"password\"]")) {
passwordName = inputElement.attribute("name");
passwordValue = getValueFromData(outgoingData, inputElement);
if (!passwordValue.isEmpty() && dataContains(outgoingData, passwordName)) {
foundForm = formElement;
break;
}
}
if (!foundForm.isNull()) {
break;
}
}
示例7: completePage
void AutoFillModel::completePage(WebPage* page)
{
if (!page) {
return;
}
QUrl pageUrl = page->url();
if (!isStored(pageUrl)) {
return;
}
QWebElementCollection inputs;
QList<QWebFrame*> frames;
frames.append(page->mainFrame());
while (!frames.isEmpty()) {
QWebFrame* frame = frames.takeFirst();
inputs.append(frame->findAllElements("input"));
frames += frame->childFrames();
}
QString server = pageUrl.host();
if (server.isEmpty()) {
server = pageUrl.toString();
}
QSqlQuery query;
query.prepare("SELECT data FROM autofill WHERE server=?");
query.addBindValue(server);
query.exec();
query.next();
QByteArray data = query.value(0).toByteArray();
if (data.isEmpty()) {
return;
}
// Why not to use encodedQueryItems = QByteArrays ?
// Because we need to filter "+" characters that must be spaces
// (not real "+" characters "%2B")
QueryItems arguments = QUrl::fromEncoded("http://bla.com/?" + data).queryItems();
for (int i = 0; i < arguments.count(); i++) {
QString key = arguments.at(i).first;
QString value = arguments.at(i).second;
key.replace("+", " ");
value.replace("+", " ");
key = QUrl::fromEncoded(key.toUtf8()).toString();
value = QUrl::fromEncoded(value.toUtf8()).toString();
for (int i = 0; i < inputs.count(); i++) {
QWebElement element = inputs.at(i);
if (element.attribute("type") != "text" && element.attribute("type") != "password" && element.attribute("type") != "") {
continue;
}
if (key == element.attribute("name")) {
element.setAttribute("value", value);
}
}
}
}
示例8: findElement
void ClickToFlash::findElement()
{
if (!m_toolButton) {
return;
}
QWidget* parent = parentWidget();
QWebView* view = 0;
while (parent) {
if (QWebView* aView = qobject_cast<QWebView*>(parent)) {
view = aView;
break;
}
parent = parent->parentWidget();
}
if (!view) {
return;
}
QPoint objectPos = view->mapFromGlobal(m_toolButton->mapToGlobal(m_toolButton->pos()));
QWebFrame* objectFrame = view->page()->frameAt(objectPos);
QWebHitTestResult hitResult;
QWebElement hitElement;
if (objectFrame) {
hitResult = objectFrame->hitTestContent(objectPos);
hitElement = hitResult.element();
}
if (!hitElement.isNull() && (hitElement.tagName().compare("embed", Qt::CaseInsensitive) == 0 ||
hitElement.tagName().compare("object", Qt::CaseInsensitive) == 0)) {
m_element = hitElement;
return;
}
// HitTestResult failed, trying to find element by src
// attribute in elements at all frames on page (less accurate)
QList<QWebFrame*> frames;
frames.append(objectFrame);
m_mainFrame = view->page()->mainFrame();
frames.append(m_mainFrame);
while (!frames.isEmpty()) {
QWebFrame* frame = frames.takeFirst();
if (!frame) {
continue;
}
QWebElement docElement = frame->documentElement();
QWebElementCollection elements;
elements.append(docElement.findAll(QLatin1String("embed")));
elements.append(docElement.findAll(QLatin1String("object")));
foreach(const QWebElement & element, elements) {
if (!checkElement(element) && !checkUrlOnElement(element)) {
continue;
}
m_element = element;
return;
}
frames += frame->childFrames();
}
}
示例9: makeElementBoxes
void DivBoxLevel::makeElementBoxes(
const QWebElement &document,
Ogre::Real scale,
std::vector<QString> tags,
Ogre::String meshName,
Ogre::SceneManager * sceneManager) {
DotSceneLoader* pDotSceneLoader = new DotSceneLoader();
pDotSceneLoader->parseDotScene("papercraft_man_line_running.scene",
"General", sceneManager, sceneManager->getRootSceneNode());
delete pDotSceneLoader;
Animation::Instance().animationStates.clear();
Animation::Instance().init(sceneManager, "arm_left");
Animation::Instance().init(sceneManager, "arm_right");
Animation::Instance().init(sceneManager, "chest");
Animation::Instance().init(sceneManager, "leg_left");
Animation::Instance().init(sceneManager, "leg_right");
Animation::Instance().init(sceneManager, "pants");
QWebElementCollection elements;
foreach(QString tag, tags)
elements.append(document.findAll(tag));
Ogre::Vector3 position = Ogre::Vector3(0.0, 1000.0, 0.0);
int elementCount = 0;
foreach(QWebElement element, elements) {
if (fits(&element, 10, 4096)) {
Ogre::String textureName =
"PageTex" + element.tagName().toStdString()
+ Ogre::StringConverter::toString(elementCount);
Box box;
box.width = element.geometry().width()*scale;
box.height = element.geometry().height()*scale;
box.sceneNode = sceneManager->createSceneNode(textureName);
element.setStyleProperty("background-color", "white");
Ogre::Entity* cube = sceneManager->createEntity(meshName);
makeOgreImage(&element, textureName);
Ogre::MaterialPtr material =
makeMaterial("PageMat" + Ogre::StringConverter::toString(position),
textureName, 1.3);
cube->getSubEntity(1)->setMaterial(material);
box.sceneNode->attachObject(cube);
box.sceneNode->setScale(box.width, box.height, box.width);
if (box.width > 50)
bigBoxes.push_back(box);
else if (box.width > 5)
smallBoxes.push_back(box);
elementCount++;
}
}
int smallBoxIndex = 0;
for (int i = 0; i < bigBoxes.size(); i++) {
CollisionActor* actor = simulation->terrainFactory->createActor()
->addPoint(bigBoxes[i].width, bigBoxes[i].height)
->addPoint(-bigBoxes[i].width, -bigBoxes[i].height)
->createCollisionShape(CollisionShape2::DEF_AABB);
if (i == 0) {
// FIRST PLANE-----------------------
actor->teleport(100.0, 100.0);
characterSceneNode = simulation->characterFactory->createActor()
->addPoint(4.0, 30.0)
->addPoint(-4.0, -10.0)
->createCollisionShape(CollisionShape2::DEF_CONVEX)
->teleport(100.0, bigBoxes[i].height * 2 + 200.0)
->sceneNode;
Ogre::SceneNode* sn = sceneManager->getSceneNode("Armature");
sceneManager->getRootSceneNode()->removeChild(sn);
characterSceneNode->addChild(sn);
sn->scale(0.4, 0.4, 0.4);
sn->translate(0, 10, 0);
sn->setOrientation(
Ogre::Quaternion(Ogre::Degree(90.0), Ogre::Vector3::UNIT_Y));
} else {
// FURTHER PLANES--------------------
float lX = bigBoxes[i - 1].sceneNode->_getDerivedPosition().x;
float lY = bigBoxes[i - 1].sceneNode->_getDerivedPosition().y;
float lW = bigBoxes[i - 1].width;
float lH = bigBoxes[i - 1].height;
float cX = bigBoxes[i].sceneNode->_getDerivedPosition().x;
float cY = bigBoxes[i].sceneNode->_getDerivedPosition().y;
float cW = bigBoxes[i].width;
float cH = bigBoxes[i].height;
if (cH - lH > 50.0 && smallBoxes.size() - 1 - smallBoxIndex > 1) {
// current is mutch higher then last
//.........这里部分代码省略.........