OSDN Git Service

Add work dir copy at log dialog
[tortoisegit/TortoiseGitJp.git] / src / TortoiseProc / GitLogListBase.cpp
index eca5524..0ab5e82 100644 (file)
@@ -58,6 +58,7 @@ CGitLogListBase::CGitLogListBase():CHintListCtrl()
        , m_pStoreSelection(NULL)\r
        , m_nSelectedFilter(LOGFILTER_ALL)\r
        , m_bVista(false)\r
+       , m_bShowWC(false)\r
 {\r
        // use the default GUI font, create a copy of it and\r
        // change the copy to BOLD (leave the rest of the font\r
@@ -73,7 +74,11 @@ CGitLogListBase::CGitLogListBase():CHintListCtrl()
        m_IsIDReplaceAction=FALSE;\r
 \r
        m_wcRev.m_CommitHash=GIT_REV_ZERO;\r
-       m_wcRev.m_Subject=_T("Working Copy");\r
+       m_wcRev.m_Subject=_T("Working dir changes");\r
+       m_wcRev.m_ParentHash.clear();\r
+       m_wcRev.m_Mark=_T('-');\r
+       m_wcRev.m_IsUpdateing=FALSE;\r
+       m_wcRev.m_IsFull = TRUE;\r
 \r
        m_hModifiedIcon = (HICON)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONMODIFIED), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);\r
        m_hReplacedIcon = (HICON)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONREPLACED), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);\r
@@ -206,7 +211,7 @@ void CGitLogListBase::InsertGitColumn()
 {\r
        CString temp;\r
 \r
-       int c = ((CHeaderCtrl*)(GetDlgItem(0)))->GetItemCount()-1;\r
+       int c = GetHeaderCtrl()->GetItemCount()-1;\r
        \r
        while (c>=0)\r
                DeleteColumn(c--);\r
@@ -356,6 +361,9 @@ void CGitLogListBase::FillBackGround(HDC hdc, int Index,CRect &rect)
                                brush = ::CreateSolidBrush(RGB(156,156,156));\r
                        else if(pLogEntry->m_Action&CTGitPath::LOGACTIONS_REBASE_EDIT)\r
                                brush = ::CreateSolidBrush(RGB(200,200,128));\r
+\r
+                       if(pLogEntry->m_CommitHash == GIT_REV_ZERO)\r
+                               brush = ::CreateSolidBrush(RGB(200,200,128));\r
                }\r
 \r
                if (brush != NULL)\r
@@ -396,7 +404,9 @@ void CGitLogListBase::FillBackGround(HDC hdc, int Index,CRect &rect)
                                brush = ::CreateSolidBrush(RGB(156,156,156));\r
                        else if(pLogEntry->m_Action&CTGitPath::LOGACTIONS_REBASE_EDIT)\r
                                brush = ::CreateSolidBrush(RGB(200,200,128));\r
-                       else \r
+                       else if(pLogEntry->m_CommitHash == GIT_REV_ZERO)\r
+                               brush = ::CreateSolidBrush(RGB(200,200,128));\r
+                       else\r
                                brush = ::CreateSolidBrush(::GetSysColor(COLOR_WINDOW));\r
                }\r
                if (brush == NULL)\r
@@ -429,6 +439,7 @@ void CGitLogListBase::DrawTagBranch(HDC hdc,CRect &rect,INT_PTR index)
                shortname = _T("");\r
                COLORREF colRef = 0;\r
 \r
+               //Determine label color\r
                if(GetShortName(str,shortname,_T("refs/heads/")))\r
                {\r
                        if( shortname == m_CurrentBranch )\r
@@ -449,6 +460,12 @@ void CGitLogListBase::DrawTagBranch(HDC hdc,CRect &rect,INT_PTR index)
                        colRef = m_Colors.GetColor(CColors::Stash);\r
                        shortname=_T("stash");\r
                }\r
+\r
+               //When row selected, ajust label color\r
+               if (!(m_Theme.IsAppThemed() && m_bVista))\r
+                       if (rItem.state & LVIS_SELECTED)\r
+                               colRef = CColors::MixColors(colRef, ::GetSysColor(COLOR_HIGHLIGHT), 150);\r
+\r
                brush = ::CreateSolidBrush(colRef);\r
                \r
 \r
@@ -842,7 +859,7 @@ void CGitLogListBase::DrawGraph(HDC hdc,CRect &rect,INT_PTR index)
                        continue;\r
 \r
                COLORREF color = i == activeLane ? activeColor : m_LineColors[i % Lanes::COLORS_NUM];\r
