| 739 | } |
| 740 | |
| 741 | STDMETHODIMP CShellExt::QueryDropContext(UINT uFlags, UINT idCmdFirst, HMENU hMenu, UINT &indexMenu) |
| 742 | { |
| 743 | if (!CRegStdDWORD(L"Software\\TortoiseGit\\EnableDragContextMenu", TRUE, false, HKEY_CURRENT_USER, KEY_WOW64_64KEY)) |
| 744 | return S_OK; |
| 745 | |
| 746 | PreserveChdir preserveChdir; |
| 747 | LoadLangDll(); |
| 748 | |
| 749 | if ((uFlags & CMF_DEFAULTONLY)!=0) |
| 750 | return S_OK; //we don't change the default action |
| 751 | |
| 752 | if (files_.empty() || folder_.empty()) |
| 753 | return S_OK; |
| 754 | |
| 755 | if (((uFlags & 0x000f)!=CMF_NORMAL)&&(!(uFlags & CMF_EXPLORE))&&(!(uFlags & CMF_VERBSONLY))) |
| 756 | return S_OK; |
| 757 | |
| 758 | bool bSourceAndTargetFromSameRepository = ((uuidSource.size() == uuidTarget.size() && _wcsnicmp(uuidSource.c_str(), uuidTarget.c_str(), uuidSource.size()) == 0)) || uuidSource.empty() || uuidTarget.empty(); |
| 759 | |
| 760 | //the drop handler only has eight commands, but not all are visible at the same time: |
| 761 | //if the source file(s) are under version control then those files can be moved |
| 762 | //to the new location or they can be moved with a rename, |
| 763 | //if they are unversioned then they can be added to the working copy |
| 764 | //if they are versioned, they also can be exported to an unversioned location |
| 765 | UINT idCmd = idCmdFirst; |
| 766 | |
| 767 | bool moveAvailable = false; |
| 768 | // Git move here |
| 769 | // available if source is versioned but not added, target is versioned, source and target from same repository or target folder is added |
| 770 | if ((bSourceAndTargetFromSameRepository || (itemStatesFolder & ITEMIS_ADDED)) && (itemStatesFolder & ITEMIS_FOLDERINGIT) && ((itemStates & (ITEMIS_NORMAL | ITEMIS_INGIT | ITEMIS_FOLDERINGIT)))) |
| 771 | { |
| 772 | InsertGitMenu(FALSE, hMenu, indexMenu++, idCmd++, IDS_DROPMOVEMENU, 0, idCmdFirst, TGitShellCommand::DropMove, uFlags); |
| 773 | moveAvailable = true; |
| 774 | } |
| 775 | |
| 776 | // Git move and rename here |
| 777 | // available if source is a single, versioned but not added item, target is versioned, source and target from same repository or target folder is added |
| 778 | if ((bSourceAndTargetFromSameRepository || (itemStatesFolder & ITEMIS_ADDED)) && (itemStatesFolder & ITEMIS_FOLDERINGIT) && (itemStates & (ITEMIS_NORMAL | ITEMIS_INGIT | ITEMIS_FOLDERINGIT)) && (itemStates & ITEMIS_ONLYONE)) |
| 779 | { |
| 780 | InsertGitMenu(FALSE, hMenu, indexMenu++, idCmd++, IDS_DROPMOVERENAMEMENU, 0, idCmdFirst, TGitShellCommand::DropMoveRename, uFlags); |
| 781 | moveAvailable = true; |
| 782 | } |
| 783 | |
| 784 | // Git copy here |
| 785 | // available if source is versioned but not added, target is versioned, source and target from same repository or target folder is added |
| 786 | //if ((bSourceAndTargetFromSameRepository||(itemStatesFolder & ITEMIS_ADDED))&&(itemStatesFolder & ITEMIS_FOLDERINGIT)&&(itemStates & ITEMIS_INGIT)&&((~itemStates) & ITEMIS_ADDED)) |
| 787 | // InsertGitMenu(FALSE, hMenu, indexMenu++, idCmd++, IDS_DROPCOPYMENU, 0, idCmdFirst, TGitShellCommand::DropCopy, uFlags); |
| 788 | |
| 789 | // Git copy and rename here, source and target from same repository |
| 790 | // available if source is a single, versioned but not added item, target is versioned or target folder is added |
| 791 | //if ((bSourceAndTargetFromSameRepository||(itemStatesFolder & ITEMIS_ADDED))&&(itemStatesFolder & ITEMIS_FOLDERINGIT)&&(itemStates & ITEMIS_INGIT)&&(itemStates & ITEMIS_ONLYONE)&&((~itemStates) & ITEMIS_ADDED)) |
| 792 | // InsertGitMenu(FALSE, hMenu, indexMenu++, idCmd++, IDS_DROPCOPYRENAMEMENU, 0, idCmdFirst, TGitShellCommand::DropCopyRename, uFlags); |
| 793 | |
| 794 | // Git add here |
| 795 | // available if target is versioned and source is either unversioned or from another repository |
| 796 | if ((itemStatesFolder & ITEMIS_FOLDERINGIT) && (((~itemStates) & ITEMIS_INGIT) || !bSourceAndTargetFromSameRepository) && !moveAvailable) |
| 797 | InsertGitMenu(FALSE, hMenu, indexMenu++, idCmd++, IDS_DROPCOPYADDMENU, 0, idCmdFirst, TGitShellCommand::DropCopyAdd, uFlags); |
| 798 |
nothing calls this directly
no test coverage detected