当前位置: 首页>>代码示例>>C++>>正文


C++ QWebElement::attribute方法代码示例

本文整理汇总了C++中QWebElement::attribute方法的典型用法代码示例。如果您正苦于以下问题:C++ QWebElement::attribute方法的具体用法?C++ QWebElement::attribute怎么用?C++ QWebElement::attribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QWebElement的用法示例。


在下文中一共展示了QWebElement::attribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: onContextMenu

bool HistoryChatView::onContextMenu(ChatView *view, QMenu *menu, const QWebHitTestResult &result)
{
  ChatId id(view->id());
  if (id.type() != ChatId::ChannelId && id.type() != ChatId::UserId)
    return false;

  const QWebElement block = result.enclosingBlockElement();
  if (!block.hasClass("blocks") || block.hasClass("removed"))
    return false;

  const QWebElement container = block.parent();
  const qint64 mdate          = container.attribute(LS("data-mdate")).toLongLong();

  if (!mdate)
    return false;

  id.init(container.attribute(LS("id")).toLatin1());
  id.setDate(mdate);
  if (id.type() != ChatId::MessageId)
    return false;

  const int permissions = this->permissions(HistoryDB::get(id));
  if (permissions == NoPermissions)
    return false;

  if (permissions & Remove) {
    QVariantList data;
    data << view->id() << (id.hasOid() ? ChatId::toBase32(id.oid().byteArray()) : id.toString());

    menu->insertAction(menu->actions().first(), removeAction(data));
  }
  return true;
}
开发者ID:youngdev,项目名称:schat,代码行数:33,代码来源:HistoryChatView.cpp

示例2: LocationBarPopup

RSSWidget::RSSWidget(WebView* view, QWidget* parent)
    : LocationBarPopup(parent)
    , ui(new Ui::RSSWidget)
    , m_view(view)
{
    ui->setupUi(this);

    QWebEngineFrame* frame = m_view->page()->mainFrame();
    QWebElementCollection links = frame->findAllElements("link[type=\"application/rss+xml\"]");

    // Make sure RSS feeds fit into a window, in case there is a lot of feeds from one page
    // See #906
    int cols = links.count() / 10 == 0 ? 1 : links.count() / 10;
    int row = 0;

    for (int i = 0; i < links.count(); i++) {
        QWebElement element = links.at(i);
        QString title = element.attribute("title");
        const QUrl url = QUrl::fromEncoded(element.attribute("href").toUtf8());
        if (url.isEmpty()) {
            continue;
        }

        if (title.isEmpty()) {
            title = tr("Untitled feed");
        }

        QPushButton* button = new QPushButton(this);
        button->setIcon(QIcon(":icons/other/feed.png"));
        button->setStyleSheet("text-align:left");
        button->setText(title);
        button->setProperty("rss-url", url);
        button->setProperty("rss-title", title);

        if (!isRssFeedAlreadyStored(url)) {
            button->setFlat(true);
            button->setToolTip(url.toString());
        }
        else {
            button->setFlat(false);
            button->setEnabled(false);
            button->setToolTip(tr("You already have this feed."));
        }

        int pos = i % cols > 0 ? (i % cols) * 2 : 0;

        ui->gridLayout->addWidget(button, row, pos);
        connect(button, SIGNAL(clicked()), this, SLOT(addRss()));

        if (i % cols == cols - 1) {
            row++;
        }
    }
}
开发者ID:DmitriK,项目名称:qupzilla,代码行数:54,代码来源:rsswidget.cpp

示例3: getDateTime

QDateTime HtmlBookmarksImporter::getDateTime(const QWebElement &element, const QString &attribute)
{
#if QT_VERSION < 0x050800
	const uint seconds(element.attribute(attribute).toUInt());

	return ((seconds > 0) ? QDateTime::fromTime_t(seconds) : QDateTime());
#else
	const qint64 seconds(element.attribute(attribute).toLongLong());

	return ((seconds != 0) ? QDateTime::fromSecsSinceEpoch(seconds) : QDateTime());
#endif
}
开发者ID:haydara,项目名称:otter,代码行数:12,代码来源:HtmlBookmarksImporter.cpp

示例4: QFrame

