summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-03-15 10:59:28 (UTC)
committer zautrix <zautrix>2005-03-15 10:59:28 (UTC)
commitf695ed8bf462bab5df0f6b41d3d3e6ed5b803484 (patch) (unidiff)
tree993f48f8048eb37354c3326ee8fc998afc598f81
parentefa425789895481dd918a55af27895a7917d2a20 (diff)
downloadkdepimpi-f695ed8bf462bab5df0f6b41d3d3e6ed5b803484.zip
kdepimpi-f695ed8bf462bab5df0f6b41d3d3e6ed5b803484.tar.gz
kdepimpi-f695ed8bf462bab5df0f6b41d3d3e6ed5b803484.tar.bz2
sync conflict dialog fix
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koeventviewerdialog.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/korganizer/koeventviewerdialog.cpp b/korganizer/koeventviewerdialog.cpp
index f606124..f734696 100644
--- a/korganizer/koeventviewerdialog.cpp
+++ b/korganizer/koeventviewerdialog.cpp
@@ -1,298 +1,302 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20#include <klocale.h> 20#include <klocale.h>
21 21
22#include <libkcal/event.h> 22#include <libkcal/event.h>
23#include <qtimer.h> 23#include <qtimer.h>
24#include <qpushbutton.h> 24#include <qpushbutton.h>
25 25
26#include "koeventviewer.h" 26#include "koeventviewer.h"
27#include "koprefs.h" 27#include "koprefs.h"
28#include <libkcal/todo.h> 28#include <libkcal/todo.h>
29#include "qapp.h" 29#include "qapp.h"
30 30
31#include "koeventviewerdialog.h" 31#include "koeventviewerdialog.h"
32extern int globalFlagBlockAgenda; 32extern int globalFlagBlockAgenda;
33 33
34KOEventViewerDialog::KOEventViewerDialog(QWidget *parent,const char *name) 34KOEventViewerDialog::KOEventViewerDialog(QWidget *parent,const char *name)
35 : KDialogBase(parent,name, 35 : KDialogBase(parent,name,
36#ifndef DESKTOP_VERSION 36#ifndef DESKTOP_VERSION
37 true , 37 true ,
38#else 38#else
39 false, 39 false,
40#endif 40#endif
41 i18n("Event Viewer"),Ok|User1|Close,Close, false, i18n("Agenda")) 41 i18n("Event Viewer"),Ok|User1|Close,Close, false, i18n("Agenda"))
42{ 42{
43 sendSignalViewerClosed = true; 43 sendSignalViewerClosed = true;
44 mEventViewer = new KOEventViewer(this); 44 mEventViewer = new KOEventViewer(this);
45 mEventViewer->setFont( KOPrefs::instance()->mEventViewFont ); 45 mEventViewer->setFont( KOPrefs::instance()->mEventViewFont );
46 setMainWidget(mEventViewer); 46 setMainWidget(mEventViewer);
47 setButtonText(Ok, i18n("Edit") ); 47 setButtonText(Ok, i18n("Edit") );
48 48
49 QObject::connect(findButton( Ok ),SIGNAL(clicked()), 49 QObject::connect(findButton( Ok ),SIGNAL(clicked()),
50 SLOT(editIncidence())); 50 SLOT(editIncidence()));
51 QObject::connect(this,SIGNAL(user1Clicked()), 51 QObject::connect(this,SIGNAL(user1Clicked()),
52 SLOT(showIncidence())); 52 SLOT(showIncidence()));
53 mIncidence = 0; 53 mIncidence = 0;
54 // TODO: Set a sensible size (based on the content?). 54 // TODO: Set a sensible size (based on the content?).
55 //showMaximized(); 55 //showMaximized();
56 //qDebug("++++++++++++KOEventViewerDialog() "); 56 //qDebug("++++++++++++KOEventViewerDialog() ");
57 // if ( KOPrefs::instance()->mCompactDialogs ) { 57 // if ( KOPrefs::instance()->mCompactDialogs ) {
58// setFixedSize( 240,284 ); 58// setFixedSize( 240,284 );
59// move( 0, 15 ); 59// move( 0, 15 );
60// } else { 60// } else {
61// setMinimumSize(300,200); 61// setMinimumSize(300,200);
62// resize(320,300); 62// resize(320,300);
63// } 63// }
64 mSyncMode = false; 64 mSyncMode = false;
65 mSyncResult = 0; 65 mSyncResult = 0;
66 66
67} 67}
68 68
69KOEventViewerDialog::~KOEventViewerDialog() 69KOEventViewerDialog::~KOEventViewerDialog()
70{ 70{
71 //qDebug("-------~KOEventViewerDialog() "); 71 //qDebug("-------~KOEventViewerDialog() ");
72} 72}
73void KOEventViewerDialog::showMe() 73void KOEventViewerDialog::showMe()
74{ 74{
75 75
76#ifdef DESKTOP_VERSION 76#ifdef DESKTOP_VERSION
77 int x,y,w,h; 77 int x,y,w,h;
78 x = geometry().x(); 78 x = geometry().x();
79 y = geometry().y(); 79 y = geometry().y();
80 w = width(); 80 w = width();
81 h = height(); 81 h = height();
82 show(); 82 show();
83 setGeometry(x,y,w,h); 83 setGeometry(x,y,w,h);
84#else 84#else
85 showMaximized(); 85 showMaximized();
86#endif 86#endif
87 raise(); 87 raise();
88 setActiveWindow(); 88 setActiveWindow();
89 mEventViewer->setFocus(); 89 mEventViewer->setFocus();
90 //raise();
90 91
91} 92}
92void KOEventViewerDialog::setSyncMode( bool b ) 93void KOEventViewerDialog::setSyncMode( bool b )
93{ 94{
94 mSyncMode = b; 95 mSyncMode = b;
95 //qDebug("KOEventViewerDialog::setSyncMode %d ",mSyncMode ); 96 //qDebug("KOEventViewerDialog::setSyncMode %d ",mSyncMode );
96 if ( mSyncMode ) { 97 if ( mSyncMode ) {
97 findButton( Close )->setText( i18n("Cancel Sync")); 98 findButton( Close )->setText( i18n("Cancel Sync"));
98 findButton( Ok )->setText( i18n("Remote")); 99 findButton( Ok )->setText( i18n("Remote"));
99 findButton( User1 )->setText( i18n("Local")); 100 findButton( User1 )->setText( i18n("Local"));
100 } else { 101 } else {
101 findButton( Close )->setText( i18n("Close")); 102 findButton( Close )->setText( i18n("Close"));
102 findButton( Ok )->setText( i18n("Edit")); 103 findButton( Ok )->setText( i18n("Edit"));
103 findButton( User1 )->setText( i18n("Agenda")); 104 findButton( User1 )->setText( i18n("Agenda"));
104 } 105 }
105 mEventViewer->setSyncMode( b ); 106 mEventViewer->setSyncMode( b );
106} 107}
107void KOEventViewerDialog::setColorMode( int m ) 108void KOEventViewerDialog::setColorMode( int m )
108{ 109{
109 mEventViewer->setColorMode( m ); 110 mEventViewer->setColorMode( m );
110} 111}
111int KOEventViewerDialog::executeS( bool local ) 112int KOEventViewerDialog::executeS( bool local )
112{ 113{
113 mSyncResult = 3; 114 mSyncResult = 3;
114 if ( local ) 115 if ( local )
115 findButton( User1 )->setFocus(); 116 findButton( User1 )->setFocus();
116 else 117 else
117 findButton( Ok )->setFocus(); 118 findButton( Ok )->setFocus();
118 exec(); 119 exec();
119 return mSyncResult; 120 return mSyncResult;
120} 121}
121 122
122void KOEventViewerDialog::updateConfig() 123void KOEventViewerDialog::updateConfig()
123{ 124{
124 mEventViewer->setFont( KOPrefs::instance()->mEventViewFont ); 125 mEventViewer->setFont( KOPrefs::instance()->mEventViewFont );
125 126
126} 127}
127void KOEventViewerDialog::setEvent(Event *event) 128void KOEventViewerDialog::setEvent(Event *event)
128{ 129{
129 mEventViewer->setEvent(event); 130 mEventViewer->setEvent(event);
130 mIncidence = event; 131 mIncidence = event;
131 mEventViewer->setFocus(); 132 mEventViewer->setFocus();
132 //findButton( Close )->setFocus(); 133 //findButton( Close )->setFocus();
133 if ( !mSyncMode ) { 134 if ( !mSyncMode ) {
134 findButton( User1 )->setText( i18n("Agenda")); 135 findButton( User1 )->setText( i18n("Agenda"));
135 } 136 }
136} 137}
137void KOEventViewerDialog::setIncidence(Incidence *in ) 138void KOEventViewerDialog::setIncidence(Incidence *in )
138{ 139{
139 if ( in->type() == "Event" ) 140 if ( in->type() == "Event" )
140 setEvent( (Event*) in ); 141 setEvent( (Event*) in );
141 else if ( in->type() =="Todo" ) 142 else if ( in->type() =="Todo" )
142 setTodo( (Todo*) in ); 143 setTodo( (Todo*) in );
143 else if ( in->type() =="Journal" ) 144 else if ( in->type() =="Journal" )
144 setJournal( (Journal*) in ); 145 setJournal( (Journal*) in );
145} 146}
146void KOEventViewerDialog::addIncidence(Incidence *in) 147void KOEventViewerDialog::addIncidence(Incidence *in)
147{ 148{
148 if ( in->type() == "Event" ) 149 if ( in->type() == "Event" )
149 addEvent( (Event*) in ); 150 addEvent( (Event*) in );
150 else if ( in->type() =="Todo" ) 151 else if ( in->type() =="Todo" )
151 mEventViewer->setTodo( (Todo*) in, false ); 152 mEventViewer->setTodo( (Todo*) in, false );
152 else if ( in->type() =="Journal" ) 153 else if ( in->type() =="Journal" )
153 mEventViewer->setJournal( (Journal*) in, false ); 154 mEventViewer->setJournal( (Journal*) in, false );
154 if ( mSyncMode ) { 155 if ( mSyncMode ) {
155 findButton( User1 )->setFocus(); 156 findButton( User1 )->setFocus();
156 setCaption(i18n("Conflict! Please choose entry")); 157 setCaption(i18n("Conflict! Please choose entry"));
157 } 158 }
158} 159}
159 160
160void KOEventViewerDialog::addEvent(Event *event) 161void KOEventViewerDialog::addEvent(Event *event)
161{ 162{
162 mEventViewer->addEvent(event); 163 mEventViewer->addEvent(event);
163 mIncidence = event; 164 mIncidence = event;
164 mEventViewer->setFocus(); 165 mEventViewer->setFocus();
165 //findButton( Close )->setFocus(); 166 //findButton( Close )->setFocus();
166 if ( !mSyncMode ) { 167 if ( !mSyncMode ) {
167 findButton( User1 )->setText( i18n("Agenda")); 168 findButton( User1 )->setText( i18n("Agenda"));
168 } 169 }
169} 170}
170 171
171void KOEventViewerDialog::setTodo(Todo *event) 172void KOEventViewerDialog::setTodo(Todo *event)
172{ 173{
173 mEventViewer->setTodo(event); 174 mEventViewer->setTodo(event);
174 mIncidence = (Incidence*)event; 175 mIncidence = (Incidence*)event;
175 mEventViewer->setFocus(); 176 mEventViewer->setFocus();
176 //findButton( Close )->setFocus(); 177 //findButton( Close )->setFocus();
177 if ( !mSyncMode ) { 178 if ( !mSyncMode ) {
178 findButton( User1 )->setText( i18n("Set complete")); 179 findButton( User1 )->setText( i18n("Set complete"));
179 } 180 }
180} 181}
181void KOEventViewerDialog::setJournal(Journal *j) 182void KOEventViewerDialog::setJournal(Journal *j)
182{ 183{
183 mEventViewer->setJournal(j); 184 mEventViewer->setJournal(j);
184 mIncidence = (Incidence*)j; 185 mIncidence = (Incidence*)j;
185 mEventViewer->setFocus(); 186 mEventViewer->setFocus();
186 //findButton( Close )->setFocus(); 187 //findButton( Close )->setFocus();
187 if ( !mSyncMode ) { 188 if ( !mSyncMode ) {
188 findButton( User1 )->setText( i18n("Agenda")); 189 findButton( User1 )->setText( i18n("Agenda"));
189 } 190 }
190} 191}
191 192
192void KOEventViewerDialog::addText(QString text) 193void KOEventViewerDialog::addText(QString text)
193{ 194{
194 mEventViewer->addText(text); 195 mEventViewer->addText(text);
195 mEventViewer->setFocus(); 196 mEventViewer->setFocus();
196 //findButton( Close )->setFocus(); 197 //findButton( Close )->setFocus();
197} 198}
198void KOEventViewerDialog::editIncidence() 199void KOEventViewerDialog::editIncidence()
199{ 200{
200 sendSignalViewerClosed = false; 201 sendSignalViewerClosed = false;
201 if ( mSyncMode ) { 202 if ( mSyncMode ) {
202 mSyncResult = 2; 203 mSyncResult = 2;
203 accept(); 204 accept();
204 return; 205 return;
205 } 206 }
206 if ( mIncidence ){ 207 if ( mIncidence ){
207#ifndef DESKTOP_VERSION 208#ifndef DESKTOP_VERSION
208 hide(); 209 hide();
209#endif 210#endif
210 emit editIncidence( mIncidence ); 211 emit editIncidence( mIncidence );
211 } 212 }
212} 213}
213void KOEventViewerDialog::showIncidence() 214void KOEventViewerDialog::showIncidence()
214{ 215{
215 sendSignalViewerClosed = false; 216 sendSignalViewerClosed = false;
216 if ( mSyncMode ) { 217 if ( mSyncMode ) {
217 mSyncResult = 1; 218 mSyncResult = 1;
218 accept(); 219 accept();
219 return; 220 return;
220 } 221 }
221 222
222 if ( mIncidence ){ 223 if ( mIncidence ){
223#ifndef DESKTOP_VERSION 224#ifndef DESKTOP_VERSION
224 hide(); 225 hide();
225#endif 226#endif
226 QDate date; 227 QDate date;
227 if ( mIncidence->type() == "Todo" ) { 228 if ( mIncidence->type() == "Todo" ) {
228 /* 229 /*
229 if ( ((Todo*)mIncidence)->hasDueDate() ) 230 if ( ((Todo*)mIncidence)->hasDueDate() )
230 date = ((Todo*)mIncidence)->dtDue().date(); 231 date = ((Todo*)mIncidence)->dtDue().date();
231 else { 232 else {
232 globalFlagBlockAgenda = 2; 233 globalFlagBlockAgenda = 2;
233 emit showAgendaView( false ); 234 emit showAgendaView( false );
234 return; 235 return;
235 } 236 }
236 */ 237 */
237 ((Todo*)mIncidence)->setCompleted( true ); 238 ((Todo*)mIncidence)->setCompleted( true );
238 ((Todo*)mIncidence)->setCompleted(QDateTime::currentDateTime() ); 239 ((Todo*)mIncidence)->setCompleted(QDateTime::currentDateTime() );
239 hide(); 240 hide();
240 emit todoCompleted(((Todo*)mIncidence)); 241 emit todoCompleted(((Todo*)mIncidence));
241 return; 242 return;
242 243
243 } else 244 } else
244 date = mIncidence->dtStart().date(); 245 date = mIncidence->dtStart().date();
245 globalFlagBlockAgenda = 1; 246 globalFlagBlockAgenda = 1;
246 emit showAgendaView( false ); 247 emit showAgendaView( false );
247 globalFlagBlockAgenda = 2; 248 globalFlagBlockAgenda = 2;
248 emit jumpToTime( date ); 249 emit jumpToTime( date );
249 } 250 }
250} 251}
251void KOEventViewerDialog::keyPressEvent ( QKeyEvent * e ) 252void KOEventViewerDialog::keyPressEvent ( QKeyEvent * e )
252{ 253{
253 switch ( e->key() ) { 254 switch ( e->key() ) {
254 255
255 case Qt::Key_A : 256 case Qt::Key_A :
256 case Qt::Key_L : 257 case Qt::Key_L :
257 showIncidence(); 258 showIncidence();
258 break; 259 break;
259 case Qt::Key_E : 260 case Qt::Key_E :
260 case Qt::Key_R : 261 case Qt::Key_R :
261 editIncidence(); 262 editIncidence();
262 break; 263 break;
263 case Qt::Key_C: 264 case Qt::Key_C:
264 case Qt::Key_Escape: 265 case Qt::Key_Escape:
265 sendSignalViewerClosed = true; 266 sendSignalViewerClosed = true;
266 close(); 267 close();
267 break; 268 break;
268 case Qt::Key_I: 269 case Qt::Key_I:
269#ifndef DESKTOP_VERSION 270#ifndef DESKTOP_VERSION
270 sendSignalViewerClosed = true; 271 sendSignalViewerClosed = true;
271 close(); 272 close();
272#else 273#else
273 sendSignalViewerClosed = true; 274 sendSignalViewerClosed = true;
274 slotViewerClosed(); 275 slotViewerClosed();
275 //accept(); 276 //accept();
276#endif 277#endif
277 break; 278 break;
278 default: 279 default:
279 KDialogBase::keyPressEvent ( e ); 280 KDialogBase::keyPressEvent ( e );
280 break; 281 break;
281 } 282 }
282 283
283} 284}
284void KOEventViewerDialog::hideEvent ( QHideEvent * e ) 285void KOEventViewerDialog::hideEvent ( QHideEvent * e )
285{ 286{
286 KDialogBase::hideEvent ( e ); 287 KDialogBase::hideEvent ( e );
287 QTimer::singleShot( 1, this, SLOT (slotViewerClosed() ) ); 288 QTimer::singleShot( 1, this, SLOT (slotViewerClosed() ) );
288} 289}
289 290
290void KOEventViewerDialog::slotViewerClosed() 291void KOEventViewerDialog::slotViewerClosed()
291{ 292{
293 if ( mSyncMode )
294 return;
295
292 if ( sendSignalViewerClosed ) { 296 if ( sendSignalViewerClosed ) {
293 //qDebug("KOEventViewerDialog::hideEvent "); 297 //qDebug("KOEventViewerDialog::hideEvent ");
294 emit signalViewerClosed(); 298 emit signalViewerClosed();
295 } 299 }
296 sendSignalViewerClosed = true; 300 sendSignalViewerClosed = true;
297} 301}
298 302