示例#1
0
void XmlEditWidgetPrivate::showValidationResults(const QString xmlAsText, ValidatorMessageHandler &validator)
{
    Element *element = NULL ;
    QDomDocument document;
    if(document.setContent(xmlAsText)) {
        FindNodeWithLocationInfo info;
        findDomNodeScan(document, document, validator.line(), validator.column(), info);
        QList<int> errorPath;
        if(!info.matchedNode.isNull()) {
            errorPath = makeDomNodePath(info.matchedNode);
        } else if(!info.lastKnownNode.isNull()) {
            errorPath = makeDomNodePath(info.lastKnownNode);
        }
        if(!errorPath.isEmpty()) {
            Element *selectedElement = regola->findElementByArray(errorPath);
            p->setCurrentItem(selectedElement);
        }
    }
    QString htmlTextError = tr("Line:%1, Col:%2 :%3")
                            .arg(validator.line())
                            .arg(validator.column())
                            .arg(validator.descriptionInPlainText());

    emit p->schemaValidationError(htmlTextError, element);
}
ValidationResults::ValidationResults(const QString text, ValidatorMessageHandler &validator, QWidget *parent) :
    QDialog(parent),
    _validator(validator)
{
    init();
    textBrowser->setText(text);
    TextEditUtils::gotoPos(textBrowser, validator.column(), validator.line());
    TextEditUtils::hiliteCurrentPos(textBrowser);
    error->setText(QString(tr("Line:%1, Col:%2 :%3"))
                   .arg(validator.line())
                   .arg(validator.column())
                   .arg(validator.description()));
}