diff options
Diffstat (limited to 'examples/tools')
-rw-r--r-- | examples/tools/README | 9 | ||||
-rw-r--r-- | examples/tools/contiguouscache/contiguouscache.pro | 9 | ||||
-rw-r--r-- | examples/tools/contiguouscache/main.cpp | 55 | ||||
-rw-r--r-- | examples/tools/contiguouscache/randomlistmodel.cpp | 96 | ||||
-rw-r--r-- | examples/tools/contiguouscache/randomlistmodel.h | 66 | ||||
-rw-r--r-- | examples/tools/customtype/customtype.pro | 8 | ||||
-rw-r--r-- | examples/tools/customtype/main.cpp | 73 | ||||
-rw-r--r-- | examples/tools/customtype/message.cpp | 89 | ||||
-rw-r--r-- | examples/tools/customtype/message.h | 75 | ||||
-rw-r--r-- | examples/tools/customtypesending/customtypesending.pro | 10 | ||||
-rw-r--r-- | examples/tools/customtypesending/main.cpp | 67 | ||||
-rw-r--r-- | examples/tools/customtypesending/message.cpp | 71 | ||||
-rw-r--r-- | examples/tools/customtypesending/message.h | 71 | ||||
-rw-r--r-- | examples/tools/customtypesending/window.cpp | 79 | ||||
-rw-r--r-- | examples/tools/customtypesending/window.h | 72 | ||||
-rw-r--r-- | examples/tools/doc/contiguouscache.qdoc | 83 | ||||
-rw-r--r-- | examples/tools/doc/src/customtype.qdoc | 143 | ||||
-rw-r--r-- | examples/tools/tools.pro | 7 |
18 files changed, 0 insertions, 1083 deletions
diff --git a/examples/tools/README b/examples/tools/README deleted file mode 100644 index db5c107c82..0000000000 --- a/examples/tools/README +++ /dev/null @@ -1,9 +0,0 @@ -Qt is equipped with a range of capable tool classes, from containers and -iterators to classes for string handling and manipulation. - -Other classes provide application infrastructure support, handling plugin -loading and managing configuration files. - - -Documentation for these examples can be found via the Examples -link in the main Qt documentation. diff --git a/examples/tools/contiguouscache/contiguouscache.pro b/examples/tools/contiguouscache/contiguouscache.pro deleted file mode 100644 index d384a1845a..0000000000 --- a/examples/tools/contiguouscache/contiguouscache.pro +++ /dev/null @@ -1,9 +0,0 @@ -QT += widgets - -HEADERS = randomlistmodel.h -SOURCES = randomlistmodel.cpp \ - main.cpp - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/tools/contiguouscache -INSTALLS += target diff --git a/examples/tools/contiguouscache/main.cpp b/examples/tools/contiguouscache/main.cpp deleted file mode 100644 index 62fa8dcf42..0000000000 --- a/examples/tools/contiguouscache/main.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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 Digia Plc and its Subsidiary(-ies) 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 "randomlistmodel.h" -#include <QListView> -#include <QApplication> - -int main(int c, char **v) -{ - QApplication a(c, v); - - QListView view; - view.setUniformItemSizes(true); - view.setModel(new RandomListModel(&view)); - view.show(); - - return a.exec(); -} diff --git a/examples/tools/contiguouscache/randomlistmodel.cpp b/examples/tools/contiguouscache/randomlistmodel.cpp deleted file mode 100644 index cd1a301dc7..0000000000 --- a/examples/tools/contiguouscache/randomlistmodel.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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 Digia Plc and its Subsidiary(-ies) 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 "randomlistmodel.h" -#include <stdlib.h> - -static const int bufferSize(500); -static const int lookAhead(100); -static const int halfLookAhead(lookAhead/2); - -RandomListModel::RandomListModel(QObject *parent) -: QAbstractListModel(parent), m_rows(bufferSize), m_count(10000) -{ -} - -RandomListModel::~RandomListModel() -{ -} - -int RandomListModel::rowCount(const QModelIndex &) const -{ - return m_count; -} - -//! [0] -QVariant RandomListModel::data(const QModelIndex &index, int role) const -{ - if (role != Qt::DisplayRole) - return QVariant(); - - int row = index.row(); - - if (row > m_rows.lastIndex()) { - if (row - m_rows.lastIndex() > lookAhead) - cacheRows(row-halfLookAhead, qMin(m_count, row+halfLookAhead)); - else while (row > m_rows.lastIndex()) - m_rows.append(fetchRow(m_rows.lastIndex()+1)); - } else if (row < m_rows.firstIndex()) { - if (m_rows.firstIndex() - row > lookAhead) - cacheRows(qMax(0, row-halfLookAhead), row+halfLookAhead); - else while (row < m_rows.firstIndex()) - m_rows.prepend(fetchRow(m_rows.firstIndex()-1)); - } - - return m_rows.at(row); -} - -void RandomListModel::cacheRows(int from, int to) const -{ - for (int i = from; i <= to; ++i) - m_rows.insert(i, fetchRow(i)); -} -//![0] - -//![1] -QString RandomListModel::fetchRow(int position) const -{ - return QString::number(rand() % ++position); -} -//![1] diff --git a/examples/tools/contiguouscache/randomlistmodel.h b/examples/tools/contiguouscache/randomlistmodel.h deleted file mode 100644 index 3acafc23ff..0000000000 --- a/examples/tools/contiguouscache/randomlistmodel.h +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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 Digia Plc and its Subsidiary(-ies) 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$ -** -****************************************************************************/ -#ifndef RANDOMLISTMODEL_H -#define RANDOMLISTMODEL_H - -#include <QContiguousCache> -#include <QAbstractListModel> - -QT_FORWARD_DECLARE_CLASS(QTimer) - -class RandomListModel : public QAbstractListModel -{ - Q_OBJECT -public: - RandomListModel(QObject *parent = 0); - ~RandomListModel(); - - int rowCount(const QModelIndex & = QModelIndex()) const Q_DECL_OVERRIDE; - QVariant data(const QModelIndex &, int) const Q_DECL_OVERRIDE; - -private: - void cacheRows(int, int) const; - QString fetchRow(int) const; - - mutable QContiguousCache<QString> m_rows; - const int m_count; -}; - -#endif diff --git a/examples/tools/customtype/customtype.pro b/examples/tools/customtype/customtype.pro deleted file mode 100644 index d05540f403..0000000000 --- a/examples/tools/customtype/customtype.pro +++ /dev/null @@ -1,8 +0,0 @@ -HEADERS = message.h -SOURCES = main.cpp \ - message.cpp -QT += widgets - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/tools/customcompleter -INSTALLS += target diff --git a/examples/tools/customtype/main.cpp b/examples/tools/customtype/main.cpp deleted file mode 100644 index 8e97d3db96..0000000000 --- a/examples/tools/customtype/main.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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 Digia Plc and its Subsidiary(-ies) 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 <QCoreApplication> -#include <QVariant> -#include "message.h" - -int main(int argc, char *argv[]) -{ - QCoreApplication app(argc, argv); - QStringList headers; - headers << "Subject: Hello World" - << "From: address@example.com"; - QString body = "This is a test.\r\n"; - -//! [printing a custom type] - Message message(body, headers); - qDebug() << "Original:" << message; -//! [printing a custom type] - -//! [storing a custom value] - QVariant stored; - stored.setValue(message); -//! [storing a custom value] - - qDebug() << "Stored:" << stored; - -//! [retrieving a custom value] - Message retrieved = stored.value<Message>(); - qDebug() << "Retrieved:" << retrieved; - retrieved = qvariant_cast<Message>(stored); - qDebug() << "Retrieved:" << retrieved; -//! [retrieving a custom value] - - return 0; -} diff --git a/examples/tools/customtype/message.cpp b/examples/tools/customtype/message.cpp deleted file mode 100644 index c470ab116e..0000000000 --- a/examples/tools/customtype/message.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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 Digia Plc and its Subsidiary(-ies) 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 "message.h" - -//! [Message class implementation] -Message::Message() -{ -} - -Message::Message(const Message &other) -{ - m_body = other.m_body; - m_headers = other.m_headers; -} - -Message::~Message() -{ -} -//! [Message class implementation] - -Message::Message(const QString &body, const QStringList &headers) -{ - m_body = body; - m_headers = headers; -} - -//! [custom type streaming operator] -QDebug operator<<(QDebug dbg, const Message &message) -{ - QStringList pieces = message.body().split("\r\n", QString::SkipEmptyParts); - if (pieces.isEmpty()) - dbg.nospace() << "Message()"; - else if (pieces.size() == 1) - dbg.nospace() << "Message(" << pieces.first() << ")"; - else - dbg.nospace() << "Message(" << pieces.first() << " ...)"; - return dbg.maybeSpace(); -} -//! [custom type streaming operator] - -//! [getter functions] -QString Message::body() const -{ - return m_body; -} - -QStringList Message::headers() const -{ - return m_headers; -} -//! [getter functions] diff --git a/examples/tools/customtype/message.h b/examples/tools/customtype/message.h deleted file mode 100644 index cdc4e39caf..0000000000 --- a/examples/tools/customtype/message.h +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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 Digia Plc and its Subsidiary(-ies) 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$ -** -****************************************************************************/ - -#ifndef MESSAGE_H -#define MESSAGE_H - -#include <QDebug> -#include <QMetaType> -#include <QStringList> - -//! [custom type definition] -class Message -{ -public: - Message(); - Message(const Message &other); - ~Message(); - - Message(const QString &body, const QStringList &headers); - - QString body() const; - QStringList headers() const; - -private: - QString m_body; - QStringList m_headers; -}; -//! [custom type definition] - -//! [custom type meta-type declaration] -Q_DECLARE_METATYPE(Message); -//! [custom type meta-type declaration] - -//! [custom type streaming operator] -QDebug operator<<(QDebug dbg, const Message &message); -//! [custom type streaming operator] - -#endif diff --git a/examples/tools/customtypesending/customtypesending.pro b/examples/tools/customtypesending/customtypesending.pro deleted file mode 100644 index faa07bf339..0000000000 --- a/examples/tools/customtypesending/customtypesending.pro +++ /dev/null @@ -1,10 +0,0 @@ -HEADERS = message.h \ - window.h -SOURCES = main.cpp \ - message.cpp \ - window.cpp -QT += widgets - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/tools/customcompleter -INSTALLS += target diff --git a/examples/tools/customtypesending/main.cpp b/examples/tools/customtypesending/main.cpp deleted file mode 100644 index 5f01e2a154..0000000000 --- a/examples/tools/customtypesending/main.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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 Digia Plc and its Subsidiary(-ies) 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 "message.h" -#include "window.h" - -//! [main function] -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - - Window window1; - QStringList headers; - headers << "Subject: Hello World" - << "From: address@example.com"; - QString body = "This is a test.\r\n"; - Message message(body, headers); - window1.setMessage(message); - - Window window2; - QObject::connect(&window1, SIGNAL(messageSent(Message)), - &window2, SLOT(setMessage(Message))); - QObject::connect(&window2, SIGNAL(messageSent(Message)), - &window1, SLOT(setMessage(Message))); - window1.show(); - window2.show(); - return app.exec(); -} -//! [main function] diff --git a/examples/tools/customtypesending/message.cpp b/examples/tools/customtypesending/message.cpp deleted file mode 100644 index 9b53b8757d..0000000000 --- a/examples/tools/customtypesending/message.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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 Digia Plc and its Subsidiary(-ies) 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 "message.h" - -Message::Message() -{ -} - -Message::Message(const Message &other) -{ - m_body = other.m_body; - m_headers = other.m_headers; -} - -Message::~Message() -{ -} - -Message::Message(const QString &body, const QStringList &headers) -{ - m_body = body; - m_headers = headers; -} - -QString Message::body() const -{ - return m_body; -} - -QStringList Message::headers() const -{ - return m_headers; -} diff --git a/examples/tools/customtypesending/message.h b/examples/tools/customtypesending/message.h deleted file mode 100644 index 3e5f17db2b..0000000000 --- a/examples/tools/customtypesending/message.h +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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 Digia Plc and its Subsidiary(-ies) 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$ -** -****************************************************************************/ - -#ifndef MESSAGE_H -#define MESSAGE_H - -#include <QDebug> -#include <QMetaType> -#include <QStringList> - -//! [custom type definition] -class Message -{ -public: - Message(); - Message(const Message &other); - ~Message(); - - Message(const QString &body, const QStringList &headers); - - QString body() const; - QStringList headers() const; - -private: - QString m_body; - QStringList m_headers; -}; -//! [custom type definition] - -//! [custom type meta-type declaration] -Q_DECLARE_METATYPE(Message); -//! [custom type meta-type declaration] - -#endif diff --git a/examples/tools/customtypesending/window.cpp b/examples/tools/customtypesending/window.cpp deleted file mode 100644 index aa4a7eab3c..0000000000 --- a/examples/tools/customtypesending/window.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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 Digia Plc and its Subsidiary(-ies) 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 "window.h" - -//! [Window constructor] -Window::Window() -{ - editor = new QTextEdit(); - QPushButton *sendButton = new QPushButton(tr("&Send message")); - - connect(sendButton, SIGNAL(clicked()), this, SLOT(sendMessage())); - - QHBoxLayout *buttonLayout = new QHBoxLayout(); - buttonLayout->addStretch(); - buttonLayout->addWidget(sendButton); - buttonLayout->addStretch(); - - QVBoxLayout *layout = new QVBoxLayout(this); - layout->addWidget(editor); - layout->addLayout(buttonLayout); - - setWindowTitle(tr("Custom Type Sending")); -} -//! [Window constructor] - -//! [sending a message] -void Window::sendMessage() -{ - thisMessage = Message(editor->toPlainText(), thisMessage.headers()); - emit messageSent(thisMessage); -} -//! [sending a message] - -//! [receiving a message] -void Window::setMessage(const Message &message) -{ - thisMessage = message; - editor->setPlainText(thisMessage.body()); -} -//! [receiving a message] diff --git a/examples/tools/customtypesending/window.h b/examples/tools/customtypesending/window.h deleted file mode 100644 index 0889800064..0000000000 --- a/examples/tools/customtypesending/window.h +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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 Digia Plc and its Subsidiary(-ies) 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$ -** -****************************************************************************/ - -#ifndef WINDOW_H -#define WINDOW_H - -#include <QWidget> -#include "message.h" - -QT_FORWARD_DECLARE_CLASS(QTextEdit) - -//! [Window class definition] -class Window : public QWidget -{ - Q_OBJECT - -public: - Window(); - -signals: - void messageSent(const Message &message); - -public slots: - void setMessage(const Message &message); - -private slots: - void sendMessage(); - -private: - Message thisMessage; - QTextEdit *editor; -}; -//! [Window class definition] - -#endif diff --git a/examples/tools/doc/contiguouscache.qdoc b/examples/tools/doc/contiguouscache.qdoc deleted file mode 100644 index 2f7ea716e6..0000000000 --- a/examples/tools/doc/contiguouscache.qdoc +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** 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 Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Free Documentation License Usage -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: http://www.gnu.org/copyleft/fdl.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \example contiguouscache - \title Contiguous Cache Example - - \brief The Contiguous Cache example shows how to use QContiguousCache to manage memory usage for - very large models. In some environments memory is limited and, even when it - isn't, users still dislike an application using excessive memory. - Using QContiguousCache to manage a list, rather than loading - the entire list into memory, allows the application to limit the amount - of memory it uses, regardless of the size of the data set it accesses - - The simplest way to use QContiguousCache is to cache as items are requested. When - a view requests an item at row N it is also likely to ask for items at rows near - to N. - - \snippet contiguouscache/randomlistmodel.cpp 0 - - After getting the row, the class determines if the row is in the bounds - of the contiguous cache's current range. It would have been equally valid to - simply have the following code instead. - - \code - while (row > m_rows.lastIndex()) - m_rows.append(fetchWord(m_rows.lastIndex()+1); - while (row < m_rows.firstIndex()) - m_rows.prepend(fetchWord(m_rows.firstIndex()-1); - \endcode - - However a list will often jump rows if the scroll bar is used directly, resulting in - the code above causing every row between the old and new rows to be fetched. - - Using QContiguousCache::lastIndex() and QContiguousCache::firstIndex() allows - the example to determine what part of the list the cache is currently caching. - These values don't represent the indexes into the cache's own memory, but rather - a virtual infinite array that the cache represents. - - By using QContiguousCache::append() and QContiguousCache::prepend() the code ensures - that items that may be still on the screen are not lost when the requested row - has not moved far from the current cache range. QContiguousCache::insert() can - potentially remove more than one item from the cache as QContiguousCache does not - allow for gaps. If your cache needs to quickly jump back and forth between - rows with significant gaps between them consider using QCache instead. - - And thats it. A perfectly reasonable cache, using minimal memory for a very large - list. In this case the accessor for getting the words into the cache - generates random information rather than fixed information. This allows you - to see how the cache range is kept for a local number of rows when running the - example. - - \snippet contiguouscache/randomlistmodel.cpp 1 - - It is also worth considering pre-fetching items into the cache outside of the - application's paint routine. This can be done either with a separate thread - or using a QTimer to incrementally expand the range of the cache prior to - rows being requested out of the current cache range. -*/ diff --git a/examples/tools/doc/src/customtype.qdoc b/examples/tools/doc/src/customtype.qdoc deleted file mode 100644 index e016933e04..0000000000 --- a/examples/tools/doc/src/customtype.qdoc +++ /dev/null @@ -1,143 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** 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 Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Free Documentation License Usage -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: http://www.gnu.org/copyleft/fdl.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \example customtype - \title Custom Type Example - - \brief The Custom Type example shows how to integrate a custom type into Qt's - meta-object system. - - Contents: - - \tableofcontents - - \section1 Overview - - Qt provides a range of standard value types that are used to provide - rich and meaningful APIs. These types are integrated with the meta-object - system, enabling them to be stored in QVariant objects, written out in - debugging information and sent between components in signal-slot - communication. - - Custom types can also be integrated with the meta-object system as long as - they are written to conform to some simple guidelines. In this example, we - introduce a simple \c Message class, we describe how we make it work with - QVariant, and we show how it can be extended to generate a printable - representation of itself for use in debugging output. - - \section1 The Message Class Definition - - The \c Message class is a simple value class that contains two pieces - of information (a QString and a QStringList), each of which can be read - using trivial getter functions: - - \snippet customtype/message.h custom type definition - - The default constructor, copy constructor and destructor are - all required, and must be public, if the type is to be integrated into the - meta-object system. Other than this, we are free to implement whatever we - need to make the type do what we want, so we also include a constructor - that lets us set the type's data members. - - To enable the type to be used with QVariant, we declare it using the - Q_DECLARE_METATYPE() macro: - - \snippet customtype/message.h custom type meta-type declaration - - We do not need to write any additional code to accompany this macro. - - To allow us to see a readable description of each \c Message object when it - is sent to the debug output stream, we define a streaming operator: - - \snippet customtype/message.h custom type streaming operator - - This facility is useful if you need to insert tracing statements in your - code for debugging purposes. - - \section1 The Message Class Implementation - - The implementation of the default constructor, copy constructor and destructor - are straightforward for the \c Message class: - - \snippet customtype/message.cpp Message class implementation - - The streaming operator is implemented in the following way: - - \snippet customtype/message.cpp custom type streaming operator - - Here, we want to represent each value depending on how many lines are stored - in the message body. We stream text to the QDebug object passed to the - operator and return the QDebug object obtained from its maybeSpace() member - function; this is described in more detail in the - \l{Creating Custom Qt Types#Making the Type Printable}{Creating Custom Qt Types} - document. - - We include the code for the getter functions for completeness: - - \snippet customtype/message.cpp getter functions - - With the type fully defined, implemented, and integrated with the - meta-object system, we can now use it. - - \section1 Using the Message - - In the example's \c{main()} function, we show how a \c Message object can - be printed to the console by sending it to the debug stream: - - \snippet customtype/main.cpp printing a custom type - - You can use the type with QVariant in exactly the same way as you would - use standard Qt value types. Here's how to store a value using the - QVariant::setValue() function: - - \snippet customtype/main.cpp storing a custom value - - Alternatively, the QVariant::fromValue() and qVariantSetValue() functions - can be used if you are using a compiler without support for member template - functions. - - The value can be retrieved using the QVariant::value() member template - function: - - \snippet customtype/main.cpp retrieving a custom value - - Alternatively, the qVariantValue() template function can be used if - you are using a compiler without support for member template functions. - - \section1 Further Reading - - The custom \c Message type can also be used with direct signal-slot - connections. - - To register a custom type for use with queued signals and slots, such as - those used in cross-thread communication, see the - \l{Queued Custom Type Example}. - - More information on using custom types with Qt can be found in the - \l{Creating Custom Qt Types} document. -*/ diff --git a/examples/tools/tools.pro b/examples/tools/tools.pro deleted file mode 100644 index 36fa776980..0000000000 --- a/examples/tools/tools.pro +++ /dev/null @@ -1,7 +0,0 @@ -requires(qtHaveModule(widgets)) - -TEMPLATE = subdirs -CONFIG += ordered -SUBDIRS = contiguouscache \ - customtype \ - customtypesending |