Ejemplo n.º 1
0
QWebElement PhpWebView::getElementByXPath(const QString & xpath)
{
    QList<QWebElement> coll = getAllElementsByXPath(xpath);
	if (coll.count() > 0)
		return coll.at(0);
	else
		return QWebElement();
}
Ejemplo n.º 2
0
QWebElement QWebFrameProto::findFirstElement(const QString & selectorQuery) const
{
  scriptDeprecated("QWebFrame will not be available in future versions");
  QWebFrame *item = qscriptvalue_cast<QWebFrame*>(thisObject());
  if (item)
    return item->findFirstElement(selectorQuery);
  return QWebElement();
}
Ejemplo n.º 3
0
QWebElement QWebFrameProto::documentElement() const
{
  scriptDeprecated("QWebFrame will not be available in future versions");
  QWebFrame *item = qscriptvalue_cast<QWebFrame*>(thisObject());
  if (item)
    return item->documentElement();
  return QWebElement();
}
Ejemplo n.º 4
0
void EWAHTMLSelector::leaveEvent( QEvent *event )
{
    Q_UNUSED( event );
    if( !m_element.isNull() )
    {
        m_element = QWebElement();

        update();
    }
}
Ejemplo n.º 5
0
void MyWebView::on_loadStarted()
{
	m_boolEnableEvtProcess = false;

	m_old_hover_element.removeClass(g_strHighlightClassName);

	m_strCurrentElemId = "";

	m_old_click_element.setStyleProperty("border-style", m_old_click_borderstyle);
	m_old_click_element.setStyleProperty("border-width", m_old_click_borderwidth);
	m_old_click_element.setStyleProperty("border-color", m_old_click_bordercolor);

	m_old_click_element = QWebElement();
	m_old_click_borderstyle = "";
	m_old_click_borderwidth = "";
	m_old_click_bordercolor = "";
}
Ejemplo n.º 6
0
static bool isEditableElement(QWebPage* page)
{
    const QWebFrame* frame = (page ? page->currentFrame() : 0);
    QWebElement element = (frame ? frame->findFirstElement(QL1S(":focus")) : QWebElement());
    if (!element.isNull()) {
        const QString tagName(element.tagName());
        if (tagName.compare(QL1S("textarea"), Qt::CaseInsensitive) == 0) {
            return true;
        }
        const QString type(element.attribute(QL1S("type")).toLower());
        if (tagName.compare(QL1S("input"), Qt::CaseInsensitive) == 0
            && (type.isEmpty() || type == QL1S("text") || type == QL1S("password"))) {
            return true;
        }
        if (element.evaluateJavaScript("this.isContentEditable").toBool()) {
            return true;
        }
    }
    return false;
}
Ejemplo n.º 7
0
void EWAHTMLSelector::mouseReleaseEvent( QMouseEvent *event )
{
    Q_UNUSED( event );

    if( m_elSelected == m_element )
    {   //-- clear selection
        m_elSelected = QWebElement();
    }
    else
    {
        m_elSelected = m_element;
    }

    if( m_webViewPtr )
    {
        m_elementsNumbersPath = m_webViewPtr->getPathFromWebElement( m_elSelected );
    }

    drawElementsRects();
    update();
}
Ejemplo n.º 8
0
QWebElement PhpWebView::getElementByCoord(QWebElement root, QPoint point)
{
	QList<WebElementStruct> list;
	findElementByCoord(root, point, list);
	qSort(list.begin(), list.end(), elementLessThan);

	/*for (int i=list.count()-1; i>=0; i--)
	{
		WebElementStruct el = list.at(i);
		QString tag = el.el.tagName();
		QString id = el.el.attribute("id", "none");
		QString pos = el.position;
		QString z = QString::number(el.z_index);
		std::cerr << tag.toUtf8().constData() << " " << QString::number(el.i).toUtf8().constData() << " [" << id.toUtf8().constData() << "]" << " " << pos.toUtf8().constData() << " " << z.toUtf8().constData() << std::endl;
	}*/
		
	if (list.count() > 0)
		return list.last().el;

	return QWebElement();
}
Ejemplo n.º 9
0
QWebElement MyWebView::FindCloserContainer(QWebElement &elem)
{
	// find by elem id
	bool       bIsContainer = false;
    QString strTemp = elem.attribute("id");
    WDomElem * welem = m_pMainWindow->m_treemodel.getElemByName (strTemp);
	// check if valid parent
	if (welem)
	{
		QDomElement delem = welem->getElem();
		if (delem.attribute(g_strClassAttr).compare("WContainerWidget") == 0 ||
			delem.attribute(g_strClassAttr).compare("WAnchor"         ) == 0 ||
			delem.attribute(g_strClassAttr).compare("WGroupBox"       ) == 0 ||
			delem.attribute(g_strClassAttr).compare("WPanel"          ) == 0 ||
			delem.attribute(g_strClassAttr).compare("WMenuItem"       ) == 0 ||
			delem.attribute(g_strClassAttr).compare("WStackedWidget"  ) == 0 ||
			delem.attribute(g_strClassAttr).compare("WTabItem"        ) == 0)
		{
			bIsContainer = true;
		}
	}
	// if container return, else keep looking
	if (bIsContainer)
	{
		return elem;
	}
	else
	{
		if (!elem.parent().isNull())
		{
            QWebElement welemTemp = elem.parent();
            return FindCloserContainer(welemTemp);
		}
		else
		{
			return QWebElement();
		}
	}
}
Ejemplo n.º 10
0
QWebElement MyWebView::FindElementByName(QWebElement &elem, QString &name)
{
	if (elem.attribute("id").compare(name, Qt::CaseInsensitive) == 0)
	{
		return elem;
	}
	else
	{
		QWebElement childelem = elem.firstChild();
		QWebElement retelem;
		while (!childelem.isNull())
		{
			retelem = FindElementByName(childelem, name);
			if (!retelem.isNull())
			{
				return retelem;
			}
			childelem = childelem.nextSibling();
		}
	}
	return QWebElement();
}