00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
#include <kdebug.h>
00023
#include <kmessagebox.h>
00024
#include <klocale.h>
00025
00026
#include "conflictdialog.h"
00027
#include "syncer.h"
00028
#include "syncee.h"
00029
00030
#include "syncuikde.h"
00031
00032
using namespace KSync;
00033
00034 SyncUiKde::SyncUiKde(
QWidget *parent,
bool confirm,
bool inform ) :
00035 mParent( parent ), m_confirm( confirm ), m_inform( inform )
00036 {
00037 }
00038
00039 SyncUiKde::~SyncUiKde()
00040 {
00041 }
00042
00043
SyncEntry *SyncUiKde::deconflict(
SyncEntry *syncEntry,
SyncEntry *targetEntry )
00044 {
00045
00046 ConflictDialog dlg( syncEntry, targetEntry, mParent );
00047
int result = dlg.exec();
00048
00049
if ( result == KDialogBase::User2 ) {
00050
return syncEntry;
00051 }
else if ( result == KDialogBase::User1 ) {
00052
return targetEntry;
00053 }
00054
00055
return 0;
00056 }
00057
00058
bool SyncUiKde::confirmDelete(
SyncEntry* entry,
SyncEntry* target )
00059 {
00060
if (!m_confirm )
return true;
00061
00062
QString text = i18n(
"%1 was deleted on %2. Do you want to delete it?").arg( target->
name() ).arg( entry->
syncee()->
source() );
00063
00064
int res =KMessageBox::questionYesNo(mParent, text, i18n(
"Delete?") );
00065
if ( res == KMessageBox::Yes )
return true;
00066
else return false;
00067
00068
return true;
00069 }
00070
00074
SyncEntry* SyncUiKde::deletedChanged(
SyncEntry* syncEntry,
SyncEntry* target )
00075 {
00076
QString text = i18n(
"%1 was deleted on %2 and changed on %3").arg( target->
name() ).arg( syncEntry->
syncee()->
source() ).arg( target->
syncee()->
source() );
00077
int res = KMessageBox::questionYesNo(mParent, text, i18n(
"Delete or Modify?"),
00078 i18n(
"Delete"), i18n(
"Modify") );
00079
if ( res == KMessageBox::Yes )
00080
return syncEntry;
00081
else if ( res == KMessageBox::No )
00082
return target;
00083
00084
return 0;
00085
00086 }
00087
00088
SyncEntry* SyncUiKde::changedChanged(
SyncEntry* syncEntry,
SyncEntry* target )
00089 {
00090
QString text = i18n(
"%1 was changed on both sources. Which one do you want to take?").arg(syncEntry->
name() );
00091
00092
int res = KMessageBox::questionYesNo(mParent, text, i18n(
"Modified two entries"),
00093 syncEntry->
syncee()->
source(),
00094 target->
syncee()->
source() );
00095
00096
if ( res == KMessageBox::Yes )
00097
return syncEntry;
00098
else if ( res == KMessageBox::No )
00099
return target;
00100
00101
return 0;
00102 }
00103
00104
void SyncUiKde::informBothDeleted(
SyncEntry* syncEntry,
SyncEntry* target )
00105 {
00106
if (m_inform)
00107 KMessageBox::information(mParent, i18n(
"The entry with the id %1 was deleted on %2 and %3").arg( syncEntry->
id() ).arg( syncEntry->
syncee()->
source() ).arg( target->
syncee()->
source() ) );
00108 }