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


C++ TilesetView::setMapDocument方法代码示例

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


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

示例1: tilesetAdded

void TilesetDock::tilesetAdded(int index, Tileset *tileset)
{
    TilesetView *view = new TilesetView;
    view->setMapDocument(mMapDocument);
    view->setZoomable(mZoomable);

    mTilesets.insert(index, tileset->sharedPointer());
    mTabBar->insertTab(index, tileset->name());
    mViewStack->insertWidget(index, view);

    updateActions();
}
开发者ID:AbelS95,项目名称:tiled,代码行数:12,代码来源:tilesetdock.cpp

示例2: setMapDocument

void TilesetDock::setMapDocument(MapDocument *mapDocument)
{
    if (mMapDocument == mapDocument)
        return;

    // Hide while we update the tab bar, to avoid repeated layouting
    widget()->hide();

    setCurrentTiles(0);

    if (mMapDocument) {
        // Remember the last visible tileset for this map
        const QString tilesetName = mTabBar->tabText(mTabBar->currentIndex());
        mCurrentTilesets.insert(mMapDocument, tilesetName);
    }

    // Clear previous content
    while (mTabBar->count())
        mTabBar->removeTab(0);
    while (mViewStack->count())
        delete mViewStack->widget(0);

    mTilesets.clear();

    // Clear all connections to the previous document
    if (mMapDocument)
        mMapDocument->disconnect(this);

    mMapDocument = mapDocument;

    if (mMapDocument) {
        mTilesets = mMapDocument->map()->tilesets();

        foreach (Tileset *tileset, mTilesets) {
            TilesetView *view = new TilesetView;
            view->setMapDocument(mMapDocument);
            view->setZoomable(mZoomable);

            mTabBar->addTab(tileset->name());
            mViewStack->addWidget(view);
        }

        connect(mMapDocument, SIGNAL(tilesetAdded(int,Tileset*)),
                SLOT(tilesetAdded(int,Tileset*)));
        connect(mMapDocument, SIGNAL(tilesetRemoved(Tileset*)),
                SLOT(tilesetRemoved(Tileset*)));
        connect(mMapDocument, SIGNAL(tilesetMoved(int,int)),
                SLOT(tilesetMoved(int,int)));
        connect(mMapDocument, SIGNAL(tilesetNameChanged(Tileset*)),
                SLOT(tilesetNameChanged(Tileset*)));
        connect(mMapDocument, SIGNAL(tilesetFileNameChanged(Tileset*)),
                SLOT(updateActions()));

        QString cacheName = mCurrentTilesets.take(mMapDocument);
        for (int i = 0; i < mTabBar->count(); ++i) {
            if (mTabBar->tabText(i) == cacheName) {
                mTabBar->setCurrentIndex(i);
                break;
            }
        }
    }
开发者ID:leisong,项目名称:tiled,代码行数:61,代码来源:tilesetdock.cpp

示例3: setMapDocument

void TilesetDock::setMapDocument(MapDocument *mapDocument)
{
    if (mMapDocument == mapDocument)
        return;

    // Hide while we update the tab bar, to avoid repeated layouting
    // But, this causes problems on OS X (issue #1055)
#ifndef Q_OS_OSX
    widget()->hide();
#endif

    setCurrentTiles(nullptr);
    setCurrentTile(nullptr);

    if (mMapDocument) {
        // Remember the last visible tileset for this map
        const QString tilesetName = mTabBar->tabText(mTabBar->currentIndex());
        mCurrentTilesets.insert(mMapDocument, tilesetName);
    }

    // Clear previous content
    while (mTabBar->count())
        mTabBar->removeTab(0);
    while (mViewStack->count())
        delete mViewStack->widget(0);

    mTilesets.clear();

    // Clear all connections to the previous document
    if (mMapDocument)
        mMapDocument->disconnect(this);

    mMapDocument = mapDocument;

    if (mMapDocument) {
        mTilesets = mMapDocument->map()->tilesets();

        for (const SharedTileset &tileset : mTilesets) {
            TilesetView *view = new TilesetView;
            view->setMapDocument(mMapDocument);
            view->setZoomable(mZoomable);

            mTabBar->addTab(tileset->name());
            mViewStack->addWidget(view);
        }

        connect(mMapDocument, &MapDocument::tilesetAdded,
                this, &TilesetDock::tilesetAdded);
        connect(mMapDocument, &MapDocument::tilesetRemoved,
                this, &TilesetDock::tilesetRemoved);
        connect(mMapDocument, &MapDocument::tilesetMoved,
                this, &TilesetDock::tilesetMoved);
        connect(mMapDocument, &MapDocument::tilesetReplaced,
                this, &TilesetDock::tilesetReplaced);
        connect(mMapDocument, &MapDocument::tilesetNameChanged,
                this, &TilesetDock::tilesetNameChanged);
        connect(mMapDocument, &MapDocument::tilesetFileNameChanged,
                this, &TilesetDock::updateActions);
        connect(mMapDocument, &MapDocument::tilesetChanged,
                this, &TilesetDock::tilesetChanged);
        connect(mMapDocument, &MapDocument::tileImageSourceChanged,
                this, &TilesetDock::tileImageSourceChanged);
        connect(mMapDocument, &MapDocument::tileAnimationChanged,
                this, &TilesetDock::tileAnimationChanged);

        QString cacheName = mCurrentTilesets.take(mMapDocument);
        for (int i = 0; i < mTabBar->count(); ++i) {
            if (mTabBar->tabText(i) == cacheName) {
                mTabBar->setCurrentIndex(i);
                break;
            }
        }

        if (Object *object = mMapDocument->currentObject())
            if (object->typeId() == Object::TileType)
                setCurrentTile(static_cast<Tile*>(object));
    }

    updateActions();

#ifndef Q_OS_OSX
    widget()->show();
#endif
}
开发者ID:AbelS95,项目名称:tiled,代码行数:84,代码来源:tilesetdock.cpp


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