update map lists when new maps and layouts are added
This commit is contained in:
parent
a4fdb0de64
commit
a14e70ef53
4 changed files with 58 additions and 1 deletions
|
@ -32,6 +32,8 @@ public:
|
||||||
QStandardItem *createGroupItem(QString groupName, int groupIndex);
|
QStandardItem *createGroupItem(QString groupName, int groupIndex);
|
||||||
QStandardItem *createMapItem(QString mapName, int groupIndex, int mapIndex);
|
QStandardItem *createMapItem(QString mapName, int groupIndex, int mapIndex);
|
||||||
|
|
||||||
|
QStandardItem *insertMapItem(QString mapName, QString groupName);
|
||||||
|
|
||||||
QStandardItem *getItem(const QModelIndex &index) const;
|
QStandardItem *getItem(const QModelIndex &index) const;
|
||||||
QModelIndex indexOfMap(QString mapName);
|
QModelIndex indexOfMap(QString mapName);
|
||||||
|
|
||||||
|
@ -68,6 +70,8 @@ public:
|
||||||
QStandardItem *createAreaItem(QString areaName, int areaIndex);
|
QStandardItem *createAreaItem(QString areaName, int areaIndex);
|
||||||
QStandardItem *createMapItem(QString mapName, int areaIndex, int mapIndex);
|
QStandardItem *createMapItem(QString mapName, int areaIndex, int mapIndex);
|
||||||
|
|
||||||
|
QStandardItem *insertMapItem(QString mapName, QString areaName, int groupIndex);
|
||||||
|
|
||||||
QStandardItem *getItem(const QModelIndex &index) const;
|
QStandardItem *getItem(const QModelIndex &index) const;
|
||||||
QModelIndex indexOfMap(QString mapName);
|
QModelIndex indexOfMap(QString mapName);
|
||||||
|
|
||||||
|
@ -104,6 +108,8 @@ public:
|
||||||
QStandardItem *createLayoutItem(QString layoutId);
|
QStandardItem *createLayoutItem(QString layoutId);
|
||||||
QStandardItem *createMapItem(QString mapName);
|
QStandardItem *createMapItem(QString mapName);
|
||||||
|
|
||||||
|
QStandardItem *insertMapItem(QString mapName, QString layoutId);
|
||||||
|
|
||||||
QStandardItem *getItem(const QModelIndex &index) const;
|
QStandardItem *getItem(const QModelIndex &index) const;
|
||||||
QModelIndex indexOfLayout(QString layoutName);
|
QModelIndex indexOfLayout(QString layoutName);
|
||||||
|
|
||||||
|
|
|
@ -1248,6 +1248,10 @@ void MainWindow::onNewMapCreated() {
|
||||||
// QStandardItem* groupItem = mapGroupItemsList->at(newMapGroup);
|
// QStandardItem* groupItem = mapGroupItemsList->at(newMapGroup);
|
||||||
// int numMapsInGroup = groupItem->rowCount();
|
// int numMapsInGroup = groupItem->rowCount();
|
||||||
|
|
||||||
|
this->mapGroupModel->insertMapItem(newMapName, editor->project->groupNames[newMapGroup]);
|
||||||
|
this->mapAreaModel->insertMapItem(newMapName, newMap->location, newMapGroup);
|
||||||
|
this->layoutTreeModel->insertMapItem(newMapName, newMap->layout->id);
|
||||||
|
|
||||||
// QStandardItem *newMapItem = createMapItem(newMapName, newMapGroup, numMapsInGroup);
|
// QStandardItem *newMapItem = createMapItem(newMapName, newMapGroup, numMapsInGroup);
|
||||||
// groupItem->appendRow(newMapItem);
|
// groupItem->appendRow(newMapItem);
|
||||||
// mapListIndexes.insert(newMapName, newMapItem->index());
|
// mapListIndexes.insert(newMapName, newMapItem->index());
|
||||||
|
|
|
@ -1775,6 +1775,7 @@ Map* Project::addNewMapToGroup(QString mapName, int groupNum, Map *newMap, bool
|
||||||
if (!existingLayout) {
|
if (!existingLayout) {
|
||||||
mapLayouts.insert(newMap->layoutId, newMap->layout);
|
mapLayouts.insert(newMap->layoutId, newMap->layout);
|
||||||
mapLayoutsTable.append(newMap->layoutId);
|
mapLayoutsTable.append(newMap->layoutId);
|
||||||
|
layoutIdsToNames.insert(newMap->layout->id, newMap->layout->name);
|
||||||
if (!importedMap) {
|
if (!importedMap) {
|
||||||
setNewMapBlockdata(newMap);
|
setNewMapBlockdata(newMap);
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,21 @@ QStandardItem *MapGroupModel::createMapItem(QString mapName, int groupIndex, int
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QStandardItem *MapGroupModel::insertMapItem(QString mapName, QString groupName) {
|
||||||
|
int groupIndex = this->project->groupNames.indexOf(groupName);
|
||||||
|
QStandardItem *group = this->groupItems[groupName];
|
||||||
|
if (!group) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
int mapIndex = group->rowCount();
|
||||||
|
QStandardItem *map = createMapItem(mapName, groupIndex, mapIndex);
|
||||||
|
group->appendRow(map);
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
void MapGroupModel::initialize() {
|
void MapGroupModel::initialize() {
|
||||||
|
this->groupItems.clear();
|
||||||
|
this->mapItems.clear();
|
||||||
for (int i = 0; i < this->project->groupNames.length(); i++) {
|
for (int i = 0; i < this->project->groupNames.length(); i++) {
|
||||||
QString group_name = this->project->groupNames.value(i);
|
QString group_name = this->project->groupNames.value(i);
|
||||||
QStandardItem *group = createGroupItem(group_name, i);
|
QStandardItem *group = createGroupItem(group_name, i);
|
||||||
|
@ -140,7 +154,21 @@ QStandardItem *MapAreaModel::createMapItem(QString mapName, int groupIndex, int
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QStandardItem *MapAreaModel::insertMapItem(QString mapName, QString areaName, int groupIndex) {
|
||||||
|
// int areaIndex = this->project->mapSectionNameToValue[areaName];
|
||||||
|
QStandardItem *area = this->areaItems[areaName];
|
||||||
|
if (!area) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
int mapIndex = area->rowCount();
|
||||||
|
QStandardItem *map = createMapItem(mapName, groupIndex, mapIndex);
|
||||||
|
area->appendRow(map);
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
void MapAreaModel::initialize() {
|
void MapAreaModel::initialize() {
|
||||||
|
this->areaItems.clear();
|
||||||
|
this->mapItems.clear();
|
||||||
for (int i = 0; i < this->project->mapSectionNameToValue.size(); i++) {
|
for (int i = 0; i < this->project->mapSectionNameToValue.size(); i++) {
|
||||||
QString mapsecName = project->mapSectionValueToName.value(i);
|
QString mapsecName = project->mapSectionValueToName.value(i);
|
||||||
QStandardItem *areaItem = createAreaItem(mapsecName, i);
|
QStandardItem *areaItem = createAreaItem(mapsecName, i);
|
||||||
|
@ -256,7 +284,26 @@ QStandardItem *LayoutTreeModel::createMapItem(QString mapName) {
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QStandardItem *LayoutTreeModel::insertMapItem(QString mapName, QString layoutId) {
|
||||||
|
QStandardItem *layout = nullptr;
|
||||||
|
if (this->layoutItems.contains(layoutId)) {
|
||||||
|
layout = this->layoutItems[layoutId];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
layout = createLayoutItem(layoutId);
|
||||||
|
this->root->appendRow(layout);
|
||||||
|
}
|
||||||
|
if (!layout) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
QStandardItem *map = createMapItem(mapName);
|
||||||
|
layout->appendRow(map);
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
void LayoutTreeModel::initialize() {
|
void LayoutTreeModel::initialize() {
|
||||||
|
this->layoutItems.clear();
|
||||||
|
this->mapItems.clear();
|
||||||
for (int i = 0; i < this->project->mapLayoutsTable.length(); i++) {
|
for (int i = 0; i < this->project->mapLayoutsTable.length(); i++) {
|
||||||
QString layoutId = project->mapLayoutsTable.value(i);
|
QString layoutId = project->mapLayoutsTable.value(i);
|
||||||
QStandardItem *layoutItem = createLayoutItem(layoutId);
|
QStandardItem *layoutItem = createLayoutItem(layoutId);
|
||||||
|
@ -265,7 +312,6 @@ void LayoutTreeModel::initialize() {
|
||||||
|
|
||||||
for (auto mapList : this->project->groupedMapNames) {
|
for (auto mapList : this->project->groupedMapNames) {
|
||||||
for (auto mapName : mapList) {
|
for (auto mapName : mapList) {
|
||||||
//
|
|
||||||
QString layoutId = project->readMapLayoutId(mapName);
|
QString layoutId = project->readMapLayoutId(mapName);
|
||||||
QStandardItem *map = createMapItem(mapName);
|
QStandardItem *map = createMapItem(mapName);
|
||||||
this->layoutItems[layoutId]->appendRow(map);
|
this->layoutItems[layoutId]->appendRow(map);
|
||||||
|
|
Loading…
Reference in a new issue