scroll mapList view to current map

This commit is contained in:
garak 2018-09-20 15:27:57 -04:00
parent fe9ebe6b73
commit b8836aa381
2 changed files with 6 additions and 0 deletions

View file

@ -190,6 +190,9 @@ void MainWindow::setMap(QString map_name) {
scaleMapView(0); scaleMapView(0);
displayMapProperties(); displayMapProperties();
ui->mapList->scrollTo(mapListIndexes.value(map_name));
ui->mapList->setCurrentIndex(mapListIndexes.value(map_name));
setWindowTitle(map_name + " - " + editor->project->getProjectTitle() + " - porymap"); setWindowTitle(map_name + " - " + editor->project->getProjectTitle() + " - porymap");
connect(editor->map, SIGNAL(mapChanged(Map*)), this, SLOT(onMapChanged(Map *))); connect(editor->map, SIGNAL(mapChanged(Map*)), this, SLOT(onMapChanged(Map *)));
@ -451,6 +454,7 @@ void MainWindow::populateMapList() {
QString map_name = names.value(j); QString map_name = names.value(j);
QStandardItem *map = createMapItem(map_name, i, j); QStandardItem *map = createMapItem(map_name, i, j);
group->appendRow(map); group->appendRow(map);
mapListIndexes.insert(map_name, map->index());
} }
} }
@ -514,6 +518,7 @@ void MainWindow::onAddNewMapToGroupClick(QAction* triggeredAction)
int numMapsInGroup = groupItem->rowCount(); int numMapsInGroup = groupItem->rowCount();
QStandardItem *newMapItem = createMapItem(newMapName, groupNum, numMapsInGroup); QStandardItem *newMapItem = createMapItem(newMapName, groupNum, numMapsInGroup);
groupItem->appendRow(newMapItem); groupItem->appendRow(newMapItem);
mapListIndexes.insert(newMapName, newMapItem->index());
setMap(newMapName); setMap(newMapName);
} }

View file

@ -126,6 +126,7 @@ private:
Ui::MainWindow *ui; Ui::MainWindow *ui;
QStandardItemModel *mapListModel; QStandardItemModel *mapListModel;
QList<QStandardItem*> *mapGroupsModel; QList<QStandardItem*> *mapGroupsModel;
QMap<QString, QModelIndex> mapListIndexes;
Editor *editor = nullptr; Editor *editor = nullptr;
QIcon* mapIcon; QIcon* mapIcon;
void setMap(QString); void setMap(QString);