OSDN Git Service

Initial version of BrowseRefsDlg
authorJohan t Hart <johanthart@gmail.com>
Tue, 21 Apr 2009 21:55:28 +0000 (23:55 +0200)
committerFrank Li <lznuaa@gmail.com>
Fri, 24 Apr 2009 01:51:10 +0000 (09:51 +0800)
src/Resources/TortoiseProcENG.rc
src/TortoiseProc/BrowseRefsDlg.cpp [new file with mode: 0644]
src/TortoiseProc/BrowseRefsDlg.h [new file with mode: 0644]
src/TortoiseProc/Commands/Command.cpp
src/TortoiseProc/TortoiseProc.vcproj
src/TortoiseProc/resource.h

index 2182cd9..52dedbe 100644 (file)
Binary files a/src/Resources/TortoiseProcENG.rc and b/src/Resources/TortoiseProcENG.rc differ
diff --git a/src/TortoiseProc/BrowseRefsDlg.cpp b/src/TortoiseProc/BrowseRefsDlg.cpp
new file mode 100644 (file)
index 0000000..beaf97e
--- /dev/null
@@ -0,0 +1,135 @@
+// BrowseRefsDlg.cpp : implementation file\r
+//\r
+\r
+#include "stdafx.h"\r
+#include "TortoiseProc.h"\r
+#include "BrowseRefsDlg.h"\r
+\r
+\r
+// CBrowseRefsDlg dialog\r
+\r
+IMPLEMENT_DYNAMIC(CBrowseRefsDlg, CDialog)\r
+\r
+CBrowseRefsDlg::CBrowseRefsDlg(CWnd* pParent /*=NULL*/)\r
+       : CDialog(CBrowseRefsDlg::IDD, pParent)\r
+{\r
+\r
+}\r
+\r
+CBrowseRefsDlg::~CBrowseRefsDlg()\r
+{\r
+}\r
+\r
+void CBrowseRefsDlg::DoDataExchange(CDataExchange* pDX)\r
+{\r
+       CDialog::DoDataExchange(pDX);\r
+       DDX_Control(pDX, IDC_TREE_REF, m_RefTreeCtrl);\r
+}\r
+\r
+\r
+BEGIN_MESSAGE_MAP(CBrowseRefsDlg, CDialog)\r
+       ON_BN_CLICKED(IDOK, &CBrowseRefsDlg::OnBnClickedOk)\r
+END_MESSAGE_MAP()\r
+\r
+\r
+// CBrowseRefsDlg message handlers\r
+\r
+void CBrowseRefsDlg::OnBnClickedOk()\r
+{\r
+       OnOK();\r
+}\r
+\r
+BOOL CBrowseRefsDlg::OnInitDialog()\r
+{\r
+       CDialog::OnInitDialog();\r
+\r
+       Refresh();\r
+\r
+\r
+       return TRUE;  // return TRUE unless you set the focus to a control\r
+       // EXCEPTION: OCX Property Pages should return FALSE\r
+}\r
+\r
+CShadowTree* CShadowTree::GetNextSub(CString& nameLeft)\r
+{\r
+       int posSlash=nameLeft.Find('/');\r
+       CString nameSub;\r
+       if(posSlash<0)\r
+       {\r
+               nameSub=nameLeft;\r
+               nameLeft.Empty();//Nothing left\r
+       }\r
+       else\r
+       {\r
+               nameSub=nameLeft.Left(posSlash);\r
+               nameLeft=nameLeft.Mid(posSlash+1);\r
+       }\r
+       if(nameSub.IsEmpty())\r
+               return NULL;\r
+\r
+       CShadowTree& nextNode=m_ShadowTree[nameSub];\r
+       nextNode.m_csName=nameSub;\r
+       nextNode.m_pParent=this;\r
+       return &nextNode;\r
+}\r
+\r
+typedef std::map<CString,CString> MAP_STRING_STRING;\r
+\r
+void CBrowseRefsDlg::Refresh()\r
+{\r
+       m_RefMap.clear();\r
+       g_Git.GetMapHashToFriendName(m_RefMap);\r
+\r
+       m_RefTreeCtrl.DeleteAllItems();\r
+       m_TreeRoot.m_ShadowTree.clear();\r
+       m_TreeRoot.m_csName="Refs";\r
+       m_TreeRoot.m_hTree=m_RefTreeCtrl.InsertItem(L"Refs",NULL,NULL);\r
+       m_RefTreeCtrl.SetItemData(m_TreeRoot.m_hTree,(DWORD_PTR)&m_TreeRoot);\r
+\r
+\r
+       MAP_STRING_STRING refName;\r
+\r
+       //First sort on ref name\r
+       for(MAP_HASH_NAME::iterator iterRef=m_RefMap.begin();iterRef!=m_RefMap.end();++iterRef)\r
+               for(STRING_VECTOR::iterator iterRefName=iterRef->second.begin();iterRefName!=iterRef->second.end();++iterRefName)\r
+                       refName[*iterRefName]=iterRef->first;\r
+\r
+       //Populate ref tree\r
+       for(MAP_STRING_STRING::iterator iterRefName=refName.begin();iterRefName!=refName.end();++iterRefName)\r
+       {\r
+               CShadowTree& treeLeaf=GetTreeNode(iterRefName->first);\r
+               treeLeaf.m_csRef=iterRefName->second;\r
+       }\r
+\r
+       m_RefTreeCtrl.Expand(m_TreeRoot.m_hTree,TVE_EXPAND);\r
+\r
+}\r
+\r
+CShadowTree& CBrowseRefsDlg::GetTreeNode(CString refName, CShadowTree* pTreePos)\r
+{\r
+       if(pTreePos==NULL)\r
+       {\r
+               if(wcsnicmp(refName,L"refs/",5)==0)\r
+                       refName=refName.Mid(5);\r
+               pTreePos=&m_TreeRoot;\r
+       }\r
+       if(refName.IsEmpty())\r
+               return *pTreePos;//Found leaf\r
+\r
+       CShadowTree* pNextTree=pTreePos->GetNextSub(refName);\r
+       if(pNextTree==NULL)\r
+       {\r
+               //Should not occur when all ref-names are valid.\r
+               ASSERT(FALSE);\r
+               return *pTreePos;\r
+       }\r
+       if(pNextTree->m_hTree==NULL)\r
+       {\r
+               //New tree. Create node in control.\r
+               pNextTree->m_hTree=m_RefTreeCtrl.InsertItem(pNextTree->m_csName,pTreePos->m_hTree,NULL);\r
+               m_RefTreeCtrl.SetItemData(pNextTree->m_hTree,(DWORD_PTR)pNextTree);\r
+       }\r
+\r
+       return GetTreeNode(refName,pNextTree);\r
+}\r
+\r
diff --git a/src/TortoiseProc/BrowseRefsDlg.h b/src/TortoiseProc/BrowseRefsDlg.h
new file mode 100644 (file)
index 0000000..8980ec9
--- /dev/null
@@ -0,0 +1,53 @@
+#pragma once\r
+\r
+#include "Git.h"\r
+#include <map>\r
+#include "afxcmn.h"\r
+\r
+class CShadowTree\r
+{\r
+public:\r
+       typedef std::map<CString,CShadowTree> TShadowTreeMap;\r
+\r
+       CShadowTree():m_hTree(NULL){}\r
+       \r
+       CShadowTree*    GetNextSub(CString& nameLeft);\r
+\r
+\r
+       CString                 m_csName;\r
+       CString                 m_csRef;\r
+\r
+       HTREEITEM               m_hTree;\r
+\r
+       TShadowTreeMap  m_ShadowTree;\r
+       CShadowTree*    m_pParent;\r
+};\r
+\r
+class CBrowseRefsDlg : public CDialog\r
+{\r
+       DECLARE_DYNAMIC(CBrowseRefsDlg)\r
+\r
+public:\r
+       CBrowseRefsDlg(CWnd* pParent = NULL);   // standard constructor\r
+       virtual ~CBrowseRefsDlg();\r
+\r
+// Dialog Data\r
+       enum { IDD = IDD_DIALOG_BROWSE_REFS };\r
+\r
+protected:\r
+       virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support\r
+\r
+       DECLARE_MESSAGE_MAP()\r
+public:\r
+       afx_msg void OnBnClickedOk();\r
+       virtual BOOL OnInitDialog();\r
+\r
+       void            Refresh();\r
+\r
+       CShadowTree&    GetTreeNode(CString refName, CShadowTree* pTreePos=NULL);\r
+\r
+       MAP_HASH_NAME   m_RefMap;\r
+\r
+       CShadowTree             m_TreeRoot;\r
+       CTreeCtrl               m_RefTreeCtrl;\r
+};\r
index acaa4fe..62d0cef 100644 (file)
@@ -62,6 +62,8 @@
 #include "SendMailCommand.h"\r
 #include "CatCommand.h"\r
 \r
