Skip to content

Commit

Permalink
Show map name change in map tree
Browse files Browse the repository at this point in the history
If a map has been renamed in the map properties view, then the map
name in the map tree is updated now.
  • Loading branch information
rueter37 committed Nov 30, 2021
1 parent d6c2b72 commit 6edcfac
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/ui/main_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1309,7 +1309,7 @@ void MainWindow::on_actionMapProperties_triggered()
if (!currentScene())
return;

currentScene()->editMapProperties();
currentScene()->editMapProperties(ui->treeMap->currentItem());
}

void MainWindow::on_actionSearch_triggered()
Expand Down
7 changes: 6 additions & 1 deletion src/ui/map/map_scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,11 @@ QMap<int, lcf::rpg::Event*> *MapScene::mapEvents()
return events;
}

void MapScene::editMapProperties()
void MapScene::editMapProperties(QTreeWidgetItem *item)
{
int old_width = m_map->width;
int old_height = m_map->height;
lcf::DBString old_name = n_mapInfo.name;

MapPropertiesDialog dlg(m_project, n_mapInfo, *m_map, m_view);
if (dlg.exec() == QDialog::Accepted) {
Expand All @@ -252,6 +253,10 @@ void MapScene::editMapProperties()
redrawPanorama();
redrawMap();
setScale(m_scale);

if (n_mapInfo.name != old_name) {
item->setData(0, Qt::DisplayRole, ToQString(n_mapInfo.name));
}
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/ui/map/map_scene.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <QMap>
#include <QMenu>
#include <QUndoStack>
#include <QTreeWidgetItem>
#include <memory>
#include <lcf/rpg/map.h>
#include <lcf/rpg/mapinfo.h>
Expand All @@ -51,7 +52,7 @@ class MapScene : public QGraphicsScene
void setLayerData(Core::Layer layer, std::vector<short> data);
void setEventData(int id, const lcf::rpg::Event &data);
QMap<int, lcf::rpg::Event *> *mapEvents();
void editMapProperties();
void editMapProperties(QTreeWidgetItem *item);

signals:

Expand Down

0 comments on commit 6edcfac

Please sign in to comment.