Skip to content

Commit

Permalink
#5537: A public Populate() method is now mandatory for DeclarationSel…
Browse files Browse the repository at this point in the history
…ector implementations
  • Loading branch information
codereader committed Sep 18, 2022
1 parent bfcafd5 commit 43f426f
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 11 deletions.
4 changes: 2 additions & 2 deletions libs/wxutil/EntityClassChooser.cpp
Expand Up @@ -226,7 +226,7 @@ class EntityClassSelector :
AddPreviewToBottom(new EntityClassDescription(this));
}

void LoadEntityClasses()
void Populate() override
{
PopulateTreeView(std::make_shared<ThreadedEntityClassLoader>(GetColumns()));
}
Expand Down Expand Up @@ -293,7 +293,7 @@ std::string EntityClassChooser::ChooseEntityClass(Purpose purpose, const std::st

void EntityClassChooser::loadEntityClasses()
{
_selector->LoadEntityClasses();
_selector->Populate();
}

void EntityClassChooser::SetSelectedDeclName(const std::string& declName)
Expand Down
3 changes: 3 additions & 0 deletions libs/wxutil/decl/DeclarationSelector.h
Expand Up @@ -71,6 +71,9 @@ class DeclarationSelector :
void loadFromPath(const std::string& registryKey) override;
void saveToPath(const std::string& registryKey) override;

// (Re-)populate the tree view, must be implemented by subclasses
virtual void Populate() = 0;

protected:
DeclarationTreeView* GetTreeView() const;

Expand Down
2 changes: 1 addition & 1 deletion radiant/ui/common/SkinChooser.cpp
Expand Up @@ -165,7 +165,7 @@ class SkinSelector :
);
}

void Populate()
void Populate() override
{
PopulateTreeView(std::make_shared<ThreadedSkinLoader>(GetColumns(), _model, _allSkinsItem, _matchingSkinsItem));
}
Expand Down
2 changes: 1 addition & 1 deletion radiant/ui/common/SoundChooser.cpp
Expand Up @@ -56,7 +56,7 @@ SoundChooser::SoundChooser(wxWindow* parent) :

void SoundChooser::loadSoundShaders()
{
_selector->LoadSoundShaders();
_selector->Populate();
}

std::string SoundChooser::getSelectedShader() const
Expand Down
4 changes: 2 additions & 2 deletions radiant/ui/common/SoundShaderSelector.h
Expand Up @@ -76,12 +76,12 @@ class SoundShaderSelector :
{
GetTreeView()->SetExpandTopLevelItemsAfterPopulation(true);

LoadSoundShaders();
Populate();

AddPreviewToBottom(_preview);
}

void LoadSoundShaders()
void Populate() override
{
PopulateTreeView(std::make_shared<ThreadedSoundShaderLoader>(GetColumns()));
}
Expand Down
5 changes: 5 additions & 0 deletions radiant/ui/materials/MaterialSelector.cpp
Expand Up @@ -82,6 +82,11 @@ MaterialSelector::MaterialSelector(wxWindow* parent, const std::function<void()>
{
AddPreviewToBottom(new TexturePreviewCombo(this));

Populate();
}

void MaterialSelector::Populate()
{
PopulateTreeView(std::make_shared<ThreadedMaterialLoader>(GetColumns(), _textureFilter));
}

Expand Down
2 changes: 2 additions & 0 deletions radiant/ui/materials/MaterialSelector.h
Expand Up @@ -50,6 +50,8 @@ class MaterialSelector :
// Get the selected Material
MaterialPtr getSelectedShader();

void Populate() override;

protected:
void onTreeViewSelectionChanged() override;
};
Expand Down
6 changes: 3 additions & 3 deletions radiant/ui/particles/ParticleSelector.cpp
Expand Up @@ -16,17 +16,17 @@ ParticleSelector::ParticleSelector(wxWindow* parent) :
sigc::mem_fun(this, &ParticleSelector::reloadParticles)
);

populateParticleList();
Populate();
}

void ParticleSelector::populateParticleList()
void ParticleSelector::Populate()
{
PopulateTreeView(std::make_shared<ThreadedParticlesLoader>(GetColumns()));
}

void ParticleSelector::reloadParticles()
{
populateParticleList();
Populate();
}

std::string ParticleSelector::GetSelectedParticle()
Expand Down
5 changes: 3 additions & 2 deletions radiant/ui/particles/ParticleSelector.h
Expand Up @@ -28,9 +28,10 @@ class ParticleSelector :
std::string GetSelectedParticle();
void SetSelectedParticle(const std::string& particleName);

private:
// Populate the list of particles
void populateParticleList();
void Populate() override;

private:
void reloadParticles();
};

Expand Down

0 comments on commit 43f426f

Please sign in to comment.