void CPatchListCtrl::OnNMDblclk(NMHDR *pNMHDR, LRESULT *pResult) { LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR); CString path=GetItemText(pNMItemActivate->iItem,0); CTGitPath gitpath; gitpath.SetFromWin(path); CAppUtils::StartUnifiedDiffViewer(path,gitpath.GetFilename()); *pResult = 0; }
int CSysImageList::GetPathIconIndex(const CTGitPath& filePath) const { CString strExtension = filePath.GetFileExtension(); strExtension.MakeUpper(); IconIndexMap::iterator it = m_indexCache.lower_bound(strExtension); if (it == m_indexCache.end() || strExtension < it->first) { // We don't have this extension in the map int iconIndex = GetFileIconIndex(filePath.GetFilename()); it = m_indexCache.insert(it, std::make_pair(strExtension, iconIndex)); } // We must have found it return it->second; }
void CPatchListCtrl::OnContextMenu(CWnd* /*pWnd*/, CPoint point) { int selected=this->GetSelectedCount(); int index=0; POSITION pos=this->GetFirstSelectedItemPosition(); index=this->GetNextSelectedItem(pos); CIconMenu popup; if (popup.CreatePopupMenu()) { if(selected == 1) { if( m_ContextMenuMask&GetMenuMask(MENU_VIEWPATCH)) popup.AppendMenuIcon(MENU_VIEWPATCH, IDS_MENU_VIEWPATCH, 0); if( m_ContextMenuMask&GetMenuMask(MENU_VIEWWITHMERGE)) popup.AppendMenuIcon(MENU_VIEWWITHMERGE, IDS_MENU_VIEWWITHMERGE, 0); popup.SetDefaultItem(MENU_VIEWPATCH, FALSE); } if(selected >= 1) { if( m_ContextMenuMask&GetMenuMask(MENU_SENDMAIL)) popup.AppendMenuIcon(MENU_SENDMAIL, IDS_MENU_SENDMAIL, IDI_MENUSENDMAIL); if( m_ContextMenuMask&GetMenuMask(MENU_APPLY)) popup.AppendMenuIcon(MENU_APPLY, IDS_MENU_APPLY, 0); } int cmd = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY, point.x, point.y, this, 0); switch (cmd) { case MENU_VIEWPATCH: { CString path=GetItemText(index,0); CTGitPath gitpath; gitpath.SetFromWin(path); CAppUtils::StartUnifiedDiffViewer(path,gitpath.GetFilename()); break; } case MENU_VIEWWITHMERGE: { CString path=GetItemText(index,0); CTGitPath gitpath; gitpath.SetFromWin(path); CTGitPath dir; dir.SetFromGit(g_Git.m_CurrentDir); CAppUtils::StartExtPatch(gitpath,dir); break; } case MENU_SENDMAIL: { LaunchProc(_T("sendmail")); break; } case MENU_APPLY: { LaunchProc(_T("importpatch")); break; } default: break; } } }