Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#5127: TreeModel columns is owned by the ModelTreeView class now. Mov…
…e stuff to .cpp file.
- Loading branch information
1 parent
912b0cc
commit 265953d
Showing
10 changed files
with
100 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,8 @@ | |
#include "ModelSelector.h" | ||
#include <wx/artprov.h> | ||
|
||
#include "ModelTreeView.h" | ||
|
||
namespace ui | ||
{ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
#include "ModelTreeView.h" | ||
|
||
#include "ModelPopulator.h" | ||
|
||
namespace ui | ||
{ | ||
|
||
ModelTreeView::ModelTreeView(wxWindow* parent) : | ||
ResourceTreeView(parent, _columns, wxBORDER_STATIC | wxDV_NO_HEADER), | ||
_showSkins(true) | ||
{ | ||
// Single visible column, containing the directory/shader name and the icon | ||
AppendIconTextColumn( | ||
_("Model Path"), _columns.iconAndName.getColumnIndex(), | ||
wxDATAVIEW_CELL_INERT, wxCOL_WIDTH_AUTOSIZE, | ||
wxALIGN_NOT, wxDATAVIEW_COL_SORTABLE | ||
); | ||
|
||
// Use the TreeModel's full string search function | ||
AddSearchColumn(_columns.iconAndName); | ||
EnableFavouriteManagement(decl::Type::Model); | ||
} | ||
|
||
void ModelTreeView::Populate() | ||
{ | ||
ResourceTreeView::Populate(std::make_shared<ModelPopulator>(_columns)); | ||
} | ||
|
||
void ModelTreeView::SetShowSkins(bool showSkins) | ||
{ | ||
if (_showSkins == showSkins) | ||
{ | ||
return; | ||
} | ||
|
||
// Try to keep the selection intact when switching modes | ||
auto previousSelection = GetSelectedFullname(); | ||
|
||
_showSkins = showSkins; | ||
|
||
SetupTreeModelFilter(); // refresh the view | ||
|
||
if (!previousSelection.empty()) | ||
{ | ||
SetSelectedFullname(previousSelection); | ||
} | ||
} | ||
|
||
std::string ModelTreeView::GetSelectedModelPath() | ||
{ | ||
return GetColumnValue(_columns.modelPath); | ||
} | ||
|
||
std::string ModelTreeView::GetSelectedSkin() | ||
{ | ||
return GetColumnValue(_columns.skin); | ||
} | ||
|
||
bool ModelTreeView::IsTreeModelRowVisible(wxutil::TreeModel::Row& row) | ||
{ | ||
if (!_showSkins && row[_columns.isSkin].getBool()) | ||
{ | ||
return false; // it's a skin, and we shouldn't show it | ||
} | ||
|
||
// Pass to the base class | ||
return ResourceTreeView::IsTreeModelRowVisible(row); | ||
} | ||
|
||
std::string ModelTreeView::GetColumnValue(const wxutil::TreeModel::Column& column) | ||
{ | ||
auto item = GetSelection(); | ||
|
||
if (!item.IsOk()) return ""; | ||
|
||
wxutil::TreeModel::Row row(item, *GetModel()); | ||
|
||
return row[column]; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters