Skip to content

Commit

Permalink
#6107: Sort layers by name
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Oct 2, 2022
1 parent b52a402 commit 6554149
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions radiant/ui/layers/LayerControlDialog.cpp
Expand Up @@ -142,8 +142,8 @@ void LayerControlDialog::queueUpdate()
class LayerControlDialog::TreePopulator
{
private:
const wxutil::TreeModel::Ptr& _layerStore;
const TreeColumns& _columns;
wxutil::TreeModel::Ptr _layerStore;

std::map<int, wxDataViewItem> _layerItemMap;

Expand All @@ -155,8 +155,8 @@ class LayerControlDialog::TreePopulator

public:
TreePopulator(const wxutil::TreeModel::Ptr& layerStore, const TreeColumns& columns) :
_layerStore(layerStore),
_columns(columns),
_layerStore(new wxutil::TreeModel(_columns)),
_layerManager(GlobalMapModule().getRoot()->getLayerManager()),
_activeLayerId(_layerManager.getActiveLayer())
{}
Expand All @@ -176,6 +176,11 @@ class LayerControlDialog::TreePopulator
return _layerItemMap;
}

const wxutil::TreeModel::Ptr& getLayerStore() const
{
return _layerStore;
}

wxDataViewItem processLayer(int layerId, const std::string& layerName)
{
auto existingItem = _layerItemMap.find(layerId);
Expand Down Expand Up @@ -245,6 +250,13 @@ void LayerControlDialog::refresh()
layerManager.foreachLayer(
std::bind(&TreePopulator::processLayer, &populator, std::placeholders::_1, std::placeholders::_2));

// Get the model and sort each hierarchy level by name
_layerStore = populator.getLayerStore();
_layerStore->SortModelByColumn(_columns.name);

// Now associate the layer store with our tree view
_layersView->AssociateModel(_layerStore.get());

_layerItemMap = std::move(populator.getLayerItemMap());

// Restore the expanded state of tree elements
Expand Down

0 comments on commit 6554149

Please sign in to comment.