本文整理汇总了C++中TilesetView::model方法的典型用法代码示例。如果您正苦于以下问题:C++ TilesetView::model方法的具体用法?C++ TilesetView::model怎么用?C++ TilesetView::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TilesetView
的用法示例。
在下文中一共展示了TilesetView::model方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateActions
void TilesetDock::updateActions()
{
bool external = false;
TilesetView *view = nullptr;
Tileset *tileset = nullptr;
const int index = mTabBar->currentIndex();
if (index > -1) {
view = tilesetViewAt(index);
tileset = mTilesets.at(index).data();
if (view) {
if (!view->model()) // Lazily set up the model
setupTilesetModel(view, tileset);
mViewStack->setCurrentIndex(index);
external = tileset->isExternal();
}
}
const bool tilesetIsDisplayed = view != nullptr;
const auto map = mMapDocument ? mMapDocument->map() : nullptr;
mEmbedTileset->setEnabled(tilesetIsDisplayed && external);
mExportTileset->setEnabled(tilesetIsDisplayed && !external);
mEditTileset->setEnabled(tilesetIsDisplayed);
mDeleteTileset->setEnabled(tilesetIsDisplayed && map && contains(map->tilesets(), tileset));
}
示例2: selectTilesInStamp
/**
* Synchronizes the selection with the given stamp. Ignored when the stamp is
* changing because of a selection change in the TilesetDock.
*/
void TilesetDock::selectTilesInStamp(const TileStamp &stamp)
{
if (mEmittingStampCaptured)
return;
QSet<Tile*> processed;
QMap<QItemSelectionModel*, QItemSelection> selections;
for (const TileStampVariation &variation : stamp.variations()) {
const TileLayer &tileLayer = *variation.tileLayer();
for (const Cell &cell : tileLayer) {
if (Tile *tile = cell.tile) {
if (processed.contains(tile))
continue;
processed.insert(tile); // avoid spending time on duplicates
Tileset *tileset = tile->tileset();
int tilesetIndex = mTilesets.indexOf(tileset->sharedPointer());
if (tilesetIndex != -1) {
TilesetView *view = tilesetViewAt(tilesetIndex);
if (!view->model()) // Lazily set up the model
setupTilesetModel(view, tileset);
const TilesetModel *model = view->tilesetModel();
const QModelIndex modelIndex = model->tileIndex(tile);
QItemSelectionModel *selectionModel = view->selectionModel();
selections[selectionModel].select(modelIndex, modelIndex);
}
}
}
}
if (!selections.isEmpty()) {
mSynchronizingSelection = true;
// Mark captured tiles as selected
for (auto i = selections.constBegin(); i != selections.constEnd(); ++i) {
QItemSelectionModel *selectionModel = i.key();
const QItemSelection &selection = i.value();
selectionModel->select(selection, QItemSelectionModel::SelectCurrent);
}
// Show/edit properties of all captured tiles
mMapDocument->setSelectedTiles(processed.toList());
// Update the current tile (useful for animation and collision editors)
auto first = selections.begin();
QItemSelectionModel *selectionModel = first.key();
const QItemSelection &selection = first.value();
const QModelIndex currentIndex = selection.first().topLeft();
if (selectionModel->currentIndex() != currentIndex)
selectionModel->setCurrentIndex(currentIndex, QItemSelectionModel::NoUpdate);
else
currentChanged(currentIndex);
mSynchronizingSelection = false;
}
}
示例3: updateActions
void TilesetDock::updateActions()
{
bool external = false;
bool isCollection = false;
bool hasSelection = false;
TilesetView *view = nullptr;
const int index = mTabBar->currentIndex();
if (index > -1) {
view = tilesetViewAt(index);
if (view) {
Tileset *tileset = mTilesets.at(index).data();
if (!view->model()) // Lazily set up the model
setupTilesetModel(view, tileset);
mViewStack->setCurrentIndex(index);
external = tileset->isExternal();
isCollection = tileset->isCollection();
hasSelection = view->selectionModel()->hasSelection();
}
}
const bool tilesetIsDisplayed = view != nullptr;
const bool mapIsDisplayed = mMapDocument != nullptr;
mNewTileset->setEnabled(mapIsDisplayed);
mImportTileset->setEnabled(tilesetIsDisplayed && external);
mExportTileset->setEnabled(tilesetIsDisplayed && !external);
mPropertiesTileset->setEnabled(tilesetIsDisplayed);
mDeleteTileset->setEnabled(tilesetIsDisplayed);
mEditTerrain->setEnabled(tilesetIsDisplayed && !external);
mAddTiles->setEnabled(tilesetIsDisplayed && isCollection && !external);
mRemoveTiles->setEnabled(tilesetIsDisplayed && isCollection
&& hasSelection && !external);
}