Skip to content
Open
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
5 changes: 5 additions & 0 deletions Changes.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
1.6.x.x (relative to 1.6.6.0)
=======

Improvements
------------

- File Browser : Added column displaying the size of files and sequences (#6698).

Fixes
-----

Expand Down
27 changes: 27 additions & 0 deletions python/GafferUI/PathListingWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import collections
import enum
import math
import os
import warnings

import imath
Expand All @@ -55,6 +56,30 @@
from Qt import QtGui
from Qt import QtWidgets

class _FileSizeColumn( GafferUI.PathColumn ) :

def cellData( self, path, canceller ) :

size = path.property( "fileSystem:size", canceller )
isFile = os.path.isfile( path.fileSequence().fileNames()[0] if path.isFileSequence() else str( path ) )

return GafferUI.PathColumn.CellData(
value = _FileSizeColumn.__formattedSize( size ) if isFile else "",
sortValue = IECore.UInt64Data( min( size + 1, 2 ** 64 - 1 ) if isFile else 0 )
)

def headerData( self, canceller ) :

return GafferUI.PathColumn.CellData( value = "Size" )

@staticmethod
def __formattedSize( size ) :

for unit in ( "bytes", "KB", "MB", "GB", "TB", "PB" ) :
if abs( size ) < 1024.0 or unit == "PB" :
return f"{size:.1f} {unit}" if unit != "bytes" else f"{size:d} {unit}"
size /= 1024.0

## The PathListingWidget displays the contents of a Path, updating the Path to represent the
# current directory as the user navigates around. It supports both a list and a tree view,
# allows customisable column listings, and supports both single and multiple selection.
Expand All @@ -69,12 +94,14 @@ class PathListingWidget( GafferUI.Widget ) :
defaultFileSystemOwnerColumn = StandardColumn( "Owner", "fileSystem:owner" )
defaultFileSystemModificationTimeColumn = StandardColumn( "Modified", "fileSystem:modificationTime" )
defaultFileSystemIconColumn = GafferUI.FileIconPathColumn()
defaultFileSystemFormattedSizeColumn = _FileSizeColumn()

defaultFileSystemColumns = (
defaultNameColumn,
defaultFileSystemOwnerColumn,
defaultFileSystemModificationTimeColumn,
defaultFileSystemIconColumn,
defaultFileSystemFormattedSizeColumn
)

## A collection of handy column definitions for IndexedIOPaths
Expand Down
Loading