[r5083]: tags / V3_12 / CompareResultsDlg.h Maximize Restore History

Download this file

CompareResultsDlg.h    203 lines (177 with data), 6.5 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
/*
* Copyright (c) 2003-2008 Rony Shapiro <ronys@users.sourceforge.net>.
* All rights reserved. Use of the code is allowed under the
* Artistic License 2.0 terms, as specified in the LICENSE file
* distributed with this code, or available from
* http://www.opensource.org/licenses/artistic-license-2.0.php
*/
#pragma once
/// CompareResultsDlg.h
//-----------------------------------------------------------------------------
#include "PWDialog.h"
#include "corelib/ItemData.h"
#include "corelib/MyString.h"
#include "corelib/PWScore.h"
#include "corelib/Report.h"
#include "corelib/uuidgen.h"
#ifdef _DEBUG
#include <bitset>
#include <string>
#endif
// The following structure is needed for compare when record is in
// both databases (indatabase = -1) but there are differences
// Subset used when record is in only one (indatabase = 0 or 1)
// If entries made equal by copying, indatabase set to -1.
struct st_CompareData {
uuid_array_t uuid0; // original DB
uuid_array_t uuid1; // comparison DB
CItemData::FieldBits bsDiffs; // list of items compared
CMyString group;
CMyString title;
CMyString user;
int id; // # in the appropriate list: "Only in Original", "Only in Comparison" or in "Both with Differences"
int indatabase; // see enum below
int listindex; // list index in CompareResultsDlg list control
bool unknflds0; // original DB
bool unknflds1; // comparison DB
st_CompareData()
: bsDiffs(0), group(_T("")), title(_T("")), user(_T("")),
id(0), indatabase(0), listindex(0),
unknflds0(false), unknflds1(false)
{
memset(uuid0, 0x00, sizeof(uuid_array_t));
memset(uuid1, 0x00, sizeof(uuid_array_t));
}
st_CompareData(const st_CompareData &that)
: bsDiffs(that.bsDiffs), group(that.group), title(that.title), user(that.user),
id(that.id), indatabase(that.indatabase), listindex(that.listindex),
unknflds0(that.unknflds0), unknflds1(that.unknflds1)
{
memcpy(uuid0, that.uuid0, sizeof(uuid_array_t));
memcpy(uuid1, that.uuid1, sizeof(uuid_array_t));
}
st_CompareData &operator=(const st_CompareData &that)
{
if (this != &that) {
memcpy(uuid0, that.uuid0, sizeof(uuid_array_t));
memcpy(uuid1, that.uuid1, sizeof(uuid_array_t));
bsDiffs = that.bsDiffs;
group = that.group;
title = that.title;
user = that.user;
id = that.id;
indatabase = that.indatabase;
listindex = that.listindex;
unknflds0 = that.unknflds0;
unknflds1 = that.unknflds1;
}
return *this;
}
};
struct equal_id
{
equal_id(int const& id) : m_id(id) {}
bool operator()(st_CompareData const& rdata) const
{
return (rdata.id == m_id);
}
int m_id;
};
// Vector of entries passed from DboxMain::Compare to CompareResultsDlg
// Used for "Only in Original DB", "Only in Comparison DB" and
// in "Both with Differences"
typedef std::vector<st_CompareData> CompareData;
// The following structure is needed for compare to send back data
// to allow copying, viewing and editing of entries
struct st_CompareInfo {
PWScore *pcore0; // original DB
PWScore *pcore1; // comparison DB
uuid_array_t uuid0; // original DB
uuid_array_t uuid1; // comparison DB
int clicked_column;
};
class CCompareResultsDlg : public CPWDialog
{
DECLARE_DYNAMIC(CCompareResultsDlg)
// Construction
public:
CCompareResultsDlg(CWnd* pParent,
CompareData &OnlyInCurrent,
CompareData &OnlyInComp,
CompareData &Conflicts,
CompareData &Identical,
CItemData::FieldBits &bsFields,
PWScore *pcore0, PWScore *pcore1,
CReport *rpt);
// st_CompareInfo Functions
enum {EDIT = 0, VIEW, COPY_TO_ORIGINALDB, COPY_TO_COMPARISONDB};
// Column indices
// IDENTICAL means CURRENT + COMPARE but identical
// BOTH means CURRENT + COMPARE but with differences
enum {IDENTICAL = -2, BOTH = -1 , CURRENT = 0, COMPARE,
GROUP, TITLE, USER, PASSWORD, NOTES, URL, AUTOTYPE, PWHIST,
CTIME, ATIME, LTIME, PMTIME, RMTIME, POLICY,
LAST};
// Dialog Data
//{{AFX_DATA(CCompareResultsDlg)
enum { IDD = IDD_COMPARE_RESULTS };
CListCtrl m_LCResults;
int m_iSortedColumn;
bool m_bSortAscending;
CMyString m_cs_Filename1, m_cs_Filename2;
int m_ShowIdenticalEntries;
//}}AFX_DATA
bool m_bOriginalDBReadOnly, m_bComparisonDBReadOnly;
bool m_OriginalDBChanged, m_ComparisonDBChanged;
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CCompareResultsDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
private:
static int CALLBACK CRCompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort);
// Implementation
protected:
UINT statustext[1];
CStatusBar m_statusBar;
bool CopyLeftOrRight(const bool bCopyLeft);
void UpdateStatusBar();
bool ProcessFunction(const int ifunction, st_CompareData *st_data);
void GetReportData(CString &data);
st_CompareData * GetCompareData(const DWORD dwItemData);
static st_CompareData * GetCompareData(const DWORD dwItemData, CCompareResultsDlg *self);
void AddEntries(const bool bAddIdentical);
virtual BOOL OnInitDialog();
// Generated message map functions
//{{AFX_MSG(CCompareResultsDlg)
virtual void OnCancel();
virtual void OnOK();
afx_msg void OnHelp();
afx_msg void OnViewCompareReport();
afx_msg void OnShowIdenticalEntries();
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnGetMinMaxInfo(MINMAXINFO* lpMMI);
afx_msg void OnColumnClick(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg void OnItemDoubleClick(NMHDR* pNotifyStruct, LRESULT* result);
afx_msg void OnItemRightClick(NMHDR* pNotifyStruct, LRESULT* result);
afx_msg void OnCompareViewEdit();
afx_msg void OnCompareCopyToOriginalDB();
afx_msg void OnCompareCopyToComparisonDB();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
private:
CompareData m_OnlyInCurrent;
CompareData m_OnlyInComp;
CompareData m_Conflicts;
CompareData m_Identical;
CItemData::FieldBits m_bsFields;
PWScore *m_pcore0, *m_pcore1;
CReport *m_prpt;
size_t m_numOnlyInCurrent, m_numOnlyInComp, m_numConflicts, m_numIdentical;
int m_cxBSpace, m_cyBSpace, m_cySBar;
int m_DialogMinWidth, m_DialogMinHeight;
int m_DialogMaxWidth, m_DialogMaxHeight;
int m_row, m_column;
int m_nCols;
};