+#include "BrowseRefsDlg.h"\r
+\r
 #if 0\r
 \r
 \r
@@ -271,7 +273,19 @@ Command * CommandServer::GetCommand(const CString& sCmd)
                }\r
        }\r
 \r
-\r
+               \r
+       // CBrowseRefsDlg dialog\r
+#if 1\r
+       class TestCommand : public Command\r
+       {\r
+               virtual bool Execute()\r
+               {\r
+                       CBrowseRefsDlg().DoModal();\r
+                       return true;\r
+               }\r
+       };\r
+       return new TestCommand;\r
+#endif\r
 \r
        switch (command)\r
        {\r
index ee4ab86..6325d5d 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="Windows-1252"?>\r
 <VisualStudioProject\r
        ProjectType="Visual C++"\r
-       Version="9.00"\r
+       Version="9,00"\r
        Name="TortoiseProc"\r
        ProjectGUID="{50797F06-39C5-4802-8E2B-7B7A4EF03214}"\r
        RootNamespace="TortoiseProc"\r
                        />\r
                </Configuration>\r
                <Configuration\r
-                       Name="Debug|x64"\r
-                       OutputDirectory="..\..\bin\Debug64\bin"\r
-                       IntermediateDirectory="..\..\obj\TortoiseProc\Debug64"\r
+                       Name="Release|Win32"\r
+                       OutputDirectory="..\..\bin\$(ConfigurationName)\bin"\r
+                       IntermediateDirectory="..\..\obj\TortoiseProc\$(ConfigurationName)"\r
                        ConfigurationType="1"\r
                        UseOfMFC="2"\r
-                       UseOfATL="0"\r
                        CharacterSet="1"\r
+                       WholeProgramOptimization="1"\r
                        >\r
                        <Tool\r
                                Name="VCPreBuildEventTool"\r
                        />\r
                        <Tool\r
                                Name="VCMIDLTool"\r
-                               PreprocessorDefinitions="_DEBUG"\r
+                               PreprocessorDefinitions="NDEBUG"\r
                                MkTypLibCompatible="false"\r
-                               TargetEnvironment="3"\r
                        />\r
                        <Tool\r
                                Name="VCCLCompilerTool"\r
-                               Optimization="0"\r
                                AdditionalIncludeDirectories="..\TortoiseProc;..\Resources;&quot;$InputDir&quot;;../../ext/ResizableLib;../Git;&quot;../../ext/apr-util/include&quot;;&quot;../../ext/apr-util/xml/expat/lib&quot;;../../ext/Subversion/subversion/include;../../ext/Subversion/subversion/libsvn_client;../../ext/apr/include;../../ext/boost;..\Utils;..\SVN;..\..\ext\ResizableLib;..\crashrpt;&quot;..\..\ext\libintl\libintl3-win32\inc&quot;;..\..\ext\hunspell;..\..\ext\scintilla\include;..\Utils\TreePropSheet;..\Utils\ColourPickerXP;..\Utils\NewMenu;..\Utils\MiscUI;..\LogCache;&quot;../../ext/cyrus-sasl/include&quot;;../../../common/openssl/inc32;.\RevisionGraph;..\TortoiseShell"\r
-                               PreprocessorDefinitions="WIN64;_WINDOWS;_DEBUG;SVN_DEBUG;ENABLE_NLS;THESAURUS"\r
-                               MinimalRebuild="true"\r
+                               PreprocessorDefinitions="WIN32;_WINDOWS;NDEBUG;THESAURUS"\r
+                               StringPooling="true"\r
+                               MinimalRebuild="false"\r
                                ExceptionHandling="2"\r
-                               RuntimeLibrary="3"\r
+                               RuntimeLibrary="2"\r
+                               BufferSecurityCheck="false"\r
                                TreatWChar_tAsBuiltInType="true"\r
                                ForceConformanceInForLoopScope="true"\r
                                RuntimeTypeInfo="true"\r
                                UsePrecompiledHeader="2"\r
                                WarningLevel="4"\r
                                DebugInformationFormat="3"\r
+                               DisableSpecificWarnings="4996,4018"\r
                        />\r
                        <Tool\r
                                Name="VCManagedResourceCompilerTool"\r
                        />\r
                        <Tool\r
                                Name="VCResourceCompilerTool"\r
-                               PreprocessorDefinitions="_DEBUG"\r
+                               PreprocessorDefinitions="NDEBUG"\r
                                Culture="1033"\r
                                AdditionalIncludeDirectories="&quot;$(IntDir)&quot;;..\TortoiseShell"\r
                        />\r
                        <Tool\r
                                Name="VCLinkerTool"\r
                                AdditionalDependencies="Crypt32.lib gdiplus.lib shfolder.lib shell32.lib comctl32.lib ws2_32.lib rpcrt4.lib shlwapi.lib wininet.lib version.lib Dnsapi.lib"\r
-                               LinkIncremental="2"\r
+                               LinkIncremental="1"\r
+                               AdditionalLibraryDirectories="../../ext/wingit"\r
                                IgnoreDefaultLibraryNames=""\r
                                DelayLoadDLLs="gdiplus.dll"\r
                                GenerateDebugInformation="true"\r
                                SubSystem="2"\r
+                               OptimizeReferences="2"\r
+                               EnableCOMDATFolding="2"\r
+                               OptimizeForWindows98="0"\r
                                RandomizedBaseAddress="1"\r
                                DataExecutionPrevention="0"\r
-                               TargetMachine="17"\r
+                               TargetMachine="1"\r
+                               Profile="true"\r
                        />\r
                        <Tool\r
                                Name="VCALinkTool"\r
                        />\r
                </Configuration>\r
                <Configuration\r
-                       Name="Release|Win32"\r
-                       OutputDirectory="..\..\bin\$(ConfigurationName)\bin"\r
-                       IntermediateDirectory="..\..\obj\TortoiseProc\$(ConfigurationName)"\r
+                       Name="Debug|x64"\r
+                       OutputDirectory="..\..\bin\Debug64\bin"\r
+                       IntermediateDirectory="..\..\obj\TortoiseProc\Debug64"\r
                        ConfigurationType="1"\r
                        UseOfMFC="2"\r
+                       UseOfATL="0"\r
                        CharacterSet="1"\r
-                       WholeProgramOptimization="1"\r
                        >\r
                        <Tool\r
                                Name="VCPreBuildEventTool"\r
                        />\r
                        <Tool\r
                                Name="VCMIDLTool"\r
-                               PreprocessorDefinitions="NDEBUG"\r
+                               PreprocessorDefinitions="_DEBUG"\r
                                MkTypLibCompatible="false"\r
+                               TargetEnvironment="3"\r
                        />\r
                        <Tool\r
                                Name="VCCLCompilerTool"\r
+                               Optimization="0"\r
                                AdditionalIncludeDirectories="..\TortoiseProc;..\Resources;&quot;$InputDir&quot;;../../ext/ResizableLib;../Git;&quot;../../ext/apr-util/include&quot;;&quot;../../ext/apr-util/xml/expat/lib&quot;;../../ext/Subversion/subversion/include;../../ext/Subversion/subversion/libsvn_client;../../ext/apr/include;../../ext/boost;..\Utils;..\SVN;..\..\ext\ResizableLib;..\crashrpt;&quot;..\..\ext\libintl\libintl3-win32\inc&quot;;..\..\ext\hunspell;..\..\ext\scintilla\include;..\Utils\TreePropSheet;..\Utils\ColourPickerXP;..\Utils\NewMenu;..\Utils\MiscUI;..\LogCache;&quot;../../ext/cyrus-sasl/include&quot;;../../../common/openssl/inc32;.\RevisionGraph;..\TortoiseShell"\r
-                               PreprocessorDefinitions="WIN32;_WINDOWS;NDEBUG;THESAURUS"\r
-                               StringPooling="true"\r
-                               MinimalRebuild="false"\r
+                               PreprocessorDefinitions="WIN64;_WINDOWS;_DEBUG;SVN_DEBUG;ENABLE_NLS;THESAURUS"\r
+                               MinimalRebuild="true"\r
                                ExceptionHandling="2"\r
-                               RuntimeLibrary="2"\r
-                               BufferSecurityCheck="false"\r
+                               RuntimeLibrary="3"\r
                                TreatWChar_tAsBuiltInType="true"\r
                                ForceConformanceInForLoopScope="true"\r
                                RuntimeTypeInfo="true"\r
                                UsePrecompiledHeader="2"\r
                                WarningLevel="4"\r
                                DebugInformationFormat="3"\r
-                               DisableSpecificWarnings="4996,4018"\r
                        />\r
                        <Tool\r
                                Name="VCManagedResourceCompilerTool"\r
                        />\r
                        <Tool\r
                                Name="VCResourceCompilerTool"\r
-                               PreprocessorDefinitions="NDEBUG"\r
+                               PreprocessorDefinitions="_DEBUG"\r
                                Culture="1033"\r
                                AdditionalIncludeDirectories="&quot;$(IntDir)&quot;;..\TortoiseShell"\r
                        />\r
                        <Tool\r
                                Name="VCLinkerTool"\r
                                AdditionalDependencies="Crypt32.lib gdiplus.lib shfolder.lib shell32.lib comctl32.lib ws2_32.lib rpcrt4.lib shlwapi.lib wininet.lib version.lib Dnsapi.lib"\r
-                               LinkIncremental="1"\r
-                               AdditionalLibraryDirectories="../../ext/wingit"\r
+                               LinkIncremental="2"\r
                                IgnoreDefaultLibraryNames=""\r
                                DelayLoadDLLs="gdiplus.dll"\r
                                GenerateDebugInformation="true"\r
                                SubSystem="2"\r
-                               OptimizeReferences="2"\r
-                               EnableCOMDATFolding="2"\r
-                               OptimizeForWindows98="0"\r
                                RandomizedBaseAddress="1"\r
                                DataExecutionPrevention="0"\r
-                               TargetMachine="1"\r
-                               Profile="true"\r
+                               TargetMachine="17"\r
                        />\r
                        <Tool\r
                                Name="VCALinkTool"\r
                        Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;h;hpp;hxx;hm;inl;inc"\r
                        >\r
                        <File\r
+                               RelativePath=".\BrowseRefsDlg.cpp"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath=".\BrowseRefsDlg.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
                                RelativePath="..\TGitCache\CacheInterface.cpp"\r
                                >\r
                        </File>\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\copy.ico"\r
+                               RelativePath="..\Resources\copy.ico"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath="..\Resources\copy.ico"\r
+                               RelativePath=".\copy.ico"\r
                                >\r
                        </File>\r
                        <File\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath="..\Resources\explorer.ico"\r
+                               RelativePath=".\explorer.ico"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\explorer.ico"\r
+                               RelativePath="..\Resources\explorer.ico"\r
                                >\r
                        </File>\r
                        <File\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\newfolder.ico"\r
+                               RelativePath="..\Resources\newfolder.ico"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath="..\Resources\newfolder.ico"\r
+                               RelativePath=".\newfolder.ico"\r
                                >\r
                        </File>\r
                        <File\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\refresh.ico"\r
+                               RelativePath="..\Resources\refresh.ico"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath="..\Resources\refresh.ico"\r
+                               RelativePath=".\refresh.ico"\r
                                >\r
                        </File>\r
                        <File\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath="..\Resources\save.ico"\r
+                               RelativePath=".\save.ico"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\save.ico"\r
+                               RelativePath="..\Resources\save.ico"\r
                                >\r
                        </File>\r
                        <File\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\up.ico"\r
+                               RelativePath="..\Resources\up.ico"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath="..\Resources\up.ico"\r
+                               RelativePath=".\up.ico"\r
                                >\r
                        </File>\r
                        <File\r
                                />\r
                        </FileConfiguration>\r
                        <FileConfiguration\r
-                               Name="Debug|x64"\r
+                               Name="Release|Win32"\r
                                >\r
                                <Tool\r
                                        Name="VCCLCompilerTool"\r
                                />\r
                        </FileConfiguration>\r
                        <FileConfiguration\r
-                               Name="Release|Win32"\r
+                               Name="Debug|x64"\r
                                >\r
                                <Tool\r
                                        Name="VCCLCompilerTool"\r
                />\r
                <Global\r
                        Name="RESOURCE_FILE"\r
-                       Value="\TortoiseGit\src\Resources\TortoiseProcENG.rc"\r
+                       Value="\Develop\TortoiseGit\src\Resources\TortoiseProcENG.rc"\r
                />\r
        </Globals>\r
 </VisualStudioProject>\r
index 0e39ff4..2d4a6a6 100644 (file)
Binary files a/src/TortoiseProc/resource.h and b/src/TortoiseProc/resource.h differ