예제 #1
0
bool PhpWebView::findElementByCoord(QWebElement & root, QPoint & point, QList<WebElementStruct> & list)
{
	QWebElement child = root.lastChild();
	bool isfind = false;
	while (!child.isNull())
	{
		if (findElementByCoord(child, point, list))
			isfind = true;
		child = child.previousSibling();
	}

	QString display = root.styleProperty("display", QWebElement::ComputedStyle);
	if (display != "none" && root.geometry().contains(point) && !isfind)
	{
		list.append(createWebElementStruct(root, list.count()));
		return true;
	}
	else
		return false;
}
void CellmlAnnotationViewMetadataNormalViewDetailsWidget::linkClicked()
{
    // Retrieve some information about the link

    mOutputOntologicalTerms->retrieveLinkInformation(mLink, mTextContent);

    // Check whether we have clicked a resource/id link or a button link

    if (mTextContent.isEmpty()) {
        // Update some information

        CellMLSupport::CellmlFileRdfTriple *rdfTriple = mRdfTriplesMapping.value(mLink);

        QString qualifier = (rdfTriple->modelQualifier() != CellMLSupport::CellmlFileRdfTriple::ModelUnknown)?
                                rdfTriple->modelQualifierAsString():
                                rdfTriple->bioQualifierAsString();
        QString rdfTripleInformation = qualifier+"|"+rdfTriple->resource()+"|"+rdfTriple->id();

        mUrls.remove(rdfTripleInformation);

        mRdfTripleInformationSha1s.removeOne(mLink);

        mRdfTriplesMapping.remove(mLink);

        --mItemsCount;

        // Determine the 'new' RDF triple information to look up, based on
        // whether there are RDF triples left and whether the current RDF triple
        // is the one being highlighted

        QWebElement rdfTripleElement = mOutputOntologicalTerms->page()->mainFrame()->documentElement().findFirst(QString("tr[id=item_%1]").arg(mLink));

        if (!mItemsCount) {
            mRdfTripleInformation = QString();
            mInformationType = None;
        } else if (!mLink.compare(mRdfTripleInformationSha1)) {
            QWebElement newRdfTripleEment = rdfTripleElement.nextSibling();

            if (newRdfTripleEment.isNull())
                newRdfTripleEment = rdfTripleElement.previousSibling();

            static const QRegularExpression ItemRegEx = QRegularExpression("^item_");

            CellMLSupport::CellmlFileRdfTriple *newRdfTriple = mRdfTriplesMapping.value(newRdfTripleEment.attribute("id").remove(ItemRegEx));
            QString newQualifier = (newRdfTriple->modelQualifier() != CellMLSupport::CellmlFileRdfTriple::ModelUnknown)?
                                       newRdfTriple->modelQualifierAsString():
                                       newRdfTriple->bioQualifierAsString();

            mRdfTripleInformation = newQualifier+"|"+newRdfTriple->resource()+"|"+newRdfTriple->id();

            if (!rdfTripleInformation.compare(mFirstRdfTripleInformation))
                mFirstRdfTripleInformation = mRdfTripleInformation;

            if (!rdfTripleInformation.compare(mLastRdfTripleInformation))
                mLastRdfTripleInformation = mRdfTripleInformation;
        }

        // Remove the RDF triple from our GUI

        rdfTripleElement.removeFromDocument();

        // Do some additional GUI updates

        mLookUpRdfTripleInformation = Any;

        if (!mLink.compare(mRdfTripleInformationSha1))
            additionalGuiUpdates(mRdfTripleInformation, mInformationType, mLookUpRdfTripleInformation);
        else
            // The looked up information is the same, so no need to look it up
            // again
            // Note: indeed, to look it up again would result in the web view
            //       flashing (since a 'new' web page would be loaded)...

            additionalGuiUpdates(mRdfTripleInformation, mInformationType, No);

        // Remove the RDF triple from the CellML file

        mCellmlFile->rdfTriples().remove(rdfTriple);

        // Let people know that an RDF triple has been removed

        emit rdfTripleRemoved(rdfTriple);
    } else {
        // We have clicked on a qualifier/resource/id link, so start by enabling
        // the looking up of any RDF triple information

        mLookUpRdfTripleInformation = Any;

        // Call our generic look up function

        QStringList rdfTripleInformation = mLink.split("|");

        genericLookUp(mLink,
                      (!rdfTripleInformation[0].compare(mTextContent))?
                          Qualifier:
                          !rdfTripleInformation[1].compare(mTextContent)?
                              Resource:
                              Id);
    }
}