-               paintGraphLane(hdc, rect.Height(),ln, x1, x2, color,activeColor, rect.top);\r
+               paintGraphLane(hdc, rect.Height(),ln, x1+rect.left, x2+rect.left, color,activeColor, rect.top);\r
        }\r
 \r
 #if 0\r
@@ -866,7 +883,6 @@ void CGitLogListBase::DrawGraph(HDC hdc,CRect &rect,INT_PTR index)
        }\r
 #endif\r
 \r
-       TRACE(_T("index %d %d\r\n"),index,data->m_Lanes.size());\r
 }\r
 \r
 void CGitLogListBase::OnNMCustomdrawLoglist(NMHDR *pNMHDR, LRESULT *pResult)\r
@@ -922,7 +938,9 @@ void CGitLogListBase::OnNMCustomdrawLoglist(NMHDR *pNMHDR, LRESULT *pResult)
                                                pLVCD->clrTextBk = RGB(156,156,156);\r
                                        else if(data->m_Action&CTGitPath::LOGACTIONS_REBASE_EDIT)\r
                                                pLVCD->clrTextBk  = RGB(200,200,128);\r
-                                       else \r
+                                       else if(data->m_CommitHash == GIT_REV_ZERO)\r
+                                               pLVCD->clrTextBk  = RGB(200,200,128);\r
+                                       else\r
                                                pLVCD->clrTextBk  = ::GetSysColor(COLOR_WINDOW);\r
 \r
                                        if(data->m_Action&CTGitPath::LOGACTIONS_REBASE_CURRENT)\r
@@ -939,13 +957,15 @@ void CGitLogListBase::OnNMCustomdrawLoglist(NMHDR *pNMHDR, LRESULT *pResult)
 \r
 //                                     if ((data->childStackDepth)||(m_mergedRevs.find(data->Rev) != m_mergedRevs.end()))\r
 //                                             crText = GetSysColor(COLOR_GRAYTEXT);\r
-//                                     if (data->Rev == m_wcRev)\r
-//                                     {\r
-//                                             SelectObject(pLVCD->nmcd.hdc, m_boldFont);\r
+//                                     \r
+                                       if (data->m_CommitHash == GIT_REV_ZERO)\r
+                                       {\r
+                                               //crText = GetSysColor(COLOR_GRAYTEXT);\r
+                                               SelectObject(pLVCD->nmcd.hdc, m_boldFont);\r
                                                // We changed the font, so we're returning CDRF_NEWFONT. This\r
                                                // tells the control to recalculate the extent of the text.\r
-//                                             *pResult = CDRF_NOTIFYSUBITEMDRAW | CDRF_NEWFONT;\r
-//                                     }\r
+                                               *pResult = CDRF_NOTIFYSUBITEMDRAW | CDRF_NEWFONT;\r
+                                       }\r
                                }\r
                        }\r
                        if (m_arShownList.GetCount() == (INT_PTR)pLVCD->nmcd.dwItemSpec)\r
@@ -971,7 +991,14 @@ void CGitLogListBase::OnNMCustomdrawLoglist(NMHDR *pNMHDR, LRESULT *pResult)
                                {\r
                                        CRect rect;\r
                                        GetSubItemRect(pLVCD->nmcd.dwItemSpec, pLVCD->iSubItem, LVIR_BOUNDS, rect);\r
+                                       if(pLVCD->iSubItem == 0)\r
+                                       {\r
+                                               CRect second;\r
+                                               GetSubItemRect(pLVCD->nmcd.dwItemSpec, pLVCD->iSubItem+1, LVIR_BOUNDS, second);\r
+                                               rect.right=second.left;\r
+                                       }\r
                                        \r
+                                       TRACE(_T("A Graphic left %d right %d\r\n"),rect.left,rect.right);\r
                                        FillBackGround(pLVCD->nmcd.hdc, (INT_PTR)pLVCD->nmcd.dwItemSpec,rect);\r
                                        DrawGraph(pLVCD->nmcd.hdc,rect,pLVCD->nmcd.dwItemSpec);\r
 \r
@@ -1006,7 +1033,8 @@ void CGitLogListBase::OnNMCustomdrawLoglist(NMHDR *pNMHDR, LRESULT *pResult)
                                                return;\r
 \r
                                        }\r
-                               }\r
+\r
+                               }       \r
                        }\r
                        \r
                        if (pLVCD->iSubItem == 1)\r
