summaryrefslogtreecommitdiffstats
path: root/examples/xmlpatterns
diff options
context:
space:
mode:
authorTobias Koenig <tokoe@kde.org>2009-05-19 18:09:09 (GMT)
committerTobias Koenig <tokoe@kde.org>2009-05-19 18:09:09 (GMT)
commitf66a475a236649c94a47f668ba3461bdc325c308 (patch)
tree4734c2dccfc8e0adfe9474d8a0acc4e634970d5b /examples/xmlpatterns
parent9519f3ee67c8ab2de8d1ab5e584f8d3adb8875bd (diff)
downloadQt-f66a475a236649c94a47f668ba3461bdc325c308.zip
Qt-f66a475a236649c94a47f668ba3461bdc325c308.tar.gz
Qt-f66a475a236649c94a47f668ba3461bdc325c308.tar.bz2
First version of documentation for schema example
Diffstat (limited to 'examples/xmlpatterns')
-rw-r--r--examples/xmlpatterns/schema/mainwindow.cpp19
-rw-r--r--examples/xmlpatterns/schema/schema.ui2
2 files changed, 12 insertions, 9 deletions
diff --git a/examples/xmlpatterns/schema/mainwindow.cpp b/examples/xmlpatterns/schema/mainwindow.cpp
index 6b43d7b..98276a3 100644
--- a/examples/xmlpatterns/schema/mainwindow.cpp
+++ b/examples/xmlpatterns/schema/mainwindow.cpp
@@ -69,7 +69,8 @@ class MessageHandler : public QAbstractMessageHandler
}
protected:
- virtual void handleMessage(QtMsgType type, const QString &description, const QUrl &identifier, const QSourceLocation &sourceLocation)
+ virtual void handleMessage(QtMsgType type, const QString &description,
+ const QUrl &identifier, const QSourceLocation &sourceLocation)
{
Q_UNUSED(type);
Q_UNUSED(identifier);
@@ -127,7 +128,7 @@ void MainWindow::schemaSelected(int index)
QFile schemaFile(QString(":/schema_%1.xsd").arg(index));
schemaFile.open(QIODevice::ReadOnly);
- const QString schemaText(QString::fromLatin1(schemaFile.readAll()));
+ const QString schemaText(QString::fromUtf8(schemaFile.readAll()));
schemaView->setPlainText(schemaText);
validate();
@@ -137,7 +138,7 @@ void MainWindow::instanceSelected(int index)
{
QFile instanceFile(QString(":/instance_%1.xml").arg((2*schemaSelection->currentIndex()) + index));
instanceFile.open(QIODevice::ReadOnly);
- const QString instanceText(QString::fromLatin1(instanceFile.readAll()));
+ const QString instanceText(QString::fromUtf8(instanceFile.readAll()));
instanceEdit->setPlainText(instanceText);
validate();
@@ -145,22 +146,22 @@ void MainWindow::instanceSelected(int index)
void MainWindow::validate()
{
- const QByteArray schemaData = schemaView->toPlainText().toLatin1();
- const QByteArray instanceData = instanceEdit->toPlainText().toLatin1();
+ const QByteArray schemaData = schemaView->toPlainText().toUtf8();
+ const QByteArray instanceData = instanceEdit->toPlainText().toUtf8();
MessageHandler messageHandler;
QXmlSchema schema;
schema.setMessageHandler(&messageHandler);
- schema.load(schemaData, QUrl("http://dummySchemaUrl/"));
+ schema.load(schemaData);
bool errorOccurred = false;
if (!schema.isValid()) {
errorOccurred = true;
} else {
QXmlSchemaValidator validator(schema);
- if (!validator.validate(instanceData, QUrl("http://dummyInstanceUrl")))
+ if (!validator.validate(instanceData))
errorOccurred = true;
}
@@ -171,7 +172,9 @@ void MainWindow::validate()
validationStatus->setText(tr("validation successful"));
}
- QString styleSheet = QString("QLabel {background: %1; padding: 3px}").arg(errorOccurred ? QColor(Qt::red).lighter(160).name() : QColor(Qt::green).lighter(160).name());
+ const QString styleSheet = QString("QLabel {background: %1; padding: 3px}")
+ .arg(errorOccurred ? QColor(Qt::red).lighter(160).name() :
+ QColor(Qt::green).lighter(160).name());
validationStatus->setStyleSheet(styleSheet);
}
diff --git a/examples/xmlpatterns/schema/schema.ui b/examples/xmlpatterns/schema/schema.ui
index af7020a..b67f444 100644
--- a/examples/xmlpatterns/schema/schema.ui
+++ b/examples/xmlpatterns/schema/schema.ui
@@ -11,7 +11,7 @@
</rect>
</property>
<property name="windowTitle">
- <string>MainWindow</string>
+ <string>XML Schema Validation</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QGridLayout" name="gridLayout">