From c106167428ea71bfe7243775046c378588a2138d Mon Sep 17 00:00:00 2001 From: Sven Strickroth Date: Tue, 22 May 2012 22:43:16 +0200 Subject: [PATCH] added basic version of repository browser Signed-off-by: Sven Strickroth --- src/Changelog.txt | 1 + src/Resources/TortoiseProcENG.rc | 12 + src/TortoiseProc/Commands/Command.cpp | 10 +- .../Commands/RepositoryBrowserCommand.cpp | 132 ++------ src/TortoiseProc/RepositoryBrowser.cpp | 349 +++++++++++++++++++++ src/TortoiseProc/RepositoryBrowser.h | 108 +++++++ src/TortoiseProc/TortoiseProc.vcproj | 20 ++ src/TortoiseProc/resource.h | 3 + 8 files changed, 528 insertions(+), 107 deletions(-) rewrite src/TortoiseProc/Commands/RepositoryBrowserCommand.cpp (71%) create mode 100644 src/TortoiseProc/RepositoryBrowser.cpp create mode 100644 src/TortoiseProc/RepositoryBrowser.h diff --git a/src/Changelog.txt b/src/Changelog.txt index 2302c53ed..189cac7f6 100644 --- a/src/Changelog.txt +++ b/src/Changelog.txt @@ -7,6 +7,7 @@ Released: unreleased * Synced TortoiseUDiff with TortoiseSVN * Fixed issue #1150: Add support for ANSI Color Codes in log Outputs * Fixed issue #969: Support for localization (you can download/create language packs for TortoiseGit, see http://code.google.com/p/tortoisegit/wiki/Translation) + * Added Repository Browser == Bug Fix == * Fixed issue #1162: Sync dialog should use same font as progress dialog (use log font for both) diff --git a/src/Resources/TortoiseProcENG.rc b/src/Resources/TortoiseProcENG.rc index 2a741f959..68499336c 100644 --- a/src/Resources/TortoiseProcENG.rc +++ b/src/Resources/TortoiseProcENG.rc @@ -281,6 +281,18 @@ BEGIN PUSHBUTTON "Cancel",IDCANCEL,177,34,50,14 END +IDD_REPOSITORY_BROWSER DIALOGEX 0, 0, 415, 279 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME +CAPTION "Repository Browser" +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + CONTROL "",IDC_REPOTREE,"SysTreeView32",TVS_HASBUTTONS | TVS_LINESATROOT | TVS_EDITLABELS | TVS_SHOWSELALWAYS | TVS_TRACKSELECT | WS_BORDER | WS_HSCROLL | WS_TABSTOP,7,22,160,227,WS_EX_CLIENTEDGE + CONTROL "",IDC_REPOLIST,"SysListView32",LVS_REPORT | LVS_SHOWSELALWAYS | LVS_SHAREIMAGELISTS | LVS_EDITLABELS | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,170,22,238,227,WS_EX_ACCEPTFILES | WS_EX_CLIENTEDGE + DEFPUSHBUTTON "OK",IDOK,246,258,50,14 + PUSHBUTTON "Cancel",IDCANCEL,302,258,50,14 + PUSHBUTTON "Help",IDHELP,358,258,50,14 +END + IDD_SETTINGSMAIN DIALOGEX 0, 0, 300, 217 STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_DISABLED | WS_CAPTION CAPTION "General" diff --git a/src/TortoiseProc/Commands/Command.cpp b/src/TortoiseProc/Commands/Command.cpp index 47121453f..e490db1c6 100644 --- a/src/TortoiseProc/Commands/Command.cpp +++ b/src/TortoiseProc/Commands/Command.cpp @@ -1,7 +1,7 @@ // TortoiseGit - a Windows shell extension for easy version control +// Copyright (C) 2008-2012 - TortoiseGit // Copyright (C) 2007-2008 - TortoiseSVN -// Copyright (C) 2008-2011 - TortoiseGit // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -72,6 +72,7 @@ #include "PasteMoveCommand.h" #include "SVNIgnoreCommand.h" #include "BisectCommand.h" +#include "RepositoryBrowserCommand.h" #if 0 @@ -87,7 +88,6 @@ #include "RebuildIconCacheCommand.h" #include "RemoveCommand.h" -#include "RepositoryBrowserCommand.h" #include "RevertCommand.h" @@ -160,7 +160,8 @@ typedef enum cmdSVNIgnore, cmdSync, cmdRequestPull, - cmdBisect + cmdBisect, + cmdRepoBrowser, } TGitCommand; static const struct CommandInfo @@ -230,6 +231,7 @@ static const struct CommandInfo { cmdSync, _T("sync") }, { cmdRequestPull, _T("requestpull") }, { cmdBisect, _T("bisect") }, + { cmdRepoBrowser, _T("repobrowser") }, }; @@ -358,6 +360,8 @@ Command * CommandServer::GetCommand(const CString& sCmd) return new SVNIgnoreCommand; case cmdBisect: return new BisectCommand; + case cmdRepoBrowser: + return new RepositoryBrowserCommand; #if 0 diff --git a/src/TortoiseProc/Commands/RepositoryBrowserCommand.cpp b/src/TortoiseProc/Commands/RepositoryBrowserCommand.cpp dissimilarity index 71% index 8dda3f08f..6d4cb11bf 100644 --- a/src/TortoiseProc/Commands/RepositoryBrowserCommand.cpp +++ b/src/TortoiseProc/Commands/RepositoryBrowserCommand.cpp @@ -1,104 +1,28 @@ -// TortoiseGit - a Windows shell extension for easy version control - -// Copyright (C) 2007-2008 - TortoiseSVN - -// 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. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software Foundation, -// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -// -#include "StdAfx.h" -#include "RepositoryBrowserCommand.h" - -#include "RepositoryBrowser.h" -#include "URLDlg.h" -#include "SVN.h" -#include "PathUtils.h" -#include "UnicodeUtils.h" - -bool RepositoryBrowserCommand::Execute() -{ - CString url; - BOOL bFile = FALSE; - SVN svn; - if (!cmdLinePath.IsEmpty()) - { - if (cmdLinePath.GetSVNPathString().Left(4).CompareNoCase(_T("svn:"))==0) - { - // If the path starts with "svn:" and there is another protocol - // found in the path (a "://" found after the "svn:") then - // remove "svn:" from the beginning of the path. - if (cmdLinePath.GetSVNPathString().Find(_T("://"), 4)>=0) - cmdLinePath.SetFromSVN(cmdLinePath.GetSVNPathString().Mid(4)); - } - - url = svn.GetURLFromPath(cmdLinePath); - - if (url.IsEmpty()) - { - if (SVN::PathIsURL(cmdLinePath)) - url = cmdLinePath.GetSVNPathString(); - else if (svn.IsRepository(cmdLinePath)) - { - // The path points to a local repository. - // Add 'file:///' so the repository browser recognizes - // it as an URL to the local repository. - if (cmdLinePath.GetWinPathString().GetAt(0) == '\\') // starts with '\' means an UNC path - { - CString p = cmdLinePath.GetWinPathString(); - p.TrimLeft('\\'); - if (CPathUtils::PathEscape(CUnicodeUtils::GetUTF8(p)).Find('%') >= 0) - { - // the path has special chars which will get escaped! - url = _T("file:///\\")+p; - } - else - url = _T("file://")+p; - } - else - url = _T("file:///")+cmdLinePath.GetWinPathString(); - url.Replace('\\', '/'); - } - } - } - if (cmdLinePath.GetUIPathString().Left(7).CompareNoCase(_T("file://"))==0) - { - cmdLinePath.SetFromUnknown(cmdLinePath.GetUIPathString().Mid(7)); - } - bFile = PathFileExists(cmdLinePath.GetWinPath()) ? !cmdLinePath.IsDirectory() : FALSE; - - if (url.IsEmpty()) - { - CURLDlg urldlg; - if (urldlg.DoModal() != IDOK) - { - return false; - } - url = urldlg.m_url; - } - - CString val = parser.GetVal(_T("rev")); - SVNRev rev(val); - CRepositoryBrowser dlg(url, rev); - if (!cmdLinePath.IsUrl()) - dlg.m_ProjectProperties.ReadProps(cmdLinePath); - else - { - if (parser.HasVal(_T("projectpropertiespath"))) - { - dlg.m_ProjectProperties.ReadProps(CTSVNPath(parser.GetVal(_T("projectpropertiespath")))); - } - } - dlg.m_path = cmdLinePath; - dlg.DoModal(); - return true; -} \ No newline at end of file +// TortoiseGit - a Windows shell extension for easy version control + +// Copyright (C) 2012 - TortoiseGit + +// 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. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +// +#include "StdAfx.h" +#include "RepositoryBrowserCommand.h" + +#include "RepositoryBrowser.h" + +bool RepositoryBrowserCommand::Execute() +{ + CRepositoryBrowser().DoModal(); + return true; +} \ No newline at end of file diff --git a/src/TortoiseProc/RepositoryBrowser.cpp b/src/TortoiseProc/RepositoryBrowser.cpp new file mode 100644 index 000000000..4f7531916 --- /dev/null +++ b/src/TortoiseProc/RepositoryBrowser.cpp @@ -0,0 +1,349 @@ +// TortoiseGit - a Windows shell extension for easy version control + +// Copyright (C) 2009-2012 - TortoiseGit +// Copyright (C) 2012 Sven Strickroth +// Copyright (C) 2003-2012 - TortoiseSVN + +// 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. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +// +// RepositoryBrowser.cpp : implementation file +// + +#include "stdafx.h" +#include "TortoiseProc.h" +#include "RepositoryBrowser.h" +#include "AppUtils.h" +#include "IconMenu.h" +#include "UnicodeUtils.h" +#include "SysImageList.h" +#include +#include "SysInfo.h" +#include "registry.h" + +// CRepositoryBrowser dialog + +IMPLEMENT_DYNAMIC(CRepositoryBrowser, CResizableStandAloneDialog) + +CRepositoryBrowser::CRepositoryBrowser(CWnd* pParent /*=NULL*/) +: CResizableStandAloneDialog(CRepositoryBrowser::IDD, pParent) +{ +} + +CRepositoryBrowser::~CRepositoryBrowser() +{ +} + +void CRepositoryBrowser::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + DDX_Control(pDX, IDC_REPOTREE, m_RepoTree); + DDX_Control(pDX, IDC_REPOLIST, m_RepoList); +} + + +BEGIN_MESSAGE_MAP(CRepositoryBrowser, CResizableStandAloneDialog) + ON_NOTIFY(TVN_SELCHANGED, IDC_REPOTREE, &CRepositoryBrowser::OnTvnSelchangedRepoTree) + ON_WM_CONTEXTMENU() +END_MESSAGE_MAP() + + +// CRepositoryBrowser message handlers + +BOOL CRepositoryBrowser::OnInitDialog() +{ + CResizableStandAloneDialog::OnInitDialog(); + CAppUtils::MarkWindowAsUnpinnable(m_hWnd); + + AddAnchor(IDC_STATIC, TOP_LEFT); + AddAnchor(IDC_REPOTREE, TOP_LEFT, BOTTOM_LEFT); + AddAnchor(IDC_REPOLIST, TOP_LEFT, BOTTOM_RIGHT); + AddAnchor(IDHELP, BOTTOM_RIGHT); + AddAnchor(IDOK, BOTTOM_RIGHT); + AddAnchor(IDCANCEL, BOTTOM_RIGHT); + + m_RepoList.SetExtendedStyle(m_RepoList.GetExtendedStyle() | LVS_EX_FULLROWSELECT); + CString temp; + temp.LoadString(IDS_STATUSLIST_COLFILENAME); + m_RepoList.InsertColumn(eCol_Name, temp, 0, 150); + temp.LoadString(IDS_LOG_SIZE); + m_RepoList.InsertColumn(eCol_FileSize, temp, 0, 100); + + // set up the list control + // set the extended style of the list control + // the style LVS_EX_FULLROWSELECT interferes with the background watermark image but it's more important to be able to select in the whole row. + CRegDWORD regFullRowSelect(_T("Software\\TortoiseGit\\FullRowSelect"), TRUE); + DWORD exStyle = LVS_EX_HEADERDRAGDROP | LVS_EX_DOUBLEBUFFER | LVS_EX_INFOTIP | LVS_EX_SUBITEMIMAGES; + if (DWORD(regFullRowSelect)) + exStyle |= LVS_EX_FULLROWSELECT; + m_RepoList.SetExtendedStyle(exStyle); + m_RepoList.SetImageList(&SYS_IMAGE_LIST(), LVSIL_SMALL); + + m_RepoTree.SetImageList(&SYS_IMAGE_LIST(), TVSIL_NORMAL); + if (SysInfo::Instance().IsVistaOrLater()) + { + DWORD exStyle = TVS_EX_FADEINOUTEXPANDOS | TVS_EX_AUTOHSCROLL | TVS_EX_DOUBLEBUFFER; + m_RepoTree.SetExtendedStyle(exStyle, exStyle); + } + + SetWindowTheme(m_RepoTree.GetSafeHwnd(), L"Explorer", NULL); + SetWindowTheme(m_RepoList.GetSafeHwnd(), L"Explorer", NULL); + + m_nIconFolder = SYS_IMAGE_LIST().GetDirIconIndex(); + m_nOpenIconFolder = SYS_IMAGE_LIST().GetDirOpenIconIndex(); + + EnableSaveRestore(L"Reposbrowser"); + + CString sWindowTitle; + GetWindowText(sWindowTitle); + CAppUtils::SetWindowTitle(m_hWnd, g_Git.m_CurrentDir, sWindowTitle); + + Refresh(); + + m_RepoList.SetFocus(); + + return FALSE; +} + +void CRepositoryBrowser::OnOK() +{ + CResizableStandAloneDialog::OnOK(); +} + +void CRepositoryBrowser::OnCancel() +{ + CResizableStandAloneDialog::OnCancel(); +} + +void CRepositoryBrowser::Refresh() +{ + m_RepoTree.DeleteAllItems(); + m_RepoList.DeleteAllItems(); + m_TreeRoot.m_ShadowTree.clear(); + m_TreeRoot.m_sName = ""; + m_TreeRoot.m_bFolder = true; + + TVINSERTSTRUCT tvinsert = {0}; + tvinsert.hParent = TVI_ROOT; + tvinsert.hInsertAfter = TVI_ROOT; + tvinsert.itemex.mask = TVIF_DI_SETITEM | TVIF_PARAM | TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_STATE; + tvinsert.itemex.pszText = L"/"; + tvinsert.itemex.lParam = (LPARAM)&m_TreeRoot; + tvinsert.itemex.iImage = m_nIconFolder; + tvinsert.itemex.iSelectedImage = m_nOpenIconFolder; + m_TreeRoot.m_hTree= m_RepoTree.InsertItem(&tvinsert); + + ReadTree(&m_TreeRoot); + m_RepoTree.Expand(m_TreeRoot.m_hTree, TVE_EXPAND); + FillListCtrlForShadowTree(&m_TreeRoot); + m_RepoTree.SelectItem(m_TreeRoot.m_hTree); +} + +int CRepositoryBrowser::ReadTreeRecursive(git_repository &repo, git_tree * tree, CShadowFilesTree * treeroot) +{ + size_t count = git_tree_entrycount(tree); + + for (int i = 0; i < count; i++) + { + const git_tree_entry *entry = git_tree_entry_byindex(tree, i); + if (entry == NULL) + continue; + int mode = git_tree_entry_attributes(entry); + + CString base = CUnicodeUtils::GetUnicode(git_tree_entry_name(entry), CP_UTF8); + + git_object *object = NULL; + git_tree_entry_2object(&object, &repo, entry); + if (object == NULL) + continue; + + CShadowFilesTree * pNextTree = &treeroot->m_ShadowTree[base]; + pNextTree->m_sName = base; + pNextTree->m_pParent = treeroot; + + if (mode & S_IFDIR) + { + pNextTree->m_bFolder = true; + + TVINSERTSTRUCT tvinsert = {0}; + tvinsert.hParent = treeroot->m_hTree; + tvinsert.hInsertAfter = TVI_SORT; + tvinsert.itemex.mask = TVIF_DI_SETITEM | TVIF_PARAM | TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_STATE; + tvinsert.itemex.pszText = base.GetBuffer(base.GetLength()); + tvinsert.itemex.lParam = (LPARAM)pNextTree; + tvinsert.itemex.iImage = m_nIconFolder; + tvinsert.itemex.iSelectedImage = m_nOpenIconFolder; + pNextTree->m_hTree = m_RepoTree.InsertItem(&tvinsert); + base.ReleaseBuffer(); + + ReadTreeRecursive(repo, (git_tree*)object, pNextTree); + } + else + { + const git_oid * oid = git_object_id(object); + + git_blob * blob; + git_blob_lookup(&blob, &repo, oid); + if (blob == NULL) + continue; + + pNextTree->m_iSize = git_blob_rawsize(blob); + git_blob_free(blob); + } + + git_object_free(object); + } + + return 0; +} + +int CRepositoryBrowser::ReadTree(CShadowFilesTree * treeroot) +{ + CStringA gitdir = CUnicodeUtils::GetMulti(g_Git.m_CurrentDir, CP_UTF8); + git_repository *repository = NULL; + git_commit *commit = NULL; + git_tree * tree = NULL; + int ret = 0; + do + { + ret = git_repository_open(&repository, gitdir.GetBuffer()); + if(ret) + break; + + CGitHash hash = g_Git.GetHash(_T("HEAD")); + ret = git_commit_lookup(&commit, repository, (git_oid *) hash.m_hash); + if(ret) + break; + + ret = git_commit_tree(&tree, commit); + if(ret) + break; + + ret = ReadTreeRecursive(*repository, tree, treeroot); + if(ret) + break; + } while(0); + + if (tree) + git_tree_free(tree); + + if (commit) + git_commit_free(commit); + + if (repository) + git_repository_free(repository); + + return ret; +} + +void CRepositoryBrowser::OnTvnSelchangedRepoTree(NMHDR *pNMHDR, LRESULT *pResult) +{ + LPNMTREEVIEW pNMTreeView = reinterpret_cast(pNMHDR); + *pResult = 0; + + FillListCtrlForTreeNode(pNMTreeView->itemNew.hItem); +} + +void CRepositoryBrowser::FillListCtrlForTreeNode(HTREEITEM treeNode) +{ + m_RepoList.DeleteAllItems(); + + CShadowFilesTree* pTree = (CShadowFilesTree*)(m_RepoTree.GetItemData(treeNode)); + if (pTree == NULL) + { + ASSERT(FALSE); + return; + } + FillListCtrlForShadowTree(pTree); +} + +void CRepositoryBrowser::FillListCtrlForShadowTree(CShadowFilesTree* pTree) +{ + for (TShadowFilesTreeMap::iterator itShadowTree = pTree->m_ShadowTree.begin(); itShadowTree != pTree->m_ShadowTree.end(); ++itShadowTree) + { + int icon = m_nIconFolder; + if (!(*itShadowTree).second.m_bFolder) + icon = SYS_IMAGE_LIST().GetFileIconIndex((*itShadowTree).second.m_sName); + + int indexItem = m_RepoList.InsertItem(m_RepoList.GetItemCount(), (*itShadowTree).second.m_sName, icon); + + m_RepoList.SetItemData(indexItem, (DWORD_PTR)&(*itShadowTree).second); + if (!(*itShadowTree).second.m_bFolder) + { + CString temp; + StrFormatByteSize((*itShadowTree).second.m_iSize, temp.GetBuffer(20), 20); + temp.ReleaseBuffer(); + m_RepoList.SetItemText(indexItem, eCol_FileSize, temp); + } + } +} + +void CRepositoryBrowser::OnContextMenu(CWnd* pWndFrom, CPoint point) +{ + if (pWndFrom == &m_RepoList) + OnContextMenu_RepoList(point); +} + +void CRepositoryBrowser::OnContextMenu_RepoList(CPoint point) +{ + TShadowFilesTreeList selectedLeafs; + selectedLeafs.reserve(m_RepoList.GetSelectedCount()); + POSITION pos = m_RepoList.GetFirstSelectedItemPosition(); + while (pos) + { + selectedLeafs.push_back((CShadowFilesTree *)m_RepoList.GetItemData(m_RepoList.GetNextSelectedItem(pos))); + } + + CIconMenu popupMenu; + popupMenu.CreatePopupMenu(); + + bool bAddSeparator = false; + + if (selectedLeafs.size() == 1) + { + CString temp; + temp.LoadString(IDS_MENULOG); + popupMenu.AppendMenuIcon(eCmd_ViewLog, temp, IDI_LOG); + bAddSeparator = true; + } + + eCmd cmd = (eCmd)popupMenu.TrackPopupMenuEx(TPM_LEFTALIGN|TPM_RETURNCMD, point.x, point.y, this, 0); + switch(cmd) + { + case eCmd_ViewLog: + { + CString sCmd; + sCmd.Format(_T("/command:log /path:\"%s%s\""), g_Git.m_CurrentDir, selectedLeafs.at(0)->GetFullName()); + CAppUtils::RunTortoiseProc(sCmd); + } + break; + } +} + +BOOL CRepositoryBrowser::PreTranslateMessage(MSG* pMsg) +{ + if (pMsg->message == WM_KEYDOWN) + { + switch (pMsg->wParam) + { + case VK_F5: + { + Refresh(); + } + break; + } + } + + return CResizableStandAloneDialog::PreTranslateMessage(pMsg); +} diff --git a/src/TortoiseProc/RepositoryBrowser.h b/src/TortoiseProc/RepositoryBrowser.h new file mode 100644 index 000000000..fcf1f03b7 --- /dev/null +++ b/src/TortoiseProc/RepositoryBrowser.h @@ -0,0 +1,108 @@ +// TortoiseGit - a Windows shell extension for easy version control + +// Copyright (C) 2009-2012 - TortoiseGit +// Copyright (C) 2012 - Sven Strickroth + +// 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. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +// +#pragma once + +#include "git2.h" +#include +#include "StandAloneDlg.h" + +class CShadowFilesTree; + +typedef std::map TShadowFilesTreeMap; + +class CShadowFilesTree +{ +public: + CShadowFilesTree() + : m_hTree(NULL) + , m_pParent(NULL) + , m_bFolder(false) + , m_iSize(0) + {} + + CString m_sName; + size_t m_iSize; + bool m_bFolder; + + HTREEITEM m_hTree; + + TShadowFilesTreeMap m_ShadowTree; + CShadowFilesTree* m_pParent; + + CString GetFullName() const + { + if (m_pParent == NULL) + return m_sName; + + return m_pParent->GetFullName() + _T("/") + m_sName; + } +}; +typedef std::vector TShadowFilesTreeList; + +class CRepositoryBrowser : public CResizableStandAloneDialog +{ + DECLARE_DYNAMIC(CRepositoryBrowser) + +public: + CRepositoryBrowser(CWnd* pParent = NULL); // standard constructor + virtual ~CRepositoryBrowser(); + + // Dialog Data + enum { IDD = IDD_REPOSITORY_BROWSER }; + + enum eCmd + { + eCmd_ViewLog = WM_APP, + }; + + enum eCol + { + eCol_Name, + eCol_FileSize, + }; + +private: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + + DECLARE_MESSAGE_MAP() + + afx_msg void OnOK(); + afx_msg void OnCancel(); + virtual BOOL OnInitDialog(); + + CTreeCtrl m_RepoTree; + CListCtrl m_RepoList; + + CShadowFilesTree m_TreeRoot; + int ReadTreeRecursive(git_repository &repo, git_tree * tree, CShadowFilesTree * treeroot); + int ReadTree(CShadowFilesTree * treeroot); + int m_nIconFolder; + int m_nOpenIconFolder; + + void Refresh(); + void FillListCtrlForTreeNode(HTREEITEM treeNode); + void FillListCtrlForShadowTree(CShadowFilesTree* pTree); + afx_msg void OnTvnSelchangedRepoTree(NMHDR *pNMHDR, LRESULT *pResult); + + afx_msg void OnContextMenu(CWnd* pWndFrom, CPoint point); + void OnContextMenu_RepoList(CPoint point); + + virtual BOOL PreTranslateMessage(MSG* pMsg); +}; diff --git a/src/TortoiseProc/TortoiseProc.vcproj b/src/TortoiseProc/TortoiseProc.vcproj index 6c37a794d..5c8b2f482 100644 --- a/src/TortoiseProc/TortoiseProc.vcproj +++ b/src/TortoiseProc/TortoiseProc.vcproj @@ -2165,6 +2165,26 @@ > + + + + + + + + + +