void TilesetDock::insertTilesetView(int index, Tileset *tileset) { TilesetView *view = new TilesetView(mMapDocument); view->setModel(new TilesetModel(tileset, view)); connect(view->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), SLOT(updateCurrentTiles())); mTabBar->insertTab(index, tileset->name()); mViewStack->insertWidget(index, view); }
void TilesetDock::insertTilesetView(int index, Tileset *tileset) { TilesetView *view = new TilesetView(mMapDocument); view->setModel(new TilesetModel(tileset, view)); connect(view->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), SLOT(updateCurrentTiles())); mViewStack->insertWidget(index, view); QVariant userdata = QVariant::fromValue(view); mDropDown->addItem(tileset->name(), userdata); mDropDown->model()->sort(0); mDropDown->setCurrentIndex(mDropDown->findData(userdata)); }
void TilesetDock::insertTilesetView(int index, Tileset *tileset) { TilesetView *view = new TilesetView(mMapDocument); view->setModel(new TilesetModel(tileset, view)); connect(view->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), SLOT(updateCurrentTiles())); connect(view, SIGNAL(deleteRequested(TilesetView*)), SLOT(deleteRequested(TilesetView*))); mViewStack->insertWidget(index, view); mDropDown->insertItem(index, QIcon(), tileset->name()); mDropDown->setCurrentIndex(index); }
void TilesetEditor::addDocument(Document *document) { TilesetDocument *tilesetDocument = qobject_cast<TilesetDocument*>(document); Q_ASSERT(tilesetDocument); TilesetView *view = new TilesetView(mWidgetStack); view->setTilesetDocument(tilesetDocument); Tileset *tileset = tilesetDocument->tileset().data(); QString path = QLatin1String("TilesetEditor/TilesetScale/") + tileset->name(); qreal scale = Preferences::instance()->settings()->value(path, 1).toReal(); view->zoomable()->setScale(scale); view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn); view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); TilesetModel *tilesetModel = new TilesetModel(tileset, view); view->setModel(tilesetModel); connect(tilesetDocument, &TilesetDocument::tileTerrainChanged, tilesetModel, &TilesetModel::tilesChanged); connect(tilesetDocument, &TilesetDocument::tileWangSetChanged, tilesetModel, &TilesetModel::tilesChanged); connect(tilesetDocument, &TilesetDocument::tileImageSourceChanged, tilesetModel, &TilesetModel::tileChanged); connect(tilesetDocument, &TilesetDocument::tileAnimationChanged, tilesetModel, &TilesetModel::tileChanged); connect(tilesetDocument, &TilesetDocument::tilesetChanged, this, &TilesetEditor::tilesetChanged); connect(view, &TilesetView::createNewTerrain, this, &TilesetEditor::addTerrainType); connect(view, &TilesetView::terrainImageSelected, this, &TilesetEditor::setTerrainImage); connect(view, &TilesetView::wangSetImageSelected, this, &TilesetEditor::setWangSetImage); connect(view, &TilesetView::wangColorImageSelected, this, &TilesetEditor::setWangColorImage); connect(view, &TilesetView::wangIdUsedChanged, mWangDock, &WangDock::onWangIdUsedChanged); connect(view, &TilesetView::currentWangIdChanged, mWangDock, &WangDock::onCurrentWangIdChanged); QItemSelectionModel *s = view->selectionModel(); connect(s, &QItemSelectionModel::selectionChanged, this, &TilesetEditor::selectionChanged); connect(s, &QItemSelectionModel::currentChanged, this, &TilesetEditor::currentChanged); connect(view, &TilesetView::pressed, this, &TilesetEditor::indexPressed); mViewForTileset.insert(tilesetDocument, view); mWidgetStack->addWidget(view); }