aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside2/doc/codesnippets/examples
diff options
context:
space:
mode:
Diffstat (limited to 'sources/pyside2/doc/codesnippets/examples')
-rw-r--r--sources/pyside2/doc/codesnippets/examples/dialogs/classwizard/main.cpp73
-rw-r--r--sources/pyside2/doc/codesnippets/examples/dialogs/licensewizard/licensewizard.cpp358
-rw-r--r--sources/pyside2/doc/codesnippets/examples/dialogs/licensewizard/main.cpp73
-rw-r--r--sources/pyside2/doc/codesnippets/examples/dialogs/trivialwizard/trivialwizard.cpp143
-rw-r--r--sources/pyside2/doc/codesnippets/examples/itemviews/simpledommodel/dommodel.cpp197
-rw-r--r--sources/pyside2/doc/codesnippets/examples/linguist/hellotr/main.cpp78
-rw-r--r--sources/pyside2/doc/codesnippets/examples/sql/querymodel/editablesqlmodel.cpp112
-rw-r--r--sources/pyside2/doc/codesnippets/examples/svggenerator/window.cpp107
-rw-r--r--sources/pyside2/doc/codesnippets/examples/uitools/textfinder/textfinder.cpp141
-rw-r--r--sources/pyside2/doc/codesnippets/examples/widgets/analogclock/analogclock.cpp155
-rw-r--r--sources/pyside2/doc/codesnippets/examples/xml/streambookmarks/xbelreader.cpp210
-rw-r--r--sources/pyside2/doc/codesnippets/examples/xml/streambookmarks/xbelwriter.cpp100
12 files changed, 0 insertions, 1747 deletions
diff --git a/sources/pyside2/doc/codesnippets/examples/dialogs/classwizard/main.cpp b/sources/pyside2/doc/codesnippets/examples/dialogs/classwizard/main.cpp
deleted file mode 100644
index 9e9566d37..000000000
--- a/sources/pyside2/doc/codesnippets/examples/dialogs/classwizard/main.cpp
+++ /dev/null
@@ -1,73 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QApplication>
-#include <QTranslator>
-#include <QLocale>
-#include <QLibraryInfo>
-
-#include "classwizard.h"
-
-int main(int argc, char *argv[])
-{
- Q_INIT_RESOURCE(classwizard);
-
- QApplication app(argc, argv);
-
- QString translatorFileName = QLatin1String("qt_");
- translatorFileName += QLocale::system().name();
- QTranslator *translator = new QTranslator(&app);
- if (translator->load(translatorFileName, QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
- app.installTranslator(translator);
-
- ClassWizard wizard;
- wizard.show();
- return app.exec();
-}
diff --git a/sources/pyside2/doc/codesnippets/examples/dialogs/licensewizard/licensewizard.cpp b/sources/pyside2/doc/codesnippets/examples/dialogs/licensewizard/licensewizard.cpp
deleted file mode 100644
index 453dac773..000000000
--- a/sources/pyside2/doc/codesnippets/examples/dialogs/licensewizard/licensewizard.cpp
+++ /dev/null
@@ -1,358 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtWidgets>
-
-#include "licensewizard.h"
-
-//! [0] //! [1] //! [2]
-# class LicenseWizard
-def __init__(self, parent)
- QWizard(self, parent)
-//! [0]
- self.setPage(self.Page_Intro, IntroPage())
- self.setPage(self.Page_Evaluate, EvaluatePage())
- self.setPage(self.Page_Register, RegisterPage())
- self.setPage(self.Page_Details, DetailsPage())
- self.setPage(self.Page_Conclusion, ConclusionPage())
-//! [1]
-
- self.setStartId(self.Page_Intro);
-//! [2]
-
-//! [3]
-
-//! [3] //! [4]
- self.setWizardStyle(QWizard.ModernStyle);
-
-//! [4] //! [5]
- self.setOption(HaveHelpButton, True);
-//! [5] //! [6]
- self.setPixmap(QWizard.LogoPixmap, QPixmap(":/images/logo.png"));
-
-//! [7]
- connect(this, SIGNAL(helpRequested()), this, SLOT(showHelp()));
-//! [7]
-
- setWindowTitle(tr("License Wizard"));
-//! [8]
-}
-//! [6] //! [8]
-
-//! [9] //! [10]
-void LicenseWizard::showHelp()
-//! [9] //! [11]
-{
- static QString lastHelpMessage;
-
- message = ""
-
- switch (currentId()) {
- case Page_Intro:
- message = tr("The decision you make here will affect which page you "
- "get to see next.");
- break;
-//! [10] //! [11]
- case Page_Evaluate:
- message = tr("Make sure to provide a valid email address, such as "
- "toni.buddenbrook@example.de.");
- break;
- case Page_Register:
- message = tr("If you don't provide an upgrade key, you will be "
- "asked to fill in your details.");
- break;
- case Page_Details:
- message = tr("Make sure to provide a valid email address, such as "
- "thomas.gradgrind@example.co.uk.");
- break;
- case Page_Conclusion:
- message = tr("You must accept the terms and conditions of the "
- "license to proceed.");
- break;
-//! [12] //! [13]
- default:
- message = tr("This help is likely not to be of any help.");
- }
-//! [12]
-
- if (lastHelpMessage == message)
- message = tr("Sorry, I already gave what help I could. "
- "Maybe you should try asking a human?");
-
-//! [14]
- QMessageBox::information(this, tr("License Wizard Help"), message);
-//! [14]
-
- lastHelpMessage = message;
-//! [15]
-}
-//! [13] //! [15]
-
-//! [16]
-IntroPage::IntroPage(QWidget *parent)
- : QWizardPage(parent)
-{
- setTitle(tr("Introduction"));
- setPixmap(QWizard::WatermarkPixmap, QPixmap(":/images/watermark.png"));
-
- topLabel = new QLabel(tr("This wizard will help you register your copy of "
- "<i>Super Product One</i>&trade; or start "
- "evaluating the product."));
- topLabel->setWordWrap(true);
-
- registerRadioButton = new QRadioButton(tr("&Register your copy"));
- evaluateRadioButton = new QRadioButton(tr("&Evaluate the product for 30 "
- "days"));
- registerRadioButton->setChecked(true);
-
- QVBoxLayout *layout = new QVBoxLayout;
- layout->addWidget(topLabel);
- layout->addWidget(registerRadioButton);
- layout->addWidget(evaluateRadioButton);
- setLayout(layout);
-}
-//! [16] //! [17]
-
-//! [18]
-# class IntroPage
-def nextId(self):
-//! [17] //! [19]
- if evaluateRadioButton.isChecked():
- return LicenseWizard.Page_Evaluate
- else:
- return LicenseWizard.Page_Register
-//! [18] //! [19]
-
-//! [20]
-EvaluatePage::EvaluatePage(QWidget *parent)
- : QWizardPage(parent)
-{
- setTitle(tr("Evaluate <i>Super Product One</i>&trade;"));
- setSubTitle(tr("Please fill both fields. Make sure to provide a valid "
- "email address (e.g., john.smith@example.com)."));
-
- nameLabel = new QLabel(tr("N&ame:"));
- nameLineEdit = new QLineEdit;
-//! [20]
- nameLabel->setBuddy(nameLineEdit);
-
- emailLabel = new QLabel(tr("&Email address:"));
- emailLineEdit = new QLineEdit;
- emailLineEdit->setValidator(new QRegExpValidator(QRegExp(".*@.*"), this));
- emailLabel->setBuddy(emailLineEdit);
-
-//! [21]
- registerField("evaluate.name*", nameLineEdit);
- registerField("evaluate.email*", emailLineEdit);
-//! [21]
-
- QGridLayout *layout = new QGridLayout;
- layout->addWidget(nameLabel, 0, 0);
- layout->addWidget(nameLineEdit, 0, 1);
- layout->addWidget(emailLabel, 1, 0);
- layout->addWidget(emailLineEdit, 1, 1);
- setLayout(layout);
-//! [22]
-}
-//! [22]
-
-//! [23]
-# class EvaluatePage
-def nextId(self):
- return LicenseWizard.Page_Conclusion
-//! [23]
-
-RegisterPage::RegisterPage(QWidget *parent)
- : QWizardPage(parent)
-{
- setTitle(tr("Register Your Copy of <i>Super Product One</i>&trade;"));
- setSubTitle(tr("If you have an upgrade key, please fill in "
- "the appropriate field."));
-
- nameLabel = new QLabel(tr("N&ame:"));
- nameLineEdit = new QLineEdit;
- nameLabel->setBuddy(nameLineEdit);
-
- upgradeKeyLabel = new QLabel(tr("&Upgrade key:"));
- upgradeKeyLineEdit = new QLineEdit;
- upgradeKeyLabel->setBuddy(upgradeKeyLineEdit);
-
- registerField("register.name*", nameLineEdit);
- registerField("register.upgradeKey", upgradeKeyLineEdit);
-
- QGridLayout *layout = new QGridLayout;
- layout->addWidget(nameLabel, 0, 0);
- layout->addWidget(nameLineEdit, 0, 1);
- layout->addWidget(upgradeKeyLabel, 1, 0);
- layout->addWidget(upgradeKeyLineEdit, 1, 1);
- setLayout(layout);
-}
-
-//! [24]
-# class RegisterPage
-def nextId(self):
- if self.upgradeKeyLineEdit.text().isEmpty():
- return LicenseWizard::Page_Details
- else:
- return LicenseWizard::Page_Conclusion
-//! [24]
-
-DetailsPage::DetailsPage(QWidget *parent)
- : QWizardPage(parent)
-{
- setTitle(tr("Fill In Your Details"));
- setSubTitle(tr("Please fill all three fields. Make sure to provide a valid "
- "email address (e.g., tanaka.aya@example.co.jp)."));
-
- companyLabel = new QLabel(tr("&Company name:"));
- companyLineEdit = new QLineEdit;
- companyLabel->setBuddy(companyLineEdit);
-
- emailLabel = new QLabel(tr("&Email address:"));
- emailLineEdit = new QLineEdit;
- emailLineEdit->setValidator(new QRegExpValidator(QRegExp(".*@.*"), this));
- emailLabel->setBuddy(emailLineEdit);
-
- postalLabel = new QLabel(tr("&Postal address:"));
- postalLineEdit = new QLineEdit;
- postalLabel->setBuddy(postalLineEdit);
-
- registerField("details.company*", companyLineEdit);
- registerField("details.email*", emailLineEdit);
- registerField("details.postal*", postalLineEdit);
-
- QGridLayout *layout = new QGridLayout;
- layout->addWidget(companyLabel, 0, 0);
- layout->addWidget(companyLineEdit, 0, 1);
- layout->addWidget(emailLabel, 1, 0);
- layout->addWidget(emailLineEdit, 1, 1);
- layout->addWidget(postalLabel, 2, 0);
- layout->addWidget(postalLineEdit, 2, 1);
- setLayout(layout);
-}
-
-//! [25]
-# class DetailsPage
-def nextId(self):
- return LicenseWizard.Page_Conclusion
-//! [25]
-
-ConclusionPage::ConclusionPage(QWidget *parent)
- : QWizardPage(parent)
-{
- setTitle(tr("Complete Your Registration"));
- setPixmap(QWizard::WatermarkPixmap, QPixmap(":/images/watermark.png"));
-
- bottomLabel = new QLabel;
- bottomLabel->setWordWrap(true);
-
- agreeCheckBox = new QCheckBox(tr("I agree to the terms of the license"));
-
- registerField("conclusion.agree*", agreeCheckBox);
-
- QVBoxLayout *layout = new QVBoxLayout;
- layout->addWidget(bottomLabel);
- layout->addWidget(agreeCheckBox);
- setLayout(layout);
-}
-
-//! [26]
-#class ConclusionPage
-def nextId(self):
- return -1
-//! [26]
-
-//! [27]
-# class ConclusionPage
-def initializePage(self):
- if wizard().hasVisitedPage(LicenseWizard::Page_Evaluate):
- licenseText = self.tr("<u>Evaluation License Agreement:</u> " \
- "You can use this software for 30 days and make one " \
- "backup, but you are not allowed to distribute it.")
- elsif wizard().hasVisitedPage(LicenseWizard.Page_Details):
- licenseText = self.tr("<u>First-Time License Agreement:</u> " \
- "You can use this software subject to the license " \
- "you will receive by email.")
- else:
- licenseText = self.tr("<u>Upgrade License Agreement:</u> " \
- "This software is licensed under the terms of your " \
- "current license.")
- }
- bottomLabel.setText(licenseText)
-//! [27]
-
-//! [28]
-void ConclusionPage::setVisible(bool visible)
-{
- QWizardPage::setVisible(visible);
-
- if (visible) {
-//! [29]
- self.wizard().setButtonText(QWizard.CustomButton1, self.tr("&Print"))
- self.wizard().setOption(QWizard.HaveCustomButton1, True)
- self.connect(wizard(), SIGNAL("customButtonClicked(int)"), self, SLOT("printButtonClicked()"))
-//! [29]
- } else {
- wizard()->setOption(QWizard::HaveCustomButton1, false);
- disconnect(wizard(), SIGNAL(customButtonClicked(int)),
- this, SLOT(printButtonClicked()));
- }
-}
-//! [28]
-
-void ConclusionPage::printButtonClicked()
-{
- QPrinter printer;
- QPrintDialog dialog(&printer, this);
- if (dialog.exec())
- QMessageBox::warning(this, tr("Print License"),
- tr("As an environmentally friendly measure, the "
- "license text will not actually be printed."));
-}
diff --git a/sources/pyside2/doc/codesnippets/examples/dialogs/licensewizard/main.cpp b/sources/pyside2/doc/codesnippets/examples/dialogs/licensewizard/main.cpp
deleted file mode 100644
index e372e9c17..000000000
--- a/sources/pyside2/doc/codesnippets/examples/dialogs/licensewizard/main.cpp
+++ /dev/null
@@ -1,73 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QApplication>
-#include <QTranslator>
-#include <QLocale>
-#include <QLibraryInfo>
-
-#include "licensewizard.h"
-
-int main(int argc, char *argv[])
-{
- Q_INIT_RESOURCE(licensewizard);
-
- QApplication app(argc, argv);
-
- QString translatorFileName = QLatin1String("qt_");
- translatorFileName += QLocale::system().name();
- QTranslator *translator = new QTranslator(&app);
- if (translator->load(translatorFileName, QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
- app.installTranslator(translator);
-
- LicenseWizard wizard;
- wizard.show();
- return app.exec();
-}
diff --git a/sources/pyside2/doc/codesnippets/examples/dialogs/trivialwizard/trivialwizard.cpp b/sources/pyside2/doc/codesnippets/examples/dialogs/trivialwizard/trivialwizard.cpp
deleted file mode 100644
index 6a06c1725..000000000
--- a/sources/pyside2/doc/codesnippets/examples/dialogs/trivialwizard/trivialwizard.cpp
+++ /dev/null
@@ -1,143 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtWidgets>
-#include <QTranslator>
-#include <QLocale>
-#include <QLibraryInfo>
-
-//! [0] //! [1]
-def createIntroPage(self):
- page = QWizardPage()
- page.setTitle("Introduction")
-
- label = QLabel("This wizard will help you register your copy of Super Product Two.")
- label.setWordWrap(True)
-
- layout = QVBoxLayout()
- layout.addWidget(label)
- page.setLayout(layout)
-
- return page
-//! [0]
-
-//! [2]
-QWizardPage *createRegistrationPage()
-//! [1] //! [3]
-
-//! [3]
- QWizardPage *page = new QWizardPage;
- page->setTitle("Registration");
- page->setSubTitle("Please fill both fields.");
-
- QLabel *nameLabel = new QLabel("Name:");
- QLineEdit *nameLineEdit = new QLineEdit;
-
- QLabel *emailLabel = new QLabel("Email address:");
- QLineEdit *emailLineEdit = new QLineEdit;
-
- QGridLayout *layout = new QGridLayout;
- layout->addWidget(nameLabel, 0, 0);
- layout->addWidget(nameLineEdit, 0, 1);
- layout->addWidget(emailLabel, 1, 0);
- layout->addWidget(emailLineEdit, 1, 1);
- page->setLayout(layout);
-
- return page;
-//! [4]
-
-//! [2] //! [4]
-
-//! [5] //! [6]
-def createConclusionPage(self):
-//! [5] //! [7]
-
-//! [7]
- QWizardPage *page = new QWizardPage;
- page->setTitle("Conclusion");
-
- QLabel *label = new QLabel("You are now successfully registered. Have a "
- "nice day!");
- label->setWordWrap(true);
-
- QVBoxLayout *layout = new QVBoxLayout;
- layout->addWidget(label);
- page->setLayout(layout);
-
- return page;
-//! [8]
-
-//! [6] //! [8]
-
-//! [9] //! [10]
-
-//! [9] //! [11]
-def main():
- app = QApplication(sys.argv)
-
- translatorFileName = "qt_"
- translatorFileName += QLocale.system().name()
- translator = QTranslator(app)
- if translator.load(translatorFileName, QLibraryInfo.location(QLibraryInfo.TranslationsPath)):
- app.installTranslator(translator)
-
- wizard = QWizard()
- wizard.addPage(createIntroPage())
- wizard.addPage(createRegistrationPage())
- wizard.addPage(createConclusionPage())
-
- wizard.setWindowTitle("Trivial Wizard")
- wizard.show()
-
- return app.exec_()
-
-if __name__ == "__main__":
- main()
-//! [10] //! [11]
diff --git a/sources/pyside2/doc/codesnippets/examples/itemviews/simpledommodel/dommodel.cpp b/sources/pyside2/doc/codesnippets/examples/itemviews/simpledommodel/dommodel.cpp
deleted file mode 100644
index b9f582640..000000000
--- a/sources/pyside2/doc/codesnippets/examples/itemviews/simpledommodel/dommodel.cpp
+++ /dev/null
@@ -1,197 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtWidgets>
-#include <QtXml>
-
-#include "domitem.h"
-#include "dommodel.h"
-
-//! [0]
-DomModel::DomModel(QDomDocument document, QObject *parent)
- : QAbstractItemModel(parent), domDocument(document)
-{
- rootItem = new DomItem(domDocument, 0);
-}
-//! [0]
-
-//! [1]
-DomModel::~DomModel()
-{
- delete rootItem;
-}
-//! [1]
-
-//! [2]
-def columnCount(self, parent):
- return 3
-//! [2]
-
-//! [3]
-QVariant DomModel::data(const QModelIndex &index, int role) const
-{
- if (!index.isValid())
- return QVariant();
-
- if (role != Qt::DisplayRole)
- return QVariant();
-
- DomItem *item = static_cast<DomItem*>(index.internalPointer());
-
- QDomNode node = item->node();
-//! [3] //! [4]
- QStringList attributes;
- QDomNamedNodeMap attributeMap = node.attributes();
-
- switch (index.column()) {
- case 0:
- return node.nodeName();
- case 1:
- for (int i = 0; i < attributeMap.count(); ++i) {
- QDomNode attribute = attributeMap.item(i);
- attributes << attribute.nodeName() + "=\""
- +attribute.nodeValue() + "\"";
- }
- return attributes.join(" ");
- case 2:
- return node.nodeValue().split("\n").join(" ");
- default:
- return QVariant();
- }
-}
-//! [4]
-
-//! [5]
-Qt::ItemFlags DomModel::flags(const QModelIndex &index) const
-{
- if (!index.isValid())
- return 0;
-
- return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
-}
-//! [5]
-
-//! [6]
-QVariant DomModel::headerData(int section, Qt::Orientation orientation,
- int role) const
-{
- if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
- switch (section) {
- case 0:
- return tr("Name");
- case 1:
- return tr("Attributes");
- case 2:
- return tr("Value");
- default:
- return QVariant();
- }
- }
-
- return QVariant();
-}
-//! [6]
-
-//! [7]
-QModelIndex DomModel::index(int row, int column, const QModelIndex &parent)
- const
-{
- if (!hasIndex(row, column, parent))
- return QModelIndex();
-
- DomItem *parentItem;
-
- if (!parent.isValid())
- parentItem = rootItem;
- else
- parentItem = static_cast<DomItem*>(parent.internalPointer());
-//! [7]
-
-//! [8]
- DomItem *childItem = parentItem->child(row);
- if (childItem)
- return createIndex(row, column, childItem);
- else
- return QModelIndex();
-}
-//! [8]
-
-//! [9]
-QModelIndex DomModel::parent(const QModelIndex &child) const
-{
- if (!child.isValid())
- return QModelIndex();
-
- DomItem *childItem = static_cast<DomItem*>(child.internalPointer());
- DomItem *parentItem = childItem->parent();
-
- if (!parentItem || parentItem == rootItem)
- return QModelIndex();
-
- return createIndex(parentItem->row(), 0, parentItem);
-}
-//! [9]
-
-//! [10]
-int DomModel::rowCount(const QModelIndex &parent) const
-{
- if (parent.column() > 0)
- return 0;
-
- DomItem *parentItem;
-
- if (!parent.isValid())
- parentItem = rootItem;
- else
- parentItem = static_cast<DomItem*>(parent.internalPointer());
-
- return parentItem->node().childNodes().count();
-}
-//! [10]
diff --git a/sources/pyside2/doc/codesnippets/examples/linguist/hellotr/main.cpp b/sources/pyside2/doc/codesnippets/examples/linguist/hellotr/main.cpp
deleted file mode 100644
index 7125841ef..000000000
--- a/sources/pyside2/doc/codesnippets/examples/linguist/hellotr/main.cpp
+++ /dev/null
@@ -1,78 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QApplication>
-#include <QPushButton>
-//! [0]
-from PySide2.QtCore import QTranslator
-//! [0]
-
-//! [1] //! [2]
-def main(args):
-//! [1] //! [3] //! [4]
- app = QApplication(args)
-//! [3]
-
-//! [5]
- translator = QTranslator()
-//! [5] //! [6]
- translator.load("hellotr_la")
-//! [6] //! [7]
- app.installTranslator(translator)
-//! [4] //! [7]
-
-//! [8]
- hello = QPushButton(QPushButton.tr("Hello world!"))
-//! [8]
- hello.resize(100, 30)
-
- hello.show()
- return app.exec_()
-//! [2]
diff --git a/sources/pyside2/doc/codesnippets/examples/sql/querymodel/editablesqlmodel.cpp b/sources/pyside2/doc/codesnippets/examples/sql/querymodel/editablesqlmodel.cpp
deleted file mode 100644
index 844ee7711..000000000
--- a/sources/pyside2/doc/codesnippets/examples/sql/querymodel/editablesqlmodel.cpp
+++ /dev/null
@@ -1,112 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtSql>
-
-#include "editablesqlmodel.h"
-
-EditableSqlModel::EditableSqlModel(QObject *parent)
- : QSqlQueryModel(parent)
-{
-}
-
-//! [0]
-def flags(self, index):
- flags = QSqlQueryModel.flags(index)
- if index.column() == 1 or index.column() == 2:
- flags |= Qt.ItemIsEditable
- return flags
-//! [0]
-
-//! [1]
-def setData(self, index, value, role):
- if index.column() < 1 or index.column() > 2:
- return False
-
- primaryKeyIndex = QSqlQueryModel.index(index.row(), 0)
- id = self.data(primaryKeyIndex).toInt()
-
- self.clear()
-
- ok = False
- if index.column() == 1:
- ok = self.setFirstName(id, value)
- else:
- ok = self.setLastName(id, value)
- self.refresh()
- return ok
-}
-//! [1]
-
-void EditableSqlModel::refresh()
-{
- setQuery("select * from person");
- setHeaderData(0, Qt::Horizontal, QObject::tr("ID"));
- setHeaderData(1, Qt::Horizontal, QObject::tr("First name"));
- setHeaderData(2, Qt::Horizontal, QObject::tr("Last name"));
-}
-
-//! [2]
-def setFirstName(self, personId, firstName):
- query = QSqlQuery()
- query.prepare("update person set firstname = ? where id = ?")
- query.addBindValue(firstName)
- query.addBindValue(personId)
- return query.exec()
-//! [2]
-
-bool EditableSqlModel::setLastName(int personId, const QString &lastName)
-{
- QSqlQuery query;
- query.prepare("update person set lastname = ? where id = ?");
- query.addBindValue(lastName);
- query.addBindValue(personId);
- return query.exec();
-}
diff --git a/sources/pyside2/doc/codesnippets/examples/svggenerator/window.cpp b/sources/pyside2/doc/codesnippets/examples/svggenerator/window.cpp
deleted file mode 100644
index 60c415949..000000000
--- a/sources/pyside2/doc/codesnippets/examples/svggenerator/window.cpp
+++ /dev/null
@@ -1,107 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QColorDialog>
-#include <QFileDialog>
-#include <QPainter>
-#include <QSvgGenerator>
-#include "window.h"
-#include "displaywidget.h"
-
-Window::Window(QWidget *parent)
- : QWidget(parent)
-{
- setupUi(this);
-}
-
-void Window::updateBackground(int background)
-{
- displayWidget->setBackground(DisplayWidget::Background(background));
-}
-
-void Window::updateColor()
-{
- QColor color = QColorDialog::getColor(displayWidget->color());
- if (color.isValid())
- displayWidget->setColor(color);
-}
-
-void Window::updateShape(int shape)
-{
- displayWidget->setShape(DisplayWidget::Shape(shape));
-}
-
-//! [save SVG]
-def saveSvg(self):
- newPath = QFileDialog.getSaveFileName(self, QObject.tr("Save SVG"), path, QObject.tr("SVG files (*.svg)"))
-
- if newPath.isEmpty():
- return
-
- path = newPath
-
-//![configure SVG generator]
- generator = QSvgGenerator()
- generator.setFileName(path)
- generator.setSize(QSize(200, 200))
- generator.setViewBox(QRect(0, 0, 200, 200))
- generator.setTitle(QObject.tr("SVG Generator Example Drawing"))
- generator.setDescription(QObject.tr("An SVG drawing created by the SVG Generator Example provided with Qt."))
-//![configure SVG generator]
-//![begin painting]
- painter = QPainter()
- painter.begin(generator)
-//![begin painting]
- displayWidget->paint(painter)
-//![end painting]
- painter.end()
-//![end painting]
-
-//! [save SVG]
diff --git a/sources/pyside2/doc/codesnippets/examples/uitools/textfinder/textfinder.cpp b/sources/pyside2/doc/codesnippets/examples/uitools/textfinder/textfinder.cpp
deleted file mode 100644
index e493945c9..000000000
--- a/sources/pyside2/doc/codesnippets/examples/uitools/textfinder/textfinder.cpp
+++ /dev/null
@@ -1,141 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtUiTools>
-#include <QtWidgets>
-#include "textfinder.h"
-
-//! [0]
-def __init__(self, parent = None):
- QWidget.__init__(self. parent)
- formWidget = self.loadUiFile()
-
-//! [1]
- self.ui_findButton = qFindChild(QPushButton, self, "findButton")
- self.ui_textEdit = qFindChild(QTextEdit, self, "textEdit")
- self.ui_lineEdit = qFindChild(QLineEdit, self, "lineEdit")
-//! [0] //! [1]
-
-//! [2]
- QMetaObject.connectSlotsByName(self)
-//! [2]
-
-//! [3a]
- self.loadTextFile()
-//! [3a]
-
-//! [3b]
- layout = QVBoxLayout()
- layout.addWidget(formWidget)
- self.setLayout(layout)
-//! [3b]
-
-//! [3c]
- self.setWindowTitle("Text Finder")
- self.isFirstTime = True
-//! [3c]
-
-//! [4]
-def loadUiFile(self):
- loader = QUiLoader()
- return loader.load(":/forms/textfinder.ui", self)
-//! [4]
-
-//! [5]
-def loadTextFile(self):
- inputFile = QFile(":/forms/input.txt")
- inputFile.open(QIODevice.ReadOnly)
- in = QTextStream(inputFile)
- line = in.readAll()
- inputFile.close()
-
- self.ui_textEdit.append(line)
- self.ui_textEdit.setUndoRedoEnabled(False)
- self.ui_textEdit.setUndoRedoEnabled(True)
-//! [5]
-
-//! [6] //! [7]
-@Slot()
-def on_findButton_clicked(self):
- searchString = self.ui_lineEdit.text()
- document = self.ui_textEdit.document()
-
- found = False
-
- if not self.isFirstTime:
- document.undo()
-
- if not searchString:
- QMessageBox.information(self, "Empty Search Field",
- "The search field is empty. Please enter a word and click Find.")
- else:
- highlightCursor = QTextCursor(document)
- cursor = QTextCursor(document)
- cursor.beginEditBlock()
-//! [6]
- plainFormat = QTextCharFormat(highlightCursor.charFormat())
- colorFormat = QTextCharFormat(plainFormat)
- colorFormat.setForeground(Qt.red)
-
- while not highlightCursor.isNull() and not highlightCursor.atEnd():
- highlightCursor = document.find(searchString, highlightCursor, QTextDocument.FindWholeWords)
-
- if not highlightCursor.isNull():
- found = True
- highlightCursor.movePosition(QTextCursor.WordRight, QTextCursor.KeepAnchor)
- highlightCursor.mergeCharFormat(colorFormat)
-//! [8]
- cursor.endEditBlock()
-//! [7] //! [9]
- self.isFirstTime = False
-
- if not found:
- QMessageBox.information(self, "Word Not Found", "Sorry, the word cannot be found.");
-//! [8] //! [9]
diff --git a/sources/pyside2/doc/codesnippets/examples/widgets/analogclock/analogclock.cpp b/sources/pyside2/doc/codesnippets/examples/widgets/analogclock/analogclock.cpp
deleted file mode 100644
index dcd24b275..000000000
--- a/sources/pyside2/doc/codesnippets/examples/widgets/analogclock/analogclock.cpp
+++ /dev/null
@@ -1,155 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtWidgets>
-
-#include "analogclock.h"
-
-//! [0] //! [1]
-AnalogClock::AnalogClock(QWidget *parent)
-//! [0] //! [2]
- : QWidget(parent)
-//! [2] //! [3]
-{
-//! [3] //! [4]
- timer = QTimer(self)
-//! [4] //! [5]
- self.connect(timer, SIGNAL("timeout()"), self.update)
-//! [5] //! [6]
- timer.start(1000)
-//! [6]
-
- setWindowTitle(tr("Analog Clock"));
- resize(200, 200);
-//! [7]
-}
-//! [1] //! [7]
-
-//! [8] //! [9]
-void AnalogClock::paintEvent(QPaintEvent *)
-//! [8] //! [10]
-{
- static const QPoint hourHand[3] = {
- QPoint(7, 8),
- QPoint(-7, 8),
- QPoint(0, -40)
- };
- static const QPoint minuteHand[3] = {
- QPoint(7, 8),
- QPoint(-7, 8),
- QPoint(0, -70)
- };
-
- QColor hourColor(127, 0, 127);
- QColor minuteColor(0, 127, 127, 191);
-
- int side = qMin(width(), height());
- QTime time = QTime::currentTime();
-//! [10]
-
-//! [11]
- QPainter painter(this);
-//! [11] //! [12]
- painter.setRenderHint(QPainter::Antialiasing);
-//! [12] //! [13]
- painter.translate(width() / 2, height() / 2);
-//! [13] //! [14]
- painter.scale(side / 200.0, side / 200.0);
-//! [9] //! [14]
-
-//! [15]
- painter.setPen(Qt::NoPen);
-//! [15] //! [16]
- painter.setBrush(hourColor);
-//! [16]
-
-//! [17] //! [18]
- painter.save();
-//! [17] //! [19]
- painter.rotate(30.0 * ((time.hour() + time.minute() / 60.0)));
- painter.drawConvexPolygon(hourHand, 3);
- painter.restore();
-//! [18] //! [19]
-
-//! [20]
- painter.setPen(hourColor);
-//! [20] //! [21]
-
- for (int i = 0; i < 12; ++i) {
- painter.drawLine(88, 0, 96, 0);
- painter.rotate(30.0);
- }
-//! [21]
-
-//! [22]
- painter.setPen(Qt::NoPen);
-//! [22] //! [23]
- painter.setBrush(minuteColor);
-
-//! [24]
- painter.save();
- painter.rotate(6.0 * (time.minute() + time.second() / 60.0));
- painter.drawConvexPolygon(minuteHand, 3);
- painter.restore();
-//! [23] //! [24]
-
-//! [25]
- painter.setPen(minuteColor);
-//! [25] //! [26]
-
-//! [27]
- for (int j = 0; j < 60; ++j) {
- if ((j % 5) != 0)
- painter.drawLine(92, 0, 96, 0);
- painter.rotate(6.0);
- }
-//! [27]
-}
-//! [26]
diff --git a/sources/pyside2/doc/codesnippets/examples/xml/streambookmarks/xbelreader.cpp b/sources/pyside2/doc/codesnippets/examples/xml/streambookmarks/xbelreader.cpp
deleted file mode 100644
index c82f02752..000000000
--- a/sources/pyside2/doc/codesnippets/examples/xml/streambookmarks/xbelreader.cpp
+++ /dev/null
@@ -1,210 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtWidgets>
-
-#include "xbelreader.h"
-
-//! [0]
-XbelReader::XbelReader(QTreeWidget *treeWidget)
- : treeWidget(treeWidget)
-{
- QStyle *style = treeWidget->style();
-
- folderIcon.addPixmap(style->standardPixmap(QStyle::SP_DirClosedIcon),
- QIcon::Normal, QIcon::Off);
- folderIcon.addPixmap(style->standardPixmap(QStyle::SP_DirOpenIcon),
- QIcon::Normal, QIcon::On);
- bookmarkIcon.addPixmap(style->standardPixmap(QStyle::SP_FileIcon));
-}
-//! [0]
-
-//! [1]
-def read(self, device):
- self.setDevice(device)
-
- while not atEnd():
- readNext()
-
- if isStartElement():
- if self.name() == "xbel" and self.attributes().value("version") == "1.0":
- self.readXBEL()
- else:
- self.raiseError(QObject.tr("The file is not an XBEL version 1.0 file."));
-
- return not self.error();
-//! [1]
-
-//! [2]
-void XbelReader::readUnknownElement()
-{
- Q_ASSERT(isStartElement());
-
- while (!atEnd()) {
- readNext();
-
- if (isEndElement())
- break;
-
- if (isStartElement())
- readUnknownElement();
- }
-}
-//! [2]
-
-//! [3]
-void XbelReader::readXBEL()
-{
- Q_ASSERT(isStartElement() && name() == "xbel");
-
- while (!atEnd()) {
- readNext();
-
- if (isEndElement())
- break;
-
- if (isStartElement()) {
- if (name() == "folder")
- readFolder(0);
- else if (name() == "bookmark")
- readBookmark(0);
- else if (name() == "separator")
- readSeparator(0);
- else
- readUnknownElement();
- }
- }
-}
-//! [3]
-
-//! [4]
-void XbelReader::readTitle(QTreeWidgetItem *item)
-{
- Q_ASSERT(isStartElement() && name() == "title");
-
- QString title = readElementText();
- item->setText(0, title);
-}
-//! [4]
-
-//! [5]
-void XbelReader::readSeparator(QTreeWidgetItem *item)
-{
- QTreeWidgetItem *separator = createChildItem(item);
- separator->setFlags(item->flags() & ~Qt::ItemIsSelectable);
- separator->setText(0, QString(30, 0xB7));
- readElementText();
-}
-//! [5]
-
-void XbelReader::readFolder(QTreeWidgetItem *item)
-{
- Q_ASSERT(isStartElement() && name() == "folder");
-
- QTreeWidgetItem *folder = createChildItem(item);
- bool folded = (attributes().value("folded") != "no");
- treeWidget->setItemExpanded(folder, !folded);
-
- while (!atEnd()) {
- readNext();
-
- if (isEndElement())
- break;
-
- if (isStartElement()) {
- if (name() == "title")
- readTitle(folder);
- else if (name() == "folder")
- readFolder(folder);
- else if (name() == "bookmark")
- readBookmark(folder);
- else if (name() == "separator")
- readSeparator(folder);
- else
- readUnknownElement();
- }
- }
-}
-
-void XbelReader::readBookmark(QTreeWidgetItem *item)
-{
- Q_ASSERT(isStartElement() && name() == "bookmark");
-
- QTreeWidgetItem *bookmark = createChildItem(item);
- bookmark->setFlags(bookmark->flags() | Qt::ItemIsEditable);
- bookmark->setIcon(0, bookmarkIcon);
- bookmark->setText(0, QObject::tr("Unknown title"));
- bookmark->setText(1, attributes().value("href").toString());
- while (!atEnd()) {
- readNext();
-
- if (isEndElement())
- break;
-
- if (isStartElement()) {
- if (name() == "title")
- readTitle(bookmark);
- else
- readUnknownElement();
- }
- }
-}
-
-QTreeWidgetItem *XbelReader::createChildItem(QTreeWidgetItem *item)
-{
- QTreeWidgetItem *childItem;
- if (item) {
- childItem = new QTreeWidgetItem(item);
- } else {
- childItem = new QTreeWidgetItem(treeWidget);
- }
- childItem->setData(0, Qt::UserRole, name().toString());
- return childItem;
-}
diff --git a/sources/pyside2/doc/codesnippets/examples/xml/streambookmarks/xbelwriter.cpp b/sources/pyside2/doc/codesnippets/examples/xml/streambookmarks/xbelwriter.cpp
deleted file mode 100644
index 372bc53bf..000000000
--- a/sources/pyside2/doc/codesnippets/examples/xml/streambookmarks/xbelwriter.cpp
+++ /dev/null
@@ -1,100 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtWidgets>
-
-#include "xbelwriter.h"
-
-//! [0]
-XbelWriter::XbelWriter(QTreeWidget *treeWidget)
- : treeWidget(treeWidget)
-{
- setAutoFormatting(true);
-}
-//! [0]
-
-//! [1]
-def writeFile(self, device):
- self.setDevice(device)
-
- self.writeStartDocument()
- self.writeDTD("<!DOCTYPE xbel>")
- self.writeStartElement("xbel")
- self.writeAttribute("version", "1.0")
- for i in range(0, self.treeWidget.topLevelItemCount()):
- self.writeItem(self.treeWidget.topLevelItem(i))
-
- self.writeEndDocument()
- return True;
-//! [1]
-
-//! [2]
-void XbelWriter::writeItem(QTreeWidgetItem *item)
-{
- QString tagName = item->data(0, Qt::UserRole).toString();
- if (tagName == "folder") {
- bool folded = !treeWidget->isItemExpanded(item);
- writeStartElement(tagName);
- writeAttribute("folded", folded ? "yes" : "no");
- writeTextElement("title", item->text(0));
- for (int i = 0; i < item->childCount(); ++i)
- writeItem(item->child(i));
- writeEndElement();
- } else if (tagName == "bookmark") {
- writeStartElement(tagName);
- if (!item->text(1).isEmpty())
- writeAttribute("href", item->text(1));
- writeTextElement("title", item->text(0));
- writeEndElement();
- } else if (tagName == "separator") {
- writeEmptyElement(tagName);
- }
-}
-//! [2]