}
/// is it possible to compare these two items?
-bool AreItemsOpenable(const CDiffContext& ctxt, SELECTIONTYPE selectionType, const DIFFITEM &di1, const DIFFITEM &di2)
+bool AreItemsOpenable(const CDiffContext& ctxt, SELECTIONTYPE selectionType, const DIFFITEM &di1, const DIFFITEM &di2, bool openableForDir /*= true*/)
{
String sLeftBasePath = ctxt.GetPath(0);
String sRightBasePath = ctxt.GetPath(1);
// Must be both directory or neither
if (di1.diffcode.isDirectory() != di2.diffcode.isDirectory()) return false;
+ if (!openableForDir && di1.diffcode.isDirectory()) return false;
+
switch (selectionType)
{
case SELECTIONTYPE_NORMAL:
return false;
}
/// is it possible to compare these three items?
-bool AreItemsOpenable(const CDiffContext& ctxt, const DIFFITEM &di1, const DIFFITEM &di2, const DIFFITEM &di3)
+bool AreItemsOpenable(const CDiffContext& ctxt, const DIFFITEM &di1, const DIFFITEM &di2, const DIFFITEM &di3, bool openableForDir /*= true*/)
{
String sLeftBasePath = ctxt.GetPath(0);
String sMiddleBasePath = ctxt.GetPath(1);
// Must be both directory or neither
if (di1.diffcode.isDirectory() != di2.diffcode.isDirectory() && di1.diffcode.isDirectory() != di3.diffcode.isDirectory()) return false;
+ if (!openableForDir && di1.diffcode.isDirectory()) return false;
+
// Must be on different sides, or one on one side & one on both
if (di1.diffcode.exists(0) && di2.diffcode.exists(1) && di3.diffcode.exists(2))
return true;
* @param [out] paths First/Second/Third paths.
* @param [out] sel1 Item's selection index in listview.
* @param [in,out] isDir Is item folder?
+ * @param [in] openableForDir Are items openable if the items are directories?
* return false if there was error or item was completely processed.
*/
bool GetOpenOneItem(const CDiffContext& ctxt, DIFFITEM *pos1, const DIFFITEM *pdi[3],
- PathContext & paths, int & sel1, bool & isdir, int nPane[3], String& errmsg)
+ PathContext & paths, int & sel1, bool & isdir, int nPane[3], String& errmsg, bool openableForDir /*= true*/)
{
pdi[0] = &ctxt.GetDiffAt(pos1);
pdi[1] = pdi[0];
pdi[2] = pdi[0];
+ if (!openableForDir && pdi[0]->diffcode.isDirectory()) return false;
+
paths = GetItemFileNames(ctxt, *pdi[0]);
for (int nIndex = 0; nIndex < paths.GetSize(); ++nIndex)
* @param [out] sel1 First item's selection index in listview.
* @param [out] sel2 Second item's selection index in listview.
* @param [in,out] isDir Is item folder?
+ * @param [in] openableForDir Are items openable if the items are directories?
* return false if there was error or item was completely processed.
*/
bool GetOpenTwoItems(const CDiffContext& ctxt, SELECTIONTYPE selectionType, DIFFITEM *pos1, DIFFITEM *pos2, const DIFFITEM *pdi[3],
- PathContext & paths, int & sel1, int & sel2, bool & isDir, int nPane[3], String& errmsg)
+ PathContext & paths, int & sel1, int & sel2, bool & isDir, int nPane[3], String& errmsg, bool openableForDir /*= true*/)
{
// Two items selected, get their info
pdi[0] = &ctxt.GetDiffAt(pos1);
nPane[1] = 1;
// Check for binary & side compatibility & file/dir compatibility
- if (!AreItemsOpenable(ctxt, selectionType, *pdi[0], *pdi[1]))
+ if (!AreItemsOpenable(ctxt, selectionType, *pdi[0], *pdi[1], openableForDir))
{
return false;
}
* @param [out] sel2 Second item's selection index in listview.
* @param [out] sel3 Third item's selection index in listview.
* @param [in,out] isDir Is item folder?
+ * @param [in] openableForDir Are items openable if the items are directories?
* return false if there was error or item was completely processed.
*/
bool GetOpenThreeItems(const CDiffContext& ctxt, DIFFITEM *pos1, DIFFITEM *pos2, DIFFITEM *pos3, const DIFFITEM *pdi[3],
- PathContext & paths, int & sel1, int & sel2, int & sel3, bool & isDir, int nPane[3], String& errmsg)
+ PathContext & paths, int & sel1, int & sel2, int & sel3, bool & isDir, int nPane[3], String& errmsg, bool openableForDir /*= true*/)
{
String pathLeft, pathMiddle, pathRight;
pdi[1] = &ctxt.GetDiffAt(pos2);
// Check for binary & side compatibility & file/dir compatibility
- if (!::AreItemsOpenable(ctxt, *pdi[0], *pdi[1], *pdi[1]) &&
- !::AreItemsOpenable(ctxt, *pdi[0], *pdi[0], *pdi[1]))
+ if (!::AreItemsOpenable(ctxt, *pdi[0], *pdi[1], *pdi[1], openableForDir) &&
+ !::AreItemsOpenable(ctxt, *pdi[0], *pdi[0], *pdi[1], openableForDir))
{
return false;
}
pdi[2] = &ctxt.GetDiffAt(pos3);
// Check for binary & side compatibility & file/dir compatibility
- if (!::AreItemsOpenable(ctxt, *pdi[0], *pdi[1], *pdi[2]))
+ if (!::AreItemsOpenable(ctxt, *pdi[0], *pdi[1], *pdi[2], openableForDir))
{
return false;
}
bool IsItemCopyable(const DIFFITEM &di, int index);
bool IsItemDeletable(const DIFFITEM &di, int index);
bool IsItemDeletableOnBoth(const CDiffContext& ctxt, const DIFFITEM &di);
-bool AreItemsOpenable(const CDiffContext& ctxt, SELECTIONTYPE selectionType, const DIFFITEM &di1, const DIFFITEM &di2);
-bool AreItemsOpenable(const CDiffContext& ctxt, const DIFFITEM &di1, const DIFFITEM &di2, const DIFFITEM &di3);
+bool AreItemsOpenable(const CDiffContext& ctxt, SELECTIONTYPE selectionType, const DIFFITEM &di1, const DIFFITEM &di2, bool openableForDir = true);
+bool AreItemsOpenable(const CDiffContext& ctxt, const DIFFITEM &di1, const DIFFITEM &di2, const DIFFITEM &di3, bool openableForDir = true);
bool IsItemOpenableOn(const DIFFITEM &di, int index);
bool IsItemOpenableOnWith(const DIFFITEM &di, int index);
bool IsItemCopyableToOn(const DIFFITEM &di, int index);
bool IsShowable(const CDiffContext& ctxt, const DIFFITEM &di, const DirViewFilterSettings& filter);
bool GetOpenOneItem(const CDiffContext& ctxt, DIFFITEM *pos1, const DIFFITEM *pdi[3],
- PathContext &paths, int & sel1, bool & isDir, int nPane[3], String& errmsg);
+ PathContext &paths, int & sel1, bool & isDir, int nPane[3], String& errmsg, bool openableForDir = true);
bool GetOpenTwoItems(const CDiffContext& ctxt, SELECTIONTYPE selectionType, DIFFITEM *pos1, DIFFITEM *pos2, const DIFFITEM *pdi[3],
- PathContext &paths, int & sel1, int & sel2, bool & isDir, int nPane[3], String& errmsg);
+ PathContext &paths, int & sel1, int & sel2, bool & isDir, int nPane[3], String& errmsg, bool openableForDir = true);
bool GetOpenThreeItems(const CDiffContext& ctxt, DIFFITEM *pos1, DIFFITEM *pos2, DIFFITEM *pos3, const DIFFITEM *pdi[3],
- PathContext &paths, int & sel1, int & sel2, int & sel3, bool & isDir, int nPane[3], String& errmsg);
+ PathContext &paths, int & sel1, int & sel2, int & sel3, bool & isDir, int nPane[3], String& errmsg, bool openableForDir = true);
void GetItemFileNames(const CDiffContext& ctxt, const DIFFITEM& di, String& strLeft, String& strRight);
PathContext GetItemFileNames(const CDiffContext& ctxt, const DIFFITEM& di);
* This handles the case that one item is selected
* and the case that two items are selected (one on each side)
*/
-void CDirView::OpenSelection(SELECTIONTYPE selectionType /*= SELECTIONTYPE_NORMAL*/, PackingInfo * infoUnpacker /*= nullptr*/)
+void CDirView::OpenSelection(SELECTIONTYPE selectionType /*= SELECTIONTYPE_NORMAL*/, PackingInfo * infoUnpacker /*= nullptr*/, bool openableForDir /*= true*/)
{
Merge7zFormatMergePluginScope scope(infoUnpacker);
CDirDoc * pDoc = GetDocument();
bool success;
if (pos2 && !pos3)
success = GetOpenTwoItems(ctxt, selectionType, pos1, pos2, pdi,
- paths, sel1, sel2, isdir, nPane, errmsg);
+ paths, sel1, sel2, isdir, nPane, errmsg, openableForDir);
else if (pos2 && pos3)
success = GetOpenThreeItems(ctxt, pos1, pos2, pos3, pdi,
- paths, sel1, sel2, sel3, isdir, nPane, errmsg);
+ paths, sel1, sel2, sel3, isdir, nPane, errmsg, openableForDir);
else
{
// Only one item selected, so perform diff on its sides
success = GetOpenOneItem(ctxt, pos1, pdi,
- paths, sel1, isdir, nPane, errmsg);
+ paths, sel1, isdir, nPane, errmsg, openableForDir);
if (isdir)
CreateFoldersPair(paths);
}
bool success;
if (pos2)
success = GetOpenTwoItems(ctxt, SELECTIONTYPE_NORMAL, pos1, pos2, pdi,
- paths, sel1, sel2, isdir, nPane, errmsg);
+ paths, sel1, sel2, isdir, nPane, errmsg, false);
else
{
// Only one item selected, so perform diff on its sides
success = GetOpenOneItem(ctxt, pos1, pdi,
- paths, sel1, isdir, nPane, errmsg);
+ paths, sel1, isdir, nPane, errmsg, false);
}
if (!success)
{
}
// Used for Open
-void CDirView::DoUpdateOpen(SELECTIONTYPE selectionType, CCmdUI* pCmdUI)
+void CDirView::DoUpdateOpen(SELECTIONTYPE selectionType, CCmdUI* pCmdUI, bool openableForDir /*= true*/)
{
int sel1 = -1, sel2 = -1, sel3 = -1;
if (!GetSelectedItems(&sel1, &sel2, &sel3))
pCmdUI->Enable(FALSE);
return;
}
+ if (!openableForDir)
+ {
+ const DIFFITEM& di1 = GetDiffItem(sel1);
+ if (di1.diffcode.isDirectory())
+ {
+ pCmdUI->Enable(FALSE);
+ return;
+ }
+ }
}
else if (sel3 == -1)
{
// Two items selected
const DIFFITEM& di1 = GetDiffItem(sel1);
const DIFFITEM& di2 = GetDiffItem(sel2);
- if (!AreItemsOpenable(GetDiffContext(), selectionType, di1, di2))
+ if (!AreItemsOpenable(GetDiffContext(), selectionType, di1, di2, openableForDir))
{
pCmdUI->Enable(FALSE);
return;
const DIFFITEM& di1 = GetDiffItem(sel1);
const DIFFITEM& di2 = GetDiffItem(sel2);
const DIFFITEM& di3 = GetDiffItem(sel3);
- if (selectionType != SELECTIONTYPE_NORMAL || !::AreItemsOpenable(GetDiffContext(), di1, di2, di3))
+ if (selectionType != SELECTIONTYPE_NORMAL || !::AreItemsOpenable(GetDiffContext(), di1, di2, di3, openableForDir))
{
pCmdUI->Enable(FALSE);
return;
if (dlg.DoModal() == IDOK)
{
infoUnpacker = dlg.GetInfoHandler();
- OpenSelection(SELECTIONTYPE_NORMAL, &infoUnpacker);
+ OpenSelection(SELECTIONTYPE_NORMAL, &infoUnpacker, false);
}
}
int sel = -1;
sel = m_pList->GetNextItem(sel, LVNI_SELECTED);
const DIFFITEM& di = GetDiffItem(sel);
+ if (di.diffcode.isDirectory())
+ {
+ pCmdUI->Enable(FALSE);
+ return;
+ }
pCmdUI->Enable(IsItemDeletableOnBoth(GetDiffContext(), di));
}
}
{
CWaitCursor waitstatus;
PackingInfo packingInfo(PLUGIN_BUILTIN_XML);
- OpenSelection(SELECTIONTYPE_NORMAL, &packingInfo);
+ OpenSelection(SELECTIONTYPE_NORMAL, &packingInfo, false);
}
void CDirView::OnMergeCompareAs(UINT nID)
void CDirView::OnUpdateMergeCompare(CCmdUI *pCmdUI)
{
- DoUpdateOpen(SELECTIONTYPE_NORMAL, pCmdUI);
+ bool openableForDir = (pCmdUI->m_nID != ID_MERGE_COMPARE_XML &&
+ pCmdUI->m_nID != ID_MERGE_COMPARE_HEX &&
+ pCmdUI->m_nID != ID_MERGE_COMPARE_IMAGE);
+
+ DoUpdateOpen(SELECTIONTYPE_NORMAL, pCmdUI, openableForDir);
}
template<SELECTIONTYPE seltype>
void DoOpenWith(SIDE_TYPE stype);
void DoOpenWithEditor(SIDE_TYPE stype);
void DoOpenParentFolder(SIDE_TYPE stype);
- void DoUpdateOpen(SELECTIONTYPE selectionType, CCmdUI* pCmdUI);
+ void DoUpdateOpen(SELECTIONTYPE selectionType, CCmdUI* pCmdUI, bool openableForDir = true);
void ConfirmAndPerformActions(FileActionScript & actions);
void PerformActionList(FileActionScript & actions);
void UpdateAfterFileScript(FileActionScript & actionList);
private:
void Open(const PathContext& paths, DWORD dwFlags[3], PackingInfo * infoUnpacker = nullptr);
- void OpenSelection(SELECTIONTYPE selectionType = SELECTIONTYPE_NORMAL, PackingInfo * infoUnpacker = nullptr);
+ void OpenSelection(SELECTIONTYPE selectionType = SELECTIONTYPE_NORMAL, PackingInfo * infoUnpacker = nullptr, bool openableForDir = true);
void OpenSelectionAs(UINT id);
bool GetSelectedItems(int * sel1, int * sel2, int * sel3);
void OpenParentDirectory();