kitchensync

syncuikde.cpp

00001 /*
00002     This file is part of KitchenSync.
00003 
00004     Copyright (c) 2002 Holger Freyther <zecke@handhelds.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 <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   /* fallback */
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()->title() );
00063 
00064     int res =KMessageBox::questionYesNo(mParent, text, i18n("Delete?"), KStdGuiItem::del(), KStdGuiItem::cancel() );
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()->title() ).arg( target->syncee()->title() );
00077     int res = KMessageBox::questionYesNo(mParent, text, i18n("Delete or Modify?"),
00078                                KStdGuiItem::del(), 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()->title(),
00094                                        target->syncee()->title() );
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()->title() ).arg( target->syncee()->title() ) );
00108 }
00109 
00110 
00117 void SyncUiKde::setConfirmDelete( bool b ) {
00118   m_confirm = b;
00119 }
KDE Home | KDE Accessibility Home | Description of Access Keys