mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-05-31 18:46:29 +03:00
Minor fix in C++ syntax highlight. Improved TextDocument indentation guessing. UIMessageBox with type TEXT_EDIT now focuses the text edit by default. ecode: Allow to merge branches. If HEAD branch doesn't have origin, on commit + push it will push the new branch into origin.
72 lines
1.7 KiB
C++
72 lines
1.7 KiB
C++
#ifndef ECODE_GITBRANCHMODEL_HPP
|
|
#define ECODE_GITBRANCHMODEL_HPP
|
|
|
|
#include "git.hpp"
|
|
|
|
#include <cstddef>
|
|
#include <optional>
|
|
|
|
#include <eepp/ui/models/model.hpp>
|
|
|
|
using namespace EE;
|
|
using namespace EE::UI;
|
|
using namespace EE::UI::Models;
|
|
|
|
namespace ecode {
|
|
|
|
class GitPlugin;
|
|
|
|
class GitBranchModel : public Model {
|
|
public:
|
|
static std::shared_ptr<GitBranchModel> asModel( std::vector<Git::Branch>&& branches,
|
|
size_t hash, GitPlugin* gitPlugin ) {
|
|
return std::make_shared<GitBranchModel>( std::move( branches ), hash, gitPlugin );
|
|
}
|
|
|
|
static size_t hashBranches( const std::vector<Git::Branch>& branches );
|
|
|
|
enum Column { Name, Remote, Type, LastCommit };
|
|
|
|
struct BranchData {
|
|
std::string branch;
|
|
std::vector<Git::Branch> data;
|
|
};
|
|
|
|
std::string refTypeToString( Git::RefType type ) const;
|
|
|
|
GitBranchModel( std::vector<Git::Branch>&& branches, size_t hash, GitPlugin* gitPlugin );
|
|
|
|
size_t treeColumn() const { return Column::Name; }
|
|
|
|
size_t rowCount( const ModelIndex& index ) const;
|
|
|
|
size_t columnCount( const ModelIndex& ) const { return 4; }
|
|
|
|
ModelIndex parentIndex( const ModelIndex& index ) const;
|
|
|
|
ModelIndex index( int row, int column, const ModelIndex& parent ) const;
|
|
|
|
UIIcon* iconFor( const ModelIndex& index ) const;
|
|
|
|
Variant data( const ModelIndex& index, ModelRole role ) const;
|
|
|
|
virtual bool classModelRoleEnabled() { return true; }
|
|
|
|
size_t getHash() const { return mHash; }
|
|
|
|
Git::Branch branch( const ModelIndex& index ) const;
|
|
|
|
std::optional<Git::Branch> branch( const std::string& name ) const;
|
|
|
|
ModelIndex refTypeIndex( Git::RefType refType ) const;
|
|
|
|
protected:
|
|
std::vector<BranchData> mBranches;
|
|
GitPlugin* mPlugin{ nullptr };
|
|
size_t mHash{ 0 };
|
|
};
|
|
|
|
} // namespace ecode
|
|
|
|
#endif // ECODE_GITBRANCHMODEL_HPP
|