109
109
if( ! parentShape )
110
110
return QModelIndex();
112
if( row < parentShape->childCount() )
112
if( row < parentShape->shapeCount() )
113
113
return createIndex( row, column, childFromIndex( parentShape, row ) );
115
115
return QModelIndex();
208
208
case PropertiesRole: return QVariant::fromValue( properties( shape ) );
209
209
case AspectRatioRole:
211
QMatrix matrix = shape->absoluteTransformation( 0 );
211
QTransform matrix = shape->absoluteTransformation( 0 );
212
212
QRectF bbox = matrix.mapRect( shape->outline().boundingRect() );
213
213
KoShapeContainer *container = dynamic_cast<KoShapeContainer*>( shape );
217
foreach( KoShape* shape, container->childShapes() )
217
foreach( KoShape* shape, container->shapes() )
218
218
bbox = bbox.united( shape->outline().boundingRect() );
220
220
return qreal(bbox.width()) / bbox.height();
345
345
KoShape * KoPADocumentModel::childFromIndex( KoShapeContainer *parent, int row ) const
347
return parent->childShapes().at(row);
347
return parent->shapes().at(row);
349
349
if( parent != m_lastContainer )
351
351
m_lastContainer = parent;
352
m_childs = parent->childShapes();
352
m_childs = parent->shapes();
353
353
qSort( m_childs.begin(), m_childs.end(), KoShape::compareShapeZIndex );
355
355
return m_childs.at( row );
360
360
if ( !m_document )
363
return parent->childShapes().indexOf( child );
363
return parent->shapes().indexOf( child );
365
365
if( parent != m_lastContainer )
367
367
m_lastContainer = parent;
368
m_childs = parent->childShapes();
368
m_childs = parent->shapes();
369
369
qSort( m_childs.begin(), m_childs.end(), KoShape::compareShapeZIndex );
371
371
return m_childs.indexOf( child );
402
402
// encode the data
403
403
QModelIndexList::ConstIterator it = indexes.begin();
404
404
for( ; it != indexes.end(); ++it)
405
stream << qVariantFromValue( qulonglong( it->internalPointer() ) );
405
stream << QVariant::fromValue( qulonglong( it->internalPointer() ) );
407
407
data->setData(format, encoded);
501
501
emit layoutAboutToBeChanged();
502
beginInsertRows( parent, group->childCount(), group->childCount()+toplevelShapes.count() );
502
beginInsertRows( parent, group->shapeCount(), group->shapeCount()+toplevelShapes.count() );
504
504
QUndoCommand * cmd = new QUndoCommand();
505
505
cmd->setText( i18n("Reparent shapes") );
520
520
if( toplevelShapes.count() )
522
522
emit layoutAboutToBeChanged();
523
beginInsertRows( parent, container->childCount(), container->childCount()+toplevelShapes.count() );
523
beginInsertRows( parent, container->shapeCount(), container->shapeCount()+toplevelShapes.count() );
525
525
QUndoCommand * cmd = new QUndoCommand();
526
526
cmd->setText( i18n("Reparent shapes") );
528
528
QList<bool> clipped;
529
QList<bool> inheritsTransform;
529
530
foreach( KoShape * shape, toplevelShapes )
531
532
if( ! shape->parent() )
533
534
clipped.append( false );
535
inheritsTransform.append(false);
537
clipped.append( shape->parent()->childClipped( shape ) );
539
clipped.append( shape->parent()->isClipped( shape ) );
540
inheritsTransform.append(shape->parent()->inheritsTransform(shape));
538
541
new KoShapeUngroupCommand( shape->parent(), QList<KoShape*>() << shape, QList<KoShape*>(), cmd );
540
543
// shapes are dropped on a container, so add them to the container
541
new KoShapeGroupCommand( container, toplevelShapes, clipped, cmd );
544
new KoShapeGroupCommand(container, toplevelShapes, clipped, inheritsTransform, cmd);
542
545
KoCanvasController * canvasController = KoToolManager::instance()->activeCanvasController();
543
546
canvasController->canvas()->addCommand( cmd );