summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Olav Tvete <paul.tvete@digia.com>2012-11-30 11:08:33 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-11-30 18:37:35 +0100
commitd25bd0c37e7aa88df041e663e3f52ac54a9b38f1 (patch)
treebcbc329493419ac75a7dbd724a4052f108491161
parent0e7ba5e763807730d6138d490f1741ede137d0eb (diff)
downloadqtbase-d25bd0c37e7aa88df041e663e3f52ac54a9b38f1.tar.gz
Fix docs for Drag and Drop examples
Change-Id: Ic1622b64603f7634b697bd7d8412dcc9f1a8c3fa Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
-rw-r--r--.gitignore2
-rw-r--r--examples/widgets/doc/images/draganddroppuzzle-example.pngbin0 -> 191122 bytes
-rw-r--r--examples/widgets/doc/images/fridgemagnets-example.png (renamed from doc/src/images/fridgemagnets-example.png)bin33012 -> 33012 bytes
-rw-r--r--examples/widgets/doc/src/fridgemagnets.qdoc (renamed from doc/src/examples/fridgemagnets.qdoc)44
4 files changed, 24 insertions, 22 deletions
diff --git a/.gitignore b/.gitignore
index 89d43cbc81..fe9fe84693 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,6 +4,8 @@
examples/*/*/*
!examples/*/*/*[.]*
!examples/*/*/README
+!examples/*/doc/*
+!examples/*/doc/*/*
examples/*/*/*[.]app
!examples/declarative/*
examples/tutorials/*/*/*
diff --git a/examples/widgets/doc/images/draganddroppuzzle-example.png b/examples/widgets/doc/images/draganddroppuzzle-example.png
new file mode 100644
index 0000000000..812278210d
--- /dev/null
+++ b/examples/widgets/doc/images/draganddroppuzzle-example.png
Binary files differ
diff --git a/doc/src/images/fridgemagnets-example.png b/examples/widgets/doc/images/fridgemagnets-example.png
index 9adb572afc..9adb572afc 100644
--- a/doc/src/images/fridgemagnets-example.png
+++ b/examples/widgets/doc/images/fridgemagnets-example.png
Binary files differ
diff --git a/doc/src/examples/fridgemagnets.qdoc b/examples/widgets/doc/src/fridgemagnets.qdoc
index fef0232b69..b53c94f0bd 100644
--- a/doc/src/examples/fridgemagnets.qdoc
+++ b/examples/widgets/doc/src/fridgemagnets.qdoc
@@ -52,7 +52,7 @@
Each fridge magnet is represented by an instance of the \c
DragLabel class:
- \snippet examples/draganddrop/fridgemagnets/draglabel.h 0
+ \snippet draganddrop/fridgemagnets/draglabel.h 0
Each instance of this QLabel subclass will be used to display an
pixmap generated from a text string. Since we cannot store both
@@ -65,7 +65,7 @@
In the \c DragLabel constructor, we first create a QImage object
on which we will draw the fridge magnet's text and frame:
- \snippet examples/draganddrop/fridgemagnets/draglabel.cpp 0
+ \snippet draganddrop/fridgemagnets/draglabel.cpp 0
Its size depends on the current font size, and its format is
QImage::Format_ARGB32_Premultiplied; i.e., the image is stored
@@ -83,7 +83,7 @@
simple lines to complex shapes like pies and chords. It can also
draw aligned text and pixmaps.
- \snippet examples/draganddrop/fridgemagnets/draglabel.cpp 1
+ \snippet draganddrop/fridgemagnets/draglabel.cpp 1
A painter can be activated by passing a paint device to the
constructor, or by using the \l{QPainter::}{begin()} method as we
@@ -100,7 +100,7 @@
flags argument is a bitwise-OR of the Qt::ImageConversionFlags;
passing 0 for flags sets all the default options).
- \snippet examples/draganddrop/fridgemagnets/draglabel.cpp 2
+ \snippet draganddrop/fridgemagnets/draglabel.cpp 2
Finally, we set the label's \l{QLabel::pixmap}{pixmap property}
and store the label's text for later use.
@@ -114,7 +114,7 @@
The \c DragWidget class inherits QWidget, providing support for
drag and drop operations:
- \snippet examples/draganddrop/fridgemagnets/dragwidget.h 0
+ \snippet draganddrop/fridgemagnets/dragwidget.h 0
To make the widget responsive to drag and drop operations, we simply
reimplement the \l{QWidget::}{dragEnterEvent()},
@@ -130,7 +130,7 @@
In the constructor, we first open the file containing the words on
our fridge magnets:
- \snippet examples/draganddrop/fridgemagnets/dragwidget.cpp 0
+ \snippet draganddrop/fridgemagnets/dragwidget.cpp 0
QFile is an I/O device for reading and writing text and binary
files and resources, and may be used by itself or in combination
@@ -143,7 +143,7 @@
to be read from the stream), we read one line at a time using
QTextStream's \l {QTextStream::}{readLine()} method.
- \snippet examples/draganddrop/fridgemagnets/dragwidget.cpp 1
+ \snippet draganddrop/fridgemagnets/dragwidget.cpp 1
For each line, we create a \c DragLabel object using the read line
as text, we calculate its position and ensure that it is visible by
@@ -156,13 +156,13 @@
We also set the \c FridgeMagnets widget's palette, minimum size
and window title.
- \snippet examples/draganddrop/fridgemagnets/dragwidget.cpp 2
+ \snippet draganddrop/fridgemagnets/dragwidget.cpp 2
Finally, to enable our user to move the fridge magnets around, we
must also set the \c FridgeMagnets widget's
\l{QWidget::acceptDrops}{acceptDrops} property.
- \snippet examples/draganddrop/fridgemagnets/dragwidget.cpp 3
+ \snippet draganddrop/fridgemagnets/dragwidget.cpp 3
Setting this property to true announces to the system that this
widget \e may be able to accept drop events (events that are sent
@@ -175,7 +175,7 @@
Let's take a look at the \l{QWidget::}{mousePressEvent()} event
handler, where drag and drop operations begin:
- \snippet examples/draganddrop/fridgemagnets/dragwidget.cpp 13
+ \snippet draganddrop/fridgemagnets/dragwidget.cpp 13
\snippet examples/draganddrop/fridgemagnets/dragwidget.cpp 14
Mouse events occur when a mouse button is pressed or released
@@ -202,7 +202,7 @@
given MIME type. In our case, we associate our item data with the
custom \c application/x-fridgemagnet type.
- \snippet examples/draganddrop/fridgemagnets/dragwidget.cpp 15
+ \snippet draganddrop/fridgemagnets/dragwidget.cpp 15
Note that we also associate the magnet's text with the
\c text/plain MIME type using QMimeData's \l{QMimeData::}{setText()}
@@ -224,7 +224,7 @@
example, we simply use the pixmap used by the label itself to make
it look like the fridge magnet itself is being moved.
- \snippet examples/draganddrop/fridgemagnets/dragwidget.cpp 16
+ \snippet draganddrop/fridgemagnets/dragwidget.cpp 16
We also specify the cursor's hot spot, its position relative to the
top-level corner of the drag pixmap, to be the point we calculated
@@ -235,7 +235,7 @@
We start the drag operation using QDrag's \l{QDrag::}{exec()} function,
requesting that the magnet is copied when the drag is completed.
- \snippet examples/draganddrop/fridgemagnets/dragwidget.cpp 17
+ \snippet draganddrop/fridgemagnets/dragwidget.cpp 17
The function returns the drop action actually performed by the user
(this can be either a copy or a move action in this case); if this
@@ -258,9 +258,9 @@
In our \c dragEnterEvent() implementation, we first determine
whether we support the event's MIME type or not:
- \snippet examples/draganddrop/fridgemagnets/dragwidget.cpp 4
- \snippet examples/draganddrop/fridgemagnets/dragwidget.cpp 5
- \snippet examples/draganddrop/fridgemagnets/dragwidget.cpp 6
+ \snippet draganddrop/fridgemagnets/dragwidget.cpp 4
+ \snippet draganddrop/fridgemagnets/dragwidget.cpp 5
+ \snippet draganddrop/fridgemagnets/dragwidget.cpp 6
If the type is \c application/x-fridgemagnet and the event
origins from any of this application's fridge magnet widgets, we
@@ -275,7 +275,7 @@
origins from any other widget, we simply accept the proposed
action.
- \snippet examples/draganddrop/fridgemagnets/dragwidget.cpp 7
+ \snippet draganddrop/fridgemagnets/dragwidget.cpp 7
We also accept the proposed action if the event's MIME type is \c
text/plain, i.e., if QMimeData::hasText() returns true. If the
@@ -283,7 +283,7 @@
\l {QDragMoveEvent::}{ignore()} method allowing the event to be
propagated further.
- \snippet examples/draganddrop/fridgemagnets/dragwidget.cpp 8
+ \snippet draganddrop/fridgemagnets/dragwidget.cpp 8
Drag move events occur when the cursor enters a widget, when it
moves within the widget, and when a modifier key is pressed on the
@@ -298,7 +298,7 @@
data.
\target drop
- \snippet examples/draganddrop/fridgemagnets/dragwidget.cpp 9
+ \snippet draganddrop/fridgemagnets/dragwidget.cpp 9
The QMimeData class provides a container for data that
records information about its MIME type. QMimeData objects
@@ -310,7 +310,7 @@
MIME type using a data stream in order to create a new \c DragLabel
object.
- \snippet examples/draganddrop/fridgemagnets/dragwidget.cpp 10
+ \snippet draganddrop/fridgemagnets/dragwidget.cpp 10
The QDataStream class provides serialization of binary data to a
QIODevice (a data stream is a binary stream of encoded information
@@ -319,7 +319,7 @@
Finally, we create a label and move it to the event's position:
- \snippet examples/draganddrop/fridgemagnets/dragwidget.cpp 11
+ \snippet draganddrop/fridgemagnets/dragwidget.cpp 11
If the source of the event is also the widget receiving the
drop event, we set the event's drop action to Qt::MoveAction and
@@ -338,7 +338,7 @@
action. This lets the user drop selected text from a text editor or
Web browser onto the widget to add more fridge magnets.
- \snippet examples/draganddrop/fridgemagnets/dragwidget.cpp 12
+ \snippet draganddrop/fridgemagnets/dragwidget.cpp 12
If the event has any other type, we call the event's
\l{QDragMoveEvent::}{ignore()} method allowing the event to be