2 /// \file ConflictDlg.h
3 /// The dialog used during a sync, to display conflicting
4 /// changes, and let the user decide what to do.
8 Copyright (C) 2010-2012, Net Direct Inc. (http://www.netdirect.ca/)
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19 See the GNU General Public License in the COPYING file at the
20 root directory of this project for more details.
23 #ifndef __BARRYDESKTOP_CONFLICTDLG_H__
24 #define __BARRYDESKTOP_CONFLICTDLG_H__
32 class ConflictDlg
: public wxDialog
34 DECLARE_EVENT_TABLE() // sets to protected:
37 typedef std::tr1::shared_ptr
<XmlNodeMap
> map_ptr
;
38 typedef std::tr1::shared_ptr
<xmlpp::DomParser
> dom_ptr
;
42 ConflictDlg::dom_ptr dom
; // never null
43 ConflictDlg::map_ptr map
; // can contain null!
46 typedef std::vector
<XmlPair
> mapped_list
;
47 typedef std::set
<Glib::ustring
> key_set
;
49 // Stored by the caller to remember the "always" selection
50 // Pass it back into the dialog to have it automatically
52 struct AlwaysMemoryBlock
56 std::string m_plugin_name
;
57 std::string m_last_command
;
58 std::string m_favour_plugin_name
;
64 m_plugin_name
.clear();
65 m_last_command
.clear();
66 m_favour_plugin_name
.clear();
77 // external data sources
78 const OpenSync::API
&m_engine
;
79 const std::vector
<OpenSync::SyncChange
> &m_changes
;
80 std::string m_supported_commands
; // a char string: "SDAIN"
81 AlwaysMemoryBlock
&m_always
;
85 key_set m_differing_keys
;
89 std::string m_command_string
; // eg. "S 1"
99 void CreateSummaries(wxSizer
*sizer
);
100 void CreateSummary(wxSizer
*sizer
, size_t change_index
);
101 void CreateSummaryGroup(wxSizer
*sizer
, size_t change_index
);
102 void CreateSummaryButtons(wxSizer
*sizer
, size_t change_index
);
103 bool IsDifferent(const XmlNodeMapping
&mapping
) const;
104 void AddEmptyNotice(wxSizer
*sizer
);
105 void AddMapping(wxSizer
*sizer
, XmlNodeMapping
&mapping
,
107 void CreateAlternateButtons(wxSizer
*sizer
);
110 void CreateDifferingKeyNameSet();
113 ConflictDlg(wxWindow
*parent
, const OpenSync::API
&engine
,
114 const std::string
&supported_commands
,
115 const std::vector
<OpenSync::SyncChange
> &changes
,
116 AlwaysMemoryBlock
&always
);
120 const std::string
& GetCommand() const { return m_command_string
; }
121 bool IsKillSync() const { return m_kill_sync
; }
122 void Clear() { clear(); }
125 // override, in order to force an answer
129 void OnShowButton(wxCommandEvent
&event
);
130 void OnSelectButton(wxCommandEvent
&event
);
131 void OnDuplicateButton(wxCommandEvent
&event
);
132 void OnAbortButton(wxCommandEvent
&event
);
133 void OnIgnoreButton(wxCommandEvent
&event
);
134 void OnKeepNewerButton(wxCommandEvent
&event
);
135 void OnKillSyncButton(wxCommandEvent
&event
);
136 void OnAlwaysCheckbox(wxCommandEvent
&event
);