kitchensync

conflictdialog.cpp

00001 /*
00002     This file is part of KitchenSync.
00003 
00004     Copyright (c) 2004 Tobias Koenig <tokoe@kde.org>
00005 
00006     This library is free software; you can redistribute it and/or
00007     modify it under the terms of the GNU Library General Public
00008     License as published by the Free Software Foundation; either
00009     version 2 of the License, or (at your option) any later version.
00010 
00011     This library 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 GNU
00014     Library General Public License for more details.
00015 
00016     You should have received a copy of the GNU Library General Public License
00017     along with this library; see the file COPYING.LIB.  If not, write to
00018     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019     Boston, MA 02110-1301, USA.
00020 */
00021 
00022 #include <qlabel.h>
00023 #include <qlayout.h>
00024 
00025 #include <klocale.h>
00026 #include <libkdepim/diffalgo.h>
00027 #include <libkdepim/htmldiffalgodisplay.h>
00028 
00029 #include "conflictdialog.h"
00030 #include "syncee.h"
00031 
00032 using namespace KSync;
00033 
00034 ConflictDialog::ConflictDialog( SyncEntry *syncEntry, SyncEntry *targetEntry,
00035                                 QWidget *parent, const char *name )
00036   : KDialogBase( Plain, i18n( "Resolve Conflict" ), User1 | User2 | Cancel, Cancel,
00037                  parent, name, true, true ), mDiffAlgo( 0 )
00038 {
00039   initGUI();
00040 
00041   mDiffAlgo = syncEntry->diffAlgo( syncEntry, targetEntry );
00042 
00043   mDisplay->setLeftSourceTitle( syncEntry->syncee()->title() );
00044   mDisplay->setRightSourceTitle( targetEntry->syncee()->title() );
00045 
00046   setButtonText( User1, targetEntry->syncee()->title() );
00047   setButtonText( User2, syncEntry->syncee()->title() );
00048   setButtonText( Cancel, i18n( "Keep Both" ) );
00049 
00050   if ( mDiffAlgo ) {
00051     mDiffAlgo->addDisplay( mDisplay );
00052     mDiffAlgo->run();
00053   } else {
00054     mDisplay->begin();
00055     mDisplay->conflictField( i18n( "Both entries have changed fields" ), i18n( "Unknown" ), i18n( "Unknown" ) );
00056     mDisplay->end();
00057   }
00058 
00059   resize( 550, 400 );
00060 }
00061 
00062 ConflictDialog::~ConflictDialog()
00063 {
00064   delete mDiffAlgo;
00065   mDiffAlgo = 0;
00066 }
00067 
00068 void ConflictDialog::slotUser1()
00069 {
00070   QDialog::done( User1 );
00071 }
00072 
00073 void ConflictDialog::slotUser2()
00074 {
00075   QDialog::done( User2 );
00076 }
00077 
00078 void ConflictDialog::initGUI()
00079 {
00080   QWidget *page = plainPage();
00081 
00082   QGridLayout *layout = new QGridLayout( page, 2, 1, marginHint(), spacingHint() );
00083 
00084   QLabel *label = new QLabel( i18n( "Which entry do you want to take precedence?" ), page );
00085   layout->addWidget( label, 0, 0, Qt::AlignCenter );
00086 
00087   mDisplay = new KPIM::HTMLDiffAlgoDisplay( page );
00088   layout->addWidget( mDisplay, 1, 0 );
00089 }
00090 
00091 #include "conflictdialog.moc"
KDE Home | KDE Accessibility Home | Description of Access Keys