kpilot Library API Documentation

doc-conflictdialog.cc

00001 /* doc-conflictdialog.cc KPilot 00002 ** 00003 ** Copyright (C) 2002 by Reinhold Kainhofer 00004 ** 00005 */ 00006 00007 /* 00008 ** This program is free software; you can redistribute it and/or modify 00009 ** it under the terms of the GNU General Public License as published by 00010 ** the Free Software Foundation; either version 2 of the License, or 00011 ** (at your option) any later version. 00012 ** 00013 ** This program is distributed in the hope that it will be useful, 00014 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 ** GNU General Public License for more details. 00017 ** 00018 ** You should have received a copy of the GNU General Public License 00019 ** along with this program in a file called COPYING; if not, write to 00020 ** the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, 00021 ** MA 02111-1307, USA. 00022 */ 00023 00024 /* 00025 ** Bug reports and questions can be sent to kde-pim@kde.org 00026 */ 00027 00028 #include "options.h" 00029 #include "doc-conflictdialog.moc" 00030 00031 #include <qlabel.h> 00032 #include <qpushbutton.h> 00033 #include <qlayout.h> 00034 #include <qbuttongroup.h> 00035 #include <kmessagebox.h> 00036 #include <qtimer.h> 00037 #include <qtable.h> 00038 #include <qcombobox.h> 00039 #include <qscrollview.h> 00040 00041 00042 ResolutionDialog::ResolutionDialog( QWidget* parent, const QString& caption, syncInfoList*sinfo, KPilotDeviceLink*lnk ) 00043 : KDialogBase( parent, "resolutionDialog", true, caption, KDialogBase::Ok|KDialogBase::Cancel, KDialogBase::Ok, true), tickleTimer(0L), fHandle(lnk) { 00044 FUNCTIONSETUP; 00045 syncInfo=sinfo; 00046 hasConflicts=false; 00047 00048 QWidget *page = new QWidget( this ); 00049 setMainWidget(page); 00050 QVBoxLayout *topLayout = new QVBoxLayout( page, 0, spacingHint() ); 00051 00052 // First, insert the texts on top: 00053 textLabel1 = new QLabel(i18n("Here is a list of all text files and DOC databases the conduit found. The conduit tried to determine the correct sync direction, but for databases in bold red letters a conflict occurred (i.e. the text was changed both on the desktop and on the handheld). For these databases please specify which version is the current one."), page); 00054 textLabel1->setAlignment( int( QLabel::WordBreak | QLabel::AlignVCenter ) ); 00055 topLayout->addWidget(textLabel1); 00056 00057 textLabel2 = new QLabel(i18n("You can also change the sync direction for databases without a conflict." ), page ); 00058 textLabel2->setAlignment( int( QLabel::WordBreak | QLabel::AlignVCenter ) ); 00059 topLayout->addWidget(textLabel2); 00060 00061 resolutionGroupBox = new QGroupBox(i18n("DOC Databases"), page ); 00062 QVBoxLayout*playout = new QVBoxLayout(resolutionGroupBox); 00063 QScrollView* sv = new QScrollView(resolutionGroupBox); 00064 playout->addWidget(sv); 00065 sv->setResizePolicy(QScrollView::AutoOneFit); 00066 sv->setHScrollBarMode(QScrollView::AlwaysOff); 00067 sv->setMargin(5); 00068 QFrame* big_box = new QFrame(sv->viewport()); 00069 sv->addChild(big_box); 00070 00071 00072 resolutionGroupBoxLayout = new QGridLayout( big_box, syncInfo->size(), 3 ); 00073 resolutionGroupBoxLayout->setAlignment( Qt::AlignTop ); 00074 00075 // Invisible button group for the information buttons to use the same slot for all of them (see Dallheimer's book, page 309f) 00076 QButtonGroup *bgroup = new QButtonGroup( this ); 00077 bgroup->hide(); 00078 QObject::connect(bgroup, SIGNAL(clicked(int)), this, SLOT(slotInfo(int))); 00079 00080 if (syncInfo) { 00081 DEBUGCONDUIT<<"Adding resolution options for the databases "<<endl; 00082 syncInfoList::Iterator it; 00083 int nr=0; 00084 DEBUGCONDUIT<<"We're having "<<(*syncInfo).size()<<" entries in the database list"<<endl; 00085 for (it=syncInfo->begin(); it!=syncInfo->end(); it++) { 00086 docSyncInfo si=(*it); 00087 conflictEntry cE; 00088 cE.index=nr; 00089 cE.conflict=(si.direction==eSyncConflict); 00090 DEBUGCONDUIT<<"Adding "<<si.handheldDB<<" to the conflict resolution dialog"<<endl; 00091 00092 QString text=si.handheldDB; 00093 if (cE.conflict) { 00094 text="<qt><b><font color=red>"+text+"</font></b></qt>"; 00095 DEBUGCONDUIT<<"We have a conflict for database "<<si.handheldDB<<endl; 00096 hasConflicts=true; 00097 } 00098 cE.dbname=new QLabel(text, big_box); 00099 resolutionGroupBoxLayout->addWidget( cE.dbname, cE.index, 0 ); 00100 00101 cE.resolution=new QComboBox( FALSE, big_box); 00102 cE.resolution->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, 00103 (QSizePolicy::SizeType)0, 0, 0, 00104 cE.resolution->sizePolicy().hasHeightForWidth() ) ); 00105 cE.resolution->clear(); 00106 cE.resolution->insertItem( i18n( "No Sync" ) ); 00107 cE.resolution->insertItem( i18n( "Sync Handheld to PC" ) ); 00108 cE.resolution->insertItem( i18n( "Sync PC to Handheld" ) ); 00109 cE.resolution->insertItem( i18n( "Delete Both Databases" ) ); 00110 cE.resolution->setCurrentItem((int)si.direction); 00111 resolutionGroupBoxLayout->addWidget( cE.resolution, cE.index, 1); 00112 00113 cE.info = new QPushButton( i18n("More Infos..."), big_box ); 00114 resolutionGroupBoxLayout->addWidget(cE.info, cE.index, 2); 00115 bgroup->insert(cE.info); 00116 00117 conflictEntries.append(cE); 00118 nr++; 00119 } 00120 } else { 00121 kdWarning()<<"The list of text files is not available to the resolution " 00122 "dialog. Something must have gone wrong ..."<<endl; 00123 } 00124 00125 00126 topLayout->addWidget( resolutionGroupBox ); 00127 resize( QSize(600, 480).expandedTo(minimumSizeHint()) ); 00128 00129 if (fHandle) tickleTimer=new QTimer(this, "TickleTimer"); 00130 if (tickleTimer) { 00131 connect( tickleTimer, SIGNAL(timeout()), this, SLOT(_tickle()) ); 00132 tickleTimer->start( 10000 ); // tickle the palm every 10 seconds to prevent a timeout until the sync is really finished. 00133 } 00134 00135 } 00136 00137 /* 00138 * Destroys the object and frees any allocated resources 00139 */ 00140 ResolutionDialog::~ResolutionDialog() 00141 { 00142 // no need to delete child widgets, Qt does it all for us 00143 } 00144 00145 /* virtual slot */ void ResolutionDialog::slotOk() { 00146 FUNCTIONSETUP; 00147 QValueList<conflictEntry>::Iterator ceIt; 00148 for (ceIt=conflictEntries.begin(); ceIt!=conflictEntries.end(); ceIt++) { 00149 (*syncInfo)[(*ceIt).index].direction=(eSyncDirectionEnum)((*ceIt).resolution->currentItem()); 00150 } 00151 KDialogBase::slotOk(); 00152 } 00153 00154 QString eTextStatusToString(eTextStatus stat) { 00155 switch(stat) { 00156 case eStatNone: return i18n("unchanged"); 00157 case eStatNew: return i18n("new"); 00158 case eStatChanged: return i18n("changed"); 00159 case eStatBookmarksChanged: return i18n("only bookmarks changed"); 00160 case eStatDeleted: return i18n("deleted"); 00161 case eStatDoesntExist: return i18n("does not exist"); 00162 default: return i18n("unknown"); 00163 } 00164 } 00165 00166 void ResolutionDialog::slotInfo(int index) { 00167 FUNCTIONSETUP; 00168 conflictEntry cE=conflictEntries[index]; 00169 int ix=cE.index; 00170 if (!syncInfo) return; 00171 docSyncInfo si=(*syncInfo)[ix]; 00172 QString text=i18n("Status of the database %1:\n\n").arg(si.handheldDB); 00173 text+=i18n("Handheld: %1\n").arg(eTextStatusToString(si.fPalmStatus)); 00174 text+=i18n("Desktop: %1\n").arg(eTextStatusToString(si.fPCStatus)); 00175 00176 KMessageBox::information(this, text, i18n("Database information")); 00177 } 00178 00179 00180 void ResolutionDialog::_tickle() { 00181 FUNCTIONSETUP; 00182 if (fHandle) fHandle->tickle(); 00183 }
KDE Logo
This file is part of the documentation for kpilot Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Jul 28 23:57:48 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003