@@ -1028,6 +1056,7 @@ void CGitLogListBase::OnNMCustomdrawLoglist(NMHDR *pNMHDR, LRESULT *pResult)
                                GitRev* pLogEntry = reinterpret_cast<GitRev *>(m_arShownList.GetAt(pLVCD->nmcd.dwItemSpec));\r
                                CRect rect;\r
                                GetSubItemRect(pLVCD->nmcd.dwItemSpec, pLVCD->iSubItem, LVIR_BOUNDS, rect);\r
+                               TRACE(_T("Action left %d right %d\r\n"),rect.left,rect.right);\r
                                // Get the selected state of the\r
                                // item being drawn.                                                    \r
 \r
@@ -1250,7 +1279,7 @@ void CGitLogListBase::OnContextMenu(CWnd* pWnd, CPoint point)
                if (GetSelectedCount() == 1)\r
                {\r
                        {\r
-                               if (m_hasWC)\r
+                               //if (m_hasWC)\r
                                {\r
                                        if(m_ContextMenuMask&GetContextMenuBit(ID_COMPARE))\r
                                                popup.AppendMenuIcon(ID_COMPARE, IDS_LOG_POPUP_COMPARE, IDI_DIFF);\r
@@ -1381,7 +1410,7 @@ void CGitLogListBase::OnContextMenu(CWnd* pWnd, CPoint point)
                        if(m_ContextMenuMask&GetContextMenuBit(ID_CHERRY_PICK))\r
                                popup.AppendMenuIcon(ID_CHERRY_PICK, IDS_CHERRY_PICK_VERSION, IDI_EXPORT);\r
 \r
-                       if(GetSelectedCount()<=2)\r
+                       if(GetSelectedCount()<=2 || (IsSelectionContinuous() && GetSelectedCount() > 0))\r
                                if(m_ContextMenuMask&GetContextMenuBit(ID_CREATE_PATCH))\r
                                        popup.AppendMenuIcon(ID_CREATE_PATCH, IDS_CREATE_PATCH, IDI_PATCH);\r
                        \r
@@ -1728,9 +1757,12 @@ int CGitLogListBase::FillGitShortLog()
        mask = CGit::LOG_INFO_ONLY_HASH | CGit::LOG_INFO_BOUNDARY;\r
 //     if(this->m_bAllBranch)\r
        mask |= m_ShowMask;\r
+       \r
+       if(m_bShowWC)\r
+               this->m_logEntries.insert(m_logEntries.begin(),this->m_wcRev);\r
 \r
        this->m_logEntries.FetchShortLog(path,m_StartRef,-1,mask);\r
-       \r
+\r
        //this->m_logEntries.ParserFromLog();\r
        if(IsInWorkingThread())\r
                PostMessage(LVM_SETITEMCOUNT, (WPARAM) this->m_logEntries.size(),(LPARAM) LVSICF_NOINVALIDATEALL);\r
@@ -1741,7 +1773,9 @@ int CGitLogListBase::FillGitShortLog()
 \r
        for(unsigned int i=0;i<m_logEntries.size();i++)\r
        {\r
-               m_logEntries[i].m_Subject=_T("parser...");\r
+               if(i>0 || m_logEntries[i].m_CommitHash != GIT_REV_ZERO)\r
+                       m_logEntries[i].m_Subject=_T("parser...");\r
+\r
                if(this->m_IsOldFirst)\r
                {\r
                        this->m_arShownList.Add(&m_logEntries[m_logEntries.size()-1-i]);\r
@@ -1949,6 +1983,7 @@ void CGitLogListBase::FetchFullLogInfo(CString &from, CString &to)
 {\r
        CGitCall_FetchFullLogInfo fetcher(this);\r
        int mask=\r
+               CGit::LOG_INFO_FULL_DIFF|\r
                CGit::LOG_INFO_STAT|\r
                CGit::LOG_INFO_FILESTATE|\r
                CGit::LOG_INFO_DETECT_COPYRENAME|\r
@@ -2034,6 +2069,9 @@ UINT CGitLogListBase::LogThread()
        int update=0;\r
        for(int i=0;i<m_logEntries.size();i++)\r
        {\r
+               if( i==0 && m_logEntries[i].m_CommitHash == GIT_REV_ZERO)\r
+                       continue;\r
+\r
                start=this->m_logEntries[i].ParserFromLog(m_logEntries.m_RawlogData,start);\r
                m_logEntries.m_HashMap[m_logEntries[i].m_CommitHash]=i;\r
 \r