コード例 #1
0
ファイル: elementwrapper.cpp プロジェクト: pvuorela/kcalcore
QString ElementWrapper::completeURI(const QString& uri) const
{
    KUrl u(xmlBase(), uri);
    
    if (u.isValid())
        return u.url();
    
    return uri;
}
コード例 #2
0
ファイル: cellmlfile.cpp プロジェクト: hsorby/opencor
QString CellmlFile::rdfTripleSubject(iface::cellml_api::CellMLElement *pElement)
{
    // Make sure that we have a 'proper' cmeta:id or generate one, if needed

    QString cmetaId = QString::fromStdWString(pElement->cmetaId());

    if (cmetaId.isEmpty()) {
        // We don't have a 'proper' cmeta:id for the CellML element, so we need
        // to generate one and in order to do so, we need to try different
        // cmeta:id values until we find one that is not used

        int counter = 0;

        while (true) {
            cmetaId = QString("id_%1").arg(++counter, 9, 10, QChar('0'));

            if (!mUsedCmetaIds.contains(cmetaId)) {
                // We have found a unique cmeta:id, so update our CellML
                // element, consider ourselves modified, update our list of
                // cmeta:ids and leave

                pElement->cmetaId(cmetaId.toStdWString());

                setModified(true);

                mUsedCmetaIds << cmetaId;

                break;
            }
        }
    }

    // Return the subject which should be used for an RDF triple

    return xmlBase()+"#"+cmetaId;
}