From f48acb91c65f83589abe3a778dd5b7daf27065d8 Mon Sep 17 00:00:00 2001 From: codereader Date: Sat, 30 Jan 2021 05:14:34 +0100 Subject: [PATCH] #4791: Add another option to let client code decide which column the decl path is located in. --- libs/wxutil/dataview/ResourceTreeView.cpp | 10 ++++++++-- libs/wxutil/dataview/ResourceTreeView.h | 9 ++++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/libs/wxutil/dataview/ResourceTreeView.cpp b/libs/wxutil/dataview/ResourceTreeView.cpp index 933812ec2b..2e248ba860 100644 --- a/libs/wxutil/dataview/ResourceTreeView.cpp +++ b/libs/wxutil/dataview/ResourceTreeView.cpp @@ -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; @@ -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() diff --git a/libs/wxutil/dataview/ResourceTreeView.h b/libs/wxutil/dataview/ResourceTreeView.h index 9a08314742..419bf0f3cc 100644 --- a/libs/wxutil/dataview/ResourceTreeView.h +++ b/libs/wxutil/dataview/ResourceTreeView.h @@ -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); @@ -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 @@ -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