singleconflictdialog.cpp
00001 /* 00002 This file is part of KitchenSync. 00003 00004 Copyright (c) 2005 Tobias Koenig <tokoe@kde.org> 00005 00006 This program is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation; either version 2 of the License, or 00009 (at your option) any later version. 00010 00011 This program is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with this program; if not, write to the Free Software 00018 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00019 */ 00020 00021 #include <kdialog.h> 00022 #include <tdelocale.h> 00023 00024 #include <tqlabel.h> 00025 #include <tqlayout.h> 00026 #include <tqpushbutton.h> 00027 00028 #include "addresseediffalgo.h" 00029 #include "genericdiffalgo.h" 00030 #include "htmldiffalgodisplay.h" 00031 #include "memberinfo.h" 00032 00033 #include "singleconflictdialog.h" 00034 00035 SingleConflictDialog::SingleConflictDialog( QSync::SyncMapping &mapping, TQWidget *parent ) 00036 : ConflictDialog( mapping, parent ), mDiffAlgo( 0 ) 00037 { 00038 initGUI(); 00039 00040 TQString format = mapping.changeAt( 0 ).objectFormatName(); 00041 QSync::SyncChange leftChange = mapping.changeAt( 0 ); 00042 QSync::SyncChange rightChange = mapping.changeAt( 1 ); 00043 00044 if ( format == "file" ) { 00045 mDiffAlgo = new KSync::GenericDiffAlgo( leftChange.data(), rightChange.data() ); 00046 } else if ( format == "vcard" ) { 00047 } else if ( format == "calendar" ) { 00048 } else if ( format == "xml-contact" ) { 00049 mDiffAlgo = new KSync::AddresseeDiffAlgo( leftChange.data(), rightChange.data() ); 00050 } 00051 00052 MemberInfo miLeft( leftChange.member() ); 00053 mDiffAlgoDisplay->setLeftSourceTitle( miLeft.name() ); 00054 MemberInfo miRight( rightChange.member() ); 00055 mDiffAlgoDisplay->setRightSourceTitle( miRight.name() ); 00056 00057 if ( mDiffAlgo ) { 00058 mDiffAlgo->addDisplay( mDiffAlgoDisplay ); 00059 mDiffAlgo->run(); 00060 } 00061 } 00062 00063 SingleConflictDialog::~SingleConflictDialog() 00064 { 00065 delete mDiffAlgo; 00066 mDiffAlgo = 0; 00067 } 00068 00069 void SingleConflictDialog::useFirstChange() 00070 { 00071 mMapping.solve( mMapping.changeAt( 0 ) ); 00072 00073 accept(); 00074 } 00075 00076 void SingleConflictDialog::useSecondChange() 00077 { 00078 mMapping.solve( mMapping.changeAt( 1 ) ); 00079 00080 accept(); 00081 } 00082 00083 void SingleConflictDialog::duplicateChange() 00084 { 00085 mMapping.duplicate(); 00086 00087 accept(); 00088 } 00089 00090 void SingleConflictDialog::ignoreChange() 00091 { 00092 mMapping.ignore(); 00093 00094 accept(); 00095 } 00096 00097 void SingleConflictDialog::initGUI() 00098 { 00099 TQGridLayout *layout = new TQGridLayout( this, 3, 4, KDialog::marginHint(), KDialog::spacingHint() ); 00100 00101 layout->addMultiCellWidget( new TQLabel( i18n( "A conflict has appeared, please solve it manually." ), this ), 0, 0, 0, 3 ); 00102 mDiffAlgoDisplay = new KSync::HTMLDiffAlgoDisplay( this ); 00103 00104 layout->addMultiCellWidget( mDiffAlgoDisplay, 1, 1, 0, 3 ); 00105 00106 TQPushButton *button = new TQPushButton( i18n( "Use Item" ), this ); 00107 connect( button, TQT_SIGNAL( clicked() ), TQT_SLOT( useFirstChange() ) ); 00108 layout->addWidget( button, 2, 0 ); 00109 00110 button = new TQPushButton( i18n( "Duplicate Items" ), this ); 00111 connect( button, TQT_SIGNAL( clicked() ), TQT_SLOT( duplicateChange() ) ); 00112 layout->addWidget( button, 2, 1 ); 00113 00114 button = new TQPushButton( i18n( "Ignore Conflict" ), this ); 00115 connect( button, TQT_SIGNAL( clicked() ), TQT_SLOT( ignoreChange() ) ); 00116 layout->addWidget( button, 2, 2 ); 00117 00118 button = new TQPushButton( i18n( "Use Item" ), this ); 00119 connect( button, TQT_SIGNAL( clicked() ), TQT_SLOT( useSecondChange() ) ); 00120 layout->addWidget( button, 2, 3 ); 00121 } 00122 00123 #include "singleconflictdialog.moc"