Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PathColumn : Allow sorting of FileIconPathColumn #6012

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Improvements
- Added the ability to edit the scale of node icons.
- Improved layout of Box node plug creator visibility toggles.
- ArnoldShader : Moved the `toon` shader's `*_tonemap_hue_saturation` parameters to appropriate sections in the UI.
- File Browser : The "Type" column can now be sorted. This sorts directories separately from files, which are sorted by their extension.

API
---
Expand Down
10 changes: 9 additions & 1 deletion src/GafferUI/PathColumn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,8 @@ FileIconPathColumn::FileIconPathColumn( SizeMode sizeMode )

PathColumn::CellData FileIconPathColumn::cellData( const Gaffer::Path &path, const IECore::Canceller *canceller ) const
{
CellData result;

std::string s = path.string();
if( const FileSystemPath *fileSystemPath = runTimeCast<const FileSystemPath>( &path ) )
{
Expand All @@ -256,7 +258,13 @@ PathColumn::CellData FileIconPathColumn::cellData( const Gaffer::Path &path, con
}
}

return CellData( /* value = */ nullptr, /* icon = */ new StringData( "fileIcon:" + s ) );
result.icon = new StringData( "fileIcon:" + s );
const auto p = std::filesystem::path( s );
// Use a sortValue of `extension:stem` to allow sorting by extension
// while maintaining a reasonable ordering within each extension.
result.sortValue = new StringData( ( std::filesystem::is_directory( p ) ? " " : p.extension().string() ) + ":" + p.stem().string() );

return result;
}

PathColumn::CellData FileIconPathColumn::headerData( const IECore::Canceller *canceller ) const
Expand Down
Loading