1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-26 03:52:01 +02:00

Merge pull request #5048 from godric3/map-editor-remove-parent-chains

remove chains of `parent()->parent()` in map editor
This commit is contained in:
Ivan Savenko 2024-12-21 15:43:48 +02:00 committed by GitHub
commit 189e7dc94d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 13 additions and 9 deletions

View File

@ -69,6 +69,7 @@ public:
void redo(); void redo();
PlayerColor defaultPlayer; PlayerColor defaultPlayer;
QDialog * settingsDialog = nullptr;
private: private:
std::unique_ptr<CMap> _map; std::unique_ptr<CMap> _map;

View File

@ -310,12 +310,12 @@ void LoseConditions::onObjectSelect()
QObject::connect(&l, &ObjectPickerLayer::selectionMade, this, &LoseConditions::onObjectPicked); QObject::connect(&l, &ObjectPickerLayer::selectionMade, this, &LoseConditions::onObjectPicked);
} }
dynamic_cast<QWidget*>(parent()->parent()->parent()->parent()->parent()->parent()->parent())->hide(); controller->settingsDialog->hide();
} }
void LoseConditions::onObjectPicked(const CGObjectInstance * obj) void LoseConditions::onObjectPicked(const CGObjectInstance * obj)
{ {
dynamic_cast<QWidget*>(parent()->parent()->parent()->parent()->parent()->parent()->parent())->show(); controller->settingsDialog->show();
for(int lvl : {0, 1}) for(int lvl : {0, 1})
{ {

View File

@ -27,7 +27,7 @@ MapSettings::MapSettings(MapController & ctrl, QWidget *parent) :
ui->setupUi(this); ui->setupUi(this);
assert(controller.map()); assert(controller.map());
controller.settingsDialog = this;
show(); show();
for(auto const & objectPtr : VLC->skillh->objects) for(auto const & objectPtr : VLC->skillh->objects)
@ -73,6 +73,7 @@ MapSettings::MapSettings(MapController & ctrl, QWidget *parent) :
MapSettings::~MapSettings() MapSettings::~MapSettings()
{ {
controller.settingsDialog = nullptr;
delete ui; delete ui;
} }

View File

@ -122,7 +122,7 @@ void TimedEvent::on_addObjectToDelete_clicked()
QObject::connect(&l, &ObjectPickerLayer::selectionMade, this, &TimedEvent::onObjectPicked); QObject::connect(&l, &ObjectPickerLayer::selectionMade, this, &TimedEvent::onObjectPicked);
} }
hide(); hide();
dynamic_cast<QWidget *>(parent()->parent()->parent()->parent()->parent()->parent()->parent())->hide(); controller.settingsDialog->hide();
} }
void TimedEvent::on_removeObjectToDelete_clicked() void TimedEvent::on_removeObjectToDelete_clicked()
@ -133,7 +133,7 @@ void TimedEvent::on_removeObjectToDelete_clicked()
void TimedEvent::onObjectPicked(const CGObjectInstance * obj) void TimedEvent::onObjectPicked(const CGObjectInstance * obj)
{ {
show(); show();
dynamic_cast<QWidget *>(parent()->parent()->parent()->parent()->parent()->parent()->parent())->show(); controller.settingsDialog->show();
for(int lvl : {0, 1}) for(int lvl : {0, 1})
{ {

View File

@ -528,12 +528,12 @@ void VictoryConditions::onObjectSelect()
QObject::connect(&l, &ObjectPickerLayer::selectionMade, this, &VictoryConditions::onObjectPicked); QObject::connect(&l, &ObjectPickerLayer::selectionMade, this, &VictoryConditions::onObjectPicked);
} }
dynamic_cast<QWidget*>(parent()->parent()->parent()->parent()->parent()->parent()->parent())->hide(); controller->settingsDialog->hide();
} }
void VictoryConditions::onObjectPicked(const CGObjectInstance * obj) void VictoryConditions::onObjectPicked(const CGObjectInstance * obj)
{ {
dynamic_cast<QWidget*>(parent()->parent()->parent()->parent()->parent()->parent()->parent())->show(); controller->settingsDialog->show();
for(int lvl : {0, 1}) for(int lvl : {0, 1})
{ {

View File

@ -202,12 +202,12 @@ void PlayerParams::on_townSelect_clicked()
QObject::connect(&l, &ObjectPickerLayer::selectionMade, this, &PlayerParams::onTownPicked); QObject::connect(&l, &ObjectPickerLayer::selectionMade, this, &PlayerParams::onTownPicked);
} }
dynamic_cast<QWidget*>(parent()->parent()->parent()->parent())->hide(); controller.settingsDialog->hide();
} }
void PlayerParams::onTownPicked(const CGObjectInstance * obj) void PlayerParams::onTownPicked(const CGObjectInstance * obj)
{ {
dynamic_cast<QWidget*>(parent()->parent()->parent()->parent())->show(); controller.settingsDialog->show();
for(int lvl : {0, 1}) for(int lvl : {0, 1})
{ {

View File

@ -22,6 +22,7 @@ PlayerSettings::PlayerSettings(MapController & ctrl, QWidget *parent) :
controller(ctrl) controller(ctrl)
{ {
ui->setupUi(this); ui->setupUi(this);
controller.settingsDialog = this;
show(); show();
int players = 0; int players = 0;
@ -46,6 +47,7 @@ PlayerSettings::PlayerSettings(MapController & ctrl, QWidget *parent) :
PlayerSettings::~PlayerSettings() PlayerSettings::~PlayerSettings()
{ {
controller.settingsDialog = nullptr;
delete ui; delete ui;
} }