当前位置: 首页>>代码示例>>C++>>正文


C++ KoSelection::count方法代码示例

本文整理汇总了C++中KoSelection::count方法的典型用法代码示例。如果您正苦于以下问题:C++ KoSelection::count方法的具体用法?C++ KoSelection::count怎么用?C++ KoSelection::count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在KoSelection的用法示例。


在下文中一共展示了KoSelection::count方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: updateSelectedPath

void KarbonCalligraphyTool::updateSelectedPath()
{
    KoPathShape *oldSelectedPath = m_selectedPath; // save old value

    KoSelection *selection = canvas()->shapeManager()->selection();

    // null pointer if it the selection isn't a KoPathShape
    // or if the selection is empty
    m_selectedPath =
        dynamic_cast<KoPathShape *>(selection->firstSelectedShape());

    // or if it's a KoPathShape but with no or more than one subpaths
    if (m_selectedPath && m_selectedPath->subpathCount() != 1) {
        m_selectedPath = 0;
    }

    // or if there ora none or more than 1 shapes selected
    if (selection->count() != 1) {
        m_selectedPath = 0;
    }

    // emit signal it there wasn't a selected path and now there is
    // or the other way around
    if ((m_selectedPath != 0) != (oldSelectedPath != 0)) {
        emit pathSelectedChanged(m_selectedPath != 0);
    }
}
开发者ID:ChrisJong,项目名称:krita,代码行数:27,代码来源:KarbonCalligraphyTool.cpp

示例2: applyChanges

void StrokeDocker::applyChanges()
{
    KoCanvasController* canvasController = KoToolManager::instance()->activeCanvasController();
    KoSelection *selection = canvasController->canvas()->shapeManager()->selection();

    canvasController->canvas()->resourceProvider()->setActiveBorder( d->border );

    if( ! selection || ! selection->count() )
        return;

    KoLineBorder * newBorder = new KoLineBorder(d->border);
    KoLineBorder * oldBorder = dynamic_cast<KoLineBorder*>( selection->firstSelectedShape()->border() );
    if( oldBorder )
    {
        newBorder->setColor( oldBorder->color() );
        newBorder->setLineBrush( oldBorder->lineBrush() );
    }

    KoShapeBorderCommand *cmd = new KoShapeBorderCommand( selection->selectedShapes(), newBorder );
    canvasController->canvas()->addCommand( cmd );
}
开发者ID:,项目名称:,代码行数:21,代码来源:

示例3: testSelectedShapes

void TestSelection::testSelectedShapes()
{
    KoSelection selection;
    MockShape *shape1 = new MockShape();
    MockShape *shape2 = new MockShape();
    MockShape *shape3 = new MockShape();

    QCOMPARE(selection.count(), 0);
    QCOMPARE(selection.selectedShapes().count(), 0);
    selection.select(shape1);
    QCOMPARE(selection.count(), 1);
    QCOMPARE(selection.selectedShapes(KoFlake::FullSelection).count(), 1);
    QCOMPARE(selection.selectedShapes(KoFlake::StrippedSelection).count(), 1);
    QCOMPARE(selection.selectedShapes(KoFlake::TopLevelSelection).count(), 1);

    selection.select(shape1); // same one.
    QCOMPARE(selection.count(), 1);
    QCOMPARE(selection.selectedShapes(KoFlake::FullSelection).count(), 1);
    QCOMPARE(selection.selectedShapes(KoFlake::StrippedSelection).count(), 1);
    QCOMPARE(selection.selectedShapes(KoFlake::TopLevelSelection).count(), 1);

    selection.select(shape2);
    selection.select(shape3);
    QCOMPARE(selection.count(), 3);
    QCOMPARE(selection.selectedShapes(KoFlake::FullSelection).count(), 3);
    QCOMPARE(selection.selectedShapes(KoFlake::StrippedSelection).count(), 3);
    QCOMPARE(selection.selectedShapes(KoFlake::TopLevelSelection).count(), 3);

    MockGroup *group1 = new MockGroup();
    group1->addShape(shape1);
    group1->addShape(shape2);
    selection.select(group1);
    QCOMPARE(selection.count(), 3);  // don't return the grouping shape.
    // Stripped returns no groups, so simply all 3 shapes
    QCOMPARE(selection.selectedShapes(KoFlake::FullSelection).count(), 3);
    // stripped returns no groups; so simply all shapes.
    QCOMPARE(selection.selectedShapes(KoFlake::StrippedSelection).count(), 3);
    // toplevel returns shape3 and group1
    QCOMPARE(selection.selectedShapes(KoFlake::TopLevelSelection).count(), 2);

    MockGroup *group2 = new MockGroup();
    group2->addShape(shape3);
    group2->addShape(group1);
    selection.select(group2);
    QCOMPARE(selection.count(), 3);  // thats 5 minus 2 grouping shapes.
    // Stripped returns no groups, so simply all 3 shapes
    QCOMPARE(selection.selectedShapes(KoFlake::FullSelection).count(), 3);
    // Stripped returns no groups, so simply all 3 shapes
    QCOMPARE(selection.selectedShapes(KoFlake::StrippedSelection).count(), 3);
    // toplevel returns only group2
    QCOMPARE(selection.selectedShapes(KoFlake::TopLevelSelection).count(), 1);


    group1->removeShape(shape1);
    group1->removeShape(shape2);
    MockContainer *container = new MockContainer();
    container->addShape(shape1);
    container->addShape(shape2);
    selection.select(container);
    QCOMPARE(selection.count(), 4);  // thats 6 minus 2 grouping shapes.
    // Stripped returns no groups, so simply all 3 shapes + container
    QCOMPARE(selection.selectedShapes(KoFlake::FullSelection).count(), 4);
    // Stripped returns no groups, and no children of a container. So; container + shape3
    QCOMPARE(selection.selectedShapes(KoFlake::StrippedSelection).count(), 2);
    // toplevel returns only group2 + container
    QCOMPARE(selection.selectedShapes(KoFlake::TopLevelSelection).count(), 2);

    delete group2;
    delete container;
}
开发者ID:abhishekmurthy,项目名称:Calligra,代码行数:70,代码来源:TestSelection.cpp


注:本文中的KoSelection::count方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。