RSSDetectionWidget::RSSDetectionWidget(WebView* view, QWidget* parent)
  : QFrame(parent, Qt::Popup)
  , view_(view)
{
  setAttribute(Qt::WA_DeleteOnClose);
  setFrameStyle(QFrame::StyledPanel | QFrame::Plain);
  setLineWidth(1);
  setMidLineWidth(2);

  gridLayout_ = new QGridLayout(this);
  gridLayout_->setMargin(5);
  gridLayout_->setSpacing(5);

  QWebFrame* frame = view_->page()->mainFrame();
  QWebElementCollection links = frame->findAllElements("link[type=\"application/rss+xml\"]");

  int cols = links.count() / 10 == 0 ? 1 : links.count() / 10;
  int row = 0;

  for (int i = 0; i < links.count(); i++) {
    QWebElement element = links.at(i);
    QString title = element.attribute("title");
    const QUrl url = QUrl::fromEncoded(element.attribute("href").toUtf8());
    if (url.isEmpty()) {
      continue;
    }

    if (title.isEmpty()) {
      title = tr("Untitled feed");
    }

    QPushButton* button = new QPushButton(this);
    button->setStyleSheet("QPushButton {text-align:left; border: none; padding: 0px;}"
                          "QPushButton:hover {color: #1155CC;}");
    button->setCursor(Qt::PointingHandCursor);
    button->setText(title);
    button->setToolTip(url.toString());
    button->setProperty("rss-url", url);
    button->setProperty("rss-title", title);

    int pos = i % cols > 0 ? (i % cols) * 2 : 0;

    gridLayout_->addWidget(button, row, pos);
    connect(button, SIGNAL(clicked()), this, SLOT(addRss()));

    if (i % cols == cols - 1) {
      row++;
    }
  }
}
开发者ID:efferre79,项目名称:quiterss,代码行数:50,代码来源:rssdetectionwidget.cpp

示例5: showSpellCheckAction

static bool showSpellCheckAction(const QWebElement& element)
{
    if (element.hasAttribute(QL1S("readonly")))
        return false;

    if (element.attribute(QL1S("spellcheck"), QL1S("true")).compare(QL1S("false"), Qt::CaseInsensitive) == 0)
        return false;

    if (element.hasAttribute(QL1S("type"))
        && element.attribute(QL1S("type")).compare(QL1S("text"), Qt::CaseInsensitive) != 0)
        return false;

    return true;
}
开发者ID:KDE,项目名称:kwebkitpart,代码行数:14,代码来源:webview.cpp

示例6: checkUrlOnElement

bool ClickToFlash::checkUrlOnElement(QWebElement el)
{
  QString checkString = el.attribute("src");
  if (checkString.isEmpty()) {
    checkString = el.attribute("data");
  }
  if (checkString.isEmpty()) {
    checkString = el.attribute("value");
  }

  checkString = page_->mainFrame()->url().resolved(QUrl(checkString)).toString(QUrl::RemoveQuery);

  return url_.toEncoded().contains(checkString.toUtf8());
}
开发者ID:DanMan,项目名称:quiterss,代码行数:14,代码来源:clicktoflash.cpp

示例7: addSearchEngine

