}
/**
- * @brief Update associated diff item
+ * @brief Update last compare result
*/
-int CHexMergeDoc::UpdateDiffItem(IDirDoc *pDirDoc)
+int CHexMergeDoc::UpdateLastCompareResult()
{
bool bDiff = false;
size_t lengthFirst = m_pView[0]->GetLength();
if (bDiff)
break;
}
- // If directory compare has results
- if (pDirDoc != nullptr && pDirDoc->HasDiffs())
- m_pDirDoc->UpdateChangedItem(m_filePaths,
- static_cast<unsigned>(-1), static_cast<unsigned>(-1), !bDiff);
GetParentFrame()->SetLastCompareResult(bDiff);
return bDiff ? 1 : 0;
}
// update status on dir view
if (bLSaveSuccess || bMSaveSuccess || bRSaveSuccess)
{
- UpdateDiffItem(m_pDirDoc);
+ int compareResult = UpdateLastCompareResult();
+ // If directory compare has results
+ if (m_pDirDoc != nullptr && m_pDirDoc->HasDiffs())
+ {
+ m_pDirDoc->UpdateChangedItem(m_filePaths,
+ static_cast<unsigned>(-1), static_cast<unsigned>(-1),
+ compareResult != 0);
+ }
}
return result;
{
m_filePaths[nBuffer] = strSavePath;
UpdateHeaderPath(nBuffer);
- UpdateDiffItem(m_pDirDoc);
+ UpdateLastCompareResult();
}
}
}
}
m_filePaths.SetPath(nBuffer, strPath);
- UpdateDiffItem(m_pDirDoc);
+ UpdateLastCompareResult();
UpdateHeaderPath(nBuffer);
return true;
}
if (nNormalBuffer > 0)
OnRefresh();
else
- UpdateDiffItem(m_pDirDoc);
+ UpdateLastCompareResult();
}
else
{
void CHexMergeDoc::OnRefresh()
{
- if (UpdateDiffItem(m_pDirDoc) == 0)
+ if (UpdateLastCompareResult() == 0)
{
CMergeFrameCommon::ShowIdenticalMessage(m_filePaths, true,
[](const tchar_t* msg, UINT flags, UINT id) -> int { return AfxMessageBox(msg, flags, id); });
// Implementation
public:
~CHexMergeDoc();
- int UpdateDiffItem(IDirDoc * pDirDoc);
+ int UpdateLastCompareResult();
bool PromptAndSaveIfNeeded(bool bAllowCancel);
IDirDoc* GetDirDoc() const override { return m_pDirDoc; };
void SetDirDoc(IDirDoc * pDirDoc) override;
if (nNormalBuffer > 0)
OnRefresh();
else
- UpdateDiffItem(m_pDirDoc);
+ UpdateLastCompareResult();
if (GetOptionsMgr()->GetBool(OPT_SCROLL_TO_FIRST))
m_pImgMergeWindow->FirstDiff();
}
}
}
- UpdateDiffItem(m_pDirDoc);
+ UpdateLastCompareResult();
m_fileInfo[pane].Update(m_filePaths[pane]);
}
return true;
}
m_filePaths.SetPath(pane, strPath);
- UpdateDiffItem(m_pDirDoc);
+ UpdateLastCompareResult();
m_fileInfo[pane].Update(m_filePaths[pane]);
UpdateHeaderPath(pane);
}
SetWindowText(sTitle.c_str());
}
-void CImgMergeFrame::UpdateLastCompareResult()
+int CImgMergeFrame::UpdateLastCompareResult()
{
- SetLastCompareResult(m_pImgMergeWindow->GetDiffCount() > 0 ? 1 : 0);
+ int result = m_pImgMergeWindow->GetDiffCount() > 0 ? 1 : 0;
+ SetLastCompareResult(result != 0);
+ return result;
}
void CImgMergeFrame::UpdateAutoPaneResize()
}
/**
- * @brief Update associated diff item
- */
-int CImgMergeFrame::UpdateDiffItem(IDirDoc *pDirDoc)
-{
- // If directory compare has results
- if (pDirDoc && pDirDoc->HasDiffs())
- {
-// FIXME:
-// const String &pathLeft = m_filePaths.GetLeft();
-// const String &pathRight = m_filePaths.GetRight();
-// CDiffContext &ctxt = const_cast<CDiffContext &>(pDirDoc->GetDiffContext());
-// if (UINT_PTR pos = pDirDoc->FindItemFromPaths(pathLeft, pathRight))
-// {
-// DIFFITEM &di = pDirDoc->GetDiffRefByKey(pos);
-// ::UpdateDiffItem(m_nBuffers, di, &ctxt);
-// }
- }
- int result = m_pImgMergeWindow->GetDiffCount() > 0 ? 1 : 0;
- SetLastCompareResult(result != 0);
- return result;
-}
-
-/**
* @brief Asks and then saves modified files.
*
* This function saves modified files. Dialog is shown for user to select
(bMModified && bMSaveSuccess) ||
(bRModified && bRSaveSuccess))
{
+ int compareResult = UpdateLastCompareResult();
// If directory compare has results
if (m_pDirDoc && m_pDirDoc->HasDiffs())
{
m_pDirDoc->UpdateChangedItem(m_filePaths,
static_cast<unsigned>(-1), static_cast<unsigned>(-1),
- m_pImgMergeWindow->GetDiffCount() == 0);
+ compareResult != 0);
}
}
void CImgMergeFrame::OnRefresh()
{
- if (UpdateDiffItem(m_pDirDoc) == 0)
+ if (UpdateLastCompareResult() == 0)
{
CMergeFrameCommon::ShowIdenticalMessage(m_filePaths, true,
[](const tchar_t* msg, UINT flags, UINT id) -> int { return AfxMessageBox(msg, flags, id); });
void RefreshOptions();
bool CloseNow() override;
void DirDocClosing(IDirDoc * pDirDoc) override { m_pDirDoc = nullptr; }
- void UpdateLastCompareResult();
+ int UpdateLastCompareResult();
void UpdateAutoPaneResize();
void UpdateSplitter();
bool GenerateReport(const String& sFileName) const override;
void CreateImgWndStatusBar(CStatusBar &, CWnd *);
private:
bool OpenImages();
- int UpdateDiffItem(IDirDoc * pDirDoc);
void UpdateHeaderSizes();
void UpdateHeaderPath(int pane);
void SetTitle(LPCTSTR lpszTitle);
++nNormalBuffer;
}
if (nNormalBuffer == 0)
- UpdateDiffItem(m_pDirDoc);
+ UpdateLastCompareResult();
if (GetOptionsMgr()->GetBool(OPT_SCROLL_TO_FIRST))
m_pWebDiffWindow->FirstDiff();
}
}
-void CWebPageDiffFrame::UpdateLastCompareResult()
+int CWebPageDiffFrame::UpdateLastCompareResult()
{
+ int result = -1;
if (m_bCompareCompleted)
- SetLastCompareResult(m_pWebDiffWindow->GetDiffCount() > 0 ? 1 : 0);
+ {
+ result = m_pWebDiffWindow->GetDiffCount() > 0 ? 1 : 0;
+ SetLastCompareResult(result);
+ }
+ return result;
}
void CWebPageDiffFrame::UpdateAutoPaneResize()
return bResult;
}
-/**
- * @brief Update associated diff item
- */
-int CWebPageDiffFrame::UpdateDiffItem(IDirDoc *pDirDoc)
-{
- int result = m_pWebDiffWindow->GetDiffCount() > 0 ? 1 : 0;
- SetLastCompareResult(result != 0);
- return result;
-}
-
/// Document commanding us to close
bool CWebPageDiffFrame::CloseNow()
{
Callback<IWebDiffCallback>([this](const WebDiffCallbackResult& result) -> HRESULT
{
m_bCompareCompleted = true;
- if (UpdateDiffItem(m_pDirDoc) == 0 &&
+ if (UpdateLastCompareResult() == 0 &&
std::count(m_filePaths.begin(), m_filePaths.end(), L"about:blank") != m_filePaths.GetSize())
{
CMergeFrameCommon::ShowIdenticalMessage(m_filePaths, true,
void RefreshOptions();
bool CloseNow() override;
void DirDocClosing(IDirDoc * pDirDoc) override { m_pDirDoc = nullptr; }
- void UpdateLastCompareResult();
+ int UpdateLastCompareResult();
void UpdateAutoPaneResize();
void UpdateSplitter();
bool GenerateReport(const String& sFileName) const;
void CreateWebWndStatusBar(CStatusBar &, CWnd *);
void OnWebDiffEvent(const WebDiffEvent& event);
bool OpenUrls(IWebDiffCallback* callback);
- int UpdateDiffItem(IDirDoc * pDirDoc);
void UpdateHeaderSizes();
void UpdateHeaderPath(int pane);
void SetTitle(LPCTSTR lpszTitle);