Changeset View
Changeset View
Standalone View
Standalone View
libs/ui/kis_mimedata.cpp
Show First 20 Lines • Show All 197 Lines • ▼ Show 20 Line(s) | 196 | void KisMimeData::initializeExternalNode(KisNodeSP *node, | |||
---|---|---|---|---|---|
198 | KisShapeController *shapeController) | 198 | KisShapeController *shapeController) | ||
199 | { | 199 | { | ||
200 | // layers store a link to the image, so update it | 200 | // layers store a link to the image, so update it | ||
201 | KisLayer *layer = qobject_cast<KisLayer*>(node->data()); | 201 | KisLayer *layer = qobject_cast<KisLayer*>(node->data()); | ||
202 | if (layer) { | 202 | if (layer) { | ||
203 | layer->setImage(image); | 203 | layer->setImage(image); | ||
204 | } | 204 | } | ||
205 | KisShapeLayer *shapeLayer = dynamic_cast<KisShapeLayer*>(node->data()); | 205 | KisShapeLayer *shapeLayer = dynamic_cast<KisShapeLayer*>(node->data()); | ||
206 | if (shapeLayer) { | 206 | if (shapeLayer) { | ||
rempt: It looks like these changes belong in a separate commit since they seem functionally unrelated… | |||||
Yes, that was part of the experimenting stage where I nulled the shapeController. Removed from the patch now. poke1024: Yes, that was part of the experimenting stage where I nulled the shapeController. Removed from… | |||||
207 | // attach the layer to a new shape controller | 207 | // attach the layer to a new shape controller | ||
208 | KisShapeLayer *shapeLayer2 = new KisShapeLayer(*shapeLayer, shapeController); | 208 | KisShapeLayer *shapeLayer2 = new KisShapeLayer(*shapeLayer, shapeController); | ||
209 | *node = shapeLayer2; | 209 | *node = shapeLayer2; | ||
210 | } | 210 | } | ||
211 | } | 211 | } | ||
212 | 212 | | |||
213 | QList<KisNodeSP> KisMimeData::tryLoadInternalNodes(const QMimeData *data, | 213 | QList<KisNodeSP> KisMimeData::tryLoadInternalNodes(const QMimeData *data, | ||
214 | KisImageSP image, | 214 | KisImageSP image, | ||
▲ Show 20 Lines • Show All 107 Lines • ▼ Show 20 Line(s) | 307 | if (nodes.isEmpty() && data->hasFormat("application/x-krita-node-url")) { | |||
322 | QFile::remove(QUrl::fromEncoded(ba).toLocalFile()); | 322 | QFile::remove(QUrl::fromEncoded(ba).toLocalFile()); | ||
323 | } | 323 | } | ||
324 | 324 | | |||
325 | if (nodes.isEmpty() && data->hasImage()) { | 325 | if (nodes.isEmpty() && data->hasImage()) { | ||
326 | QImage qimage = qvariant_cast<QImage>(data->imageData()); | 326 | QImage qimage = qvariant_cast<QImage>(data->imageData()); | ||
327 | 327 | | |||
328 | KisPaintDeviceSP device = new KisPaintDevice(KoColorSpaceRegistry::instance()->rgb8()); | 328 | KisPaintDeviceSP device = new KisPaintDevice(KoColorSpaceRegistry::instance()->rgb8()); | ||
329 | device->convertFromQImage(qimage, 0); | 329 | device->convertFromQImage(qimage, 0); | ||
330 | | ||||
331 | if (image) { | ||||
330 | nodes << new KisPaintLayer(image.data(), image->nextLayerName(), OPACITY_OPAQUE_U8, device); | 332 | nodes << new KisPaintLayer(image.data(), image->nextLayerName(), OPACITY_OPAQUE_U8, device); | ||
333 | } | ||||
331 | 334 | | |||
332 | alwaysRecenter = true; | 335 | alwaysRecenter = true; | ||
333 | } | 336 | } | ||
334 | 337 | | |||
335 | if (!nodes.isEmpty()) { | 338 | if (!nodes.isEmpty()) { | ||
336 | Q_FOREACH (KisNodeSP node, nodes) { | 339 | Q_FOREACH (KisNodeSP node, nodes) { | ||
337 | QRect bounds = node->projection()->exactBounds(); | 340 | QRect bounds = node->projection()->exactBounds(); | ||
338 | if (alwaysRecenter || forceRecenter || | 341 | if (alwaysRecenter || forceRecenter || | ||
▲ Show 20 Lines • Show All 58 Lines • ▼ Show 20 Line(s) | 397 | if(!nodeAllowsAsChild(parentDummy->node(), nodes)) { | |||
397 | 400 | | |||
398 | result = (!parentDummy) ? false : | 401 | result = (!parentDummy) ? false : | ||
399 | correctNewNodeLocation(nodes, parentDummy, aboveThisDummy); | 402 | correctNewNodeLocation(nodes, parentDummy, aboveThisDummy); | ||
400 | } | 403 | } | ||
401 | 404 | | |||
402 | return result; | 405 | return result; | ||
403 | } | 406 | } | ||
404 | 407 | | |||
405 | bool KisMimeData::insertMimeLayers(const QMimeData *data, | 408 | KisNodeList KisMimeData::loadNodesFast( | ||
409 | const QMimeData *data, | ||||
406 | KisImageSP image, | 410 | KisImageSP image, | ||
407 | KisShapeController *shapeController, | 411 | KisShapeController *shapeController, | ||
408 | KisNodeDummy *parentDummy, | 412 | bool ©Node) | ||
409 | KisNodeDummy *aboveThisDummy, | | |||
410 | bool copyNode, | | |||
411 | KisNodeInsertionAdapter *nodeInsertionAdapter) | | |||
412 | { | 413 | { | ||
413 | QList<KisNodeSP> nodes = | 414 | QList<KisNodeSP> nodes = | ||
414 | KisMimeData::tryLoadInternalNodes(data, | 415 | KisMimeData::tryLoadInternalNodes(data, | ||
415 | image, | 416 | image, | ||
416 | shapeController, | 417 | shapeController, | ||
417 | copyNode /* IN-OUT */); | 418 | copyNode /* IN-OUT */); | ||
418 | 419 | | |||
419 | if (nodes.isEmpty()) { | 420 | if (nodes.isEmpty()) { | ||
420 | QRect imageBounds = image->bounds(); | 421 | QRect imageBounds = image->bounds(); | ||
421 | nodes = KisMimeData::loadNodes(data, | 422 | nodes = KisMimeData::loadNodes(data, | ||
422 | imageBounds, imageBounds.center(), | 423 | imageBounds, imageBounds.center(), | ||
423 | false, | 424 | false, | ||
424 | image, shapeController); | 425 | image, shapeController); | ||
425 | /** | 426 | /** | ||
426 | * Don't try to move a node originating from another image, | 427 | * Don't try to move a node originating from another image, | ||
427 | * just copy it. | 428 | * just copy it. | ||
428 | */ | 429 | */ | ||
429 | copyNode = true; | 430 | copyNode = true; | ||
430 | } | 431 | } | ||
431 | 432 | | |||
433 | return nodes; | ||||
434 | } | ||||
435 | | ||||
436 | bool KisMimeData::insertMimeLayers(const QMimeData *data, | ||||
437 | KisImageSP image, | ||||
438 | KisShapeController *shapeController, | ||||
439 | KisNodeDummy *parentDummy, | ||||
440 | KisNodeDummy *aboveThisDummy, | ||||
441 | bool copyNode, | ||||
442 | KisNodeInsertionAdapter *nodeInsertionAdapter) | ||||
443 | { | ||||
444 | QList<KisNodeSP> nodes = loadNodesFast(data, image, shapeController, copyNode /* IN-OUT */); | ||||
445 | | ||||
432 | if (nodes.isEmpty()) return false; | 446 | if (nodes.isEmpty()) return false; | ||
433 | 447 | | |||
434 | bool result = true; | 448 | bool result = true; | ||
435 | 449 | | |||
436 | if (!correctNewNodeLocation(nodes, parentDummy, aboveThisDummy)) { | 450 | if (!correctNewNodeLocation(nodes, parentDummy, aboveThisDummy)) { | ||
437 | return false; | 451 | return false; | ||
438 | } | 452 | } | ||
439 | 453 | | |||
Show All 14 Lines |
It looks like these changes belong in a separate commit since they seem functionally unrelated to the patch?