Skip to content

Commit

Permalink
#6021: Add default SortModel implementation to ThreadedDeclarationTre…
Browse files Browse the repository at this point in the history
…ePopulator
  • Loading branch information
codereader committed Jul 30, 2022
1 parent 5a3b09c commit bc97638
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 39 deletions.
6 changes: 6 additions & 0 deletions libs/wxutil/dataview/ThreadedDeclarationTreePopulator.h
Expand Up @@ -57,6 +57,12 @@ class ThreadedDeclarationTreePopulator :
}

protected:
// Default sorting behaviour is to sort the tree alphabetically with folders on top
void SortModel(const TreeModel::Ptr& model) override
{
model->SortModelFoldersFirst(_columns.leafName, _columns.isFolder);
}

/**
* Populates the given row with values matching for a certain declaration or folder
*
Expand Down
13 changes: 2 additions & 11 deletions radiant/ui/animationpreview/MD5AnimationViewer.cpp
Expand Up @@ -21,16 +21,12 @@ namespace ui
class ThreadedModelDefLoader final :
public wxutil::ThreadedDeclarationTreePopulator
{
private:
const wxutil::DeclarationTreeView::Columns& _columns;

public:
ThreadedModelDefLoader(const wxutil::DeclarationTreeView::Columns& columns) :
ThreadedDeclarationTreePopulator(decl::Type::ModelDef, columns, "model16green.png"),
_columns(columns)
ThreadedDeclarationTreePopulator(decl::Type::ModelDef, columns, "model16green.png")
{}

~ThreadedModelDefLoader()
~ThreadedModelDefLoader() override
{
EnsureStopped();
}
Expand All @@ -49,11 +45,6 @@ class ThreadedModelDefLoader final :
});;
});
}

void SortModel(const wxutil::TreeModel::Ptr& model) override
{
model->SortModelFoldersFirst(_columns.leafName, _columns.isFolder);
}
};

MD5AnimationViewer::MD5AnimationViewer(wxWindow* parent, RunMode runMode) :
Expand Down
7 changes: 0 additions & 7 deletions radiant/ui/common/ShaderSelector.cpp
Expand Up @@ -40,13 +40,11 @@ class ThreadedMaterialLoader final :
public wxutil::ThreadedDeclarationTreePopulator
{
private:
const wxutil::DeclarationTreeView::Columns& _columns;
const ShaderSelector::PrefixList& _prefixes;

public:
ThreadedMaterialLoader(const wxutil::DeclarationTreeView::Columns& columns, const ShaderSelector::PrefixList& prefixes) :
ThreadedDeclarationTreePopulator(decl::Type::Material, columns, TEXTURE_ICON),
_columns(columns),
_prefixes(prefixes)
{}

Expand Down Expand Up @@ -76,11 +74,6 @@ class ThreadedMaterialLoader final :
}
});
}

void SortModel(const wxutil::TreeModel::Ptr& model) override
{
model->SortModelFoldersFirst(_columns.leafName, _columns.isFolder);
}
};

// Constructor creates elements
Expand Down
12 changes: 1 addition & 11 deletions radiant/ui/common/SoundChooser.cpp
Expand Up @@ -34,13 +34,9 @@ namespace
class ThreadedSoundShaderLoader :
public wxutil::ThreadedDeclarationTreePopulator
{
private:
const wxutil::DeclarationTreeView::Columns& _columns;

public:
ThreadedSoundShaderLoader(const wxutil::DeclarationTreeView::Columns& columns) :
ThreadedDeclarationTreePopulator(decl::Type::SoundShader, columns, SHADER_ICON),
_columns(columns)
ThreadedDeclarationTreePopulator(decl::Type::SoundShader, columns, SHADER_ICON)
{}

~ThreadedSoundShaderLoader()
Expand Down Expand Up @@ -79,12 +75,6 @@ class ThreadedSoundShaderLoader :
});
});
}

void SortModel(const wxutil::TreeModel::Ptr& model) override
{
// angua: Ensure sound shaders are sorted before giving them to the tree view
model->SortModelFoldersFirst(_columns.iconAndName, _columns.isFolder);
}
};

// Constructor
Expand Down
8 changes: 1 addition & 7 deletions radiant/ui/eclasstree/EClassTreeBuilder.cpp
Expand Up @@ -14,8 +14,7 @@ namespace
}

EClassTreeBuilder::EClassTreeBuilder(const wxutil::DeclarationTreeView::Columns& columns) :
ThreadedDeclarationTreePopulator(decl::Type::EntityDef, columns, ENTITY_ICON),
_columns(columns)
ThreadedDeclarationTreePopulator(decl::Type::EntityDef, columns, ENTITY_ICON)
{}

EClassTreeBuilder::~EClassTreeBuilder()
Expand Down Expand Up @@ -53,11 +52,6 @@ void EClassTreeBuilder::PopulateModel(const wxutil::TreeModel::Ptr& model)
ThrowIfCancellationRequested();
}

void EClassTreeBuilder::SortModel(const wxutil::TreeModel::Ptr& model)
{
model->SortModelByColumn(_columns.leafName);
}

std::string EClassTreeBuilder::GetInheritancePathRecursively(IEntityClass& eclass)
{
std::string returnValue;
Expand Down
3 changes: 0 additions & 3 deletions radiant/ui/eclasstree/EClassTreeBuilder.h
Expand Up @@ -19,8 +19,6 @@ class EClassTreeBuilder final :
public wxutil::ThreadedDeclarationTreePopulator
{
private:
const wxutil::DeclarationTreeView::Columns& _columns;

wxIcon _entityIcon;

std::unique_ptr<wxutil::VFSTreePopulator> _treePopulator;
Expand All @@ -32,7 +30,6 @@ class EClassTreeBuilder final :

protected:
void PopulateModel(const wxutil::TreeModel::Ptr& model) override;
void SortModel(const wxutil::TreeModel::Ptr& model) override;

private:
// Returns an inheritance path, like this: "moveables/swords/"
Expand Down

0 comments on commit bc97638

Please sign in to comment.