1 | /* |
2 | This file is part of libkdepim. |
3 | |
4 | Copyright (c) 2004 Tobias Koenig <tokoe@kde.org> |
5 | |
6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. |
10 | |
11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. |
15 | |
16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
19 | Boston, MA 02110-1301, USA. |
20 | */ |
21 | |
22 | #ifndef KDEPIM_DIFFALGO_H |
23 | #define KDEPIM_DIFFALGO_H |
24 | |
25 | #include "libkdepim-copy_export.h" |
26 | #include <QList> |
27 | |
28 | namespace KPIM { |
29 | |
30 | /** |
31 | DiffAlgo and DiffAlgoDisplay work together for displaying differences between |
32 | two PIM objects like contacts, events or todos. |
33 | DiffAlgo is the bas class for the diffing algorithm and DiffAlgoDisplay is |
34 | responsible for representation. The separation makes it possible to use one |
35 | display for all diffing algorithm and vice versa. |
36 | */ |
37 | class DiffAlgoDisplay |
38 | { |
39 | public: |
40 | virtual ~DiffAlgoDisplay(){} |
41 | /** |
42 | Is called on the start of the diff. |
43 | */ |
44 | virtual void begin() = 0; |
45 | |
46 | /** |
47 | Is called on the end of the diff. |
48 | */ |
49 | virtual void end() = 0; |
50 | |
51 | /** |
52 | Sets the title of the left data source. |
53 | */ |
54 | virtual void setLeftSourceTitle( const QString &title ) = 0; |
55 | |
56 | /** |
57 | Sets the title of the right data source. |
58 | */ |
59 | virtual void setRightSourceTitle( const QString &title ) = 0; |
60 | |
61 | /** |
62 | Adds a field which is only available in the left data source. |
63 | */ |
64 | virtual void additionalLeftField( const QString &id, const QString &value ) = 0; |
65 | |
66 | /** |
67 | Adds a field which is only available in the right data source. |
68 | */ |
69 | virtual void additionalRightField( const QString &id, const QString &value ) = 0; |
70 | |
71 | /** |
72 | Adds a conflict between two fields. |
73 | */ |
74 | virtual void conflictField( const QString &id, const QString &leftValue, |
75 | const QString &rightValue ) = 0; |
76 | }; |
77 | |
78 | |
79 | class KDEPIM_COPY_EXPORT DiffAlgo |
80 | { |
81 | public: |
82 | /** |
83 | Destructor. |
84 | */ |
85 | virtual ~DiffAlgo() {} |
86 | |
87 | /** |
88 | Starts the diffing algorithm. |
89 | */ |
90 | virtual void run() = 0; |
91 | |
92 | /** |
93 | Must be called on the start of the diff. |
94 | */ |
95 | void begin(); |
96 | |
97 | /** |
98 | Must be called on the end of the diff. |
99 | */ |
100 | void end(); |
101 | |
102 | /** |
103 | Sets the title of the left data source. |
104 | */ |
105 | void setLeftSourceTitle( const QString &title ); |
106 | |
107 | /** |
108 | Sets the title of the right data source. |
109 | */ |
110 | void setRightSourceTitle( const QString &title ); |
111 | |
112 | /** |
113 | Adds a field which is only available in the left data source. |
114 | */ |
115 | void additionalLeftField( const QString &id, const QString &value ); |
116 | |
117 | /** |
118 | Adds a field which is only available in the right data source. |
119 | */ |
120 | void additionalRightField( const QString &id, const QString &value ); |
121 | |
122 | /** |
123 | Adds a conflict between two fields. |
124 | */ |
125 | void conflictField( const QString &id, const QString &leftValue, |
126 | const QString &rightValue ); |
127 | |
128 | void addDisplay( DiffAlgoDisplay *display ); |
129 | void removeDisplay( DiffAlgoDisplay *display ); |
130 | |
131 | |
132 | private: |
133 | QList<DiffAlgoDisplay*> mDisplays; |
134 | }; |
135 | |
136 | } |
137 | |
138 | #endif |
139 | |