Revision: 5067
http://winmerge.svn.sourceforge.net/winmerge/?rev=5067&view=rev
Author: kimmov
Date: 2008-02-22 07:48:03 -0800 (Fri, 22 Feb 2008)
Log Message:
-----------
Move PATCHFILES definition to PatchTool.h to make includes more logical. Make dialog member of CPatchTool a pointer. Convert some CStrings to strings. Fix and improve doxygen comments.
Modified Paths:
--------------
trunk/Src/MainFrm.cpp
trunk/Src/PatchDlg.cpp
trunk/Src/PatchDlg.h
trunk/Src/PatchTool.cpp
trunk/Src/PatchTool.h
Modified: trunk/Src/MainFrm.cpp
===================================================================
--- trunk/Src/MainFrm.cpp 2008-02-22 15:41:47 UTC (rev 5066)
+++ trunk/Src/MainFrm.cpp 2008-02-22 15:48:03 UTC (rev 5067)
@@ -2086,7 +2086,7 @@
{
if (patcher.GetOpenToEditor())
{
- OpenFileToExternalEditor(patcher.GetPatchFile());
+ OpenFileToExternalEditor(patcher.GetPatchFile().c_str());
}
}
}
Modified: trunk/Src/PatchDlg.cpp
===================================================================
--- trunk/Src/PatchDlg.cpp 2008-02-22 15:41:47 UTC (rev 5066)
+++ trunk/Src/PatchDlg.cpp 2008-02-22 15:48:03 UTC (rev 5067)
@@ -24,6 +24,7 @@
#include "stdafx.h"
#include "merge.h"
+#include "PatchTool.h"
#include "PatchDlg.h"
#include "diff.h"
#include "coretools.h"
@@ -57,7 +58,9 @@
{
}
-
+/**
+ * @brief Map dialog controls and class member variables.
+ */
void CPatchDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
@@ -98,7 +101,8 @@
// CPatchDlg message handlers
/**
- * @brief OK button pressed: check options and filenames and close dialog
+ * @brief Called when dialog is closed with OK.
+ * Check options and filenames given and close the dialog.
*/
void CPatchDlg::OnOK()
{
@@ -432,7 +436,8 @@
}
/**
- * @brief Add file to internal list.
+ * @brief Add patch item to internal list.
+ * @param [in] pf Patch item to add.
*/
void CPatchDlg::AddItem(PATCHFILES pf)
{
@@ -440,8 +445,8 @@
}
/**
- * @brief Returns amount of files in internal list.
- * @return Count of filepairs in list.
+ * @brief Returns amount of patch items in the internal list.
+ * @return Count of patch items in the list.
*/
int CPatchDlg::GetItemCount()
{
@@ -449,8 +454,8 @@
}
/**
- * @brief Return ref to first files in internal list
- * @return POSITION of first item in list.
+ * @brief Return ref to first item in the internal list
+ * @return POSITION of first item in the list.
*/
POSITION CPatchDlg::GetFirstItem()
{
@@ -458,11 +463,11 @@
}
/**
- * @brief Return next files in internal list
+ * @brief Return next item in the internal list
* @param [in, out] pos
* - in POSITION for item to get
* - out Next item's POSITION
- * @return PATCHFILE from given position.
+ * @return PATCHFILES from given position.
*/
PATCHFILES CPatchDlg::GetNextItem(POSITION &pos)
{
@@ -480,7 +485,7 @@
}
/**
- * @brief Empties internal file list.
+ * @brief Empties internal item list.
*/
void CPatchDlg::ClearItems()
{
Modified: trunk/Src/PatchDlg.h
===================================================================
--- trunk/Src/PatchDlg.h 2008-02-22 15:41:47 UTC (rev 5066)
+++ trunk/Src/PatchDlg.h 2008-02-22 15:48:03 UTC (rev 5067)
@@ -19,37 +19,21 @@
*
* @brief Declaration file for patch creation dialog
*/
-// RCS ID line follows -- this is updated by CVS
+// ID line follows -- this is updated by SVN
// $Id$
#if !defined(AFX_PATCHDLG_H__AB3CE671_1328_11D7_B088_005004D9D386__INCLUDED_)
#define AFX_PATCHDLG_H__AB3CE671_1328_11D7_B088_005004D9D386__INCLUDED_
-
#include "resource.h"
#include "SuperComboBox.h"
+struct PATCHFILES;
+
/////////////////////////////////////////////////////////////////////////////
// PatchDlg dialog
/**
- * @brief Files used for patch creating.
- * Stores paths of two files used to create a patch. Left side file
- * is considered as "original" file and right side file as "changed" file.
- * Times are for printing filetimes to patch file.
- */
-struct PATCHFILES
-{
- String lfile; /**< Left file */
- String pathLeft; /**< Left path added to patch file */
- String rfile; /**< Right file */
- String pathRight; /**< Right path added to patch file */
- time_t ltime; /**< Left time */
- time_t rtime; /**< Right time */
- PATCHFILES() : ltime(0), rtime(0) {};
-};
-
-/**
* @brief Dialog class for Generate Patch -dialog.
* This dialog allows user to select files from which to create a patch,
* patch file's filename and several options related to patch.
Modified: trunk/Src/PatchTool.cpp
===================================================================
--- trunk/Src/PatchTool.cpp 2008-02-22 15:41:47 UTC (rev 5066)
+++ trunk/Src/PatchTool.cpp 2008-02-22 15:48:03 UTC (rev 5067)
@@ -25,13 +25,37 @@
#include "stdafx.h"
#include "UnicodeString.h"
#include "DiffWrapper.h"
-#include "patchDlg.h"
#include "patchtool.h"
+#include "PatchDlg.h"
#include "Coretools.h"
#include "paths.h"
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+/**
+ * @brief Default constructor.
+ */
+CPatchTool::CPatchTool()
+: m_pDlgPatch(NULL)
+{
+}
+
+/**
+ * @brief Default destructor.
+ */
+CPatchTool::~CPatchTool()
+{
+ delete m_pDlgPatch;
+}
+
/**
- * @brief Adds files to list for patching
+ * @brief Adds files to list for patching.
+ * @param [in] file1 First file to add.
+ * @param [in] file2 Second file to add.
*/
void CPatchTool::AddFiles(const String &file1, const String &file2)
{
@@ -43,6 +67,17 @@
m_fileList.AddTail(files);
}
+/**
+ * @brief Add files with alternative paths.
+ * This function adds files with alternative paths. Alternative path is the
+ * one that is added to the patch file. So while @p file1 and @p file2 are
+ * paths in disk (can be temp file names), @p altPath1 and @p altPath2 are
+ * "visible " paths printed to the patch file.
+ * @param [in] file1 First path in disk.
+ * @param [in] altPath1 First path as printed to the patch file.
+ * @param [in] file2 Second path in disk.
+ * @param [in] altPath2 Second path as printed to the patch file.
+ */
void CPatchTool::AddFiles(const String &file1, const String &altPath1,
const String &file2, const String &altPath2)
{
@@ -57,7 +92,7 @@
}
/**
- * @brief Create patch from files given
+ * @brief Create a patch from files given.
* @note Files can be given using AddFiles() or selecting using
* CPatchDlg.
*/
@@ -68,6 +103,9 @@
BOOL bDiffSuccess;
int retVal = 0;
+ if (m_pDlgPatch == NULL)
+ m_pDlgPatch = new CPatchDlg();
+
// If files already inserted, add them to dialog
int count = m_fileList.GetCount();
POSITION pos = m_fileList.GetHeadPosition();
@@ -75,13 +113,13 @@
for (int i = 0; i < count; i++)
{
PATCHFILES files = m_fileList.GetNext(pos);
- m_dlgPatch.AddItem(files);
+ m_pDlgPatch->AddItem(files);
}
if (ShowDialog())
{
String path;
- SplitFilename(m_dlgPatch.m_fileResult, &path, NULL, NULL);
+ SplitFilename(m_pDlgPatch->m_fileResult, &path, NULL, NULL);
if (!paths_CreateIfNeeded(path.c_str()))
{
LangMessageBox(IDS_FOLDER_NOTEXIST, MB_OK | MB_ICONSTOP);
@@ -89,16 +127,16 @@
}
// Select patch create -mode
- m_diffWrapper.SetCreatePatchFile(m_dlgPatch.m_fileResult);
- m_diffWrapper.SetAppendFiles(m_dlgPatch.m_appendFile);
+ m_diffWrapper.SetCreatePatchFile(m_pDlgPatch->m_fileResult);
+ m_diffWrapper.SetAppendFiles(m_pDlgPatch->m_appendFile);
m_diffWrapper.SetPrediffer(NULL);
- int fileCount = m_dlgPatch.GetItemCount();
- POSITION pos = m_dlgPatch.GetFirstItem();
+ int fileCount = m_pDlgPatch->GetItemCount();
+ POSITION pos = m_pDlgPatch->GetFirstItem();
for (int i = 0; i < fileCount; i++)
{
- PATCHFILES files = m_dlgPatch.GetNextItem(pos);
+ PATCHFILES files = m_pDlgPatch->GetNextItem(pos);
// Set up DiffWrapper
m_diffWrapper.SetPaths(files.lfile, files.rfile, FALSE);
@@ -122,7 +160,7 @@
else if (status.bPatchFileFailed)
{
CString errMsg;
- LangFormatString1(errMsg, IDS_FILEWRITE_ERROR, m_dlgPatch.m_fileResult);
+ LangFormatString1(errMsg, IDS_FILEWRITE_ERROR, m_pDlgPatch->m_fileResult);
AfxMessageBox(errMsg, MB_ICONSTOP);
bResult = FALSE;
break;
@@ -137,12 +175,12 @@
LangMessageBox(IDS_DIFF_SUCCEEDED, MB_ICONINFORMATION|MB_DONT_DISPLAY_AGAIN,
IDS_DIFF_SUCCEEDED);
- m_sPatchFile = m_dlgPatch.m_fileResult;
- m_bOpenToEditor = m_dlgPatch.m_openToEditor;
+ m_sPatchFile = m_pDlgPatch->m_fileResult;
+ m_bOpenToEditor = m_pDlgPatch->m_openToEditor;
retVal = 1;
}
}
- m_dlgPatch.ClearItems();
+ m_pDlgPatch->ClearItems();
return retVal;
}
@@ -156,30 +194,30 @@
PATCHOPTIONS patchOptions;
BOOL bRetVal = TRUE;
- if (m_dlgPatch.DoModal() == IDOK)
+ if (m_pDlgPatch->DoModal() == IDOK)
{
// There must be one filepair
- if (m_dlgPatch.GetItemCount() < 1)
+ if (m_pDlgPatch->GetItemCount() < 1)
bRetVal = FALSE;
// These two are from dropdown list - can't be wrong
- patchOptions.outputStyle = m_dlgPatch.m_outputStyle;
- patchOptions.nContext = m_dlgPatch.m_contextLines;
+ patchOptions.outputStyle = m_pDlgPatch->m_outputStyle;
+ patchOptions.nContext = m_pDlgPatch->m_contextLines;
// Checkbox - can't be wrong
- patchOptions.bAddCommandline = m_dlgPatch.m_includeCmdLine;
+ patchOptions.bAddCommandline = m_pDlgPatch->m_includeCmdLine;
m_diffWrapper.SetPatchOptions(&patchOptions);
// These are from checkboxes and radiobuttons - can't be wrong
- diffOptions.nIgnoreWhitespace = m_dlgPatch.m_whitespaceCompare;
- diffOptions.bIgnoreBlankLines = m_dlgPatch.m_ignoreBlanks;
- m_diffWrapper.SetAppendFiles(m_dlgPatch.m_appendFile);
+ diffOptions.nIgnoreWhitespace = m_pDlgPatch->m_whitespaceCompare;
+ diffOptions.bIgnoreBlankLines = m_pDlgPatch->m_ignoreBlanks;
+ m_diffWrapper.SetAppendFiles(m_pDlgPatch->m_appendFile);
// Use this because non-sensitive setting can't write
// patch file EOLs correctly
diffOptions.bIgnoreEol = FALSE;
- diffOptions.bIgnoreCase = !m_dlgPatch.m_caseSensitive;
+ diffOptions.bIgnoreCase = !m_pDlgPatch->m_caseSensitive;
m_diffWrapper.SetOptions(&diffOptions);
}
else
@@ -191,7 +229,7 @@
/**
* @brief Returns filename and path for patch-file
*/
-CString CPatchTool::GetPatchFile() const
+String CPatchTool::GetPatchFile() const
{
return m_sPatchFile;
}
Modified: trunk/Src/PatchTool.h
===================================================================
--- trunk/Src/PatchTool.h 2008-02-22 15:41:47 UTC (rev 5066)
+++ trunk/Src/PatchTool.h 2008-02-22 15:48:03 UTC (rev 5067)
@@ -19,25 +19,48 @@
*
* @brief Declaration file for PatchTool class
*/
-// RCS ID line follows -- this is updated by CVS
+// ID line follows -- this is updated by SVN
// $Id$
#ifndef _PATCHTOOL_H_
#define _PATCHTOOL_H_
-#include "PatchDlg.h"
+class CPatchDlg;
/**
- * @brief Provides patch creation functionality.
+ * @brief Files used for patch creating.
+ * Stores paths of two files used to create a patch. Left side file
+ * is considered as "original" file and right side file as "changed" file.
+ * Times are for printing filetimes to patch file.
*/
+struct PATCHFILES
+{
+ String lfile; /**< Left file */
+ String pathLeft; /**< Left path added to patch file */
+ String rfile; /**< Right file */
+ String pathRight; /**< Right path added to patch file */
+ time_t ltime; /**< Left time */
+ time_t rtime; /**< Right time */
+ PATCHFILES() : ltime(0), rtime(0) {};
+};
+
+/**
+ * @brief A class which creates patch files.
+ * This class is used to create patch files. The files to patch can be added
+ * to list before calling CreatePatch(). Or user can select files in the
+ * the dialog that CreatePatch() shows.
+ */
class CPatchTool
{
public:
+ CPatchTool();
+ ~CPatchTool();
+
void AddFiles(const String &file1, const String &file2);
void AddFiles(const String &file1, const String &altPath1,
const String &file2, const String &altPath2);
int CreatePatch();
- CString GetPatchFile() const;
+ String GetPatchFile() const;
BOOL GetOpenToEditor() const;
protected:
@@ -46,9 +69,9 @@
private:
CList<PATCHFILES, PATCHFILES&> m_fileList; /**< List of files to patch. */
CDiffWrapper m_diffWrapper; /**< DiffWrapper instance we use to create patch. */
- CPatchDlg m_dlgPatch; /**< Dialog for selecting files and options. */
- CString m_sPatchFile; /**< Patch file path and filename. */
+ CPatchDlg *m_pDlgPatch; /**< Dialog for selecting files and options. */
+ String m_sPatchFile; /**< Patch file path and filename. */
BOOL m_bOpenToEditor; /**< Is patch file opened to external editor? */
};
-#endif // _PATCHTOOL_H_
\ No newline at end of file
+#endif // _PATCHTOOL_H_
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|