kitchensync
conflictdialog.cpp00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
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"
|