1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-03-17 20:58:07 +02:00

remove chains of parent()->parent()

This commit is contained in:
godric3 2024-12-07 22:31:08 +01:00
parent 3115894307
commit c1413b9368
7 changed files with 13 additions and 9 deletions

View File

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

View File

@ -310,12 +310,12 @@ void LoseConditions::onObjectSelect()
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)
{
dynamic_cast<QWidget*>(parent()->parent()->parent()->parent()->parent()->parent()->parent())->show();
controller->settingsDialog->show();
for(int lvl : {0, 1})
{

View File

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

View File

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

View File

@ -528,12 +528,12 @@ void VictoryConditions::onObjectSelect()
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)
{
dynamic_cast<QWidget*>(parent()->parent()->parent()->parent()->parent()->parent()->parent())->show();
controller->settingsDialog->show();
for(int lvl : {0, 1})
{

View File

@ -202,12 +202,12 @@ void PlayerParams::on_townSelect_clicked()
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)
{
dynamic_cast<QWidget*>(parent()->parent()->parent()->parent())->show();
controller.settingsDialog->show();
for(int lvl : {0, 1})
{

View File

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