diff options
Diffstat (limited to 'examples/draganddrop')
-rw-r--r-- | examples/draganddrop/delayedencoding/delayedencoding.pro | 17 | ||||
-rw-r--r-- | examples/draganddrop/delayedencoding/delayedencoding.qrc | 6 | ||||
-rw-r--r-- | examples/draganddrop/delayedencoding/images/drag.png | bin | 977 -> 0 bytes | |||
-rw-r--r-- | examples/draganddrop/delayedencoding/images/example.svg | 58 | ||||
-rw-r--r-- | examples/draganddrop/delayedencoding/main.cpp | 51 | ||||
-rw-r--r-- | examples/draganddrop/delayedencoding/mimedata.cpp | 65 | ||||
-rw-r--r-- | examples/draganddrop/delayedencoding/mimedata.h | 63 | ||||
-rw-r--r-- | examples/draganddrop/delayedencoding/sourcewidget.cpp | 115 | ||||
-rw-r--r-- | examples/draganddrop/delayedencoding/sourcewidget.h | 70 | ||||
-rw-r--r-- | examples/draganddrop/draganddrop.pro | 8 |
10 files changed, 0 insertions, 453 deletions
diff --git a/examples/draganddrop/delayedencoding/delayedencoding.pro b/examples/draganddrop/delayedencoding/delayedencoding.pro deleted file mode 100644 index d0e6395..0000000 --- a/examples/draganddrop/delayedencoding/delayedencoding.pro +++ /dev/null @@ -1,17 +0,0 @@ -QT += svg - -HEADERS = mimedata.h \ - sourcewidget.h -RESOURCES = delayedencoding.qrc -SOURCES = main.cpp \ - mimedata.cpp \ - sourcewidget.cpp - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtsvg/draganddrop/delayedencoding -sources.files = $$SOURCES $$HEADERS *.pro $$RESOURCES images -sources.path = $$[QT_INSTALL_EXAMPLES]/qtsvg/draganddrop/delayedencoding -INSTALLS += target sources - -simulator: warning(This example does not work on Simulator platform) -QT+=widgets diff --git a/examples/draganddrop/delayedencoding/delayedencoding.qrc b/examples/draganddrop/delayedencoding/delayedencoding.qrc deleted file mode 100644 index 374f211..0000000 --- a/examples/draganddrop/delayedencoding/delayedencoding.qrc +++ /dev/null @@ -1,6 +0,0 @@ -<!DOCTYPE RCC><RCC version="1.0"> -<qresource prefix=""> - <file>images/drag.png</file> - <file>images/example.svg</file> -</qresource> -</RCC> diff --git a/examples/draganddrop/delayedencoding/images/drag.png b/examples/draganddrop/delayedencoding/images/drag.png Binary files differdeleted file mode 100644 index dd795cf..0000000 --- a/examples/draganddrop/delayedencoding/images/drag.png +++ /dev/null diff --git a/examples/draganddrop/delayedencoding/images/example.svg b/examples/draganddrop/delayedencoding/images/example.svg deleted file mode 100644 index 89a9129..0000000 --- a/examples/draganddrop/delayedencoding/images/example.svg +++ /dev/null @@ -1,58 +0,0 @@ -<?xml version="1.0" standalone="no"?> -<!-- *********************************************************************** -** -** Copyright (C) 2012 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$ -** -************************************************************************ --> -<svg width="8cm" height="8cm" viewBox="0 0 400 400" - xmlns="http://www.w3.org/2000/svg" baseProfile="tiny" version="1.1"> - <title>Sphere</title> - <desc>A gradient filled sphere.</desc> - <g> - <defs> - <radialGradient id="blueSphere" gradientUnits="userSpaceOnUse" - cx="200" cy="200" r="100" fx="150" fy="150"> - <stop offset="0%" stop-color="white" /> - <stop offset="75%" stop-color="blue" /> - <stop offset="100%" stop-color="black" /> - </radialGradient> - </defs> - <rect fill="lightblue" x="0" y="0" width="400" height="400" /> - <circle fill="url(#blueSphere)" stroke="black" stroke-width="2" - cx="200" cy="200" r="100"/> - </g> -</svg> diff --git a/examples/draganddrop/delayedencoding/main.cpp b/examples/draganddrop/delayedencoding/main.cpp deleted file mode 100644 index 6b6063b..0000000 --- a/examples/draganddrop/delayedencoding/main.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 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 "sourcewidget.h" - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - SourceWidget window; - window.show(); - return app.exec(); -} - diff --git a/examples/draganddrop/delayedencoding/mimedata.cpp b/examples/draganddrop/delayedencoding/mimedata.cpp deleted file mode 100644 index efa096e..0000000 --- a/examples/draganddrop/delayedencoding/mimedata.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 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 "mimedata.h" - -MimeData::MimeData() - : QMimeData() -{ -} - -//![0] -QStringList MimeData::formats() const -{ - return QMimeData::formats() << "image/png"; -} -//![0] - -//![1] -QVariant MimeData::retrieveData(const QString &mimeType, QVariant::Type type) - const -{ - emit dataRequested(mimeType); - - return QMimeData::retrieveData(mimeType, type); -} -//![1] - diff --git a/examples/draganddrop/delayedencoding/mimedata.h b/examples/draganddrop/delayedencoding/mimedata.h deleted file mode 100644 index 4d84bd0..0000000 --- a/examples/draganddrop/delayedencoding/mimedata.h +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 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 MIMEDATA_H -#define MIMEDATA_H - -#include <QMimeData> - -//![0] -class MimeData : public QMimeData -{ - Q_OBJECT - -public: - MimeData(); - QStringList formats() const; - -signals: - void dataRequested(const QString &mimeType) const; - -protected: - QVariant retrieveData(const QString &mimetype, QVariant::Type type) const; -}; -//![0] - -#endif diff --git a/examples/draganddrop/delayedencoding/sourcewidget.cpp b/examples/draganddrop/delayedencoding/sourcewidget.cpp deleted file mode 100644 index 0373edb..0000000 --- a/examples/draganddrop/delayedencoding/sourcewidget.cpp +++ /dev/null @@ -1,115 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 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 <QtSvg> -#include "mimedata.h" -#include "sourcewidget.h" - -SourceWidget::SourceWidget(QWidget *parent) - : QWidget(parent) -{ - QFile imageFile(":/images/example.svg"); - imageFile.open(QIODevice::ReadOnly); - imageData = imageFile.readAll(); - imageFile.close(); - - QScrollArea *imageArea = new QScrollArea; - imageLabel = new QSvgWidget; - imageLabel->renderer()->load(imageData); - imageArea->setWidget(imageLabel); - //imageLabel->setMinimumSize(imageLabel->renderer()->viewBox().size()); - - QLabel *instructTopLabel = new QLabel(tr("This is an SVG drawing:")); - QLabel *instructBottomLabel = new QLabel( - tr("Drag the icon to copy the drawing as a PNG file:")); - instructBottomLabel->setWordWrap(true); - QPushButton *dragIcon = new QPushButton(tr("Export")); - dragIcon->setIcon(QIcon(":/images/drag.png")); - - connect(dragIcon, SIGNAL(pressed()), this, SLOT(startDrag())); - - QGridLayout *layout = new QGridLayout; - layout->addWidget(instructTopLabel, 0, 0, 1, 2); - layout->addWidget(imageArea, 1, 0, 2, 2); - layout->addWidget(instructBottomLabel, 3, 0); - layout->addWidget(dragIcon, 3, 1); - setLayout(layout); - setWindowTitle(tr("Delayed Encoding")); -} - -//![1] -void SourceWidget::createData(const QString &mimeType) -{ - if (mimeType != "image/png") - return; - - QImage image(imageLabel->size(), QImage::Format_RGB32); - QPainter painter; - painter.begin(&image); - imageLabel->renderer()->render(&painter); - painter.end(); - - QByteArray data; - QBuffer buffer(&data); - buffer.open(QIODevice::WriteOnly); - image.save(&buffer, "PNG"); - buffer.close(); - - mimeData->setData("image/png", data); -} -//![1] - -//![0] -void SourceWidget::startDrag() -{ - mimeData = new MimeData; - - connect(mimeData, SIGNAL(dataRequested(QString)), - this, SLOT(createData(QString)), Qt::DirectConnection); - - QDrag *drag = new QDrag(this); - drag->setMimeData(mimeData); - drag->setPixmap(QPixmap(":/images/drag.png")); - - drag->exec(Qt::CopyAction); -} -//![0] - diff --git a/examples/draganddrop/delayedencoding/sourcewidget.h b/examples/draganddrop/delayedencoding/sourcewidget.h deleted file mode 100644 index ef2766a..0000000 --- a/examples/draganddrop/delayedencoding/sourcewidget.h +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 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 SOURCEWIDGET_H -#define SOURCEWIDGET_H - -#include <QByteArray> -#include <QWidget> - -QT_BEGIN_NAMESPACE -class QSvgWidget; -QT_END_NAMESPACE -class MimeData; - -class SourceWidget : public QWidget -{ - Q_OBJECT - -public: - SourceWidget(QWidget *parent = 0); -//![0] -public slots: - void createData(const QString &mimetype); - void startDrag(); - -private: - QByteArray imageData; - QSvgWidget *imageLabel; - MimeData *mimeData; -//![0] -}; - -#endif diff --git a/examples/draganddrop/draganddrop.pro b/examples/draganddrop/draganddrop.pro deleted file mode 100644 index 75e3e99..0000000 --- a/examples/draganddrop/draganddrop.pro +++ /dev/null @@ -1,8 +0,0 @@ -TEMPLATE = subdirs -!contains(QT_CONFIG, no-widgets): SUBDIRS += delayedencoding -QT+=widgets - -# install -sources.files = draganddrop.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtsvg/draganddrop -INSTALLS += sources |