void WebView::addSearchEngine()
{
    QAction *action = qobject_cast<QAction*>(sender());
    if (!action)
        return;

    QVariant variant = action->data();
    if (!variant.canConvert<QWebElement>())
        return;

    QWebElement element = qvariant_cast<QWebElement>(variant);
    QString elementName = element.attribute(QLatin1String("name"));
    QWebElement formElement = element;
    while (formElement.tagName().toLower() != QLatin1String("form"))
        formElement = formElement.parent();

    if (formElement.isNull() || formElement.attribute(QLatin1String("action")).isEmpty())
        return;

    QString method = formElement.attribute(QLatin1String("method"), QLatin1String("get")).toLower();
    if (method != QLatin1String("get")) {
        QMessageBox::warning(this, tr("Method not supported"),
                             tr("%1 method is not supported.").arg(method.toUpper()));
        return;
    }

    QUrl searchUrl(page()->mainFrame()->baseUrl().resolved(QUrl(formElement.attribute(QLatin1String("action")))));
    QMap<QString, QString> searchEngines;
    QWebElementCollection inputFields = formElement.findAll(QLatin1String("input"));
    foreach (QWebElement inputField, inputFields) {
        QString type = inputField.attribute(QLatin1String("type"), QLatin1String("text"));
        QString name = inputField.attribute(QLatin1String("name"));
        QString value = inputField.evaluateJavaScript(QLatin1String("this.value")).toString();

        if (type == QLatin1String("submit")) {
            searchEngines.insert(value, name);
        } else if (type == QLatin1String("text")) {
            if (inputField == element)
                value = QLatin1String("{searchTerms}");

            searchUrl.addQueryItem(name, value);
        } else if (type == QLatin1String("checkbox") || type == QLatin1String("radio")) {
            if (inputField.evaluateJavaScript(QLatin1String("this.checked")).toBool()) {
                searchUrl.addQueryItem(name, value);
            }
        } else if (type == QLatin1String("hidden")) {
            searchUrl.addQueryItem(name, value);
        }
    }
开发者ID:mariuz,项目名称:fram,代码行数:49,代码来源:webview.cpp

示例8: parseSearchProductPage

//void ArestShopPlugin::SinglePageFound()
//{
//#ifdef USE_WEBKIT
//	QWebFrame * ptrFrame = getWebPage()->mainFrame();
//	parseProductPage(m_stCompData);
//	m_stCompData.strCompURL = ptrFrame->url().toString();
//	emit priceSearchedFinished(m_stCompData);
//	productFoundFinish();
//#endif
//};
void ArestShopPlugin::parseSearchProductPage(SearchResult & stResult,bool & bNextPage)
{
	//run XML search page parse

	bNextPage=false;
#ifdef USE_WEBKIT
	QWebFrame * ptrFrame = getWebPage()->mainFrame();
	//////////////////////////////////////////////////////////////////////////
	QWebElementCollection tableProdRows = ptrFrame->findAllElements("table[class=pricelist]");
	
	for(int iIndex=0;iIndex<tableProdRows.count();++iIndex)
	{
		QWebElement prodNameHeader = tableProdRows.at(iIndex).findFirst("td[class=nazwa]");
		if (prodNameHeader.isNull())
			continue;
		QWebElement productLink = prodNameHeader.findFirst("a");
		QUrl stProductURL = productLink.attribute("href");
		//////////////////////////////////////////////////////////////////////////
		QString strName = productLink.toPlainText();
		stResult.insert(std::make_pair(strName,stProductURL));
	}
	//////////////////////////////////////////////////////////////////////////
	QWebElement tablePageNavi = ptrFrame->findFirstElement("li[class=next]");
	if (tablePageNavi.isNull())
	{
		bNextPage=false;
		return;
	}
	bNextPage=true;
#endif
	stResult.insert(Arest::mSearchResult.begin(),Arest::mSearchResult.end());
	bNextPage=m_bLoadNextPage;
}
开发者ID:T4ng10r,项目名称:ComputerComponentsShop,代码行数:43,代码来源:ArestShop.cpp

示例9: scrap

void dilbert::scrap(bool ok)
{
    if (ok)
    {
        ui->progressBar->hide();
        QWebElementCollection imgs = view->page()->mainFrame()->findAllElements("img");
        QWebElement img;
        if (comicid == latest || comicid == QDate(1989, 04, 16))
            img = imgs.at(1);
        else
            img = imgs.at(2);
        QString imgLink = QString("http://dilbert.com").append(img.attribute("src").toAscii().constData());
        ui->webView->setUrl(QUrl(imgLink));
        if (comicid == QDate(1989, 04, 16))
        {
            ui->prev->setEnabled(false);
        }
        else
        {
            ui->prev->setEnabled(true);
        }
        if (comicid == latest)
        {
            ui->next->setEnabled(false);
        }
        else
        {
            ui->next->setEnabled(true);
        }
    }
}
开发者ID:dhruvbhutani,项目名称:komedia,代码行数:31,代码来源:dilbert.cpp

示例10: mousePressEvent

			void KinotifyWidget::mousePressEvent (QMouseEvent *event)
			{
				const QWebHitTestResult& r = page ()->mainFrame ()->hitTestContent (event->pos ());
				if (!r.linkUrl ().isEmpty ())
				{
					QWebView::mousePressEvent (event);
					return;
				}

				QWebElement elem = r.element ();
				if (elem.isNull () || elem.attribute ("type") != "button")
				{
					disconnect (CheckTimer_,
							SIGNAL (timeout ()),
							this,
							SIGNAL (checkNotificationQueue ()));

					disconnect (&Machine_,
							SIGNAL (finished ()),
							this,
							SLOT (closeNotification ()));

					emit checkNotificationQueue ();
					closeNotification ();
				}
				else
					QWebView::mousePressEvent (event);
			}
开发者ID:nobodyzzz,项目名称:leechcraft,代码行数:28,代码来源:kinotifywidget.cpp

示例11: foreach

 foreach (QWebElement link, links) {
     QString js = link.attribute("onclick");
     int pos = linkRE.indexIn(js);
     if (pos > -1) {
         results[linkRE.cap(1)] = name;
     }
 }
开发者ID:chxyfish,项目名称:merkaartor,代码行数:7,代码来源:cadastrewrapper.cpp

示例12: elemRect

 QList<CachedHandler> ChromeDOM::getCachedHandlers(const QString &elementId, const QRectF & ownerArea)
 {
   QWebElement snippet = getElementById(elementId);
   QList <QWebElement> controls =  snippet.findAll(".GinebraCached").toList();
   QList <CachedHandler> handlers;
   for (int i = 0; i < controls.size(); i++){
     QWebElement elem = controls.at(i);
     //Element rectangle relative to snippet, so we can handle mouse events relative to snippet
     //qDebug() << "====> Owner X: " << ownerArea.x() << " Owner Width: " << ownerArea.width() << " Elem X: " << elem.geometry().x() << " Elem Width: " << elem.geometry().width();
     QRectF elemRect(elem.geometry().x() - ownerArea.x(), elem.geometry().y() - ownerArea.y(), elem.geometry().width(), elem.geometry().height());
     //NB: For now we handle only onclick from cache. Should add at least long-press too.
     CachedHandler handler(elem.attribute("id"), elem.attribute("data-GinebraOnClick"), elemRect, m_chrome, elem.attribute("data-GinebraTargetView"));
     //qDebug() << "Cached handler" << handler.elementId() << ": "  << handler.script() << ": "  << handler.rect();
     handlers.append(handler);
   }
   return handlers;
 }
开发者ID:cdaffara,项目名称:symbiandump-ossapps,代码行数:17,代码来源:ChromeDOM.cpp

示例13: fixObjectNode

void EnmlFormatter::fixObjectNode(QWebElement &e) {
    QString type = e.attribute("type", "");
    if (type == "application/pdf") {
        qint32 lid = e.attribute("lid", "0").toInt();
        e.removeAttribute("width");
        e.removeAttribute("height");
        e.removeAttribute("lid");
        e.removeAttribute("border");
        if (lid>0) {
            resources.append(lid);
             e.setOuterXml(e.toOuterXml().replace("<object", "<en-media").replace("</object", "</en-media"));
        }
        removeInvalidAttributes(e);
    } else {
        e.removeFromDocument();
    }
}
开发者ID:amareknight,项目名称:Nixnote2,代码行数:17,代码来源:enmlformatter.cpp

示例14: findChromeParent

  QWebElement ChromeDOM::findChromeParent(QWebElement element)
  {
    while(!(element = element.parent()).isNull()){
      if (element.attribute("class") == "GinebraSnippet"){
	return element;
      }
    }
    return element;
  }
开发者ID:cdaffara,项目名称:symbiandump-ossapps,代码行数:9,代码来源:ChromeDOM.cpp

示例15: checkElement

bool ClickToFlash::checkElement(QWebElement el)
{
  if (argumentNames_ == el.attributeNames()) {
    foreach (const QString &name, argumentNames_) {
      if (argumentValues_.indexOf(el.attribute(name)) == -1) {
        return false;
      }
    }
    return true;
  }
开发者ID:DanMan,项目名称:quiterss,代码行数:10,代码来源:clicktoflash.cpp


注:本文中的QWebElement::attribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。