kitchensync

singleconflictdialog.cpp
1/*
2 This file is part of KitchenSync.
3
4 Copyright (c) 2005 Tobias Koenig <tokoe@kde.org>
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program 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
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19*/
20
21#include <kdialog.h>
22#include <tdelocale.h>
23
24#include <tqlabel.h>
25#include <tqlayout.h>
26#include <tqpushbutton.h>
27
28#include "addresseediffalgo.h"
29#include "genericdiffalgo.h"
30#include "htmldiffalgodisplay.h"
31#include "memberinfo.h"
32
33#include "singleconflictdialog.h"
34
35SingleConflictDialog::SingleConflictDialog( QSync::SyncMapping &mapping, TQWidget *parent )
36 : ConflictDialog( mapping, parent ), mDiffAlgo( 0 )
37{
38 initGUI();
39
40 TQString format = mapping.changeAt( 0 ).objectFormatName();
41 QSync::SyncChange leftChange = mapping.changeAt( 0 );
42 QSync::SyncChange rightChange = mapping.changeAt( 1 );
43
44 if ( format == "file" ) {
45 mDiffAlgo = new KSync::GenericDiffAlgo( leftChange.data(), rightChange.data() );
46 } else if ( format == "vcard" ) {
47 } else if ( format == "calendar" ) {
48 } else if ( format == "xml-contact" ) {
49 mDiffAlgo = new KSync::AddresseeDiffAlgo( leftChange.data(), rightChange.data() );
50 }
51
52 MemberInfo miLeft( leftChange.member() );
53 mDiffAlgoDisplay->setLeftSourceTitle( miLeft.name() );
54 MemberInfo miRight( rightChange.member() );
55 mDiffAlgoDisplay->setRightSourceTitle( miRight.name() );
56
57 if ( mDiffAlgo ) {
58 mDiffAlgo->addDisplay( mDiffAlgoDisplay );
59 mDiffAlgo->run();
60 }
61}
62
63SingleConflictDialog::~SingleConflictDialog()
64{
65 delete mDiffAlgo;
66 mDiffAlgo = 0;
67}
68
69void SingleConflictDialog::useFirstChange()
70{
71 mMapping.solve( mMapping.changeAt( 0 ) );
72
73 accept();
74}
75
76void SingleConflictDialog::useSecondChange()
77{
78 mMapping.solve( mMapping.changeAt( 1 ) );
79
80 accept();
81}
82
83void SingleConflictDialog::duplicateChange()
84{
85 mMapping.duplicate();
86
87 accept();
88}
89
90void SingleConflictDialog::ignoreChange()
91{
92 mMapping.ignore();
93
94 accept();
95}
96
97void SingleConflictDialog::initGUI()
98{
99 TQGridLayout *layout = new TQGridLayout( this, 3, 4, KDialog::marginHint(), KDialog::spacingHint() );
100
101 layout->addMultiCellWidget( new TQLabel( i18n( "A conflict has appeared, please solve it manually." ), this ), 0, 0, 0, 3 );
102 mDiffAlgoDisplay = new KSync::HTMLDiffAlgoDisplay( this );
103
104 layout->addMultiCellWidget( mDiffAlgoDisplay, 1, 1, 0, 3 );
105
106 TQPushButton *button = new TQPushButton( i18n( "Use Item" ), this );
107 connect( button, TQT_SIGNAL( clicked() ), TQT_SLOT( useFirstChange() ) );
108 layout->addWidget( button, 2, 0 );
109
110 button = new TQPushButton( i18n( "Duplicate Items" ), this );
111 connect( button, TQT_SIGNAL( clicked() ), TQT_SLOT( duplicateChange() ) );
112 layout->addWidget( button, 2, 1 );
113
114 button = new TQPushButton( i18n( "Ignore Conflict" ), this );
115 connect( button, TQT_SIGNAL( clicked() ), TQT_SLOT( ignoreChange() ) );
116 layout->addWidget( button, 2, 2 );
117
118 button = new TQPushButton( i18n( "Use Item" ), this );
119 connect( button, TQT_SIGNAL( clicked() ), TQT_SLOT( useSecondChange() ) );
120 layout->addWidget( button, 2, 3 );
121}
122
123#include "singleconflictdialog.moc"
Base class for SingleConflictDialog and MultiConflictDialog.