1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260
|
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//
// copyright : (C) 2014 Eran Ifrah
// file name : gitentry.h
//
// -------------------------------------------------------------------------
// A
// _____ _ _ _ _
// / __ \ | | | | (_) |
// | / \/ ___ __| | ___| | _| |_ ___
// | | / _ \ / _ |/ _ \ | | | __/ _ )
// | \__/\ (_) | (_| | __/ |___| | || __/
// \____/\___/ \__,_|\___\_____/_|\__\___|
//
// F i l e
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//
// copyright : (C) 2011 by René Kraus (aka upCASE)
//
//////////////////////////////////////////////////////////////////////////////
#ifndef __gitentry__
#define __gitentry__
#include "cl_config.h"
#include "wxStringHash.h"
#include <map>
#include <vector>
#include <wx/colour.h>
#include <wx/event.h>
struct GitLabelCommand {
GitLabelCommand() {}
GitLabelCommand(const wxString& l, const wxString& c)
: label(l)
, command(c)
{
}
wxString label; // The menu label
wxString command; // The command string, without the initial 'git' or the extras like --no-pager
};
typedef std::vector<GitLabelCommand> vGitLabelCommands_t;
class GitCommandsEntries // Holds a command-list for a particular git command e.g. 'git pull' might be that, or 'git
// pull --rebase'
{
protected:
vGitLabelCommands_t m_commands;
wxString m_commandName;
int m_lastUsed;
public:
GitCommandsEntries() {}
GitCommandsEntries(const wxString& commandName)
: m_commandName(commandName)
, m_lastUsed(-1)
{
}
GitCommandsEntries(const GitCommandsEntries& gce)
: m_commands(gce.m_commands)
, m_commandName(gce.m_commandName)
, m_lastUsed(gce.m_lastUsed)
{
}
virtual ~GitCommandsEntries() {}
void FromJSON(const JSONItem& json);
void ToJSON(JSONItem& arr) const;
const wxString& GetCommandname() const { return m_commandName; }
const vGitLabelCommands_t& GetCommands() const { return m_commands; }
void SetCommands(const vGitLabelCommands_t& commands) { m_commands = commands; }
const wxString GetDefaultCommand() const
{
wxString str;
if(m_lastUsed >= 0 && m_lastUsed < (int)m_commands.size()) {
str = m_commands.at(m_lastUsed).command;
}
return str;
}
int GetLastUsedCommandIndex() const { return m_lastUsed; }
void SetLastUsedCommandIndex(int index) { m_lastUsed = index; }
};
typedef std::unordered_map<wxString, GitCommandsEntries> GitCommandsEntriesMap_t;
class GitWorkspace
{
public:
GitWorkspace() {}
GitWorkspace(const wxString& name)
: m_name(name)
{
}
const wxString& GetWorkspaceName() const { return m_name; }
void SetWorkspaceName(const wxString& name) { m_name = name; }
const wxString GetProjectUserEnteredRepoPath(const wxString& projectName);
void SetProjectUserEnteredRepoPath(const wxString& projectName, const wxString& userEnteredRepoPath);
void FromJSON(const JSONItem& json);
void ToJSON(JSONItem& arr) const;
protected:
wxString m_name;
wxStringMap_t m_projectData;
wxStringMap_t m_userEnteredRepoPath;
};
typedef std::unordered_map<wxString, GitWorkspace> GitWorkspaceMap_t;
extern const wxEventType wxEVT_GIT_CONFIG_CHANGED;
class GitEntry : public clConfigItem
{
wxColour m_colourTrackedFile;
wxColour m_colourDiffFile;
wxString m_pathGIT;
wxString m_pathGITK;
wxStringMap_t m_entries;
GitCommandsEntriesMap_t m_commandsMap;
GitWorkspaceMap_t m_workspacesMap;
size_t m_flags;
int m_gitDiffDlgSashPos;
int m_gitDiffChooseDlgRadioSel1;
int m_gitDiffChooseDlgRadioSel2;
wxArrayString m_gitDiffChooseDlgCBoxValues1;
wxArrayString m_gitDiffChooseDlgCBoxValues2;
int m_gitConsoleSashPos;
int m_gitCommitDlgHSashPos;
int m_gitCommitDlgVSashPos;
wxArrayString m_recentCommits;
wxString m_gitShellCommand;
bool m_gitBlameShowLogControls;
bool m_gitBlameShowParentCommit;
int m_gitBlameDlgMainSashPos;
int m_gitBlameDlgHSashPos;
int m_gitBlameDlgVSashPos;
public:
enum {
Git_Verbose_Log = (1 << 0),
Git_Show_Terminal = (1 << 1),
Git_Colour_Tree_View = (1 << 2),
Git_Show_Commit_Info = (1 << 4),
};
struct GitProperties {
wxString global_username;
wxString global_email;
wxString local_username;
wxString local_email;
};
public:
GitEntry();
virtual ~GitEntry();
public:
static GitEntry::GitProperties ReadGitProperties(const wxString& localRepoPath = "");
static void WriteGitProperties(const wxString& localRepoPath, const GitEntry::GitProperties& props);
void EnableFlag(size_t flag, bool b)
{
if(b) {
m_flags |= flag;
} else {
m_flags &= ~flag;
}
}
void Save();
GitEntry& Load();
wxArrayString& GetRecentCommit() { return m_recentCommits; }
void AddRecentCommit(const wxString& commitMessage);
void SetGitShellCommand(const wxString& gitShellCommand) { this->m_gitShellCommand = gitShellCommand; }
const wxString& GetGitShellCommand() const { return m_gitShellCommand; }
void SetGitCommitDlgHSashPos(int gitCommitDlgHSashPos) { this->m_gitCommitDlgHSashPos = gitCommitDlgHSashPos; }
void SetGitCommitDlgVSashPos(int gitCommitDlgVSashPos) { this->m_gitCommitDlgVSashPos = gitCommitDlgVSashPos; }
int GetGitCommitDlgHSashPos() const { return m_gitCommitDlgHSashPos; }
int GetGitCommitDlgVSashPos() const { return m_gitCommitDlgVSashPos; }
void SetGitDiffDlgSashPos(int gitDiffDlgSashPos) { this->m_gitDiffDlgSashPos = gitDiffDlgSashPos; }
int GetGitDiffDlgSashPos() const { return m_gitDiffDlgSashPos; }
void SetGitDiffChooseDlgRadioSel1(int sel) { this->m_gitDiffChooseDlgRadioSel1 = sel; }
int GetGitDiffChooseDlgRadioSel1() const { return m_gitDiffChooseDlgRadioSel1; }
void SetGitDiffChooseDlgRadioSel2(int sel) { this->m_gitDiffChooseDlgRadioSel2 = sel; }
int GetGitDiffChooseDlgRadioSel2() const { return m_gitDiffChooseDlgRadioSel2; }
void SetGitDiffChooseDlgCBoxValues1(const wxArrayString& arr) { this->m_gitDiffChooseDlgCBoxValues1 = arr; }
wxArrayString& GetGitDiffChooseDlgCBoxValues1() { return m_gitDiffChooseDlgCBoxValues1; }
void SetGitDiffChooseDlgCBoxValues2(const wxArrayString& arr) { this->m_gitDiffChooseDlgCBoxValues2 = arr; }
wxArrayString& GetGitDiffChooseDlgCBoxValues2() { return m_gitDiffChooseDlgCBoxValues2; }
void SetEntries(const wxStringMap_t& entries) { this->m_entries = entries; }
void SetFlags(size_t flags) { this->m_flags = flags; }
const wxStringMap_t& GetEntries() const { return m_entries; }
size_t GetFlags() const { return m_flags; }
void SetEntry(const wxString& workspace, const wxString& repo) { this->m_entries[workspace] = repo; }
void DeleteEntry(const wxString& workspace);
GitCommandsEntriesMap_t GetCommandsMap() const { return m_commandsMap; }
void SetTrackedFileColour(const wxColour& colour) { this->m_colourTrackedFile = colour; }
void SetDiffFileColour(const wxColour& colour) { this->m_colourDiffFile = colour; }
void SetGITExecutablePath(const wxString& exe) { this->m_pathGIT = exe; }
void SetGITKExecutablePath(const wxString& exe) { this->m_pathGITK = exe; }
const wxString& GetPath(const wxString& workspace) { return m_entries[workspace]; }
const wxColour& GetTrackedFileColour() { return this->m_colourTrackedFile; }
const wxColour& GetDiffFileColour() { return this->m_colourDiffFile; }
wxString GetGITExecutablePath() const;
wxString GetGITKExecutablePath() const;
void SetGitConsoleSashPos(int gitConsoleSashPos) { this->m_gitConsoleSashPos = gitConsoleSashPos; }
int GetGitConsoleSashPos() const { return m_gitConsoleSashPos; }
void SetGitBlameShowLogControls(bool gitBlameShowLogControls)
{
this->m_gitBlameShowLogControls = gitBlameShowLogControls;
}
bool GetGitBlameShowLogControls() const { return m_gitBlameShowLogControls; }
void SetGitBlameShowParentCommit(bool gitBlameShowParentCommit)
{
this->m_gitBlameShowParentCommit = gitBlameShowParentCommit;
}
bool GetGitBlameShowParentCommit() const { return m_gitBlameShowParentCommit; }
void SetGitBlameDlgMainSashPos(int MainSashPos) { this->m_gitBlameDlgMainSashPos = MainSashPos; }
void SetGitBlameDlgHSashPos(int HSashPos) { this->m_gitBlameDlgHSashPos = HSashPos; }
void SetGitBlameDlgVSashPos(int VSashPos) { this->m_gitBlameDlgVSashPos = VSashPos; }
int GetGitBlameDlgMainSashPos() const { return m_gitBlameDlgMainSashPos; }
int GetGitBlameDlgHSashPos() const { return m_gitBlameDlgHSashPos; }
int GetGitBlameDlgVSashPos() const { return m_gitBlameDlgVSashPos; }
GitCommandsEntries& GetGitCommandsEntries(const wxString& entryName);
void AddGitCommandsEntry(GitCommandsEntries& entries, const wxString& entryName);
void DeleteGitCommandsEntry(const wxString& entryName) { m_commandsMap.erase(entryName); }
wxString GetProjectUserEnteredRepoPath(const wxString& nameHash);
void SetProjectUserEnteredRepoPath(const wxString& userEnteredRepoPath, const wxString& nameHash);
virtual void FromJSON(const JSONItem& json);
virtual JSONItem ToJSON() const;
bool IsShowBlameInfoInStatusBar() const { return m_flags & Git_Show_Commit_Info; }
};
#endif
|