diff options
Diffstat (limited to 'doc/src/snippets')
-rw-r--r-- | doc/src/snippets/code/doc_src_emb-charinput.qdoc | 2 | ||||
-rw-r--r-- | doc/src/snippets/code/doc_src_linguist-manual.qdoc | 6 | ||||
-rw-r--r-- | doc/src/snippets/code/doc_src_qmake-manual.qdoc | 2 | ||||
-rw-r--r-- | doc/src/snippets/code/doc_src_qthelp.qdoc | 6 | ||||
-rw-r--r-- | doc/src/snippets/code/src_corelib_global_qglobal.cpp | 24 | ||||
-rw-r--r-- | doc/src/snippets/code/src_corelib_kernel_qobject.cpp | 9 | ||||
-rw-r--r-- | doc/src/snippets/code/src_network_access_qnetworkreply.cpp | 10 | ||||
-rw-r--r-- | doc/src/snippets/code/src_network_ssl_qsslsocket.cpp | 11 | ||||
-rw-r--r-- | doc/src/snippets/qxmlschema/main.cpp | 118 | ||||
-rw-r--r-- | doc/src/snippets/qxmlschema/qxmlschema.pro | 3 | ||||
-rw-r--r-- | doc/src/snippets/qxmlschemavalidator/main.cpp | 160 | ||||
-rw-r--r-- | doc/src/snippets/qxmlschemavalidator/qxmlschemavalidator.pro | 3 | ||||
-rw-r--r-- | doc/src/snippets/snippets.pro | 2 | ||||
-rw-r--r-- | doc/src/snippets/statemachine/eventtest.cpp | 34 |
14 files changed, 381 insertions, 9 deletions
diff --git a/doc/src/snippets/code/doc_src_emb-charinput.qdoc b/doc/src/snippets/code/doc_src_emb-charinput.qdoc index 2539e13..f6b33fe 100644 --- a/doc/src/snippets/code/doc_src_emb-charinput.qdoc +++ b/doc/src/snippets/code/doc_src_emb-charinput.qdoc @@ -4,7 +4,7 @@ //! [1] -configure -qt-kbd-s15000 +configure -qt-kbd-linuxinput //! [1] diff --git a/doc/src/snippets/code/doc_src_linguist-manual.qdoc b/doc/src/snippets/code/doc_src_linguist-manual.qdoc index ce3b997..5697300 100644 --- a/doc/src/snippets/code/doc_src_linguist-manual.qdoc +++ b/doc/src/snippets/code/doc_src_linguist-manual.qdoc @@ -42,7 +42,7 @@ Options: -pluralonly Only include plural form messages. -silent - Don't explain what is being done. + Do not explain what is being done. -version Display the version of lupdate and exit. //! [4] @@ -55,14 +55,14 @@ Usage: Options: -help Display this information and exit -compress - Compress the .qm files + Compress the QM files -nounfinished Do not include unfinished translations -removeidentical If the translated text is the same as the source text, do not include the message -silent - Don't explain what is being done + Do not explain what is being done -version Display the version of lrelease and exit //! [5] diff --git a/doc/src/snippets/code/doc_src_qmake-manual.qdoc b/doc/src/snippets/code/doc_src_qmake-manual.qdoc index b93e151..753d560 100644 --- a/doc/src/snippets/code/doc_src_qmake-manual.qdoc +++ b/doc/src/snippets/code/doc_src_qmake-manual.qdoc @@ -689,7 +689,7 @@ qmake -o Makefile hello.pro //! [115] -qmake -tp vc -o hello.dsp hello.pro +qmake -tp vc hello.pro //! [115] diff --git a/doc/src/snippets/code/doc_src_qthelp.qdoc b/doc/src/snippets/code/doc_src_qthelp.qdoc index 11d231f..949e2a5 100644 --- a/doc/src/snippets/code/doc_src_qthelp.qdoc +++ b/doc/src/snippets/code/doc_src_qthelp.qdoc @@ -92,8 +92,7 @@ if (links.count()) { </keywords> <files> <file>classic.css</file> - <file>index.html</file> - <file>doc.html</file> + <file>*.html</file> </files> </filterSection> </QtHelpProject> @@ -154,8 +153,7 @@ if (links.count()) { ... <files> <file>classic.css</file> - <file>index.html</file> - <file>doc.html</file> + <file>*.html</file> </files> ... //! [13] diff --git a/doc/src/snippets/code/src_corelib_global_qglobal.cpp b/doc/src/snippets/code/src_corelib_global_qglobal.cpp index 287181a..50052c3 100644 --- a/doc/src/snippets/code/src_corelib_global_qglobal.cpp +++ b/doc/src/snippets/code/src_corelib_global_qglobal.cpp @@ -358,6 +358,30 @@ QString global_greeting(int type) //! [36] +//! [qttrid] + //% "%n fooish bar(s) found.\n" + //% "Do you want to continue?" + QString text = qtTrId("qtn_foo_bar", n); +//! [qttrid] + + +//! [qttrid_noop] +static const char * const ids[] = { + //% "This is the first text." + QT_TRID_NOOP("qtn_1st_text"), + //% "This is the second text." + QT_TRID_NOOP("qtn_2nd_text"), + 0 +}; + +void TheClass::addLabels() +{ + for (int i = 0; ids[i]; ++i) + new QLabel(qtTrId(ids[i]), this); +} +//! [qttrid_noop] + + //! [37] qWarning("%s: %s", qPrintable(key), qPrintable(value)); //! [37] diff --git a/doc/src/snippets/code/src_corelib_kernel_qobject.cpp b/doc/src/snippets/code/src_corelib_kernel_qobject.cpp index 5a7c5a7..5c0f80c 100644 --- a/doc/src/snippets/code/src_corelib_kernel_qobject.cpp +++ b/doc/src/snippets/code/src_corelib_kernel_qobject.cpp @@ -376,6 +376,15 @@ hostNameLabel->setText(tr("Name:")); QString example = tr("Example"); //! [40] +//! [meta data] +//: This is a comment for the translator. +//= qtn_foo_bar +//~ loc-layout_id foo_dialog +//~ loc-blank False +//~ magic-stuff This might mean something magic. +QString text = MyMagicClass::tr("Sim sala bim."); +//! [meta data] + //! [explicit tr context] QString text = QScrollBar::tr("Page up"); //! [explicit tr context] diff --git a/doc/src/snippets/code/src_network_access_qnetworkreply.cpp b/doc/src/snippets/code/src_network_access_qnetworkreply.cpp new file mode 100644 index 0000000..78b388b --- /dev/null +++ b/doc/src/snippets/code/src_network_access_qnetworkreply.cpp @@ -0,0 +1,10 @@ +//! [0] +QList<QSslCertificate> cert = QSslCertificate::fromPath(QLatin1String("server-certificate.pem")); +QSslError error(QSslError::SelfSignedCertificate, cert.at(0)); +QList<QSslError> expectedSslErrors; +expectedSslErrors.append(error); + +QNetworkReply *reply = manager.get(QNetworkRequest(QUrl("https://server.tld/index.html"))); +reply->ignoreSslErrors(expectedSslErrors); +// here connect signals etc. +//! [0] diff --git a/doc/src/snippets/code/src_network_ssl_qsslsocket.cpp b/doc/src/snippets/code/src_network_ssl_qsslsocket.cpp index afffbab..7845e9b 100644 --- a/doc/src/snippets/code/src_network_ssl_qsslsocket.cpp +++ b/doc/src/snippets/code/src_network_ssl_qsslsocket.cpp @@ -54,3 +54,14 @@ socket->connectToHostEncrypted("imap", 993); if (socket->waitForEncrypted(1000)) qDebug("Encrypted!"); //! [5] + +//! [6] +QList<QSslCertificate> cert = QSslCertificate::fromPath(QLatin1String("server-certificate.pem")); +QSslError error(QSslError::SelfSignedCertificate, cert.at(0)); +QList<QSslError> expectedSslErrors; +expectedSslErrors.append(error); + +QSslSocket socket; +socket.ignoreSslErrors(expectedSslErrors); +socket.connectToHostEncrypted("server.tld", 443); +//! [6] diff --git a/doc/src/snippets/qxmlschema/main.cpp b/doc/src/snippets/qxmlschema/main.cpp new file mode 100644 index 0000000..e5989ee --- /dev/null +++ b/doc/src/snippets/qxmlschema/main.cpp @@ -0,0 +1,118 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtCore> +#include <QtXmlPatterns> + +class Schema +{ + public: + void loadFromUrl() const; + void loadFromFile() const; + void loadFromData() const; +}; + +void Schema::loadFromUrl() const +{ +//! [0] + QUrl url("http://www.schema-example.org/myschema.xsd"); + + QXmlSchema schema; + if (schema.load(url) == true) + qDebug() << "schema is valid"; + else + qDebug() << "schema is invalid"; +//! [0] +} + +void Schema::loadFromFile() const +{ +//! [1] + QFile file("myschema.xsd"); + file.open(QIODevice::ReadOnly); + + QXmlSchema schema; + schema.load(&file, QUrl::fromLocalFile(file.fileName())); + + if (schema.isValid()) + qDebug() << "schema is valid"; + else + qDebug() << "schema is invalid"; +//! [1] +} + +void Schema::loadFromData() const +{ +//! [2] + QByteArray data( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<xsd:schema" + " xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"" + " xmlns=\"http://www.qtsoftware.com/xmlschematest\"" + " targetNamespace=\"http://www.qtsoftware.com/xmlschematest\"" + " version=\"1.0\"" + " elementFormDefault=\"qualified\">" + "</xsd:schema>" ); + + QBuffer buffer(&data); + buffer.open(QIODevice::ReadOnly); + + QXmlSchema schema; + schema.load(&buffer); + + if (schema.isValid()) + qDebug() << "schema is valid"; + else + qDebug() << "schema is invalid"; +//! [2] +} + +int main(int argc, char **argv) +{ + QCoreApplication app(argc, argv); + + Schema schema; + + schema.loadFromUrl(); + schema.loadFromFile(); + schema.loadFromData(); + + return 0; +} diff --git a/doc/src/snippets/qxmlschema/qxmlschema.pro b/doc/src/snippets/qxmlschema/qxmlschema.pro new file mode 100644 index 0000000..7e8782a --- /dev/null +++ b/doc/src/snippets/qxmlschema/qxmlschema.pro @@ -0,0 +1,3 @@ +SOURCES += main.cpp + +QT += xmlpatterns diff --git a/doc/src/snippets/qxmlschemavalidator/main.cpp b/doc/src/snippets/qxmlschemavalidator/main.cpp new file mode 100644 index 0000000..581f40f --- /dev/null +++ b/doc/src/snippets/qxmlschemavalidator/main.cpp @@ -0,0 +1,160 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtCore> +#include <QtXmlPatterns> + +class SchemaValidator +{ + public: + void validateFromUrl() const; + void validateFromFile() const; + void validateFromData() const; + void validateComplete() const; + + private: + QXmlSchema getSchema() const; +}; + +void SchemaValidator::validateFromUrl() const +{ +//! [0] + const QXmlSchema schema = getSchema(); + + const QUrl url("http://www.schema-example.org/test.xml"); + + QXmlSchemaValidator validator(schema); + if (validator.validate(url)) + qDebug() << "instance document is valid"; + else + qDebug() << "instance document is invalid"; +//! [0] +} + +void SchemaValidator::validateFromFile() const +{ +//! [1] + const QXmlSchema schema = getSchema(); + + QFile file("test.xml"); + file.open(QIODevice::ReadOnly); + + QXmlSchemaValidator validator(schema); + if (validator.validate(&file, QUrl::fromLocalFile(file.fileName()))) + qDebug() << "instance document is valid"; + else + qDebug() << "instance document is invalid"; +//! [1] +} + +void SchemaValidator::validateFromData() const +{ +//! [2] + const QXmlSchema schema = getSchema(); + + QByteArray data("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<test></test>"); + + QBuffer buffer(&data); + buffer.open(QIODevice::ReadOnly); + + QXmlSchemaValidator validator(schema); + if (validator.validate(&buffer)) + qDebug() << "instance document is valid"; + else + qDebug() << "instance document is invalid"; +//! [2] +} + +QXmlSchema SchemaValidator::getSchema() const +{ + QByteArray data("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<xsd:schema" + " xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"" + " xmlns=\"http://www.qtsoftware.com/xmlschematest\"" + " targetNamespace=\"http://www.qtsoftware.com/xmlschematest\"" + " version=\"1.0\"" + " elementFormDefault=\"qualified\">" + "</xsd:schema>"); + + QBuffer buffer(&data); + buffer.open(QIODevice::ReadOnly); + + QXmlSchema schema; + schema.load(&buffer); + + return schema; +} + +void SchemaValidator::validateComplete() const +{ +//! [3] + QUrl schemaUrl("file:///home/user/schema.xsd"); + + QXmlSchema schema; + schema.load(schemaUrl); + + if (schema.isValid()) { + QFile file("test.xml"); + file.open(QIODevice::ReadOnly); + + QXmlSchemaValidator validator(schema); + if (validator.validate(&file, QUrl::fromLocalFile(file.fileName()))) + qDebug() << "instance document is valid"; + else + qDebug() << "instance document is invalid"; + } +//! [3] +} + +int main(int argc, char **argv) +{ + QCoreApplication app(argc, argv); + + SchemaValidator validator; + + validator.validateFromUrl(); + validator.validateFromFile(); + validator.validateFromData(); + validator.validateComplete(); + + return 0; +} diff --git a/doc/src/snippets/qxmlschemavalidator/qxmlschemavalidator.pro b/doc/src/snippets/qxmlschemavalidator/qxmlschemavalidator.pro new file mode 100644 index 0000000..7e8782a --- /dev/null +++ b/doc/src/snippets/qxmlschemavalidator/qxmlschemavalidator.pro @@ -0,0 +1,3 @@ +SOURCES += main.cpp + +QT += xmlpatterns diff --git a/doc/src/snippets/snippets.pro b/doc/src/snippets/snippets.pro index 50e33b3..e3e7eca 100644 --- a/doc/src/snippets/snippets.pro +++ b/doc/src/snippets/snippets.pro @@ -73,6 +73,8 @@ SUBDIRS = brush \ quiloader \ qx11embedcontainer \ qx11embedwidget \ + qxmlschema \ + qxmlschemavalidator \ reading-selections \ scribe-overview \ separations \ diff --git a/doc/src/snippets/statemachine/eventtest.cpp b/doc/src/snippets/statemachine/eventtest.cpp new file mode 100644 index 0000000..e0f359a --- /dev/null +++ b/doc/src/snippets/statemachine/eventtest.cpp @@ -0,0 +1,34 @@ + +#include <QtGui> + +class MyTransition : public QAbstractTransition +{ + Q_OBJECT +public: + MyTransition() {} + +protected: +//![0] + bool eventTest(QEvent *event) + { + if (event->type() == QEvent::Wrapped) { + QEvent *wrappedEvent = static_cast<QWrappedEvent *>(event)->event(); + if (wrappedEvent->type() == QEvent::KeyPress) { + QKeyEvent *keyEvent = static_cast<QKeyEvent *>(wrappedEvent); + // Do your event test + } + } + return false; + } +//![0] + + void onTransition(QEvent *event) + { + + } +}; + +int main(int argv, char **args) +{ + return 0; +} |