diff --git a/include/eepp/ui/models/filesystemmodel.hpp b/include/eepp/ui/models/filesystemmodel.hpp index 9d3d0a1c1..076d7ab95 100644 --- a/include/eepp/ui/models/filesystemmodel.hpp +++ b/include/eepp/ui/models/filesystemmodel.hpp @@ -130,6 +130,8 @@ class EE_API FileSystemModel : public Model { void rename( const FileInfo& file ); + void updateChilds( const FileInfo& oldParentFile, const FileInfo& newParentFile ); + friend class FileSystemModel; std::string mName; String mDisplayName; diff --git a/src/eepp/ui/models/filesystemmodel.cpp b/src/eepp/ui/models/filesystemmodel.cpp index e8d2a219f..79af9748e 100644 --- a/src/eepp/ui/models/filesystemmodel.cpp +++ b/src/eepp/ui/models/filesystemmodel.cpp @@ -132,11 +132,25 @@ FileSystemModel::Node* FileSystemModel::Node::createChild( const std::string& ch } void FileSystemModel::Node::rename( const FileInfo& file ) { + auto oldParentFile = mInfo; mInfo = file; mName = file.getFileName(); mHash = String::hash( mName ); mDisplayName = mName; updateMimeType(); + updateChilds( oldParentFile, mInfo ); +} + +void FileSystemModel::Node::updateChilds( const FileInfo& oldParentFile, + const FileInfo& newParentFile ) { + for ( Node* child : mChildren ) { + if ( String::startsWith( child->mInfo.getFilepath(), oldParentFile.getFilepath() ) ) { + std::string newFilePath( child->mInfo.getFilepath() ); + newFilePath.replace( 0, oldParentFile.getFilepath().size(), + newParentFile.getFilepath() ); + child->rename( FileInfo( newFilePath ) ); + } + } } ModelIndex FileSystemModel::Node::index( const FileSystemModel& model, int column ) const { diff --git a/src/tools/ecode/plugins/git/git.cpp b/src/tools/ecode/plugins/git/git.cpp index 8c861925e..ad2df3997 100644 --- a/src/tools/ecode/plugins/git/git.cpp +++ b/src/tools/ecode/plugins/git/git.cpp @@ -366,6 +366,10 @@ static void parseAheadBehind( std::string_view aheadBehind, Git::Branch& branch static constexpr auto AHEAD = "ahead "sv; if ( aheadBehind.empty() ) return; + if ( aheadBehind == "gone" ) { + branch.gone = true; + return; + } auto split = String::split( aheadBehind, ',' ); for ( auto s : split ) { s = String::trim( s ); diff --git a/src/tools/ecode/plugins/git/git.hpp b/src/tools/ecode/plugins/git/git.hpp index 9c104df49..4057c9632 100644 --- a/src/tools/ecode/plugins/git/git.hpp +++ b/src/tools/ecode/plugins/git/git.hpp @@ -229,6 +229,8 @@ class Git { int64_t ahead{ 0 }; int64_t behind{ 0 }; + bool gone{ false }; + const char* typeStr() const { return refTypeToString( type ); } }; diff --git a/src/tools/ecode/plugins/git/gitbranchmodel.cpp b/src/tools/ecode/plugins/git/gitbranchmodel.cpp index d87d1d156..77fbd08b5 100644 --- a/src/tools/ecode/plugins/git/gitbranchmodel.cpp +++ b/src/tools/ecode/plugins/git/gitbranchmodel.cpp @@ -105,6 +105,9 @@ Variant GitBranchModel::data( const ModelIndex& index, ModelRole role ) const { return Variant( String::format( "%s (-%ld)", branch.name, branch.behind ) ); } + } else if ( branch.type == Git::Head && branch.gone ) { + return Variant( String::format( + "%s (%s)", branch.name, mPlugin->i18n( "gone", "gone" ).toUtf8() ) ); } else if ( branch.type == Git::Stash ) { return Variant( String::format( "%s: %s", branch.date, branch.name ) ); }