Krita Source Code Documentation
Loading...
Searching...
No Matches
KoDrag Class Reference

#include <KoDrag.h>

Public Member Functions

void addToClipboard ()
 
 KoDrag ()
 
QMimeData * mimeData ()
 
void setData (const QString &mimeType, const QByteArray &data)
 
bool setSvg (const QList< KoShape * > shapes)
 
 ~KoDrag ()
 

Private Attributes

KoDragPrivate *const d
 

Detailed Description

Class for simplifying adding a odf to the clip board

For saving the odf a KoDragOdfSaveHelper class is used. It implements the writing of the body of the document. The setOdf takes care of saving styles and all the other common stuff.

Definition at line 28 of file KoDrag.h.

Constructor & Destructor Documentation

◆ KoDrag()

KoDrag::KoDrag ( )

Definition at line 37 of file KoDrag.cpp.

38 : d(new KoDragPrivate())
39{
40}
KoDragPrivate *const d
Definition KoDrag.h:60

◆ ~KoDrag()

KoDrag::~KoDrag ( )

Definition at line 42 of file KoDrag.cpp.

43{
44 delete d;
45}

References d.

Member Function Documentation

◆ addToClipboard()

void KoDrag::addToClipboard ( )

Add the mimeData to the clipboard

Definition at line 86 of file KoDrag.cpp.

87{
88 if (d->mimeData) {
89 QApplication::clipboard()->setMimeData(d->mimeData);
90 d->mimeData = 0;
91 }
92}
QMimeData * mimeData
Definition KoDrag.cpp:34

References d, and KoDragPrivate::mimeData.

◆ mimeData()

QMimeData * KoDrag::mimeData ( )

Get the mime data

This transfers the ownership of the mimeData to the caller

This function is for use in automated tests

Definition at line 94 of file KoDrag.cpp.

95{
96 QMimeData *mimeData = d->mimeData;
97 d->mimeData = 0;
98 return mimeData;
99}
QMimeData * mimeData()
Definition KoDrag.cpp:94

References d, KoDragPrivate::mimeData, and mimeData().

◆ setData()

void KoDrag::setData ( const QString & mimeType,
const QByteArray & data )

Add additional mimeTypes

Definition at line 78 of file KoDrag.cpp.

79{
80 if (d->mimeData == 0) {
81 d->mimeData = new QMimeData();
82 }
83 d->mimeData->setData(mimeType, data);
84}

References d, and KoDragPrivate::mimeData.

◆ setSvg()

bool KoDrag::setSvg ( const QList< KoShape * > shapes)

Load SVG data into the current mime data

Definition at line 47 of file KoDrag.cpp.

48{
49 QRectF boundingRect;
50 QList<KoShape*> shapes;
51
52 Q_FOREACH (KoShape *shape, originalShapes) {
53 boundingRect |= shape->boundingRect();
54
55 KoShape *clonedShape = shape->cloneShapeAndBakeAbsoluteTransform();
56 shapes.append(clonedShape);
57 }
58
59 std::sort(shapes.begin(), shapes.end(), KoShape::compareShapeZIndex);
60
61 QBuffer buffer;
62 QLatin1String mimeType("image/svg+xml");
63
64 buffer.open(QIODevice::WriteOnly);
65
66 const QSizeF pageSize(boundingRect.right(), boundingRect.bottom());
67 SvgWriter writer(shapes);
68 writer.save(buffer, pageSize);
69
70 buffer.close();
71
72 qDeleteAll(shapes);
73
74 setData(mimeType, buffer.data());
75 return true;
76}
void setData(const QString &mimeType, const QByteArray &data)
Definition KoDrag.cpp:78
KoShape * cloneShapeAndBakeAbsoluteTransform() const
creates a deep copy of the shape/shapes tree and bakes the absolute transform of this into the result...
Definition KoShape.cpp:207
static bool compareShapeZIndex(KoShape *s1, KoShape *s2)
Definition KoShape.cpp:434
virtual QRectF boundingRect() const
Get the bounding box of the shape.
Definition KoShape.cpp:335
Implements exporting shapes to SVG.
Definition SvgWriter.h:33

References KoShape::boundingRect(), KoShape::cloneShapeAndBakeAbsoluteTransform(), KoShape::compareShapeZIndex(), SvgWriter::save(), and setData().

Member Data Documentation

◆ d

KoDragPrivate* const KoDrag::d
private

Definition at line 60 of file KoDrag.h.


The documentation for this class was generated from the following files: