#ifndef ECODE_GITSTATUSMODEL_HPP #define ECODE_GITSTATUSMODEL_HPP #include "git.hpp" #include using namespace EE; using namespace EE::UI; using namespace EE::UI::Models; namespace ecode { class GitPlugin; class GitStatusModel : public Model { public: static std::shared_ptr asModel( Git::FilesStatus status, GitPlugin* gitPlugin ) { return std::make_shared( std::move( status ), gitPlugin ); } struct RepoStatusType; struct RepoStatus; struct DiffFile : Git::DiffFile { DiffFile( Git::DiffFile&& df, RepoStatusType* parent ) : Git::DiffFile( df ), parent( parent ){}; RepoStatusType* parent; }; struct RepoStatusType { std::string typeStr; Git::GitStatusType type; std::vector files; RepoStatus* parent{ nullptr }; }; struct RepoStatus { std::string repo; std::vector type; bool hasStatusType( Git::GitStatusType statusType ) const { for ( const auto& t : type ) { if ( t.type == statusType ) return true; } return false; } }; enum Column { File, State, Inserted, Removed, RelativeDirectory }; GitStatusModel( Git::FilesStatus&& status, GitPlugin* gitPlugin ); size_t treeColumn() const { return Column::File; } size_t rowCount( const ModelIndex& index ) const; size_t columnCount( const ModelIndex& ) const { return 5; } ModelIndex parentIndex( const ModelIndex& index ) const; enum ModelCategory { Repo, Status, GitFile }; ModelIndex index( int row, int column, const ModelIndex& parent ) const; Variant data( const ModelIndex& index, ModelRole role ) const; virtual bool classModelRoleEnabled() { return true; } const RepoStatus* repo( const ModelIndex& index ) const; const RepoStatusType* statusType( const ModelIndex& index ) const; const DiffFile* file( const ModelIndex& index ) const; std::vector getFiles( const std::string& repo, uint32_t statusType = Git::STATUS_TYPE_ALL ) const; protected: std::vector mStatus; GitPlugin* mPlugin{ nullptr }; }; } // namespace ecode #endif // ECODE_GITSTATUSMODEL_HPP