Skip to content

Commit

Permalink
#4791: Add another option to let client code decide which column the …
Browse files Browse the repository at this point in the history
…decl path is located in.
  • Loading branch information
codereader committed Jan 30, 2021
1 parent dd4b98b commit f48acb9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
10 changes: 8 additions & 2 deletions libs/wxutil/dataview/ResourceTreeView.cpp
Expand Up @@ -45,7 +45,8 @@ ResourceTreeView::ResourceTreeView(wxWindow* parent, const TreeModel::Ptr& model
_mode(TreeMode::ShowAll),
_expandTopLevelItemsAfterPopulation(false),
_columnToSelectAfterPopulation(nullptr),
_declType(decl::Type::None)
_declType(decl::Type::None),
_declPathColumn(_columns.fullName)
{
_treeStore = model;

Expand Down Expand Up @@ -526,7 +527,12 @@ void ResourceTreeView::_onSetFavourite(bool isFavourite)

std::string ResourceTreeView::GetResourcePath(const TreeModel::Row& row)
{
return row[_columns.fullName];
return row[_declPathColumn];
}

void ResourceTreeView::SetDeclPathColumn(const TreeModel::Column& declPathColumn)
{
_declPathColumn = declPathColumn;
}

std::string ResourceTreeView::GetResourcePathOfSelection()
Expand Down
9 changes: 8 additions & 1 deletion libs/wxutil/dataview/ResourceTreeView.h
Expand Up @@ -91,6 +91,9 @@ class ResourceTreeView :

wxString _filterText;

// The column that is hosting the declaration path (used by e.g. "copy to clipboard")
TreeModel::Column _declPathColumn;

public:
ResourceTreeView(wxWindow* parent, const Columns& columns, long style = wxDV_SINGLE);
ResourceTreeView(wxWindow* parent, const TreeModel::Ptr& model, const Columns& columns, long style = wxDV_SINGLE);
Expand Down Expand Up @@ -121,6 +124,10 @@ class ResourceTreeView :
virtual std::string GetSelectedElement(const TreeModel::Column& column);
virtual void SetSelectedElement(const std::string& value, const TreeModel::Column& column);

// Set the column containing the resource path used to define the game-compatible
// declaration path, also used by the "Copy resource path" context menu item
virtual void SetDeclPathColumn(const TreeModel::Column& declPathColumn);

virtual void Clear();

// Enable favourite management for the given declaration type
Expand Down Expand Up @@ -159,7 +166,7 @@ class ResourceTreeView :

// Get the resource path for the given item. Determines the availabilty
// and functionality of the "Copy resource path" context menu item
// The default implementation returns the value of the "fullPath" column.
// The default implementation returns the value of the "fullName" column.
virtual std::string GetResourcePath(const TreeModel::Row& row);

// Retrieve the resource path of the currently selected item
Expand Down

0 comments on commit f48acb9

Please sign in to comment.