summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/dateentryimpl.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/core/pim/datebook/dateentryimpl.cpp b/core/pim/datebook/dateentryimpl.cpp
index 2cdda9d..33b9d9b 100644
--- a/core/pim/datebook/dateentryimpl.cpp
+++ b/core/pim/datebook/dateentryimpl.cpp
@@ -1,573 +1,574 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "dateentryimpl.h" 21#include "dateentryimpl.h"
22#include "repeatentry.h" 22#include "repeatentry.h"
23 23
24#include <qpe/qpeapplication.h> 24#include <qpe/qpeapplication.h>
25#include <qpe/categoryselect.h> 25#include <qpe/categoryselect.h>
26#include <qpe/datebookmonth.h> 26#include <qpe/datebookmonth.h>
27#include <qpe/global.h> 27#include <qpe/global.h>
28#include <qpe/timeconversion.h> 28#include <qpe/timeconversion.h>
29#include <qpe/timestring.h> 29#include <qpe/timestring.h>
30#include <qpe/tzselect.h> 30#include <qpe/tzselect.h>
31 31
32#include <qevent.h> 32#include <qevent.h>
33#include <qcheckbox.h> 33#include <qcheckbox.h>
34#include <qcombobox.h> 34#include <qcombobox.h>
35#include <qlayout.h> 35#include <qlayout.h>
36#include <qlineedit.h> 36#include <qlineedit.h>
37#include <qmultilineedit.h> 37#include <qmultilineedit.h>
38#include <qpopupmenu.h> 38#include <qpopupmenu.h>
39#include <qscrollview.h> 39#include <qscrollview.h>
40#include <qspinbox.h> 40#include <qspinbox.h>
41#include <qtoolbutton.h> 41#include <qtoolbutton.h>
42 42
43#include "timepicker.h" 43#include "timepicker.h"
44#include "onoteedit.h" 44#include "onoteedit.h"
45 45
46#include <stdlib.h> 46#include <stdlib.h>
47#include <stdio.h> 47#include <stdio.h>
48 48
49/* 49/*
50 * Constructs a DateEntry which is a child of 'parent', with the 50 * Constructs a DateEntry which is a child of 'parent', with the
51 * name 'name' and widget flags set to 'f' 51 * name 'name' and widget flags set to 'f'
52 * 52 *
53 * The dialog will by default be modeless, unless you set 'modal' to 53 * The dialog will by default be modeless, unless you set 'modal' to
54 * TRUE to construct a modal dialog. 54 * TRUE to construct a modal dialog.
55 */ 55 */
56 56
57DateEntry::DateEntry( bool startOnMonday, const QDateTime &start, 57DateEntry::DateEntry( bool startOnMonday, const QDateTime &start,
58 const QDateTime &end, bool whichClock, QWidget* parent, 58 const QDateTime &end, bool whichClock, QWidget* parent,
59 const char* name ) 59 const char* name )
60 : DateEntryBase( parent, name ), 60 : DateEntryBase( parent, name ),
61 ampm( whichClock ), 61 ampm( whichClock ),
62 startWeekOnMonday( startOnMonday ), 62 startWeekOnMonday( startOnMonday ),
63 m_showStart(true) 63 m_showStart(true)
64{ 64{
65 init(); 65 init();
66 setDates(start,end); 66 setDates(start,end);
67 setFocusProxy(comboDescription); 67 setFocusProxy(comboDescription);
68} 68}
69 69
70bool DateEntry::eventFilter(QObject *obj, QEvent *ev ) 70bool DateEntry::eventFilter(QObject *obj, QEvent *ev )
71{ 71{
72 if( ev->type() == QEvent::FocusIn ){ 72 if( ev->type() == QEvent::FocusIn ){
73 if( obj == comboStart ){ 73 if( obj == comboStart ){
74 timePickerStart->setHour(startTime.hour()); 74 timePickerStart->setHour(startTime.hour());
75 timePickerStart->setMinute(startTime.minute()); 75 timePickerStart->setMinute(startTime.minute());
76 TimePickerLabel->setText( tr("Start Time" ) ); 76 TimePickerLabel->setText( tr("Start Time" ) );
77 m_showStart= true; 77 m_showStart= true;
78 }else if( obj == comboEnd ){ 78 }else if( obj == comboEnd ){
79 timePickerStart->setHour(endTime.hour()); 79 timePickerStart->setHour(endTime.hour());
80 timePickerStart->setMinute(endTime.minute()); 80 timePickerStart->setMinute(endTime.minute());
81 TimePickerLabel->setText( tr("End Time") ); 81 TimePickerLabel->setText( tr("End Time") );
82 m_showStart = false; 82 m_showStart = false;
83 } 83 }
84 } else if( ev->type() == QEvent::FocusOut ){ 84 } else if( ev->type() == QEvent::FocusOut ){
85 if( obj == comboEnd ){ 85 if( obj == comboEnd ){
86 QString s; 86 QString s;
87 s.sprintf("%.2d:%.2d",endTime.hour(), endTime.minute()); 87 s.sprintf("%.2d:%.2d",endTime.hour(), endTime.minute());
88 comboEnd->setText(s); 88 comboEnd->setText(s);
89 } 89 }
90 else if( obj == comboStart ){ 90 else if( obj == comboStart ){
91 QString s; 91 QString s;
92 s.sprintf("%.2d:%.2d",startTime.hour(), startTime.minute()); 92 s.sprintf("%.2d:%.2d",startTime.hour(), startTime.minute());
93 comboStart->setText(s); 93 comboStart->setText(s);
94 } 94 }
95 } 95 }
96 96
97 return false; 97 return false;
98} 98}
99 99
100static void addOrPick( QComboBox* combo, const QString& t ) 100static void addOrPick( QComboBox* combo, const QString& t )
101{ 101{
102 // Pick an item if one excists 102 // Pick an item if one excists
103 for (int i=0; i<combo->count(); i++) { 103 for (int i=0; i<combo->count(); i++) {
104 if ( combo->text(i) == t ) { 104 if ( combo->text(i) == t ) {
105 combo->setCurrentItem(i); 105 combo->setCurrentItem(i);
106 return; 106 return;
107 } 107 }
108 } 108 }
109 109
110 // Else add one 110 // Else add one
111 combo->insertItem(t); 111 combo->insertItem(t);
112 combo->setCurrentItem(combo->count()-1); 112 combo->setCurrentItem(combo->count()-1);
113} 113}
114 114
115DateEntry::DateEntry( bool startOnMonday, const Event &event, bool whichClock, 115DateEntry::DateEntry( bool startOnMonday, const Event &event, bool whichClock,
116 QWidget* parent, const char* name ) 116 QWidget* parent, const char* name )
117 : DateEntryBase( parent, name ), 117 : DateEntryBase( parent, name ),
118 ampm( whichClock ), 118 ampm( whichClock ),
119 startWeekOnMonday( startOnMonday ), 119 startWeekOnMonday( startOnMonday ),
120 m_showStart(true) 120 m_showStart(true)
121 121
122{ 122{
123 init(); 123 init();
124 setDates(event.start(),event.end()); 124 setDates(event.start(),event.end());
125 comboCategory->setCategories( event.categories(), "Calendar", tr("Calendar") ); 125 comboCategory->setCategories( event.categories(), "Calendar", tr("Calendar") );
126 if(!event.description().isEmpty()) 126 if(!event.description().isEmpty())
127 addOrPick( comboDescription, event.description() ); 127 addOrPick( comboDescription, event.description() );
128 if(!event.location().isEmpty()) 128 if(!event.location().isEmpty())
129 addOrPick( comboLocation, event.location() ); 129 addOrPick( comboLocation, event.location() );
130 checkAlarm->setChecked( event.hasAlarm() ); 130 checkAlarm->setChecked( event.hasAlarm() );
131 checkAllDay->setChecked( event.type() == Event::AllDay ); 131 checkAllDay->setChecked( event.type() == Event::AllDay );
132 if(!event.notes().isEmpty()) noteStr=event.notes(); 132 if(!event.notes().isEmpty()) noteStr=event.notes();
133 else noteStr=""; 133 else noteStr="";
134 spinAlarm->setValue(event.alarmTime()); 134 spinAlarm->setValue(event.alarmTime());
135 if ( event.alarmSound() != Event::Silent ) 135 if ( event.alarmSound() != Event::Silent )
136 comboSound->setCurrentItem( 1 ); 136 comboSound->setCurrentItem( 1 );
137 if ( event.hasRepeat() ) { 137 if ( event.hasRepeat() ) {
138 rp = event.repeatPattern(); 138 rp = event.repeatPattern();
139 cmdRepeat->setText( tr("Repeat...") ); 139 cmdRepeat->setText( tr("Repeat...") );
140 } 140 }
141 setRepeatLabel(); 141 setRepeatLabel();
142} 142}
143 143
144void DateEntry::setDates( const QDateTime& s, const QDateTime& e ) 144void DateEntry::setDates( const QDateTime& s, const QDateTime& e )
145{ 145{
146 startDate = s.date(); 146 startDate = s.date();
147 endDate = e.date(); 147 endDate = e.date();
148 startTime = s.time(); 148 startTime = s.time();
149 endTime = e.time(); 149 endTime = e.time();
150 150
151 startDateChanged( s.date().year(), s.date().month(), s.date().day() ); 151 startDateChanged( s.date().year(), s.date().month(), s.date().day() );
152 endDateChanged( e.date().year(), e.date().month(), e.date().day() ); 152 endDateChanged( e.date().year(), e.date().month(), e.date().day() );
153 153
154 updateTimeEdit(true,true); 154 updateTimeEdit(true,true);
155} 155}
156 156
157void DateEntry::updateTimeEdit(bool s, bool e) { 157void DateEntry::updateTimeEdit(bool s, bool e) {
158 158
159 // Comboboxes 159 // Comboboxes
160 QString strStart, strEnd; 160 QString strStart, strEnd;
161 int shour, ehour; 161 int shour, ehour;
162 if ( ampm ) { 162 if ( ampm ) {
163 shour = startTime.hour(); 163 shour = startTime.hour();
164 ehour = endTime.hour(); 164 ehour = endTime.hour();
165 if ( shour >= 12 ) { 165 if ( shour >= 12 ) {
166 if ( shour > 12 ) 166 if ( shour > 12 )
167 shour -= 12; 167 shour -= 12;
168 strStart.sprintf( "%d:%02d PM", shour, startTime.minute() ); 168 strStart.sprintf( "%d:%02d PM", shour, startTime.minute() );
169 } else { 169 } else {
170 if ( shour == 0 ) 170 if ( shour == 0 )
171 shour = 12; 171 shour = 12;
172 strStart.sprintf( "%d:%02d AM", shour, startTime.minute() ); 172 strStart.sprintf( "%d:%02d AM", shour, startTime.minute() );
173 } 173 }
174 if ( ehour == 24 && endTime.minute() == 0 ) { 174 if ( ehour == 24 && endTime.minute() == 0 ) {
175 strEnd = "11:59 PM"; // or "midnight" 175 strEnd = "11:59 PM"; // or "midnight"
176 } else if ( ehour >= 12 ) { 176 } else if ( ehour >= 12 ) {
177 if ( ehour > 12 ) 177 if ( ehour > 12 )
178 ehour -= 12; 178 ehour -= 12;
179 strEnd.sprintf( "%d:%02d PM", ehour, endTime.minute() ); 179 strEnd.sprintf( "%d:%02d PM", ehour, endTime.minute() );
180 } else { 180 } else {
181 if ( ehour == 0 ) 181 if ( ehour == 0 )
182 ehour = 12; 182 ehour = 12;
183 strEnd.sprintf( "%d:%02d AM", ehour, endTime.minute() ); 183 strEnd.sprintf( "%d:%02d AM", ehour, endTime.minute() );
184 } 184 }
185 } else { 185 } else {
186 strStart.sprintf( "%02d:%02d", startTime.hour(), startTime.minute() ); 186 strStart.sprintf( "%02d:%02d", startTime.hour(), startTime.minute() );
187 strEnd.sprintf( "%02d:%02d", endTime.hour(), endTime.minute() ); 187 strEnd.sprintf( "%02d:%02d", endTime.hour(), endTime.minute() );
188 } 188 }
189 189
190 if (s) comboStart->setText(strStart); 190 if (s) comboStart->setText(strStart);
191 if (e) comboEnd->setText(strEnd); 191 if (e) comboEnd->setText(strEnd);
192} 192}
193 193
194void DateEntry::init() 194void DateEntry::init()
195{ 195{
196 comboDescription->setInsertionPolicy(QComboBox::AtCurrent); 196 comboDescription->setInsertionPolicy(QComboBox::AtCurrent);
197 comboLocation->setInsertionPolicy(QComboBox::AtCurrent); 197 comboLocation->setInsertionPolicy(QComboBox::AtCurrent);
198 198
199 initCombos(); 199 initCombos();
200 QPopupMenu *m1 = new QPopupMenu( this ); 200 QPopupMenu *m1 = new QPopupMenu( this );
201 startPicker = new DateBookMonth( m1, 0, TRUE ); 201 startPicker = new DateBookMonth( m1, 0, TRUE );
202 m1->insertItem( startPicker ); 202 m1->insertItem( startPicker );
203 buttonStart->setPopup( m1 ); 203 buttonStart->setPopup( m1 );
204 connect( startPicker, SIGNAL( dateClicked( int, int, int ) ), 204 connect( startPicker, SIGNAL( dateClicked( int, int, int ) ),
205 this, SLOT( startDateChanged( int, int, int ) ) ); 205 this, SLOT( startDateChanged( int, int, int ) ) );
206 206
207 //Let start button change both start and end dates 207 //Let start button change both start and end dates
208 connect( startPicker, SIGNAL( dateClicked( int, int, int ) ), 208 connect( startPicker, SIGNAL( dateClicked( int, int, int ) ),
209 this, SLOT( endDateChanged( int, int, int ) ) ); 209 this, SLOT( endDateChanged( int, int, int ) ) );
210 connect( qApp, SIGNAL( clockChanged( bool ) ), 210 connect( qApp, SIGNAL( clockChanged( bool ) ),
211 this, SLOT( slotChangeClock( bool ) ) ); 211 this, SLOT( slotChangeClock( bool ) ) );
212 connect( qApp, SIGNAL(weekChanged(bool)), 212 connect( qApp, SIGNAL(weekChanged(bool)),
213 this, SLOT(slotChangeStartOfWeek(bool)) ); 213 this, SLOT(slotChangeStartOfWeek(bool)) );
214 214
215 connect( editNote, SIGNAL(clicked()), 215 connect( editNote, SIGNAL(clicked()),
216 this, SLOT(slotEditNote()) ); 216 this, SLOT(slotEditNote()) );
217 217
218 QPopupMenu *m2 = new QPopupMenu( this ); 218 QPopupMenu *m2 = new QPopupMenu( this );
219 endPicker = new DateBookMonth( m2, 0, TRUE ); 219 endPicker = new DateBookMonth( m2, 0, TRUE );
220 m2->insertItem( endPicker ); 220 m2->insertItem( endPicker );
221 buttonEnd->setPopup( m2 ); 221 buttonEnd->setPopup( m2 );
222 connect( endPicker, SIGNAL( dateClicked( int, int, int ) ), 222 connect( endPicker, SIGNAL( dateClicked( int, int, int ) ),
223 this, SLOT( endDateChanged( int, int, int ) ) ); 223 this, SLOT( endDateChanged( int, int, int ) ) );
224 224
225 connect(timePickerStart, SIGNAL( timeChanged(const QTime &) ), 225 connect(timePickerStart, SIGNAL( timeChanged(const QTime &) ),
226 this, SLOT( startTimePicked(const QTime &) )); 226 this, SLOT( startTimePicked(const QTime &) ));
227 // install eventFilters 227 // install eventFilters
228 comboEnd->installEventFilter( this ); 228 comboEnd->installEventFilter( this );
229 comboStart->installEventFilter( this ); 229 comboStart->installEventFilter( this );
230} 230}
231 231
232/* 232/*
233 * Destroys the object and frees any allocated resources 233 * Destroys the object and frees any allocated resources
234 */ 234 */
235DateEntry::~DateEntry() 235DateEntry::~DateEntry()
236{ 236{
237 // no need to delete child widgets, Qt does it all for us 237 // no need to delete child widgets, Qt does it all for us
238 //cout << "Del: " << comboStart->currentText() << endl; 238 //cout << "Del: " << comboStart->currentText() << endl;
239} 239}
240 240
241/* 241/*
242 * public slot 242 * public slot
243 */ 243 */
244 244
245void DateEntry::slotEditNote() { 245void DateEntry::slotEditNote() {
246 QString s; 246 QString s;
247 s.sprintf("<B>%d/%d</B> ", startDate.day(), startDate.month()); 247 s = "<B>"+ TimeString::longDateString( startDate ) + "</B>";
248// s.sprintf("<B>%d/%d</B> ", startDate.day(), startDate.month());
248 NoteEntry noteDlg(s+comboDescription->currentText(), noteStr, 249 NoteEntry noteDlg(s+comboDescription->currentText(), noteStr,
249 this,0,TRUE); 250 this,0,TRUE);
250 251
251#if defined(Q_WS_QWS) || defined(_WS_QWS_) 252#if defined(Q_WS_QWS) || defined(_WS_QWS_)
252 noteDlg.showMaximized(); 253 noteDlg.showMaximized();
253#endif 254#endif
254 if (noteDlg.exec() ) { 255 if (noteDlg.exec() ) {
255 noteStr=noteDlg.note->text(); 256 noteStr=noteDlg.note->text();
256 } 257 }
257 258
258} 259}
259 260
260void DateEntry::endDateChanged( int y, int m, int d ) 261void DateEntry::endDateChanged( int y, int m, int d )
261{ 262{
262 endDate.setYMD( y, m, d ); 263 endDate.setYMD( y, m, d );
263 if ( endDate < startDate ) { 264 if ( endDate < startDate ) {
264 endDate = startDate; 265 endDate = startDate;
265 } 266 }
266 267
267 buttonEnd->setText( TimeString::shortDate( endDate ) ); 268 buttonEnd->setText( TimeString::shortDate( endDate ) );
268 269
269 endPicker->setDate( endDate.year(), endDate.month(), endDate.day() ); 270 endPicker->setDate( endDate.year(), endDate.month(), endDate.day() );
270} 271}
271 272
272static QTime parseTime( const QString& s, bool ampm ) 273static QTime parseTime( const QString& s, bool ampm )
273{ 274{
274 QTime tmpTime; 275 QTime tmpTime;
275 QStringList l = QStringList::split( ':', s ); 276 QStringList l = QStringList::split( ':', s );
276 int hour = l[0].toInt(); 277 int hour = l[0].toInt();
277 if ( ampm ) { 278 if ( ampm ) {
278 int i=0; 279 int i=0;
279 while (i<int(l[1].length()) && l[1][i]>='0' && l[1][i]<='9') 280 while (i<int(l[1].length()) && l[1][i]>='0' && l[1][i]<='9')
280 i++; 281 i++;
281 QString digits = l[1].left(i); 282 QString digits = l[1].left(i);
282 if ( l[1].contains( "PM", FALSE ) ) { 283 if ( l[1].contains( "PM", FALSE ) ) {
283 if ( hour != 12 ) 284 if ( hour != 12 )
284 hour += 12; 285 hour += 12;
285 } else { 286 } else {
286 if ( hour == 12 ) 287 if ( hour == 12 )
287 hour = 0; 288 hour = 0;
288 } 289 }
289 l[1] = digits; 290 l[1] = digits;
290 } 291 }
291 int minute = l[1].toInt(); 292 int minute = l[1].toInt();
292 if ( minute > 59 ) 293 if ( minute > 59 )
293 minute = 59; 294 minute = 59;
294 else if ( minute < 0 ) 295 else if ( minute < 0 )
295 minute = 0; 296 minute = 0;
296 if ( hour > 23 ) { 297 if ( hour > 23 ) {
297 hour = 23; 298 hour = 23;
298 minute = 59; 299 minute = 59;
299 } else if ( hour < 0 ) 300 } else if ( hour < 0 )
300 hour = 0; 301 hour = 0;
301 tmpTime.setHMS( hour, minute, 0 ); 302 tmpTime.setHMS( hour, minute, 0 );
302 return tmpTime; 303 return tmpTime;
303} 304}
304 305
305/* 306/*
306 * public slot 307 * public slot
307 */ 308 */
308void DateEntry::endTimeChanged( const QString &s ) 309void DateEntry::endTimeChanged( const QString &s )
309{ 310{
310 endTimeChanged( parseTime(s,ampm) ); 311 endTimeChanged( parseTime(s,ampm) );
311} 312}
312 313
313void DateEntry::endTimeChanged( const QTime &t ) { 314void DateEntry::endTimeChanged( const QTime &t ) {
314 if ( endDate > startDate || t >= startTime ) { 315 if ( endDate > startDate || t >= startTime ) {
315 endTime = t; 316 endTime = t;
316 } else { 317 } else {
317 endTime = startTime; 318 endTime = startTime;
318 //comboEnd->setCurrentItem( comboStart->currentItem() ); 319 //comboEnd->setCurrentItem( comboStart->currentItem() );
319 } 320 }
320 timePickerStart->setHour(endTime.hour()); 321 timePickerStart->setHour(endTime.hour());
321 timePickerStart->setMinute(endTime.minute()); 322 timePickerStart->setMinute(endTime.minute());
322} 323}
323 324
324/* 325/*
325 * public slot 326 * public slot
326 */ 327 */
327void DateEntry::startDateChanged( int y, int m, int d ) 328void DateEntry::startDateChanged( int y, int m, int d )
328{ 329{
329 QDate prev = startDate; 330 QDate prev = startDate;
330 startDate.setYMD( y, m, d ); 331 startDate.setYMD( y, m, d );
331 if ( rp.type == Event::Weekly && 332 if ( rp.type == Event::Weekly &&
332 startDate.dayOfWeek() != prev.dayOfWeek() ) { 333 startDate.dayOfWeek() != prev.dayOfWeek() ) {
333 // if we change the start of a weekly repeating event 334 // if we change the start of a weekly repeating event
334 // set the repeating day appropriately 335 // set the repeating day appropriately
335 char mask = 1 << (prev.dayOfWeek()-1); 336 char mask = 1 << (prev.dayOfWeek()-1);
336 rp.days &= (~mask); 337 rp.days &= (~mask);
337 rp.days |= 1 << (startDate.dayOfWeek()-1); 338 rp.days |= 1 << (startDate.dayOfWeek()-1);
338 } 339 }
339 340
340 buttonStart->setText( TimeString::shortDate( startDate ) ); 341 buttonStart->setText( TimeString::shortDate( startDate ) );
341 342
342 // our pickers must be reset... 343 // our pickers must be reset...
343 startPicker->setDate( y, m, d ); 344 startPicker->setDate( y, m, d );
344 endPicker->setDate( y, m, d ); 345 endPicker->setDate( y, m, d );
345} 346}
346 347
347/* 348/*
348 * public slot 349 * public slot
349 */ 350 */
350void DateEntry::startTimeEdited( const QString &s ) 351void DateEntry::startTimeEdited( const QString &s )
351{ 352{
352 startTimeChanged(parseTime(s,ampm)); 353 startTimeChanged(parseTime(s,ampm));
353 updateTimeEdit(false,true); 354 updateTimeEdit(false,true);
354 timePickerStart->setHour(startTime.hour()); 355 timePickerStart->setHour(startTime.hour());
355 timePickerStart->setMinute(startTime.minute()); 356 timePickerStart->setMinute(startTime.minute());
356} 357}
357 358
358void DateEntry::startTimeChanged( const QTime &t ) 359void DateEntry::startTimeChanged( const QTime &t )
359{ 360{
360 int duration=startTime.secsTo(endTime); 361 int duration=startTime.secsTo(endTime);
361 startTime = t; 362 startTime = t;
362 endTime=t.addSecs(duration); 363 endTime=t.addSecs(duration);
363} 364}
364void DateEntry::startTimePicked( const QTime &t ) { 365void DateEntry::startTimePicked( const QTime &t ) {
365 if(m_showStart ){ 366 if(m_showStart ){
366 startTimeChanged(t); 367 startTimeChanged(t);
367 updateTimeEdit(true,true); 368 updateTimeEdit(true,true);
368 }else{ 369 }else{
369 endTimeChanged(t); 370 endTimeChanged(t);
370 updateTimeEdit(false, true ); 371 updateTimeEdit(false, true );
371 } 372 }
372} 373}
373 374
374/* 375/*
375 * public slot 376 * public slot
376 */ 377 */
377void DateEntry::typeChanged( const QString &s ) 378void DateEntry::typeChanged( const QString &s )
378{ 379{
379 bool b = s != "All Day"; 380 bool b = s != "All Day";
380 buttonStart->setEnabled( b ); 381 buttonStart->setEnabled( b );
381 comboStart->setEnabled( b ); 382 comboStart->setEnabled( b );
382 comboEnd->setEnabled( b ); 383 comboEnd->setEnabled( b );
383} 384}
384 385
385void DateEntry::slotRepeat() 386void DateEntry::slotRepeat()
386{ 387{
387 // Work around for compiler Bug.. 388 // Work around for compiler Bug..
388 RepeatEntry *e; 389 RepeatEntry *e;
389 390
390 // it is better in my opinion to just grab this from the mother, 391 // it is better in my opinion to just grab this from the mother,
391 // since, this dialog doesn't need to keep track of it... 392 // since, this dialog doesn't need to keep track of it...
392 if ( rp.type != Event::NoRepeat ) 393 if ( rp.type != Event::NoRepeat )
393 e = new RepeatEntry( startWeekOnMonday, rp, startDate, this); 394 e = new RepeatEntry( startWeekOnMonday, rp, startDate, this);
394 else 395 else
395 e = new RepeatEntry( startWeekOnMonday, startDate, this ); 396 e = new RepeatEntry( startWeekOnMonday, startDate, this );
396 397
397#if defined(Q_WS_QWS) || defined(_WS_QWS_) 398#if defined(Q_WS_QWS) || defined(_WS_QWS_)
398 e->showMaximized(); 399 e->showMaximized();
399#endif 400#endif
400 if ( e->exec() ) { 401 if ( e->exec() ) {
401 rp = e->repeatPattern(); 402 rp = e->repeatPattern();
402 setRepeatLabel(); 403 setRepeatLabel();
403 } 404 }
404} 405}
405 406
406void DateEntry::slotChangeStartOfWeek( bool onMonday ) 407void DateEntry::slotChangeStartOfWeek( bool onMonday )
407{ 408{
408 startWeekOnMonday = onMonday; 409 startWeekOnMonday = onMonday;
409} 410}
410 411
411Event DateEntry::event() 412Event DateEntry::event()
412{ 413{
413 Event ev; 414 Event ev;
414 Event::SoundTypeChoice st; 415 Event::SoundTypeChoice st;
415 ev.setDescription( comboDescription->currentText() ); 416 ev.setDescription( comboDescription->currentText() );
416 ev.setLocation( comboLocation->currentText() ); 417 ev.setLocation( comboLocation->currentText() );
417 ev.setCategories( comboCategory->currentCategories() ); 418 ev.setCategories( comboCategory->currentCategories() );
418 ev.setType( checkAllDay->isChecked() ? Event::AllDay : Event::Normal ); 419 ev.setType( checkAllDay->isChecked() ? Event::AllDay : Event::Normal );
419 if ( startDate > endDate ) { 420 if ( startDate > endDate ) {
420 QDate tmp = endDate; 421 QDate tmp = endDate;
421 endDate = startDate; 422 endDate = startDate;
422 startDate = tmp; 423 startDate = tmp;
423 } 424 }
424 425
425 // This is now done in the changed slots 426 // This is now done in the changed slots
426 // startTime = parseTime( comboStart->text(), ampm ); 427 // startTime = parseTime( comboStart->text(), ampm );
427 //endTime = parseTime( comboEnd->text(), ampm ); 428 //endTime = parseTime( comboEnd->text(), ampm );
428 429
429 if ( startTime > endTime && endDate == startDate ) { 430 if ( startTime > endTime && endDate == startDate ) {
430 QTime tmp = endTime; 431 QTime tmp = endTime;
431 endTime = startTime; 432 endTime = startTime;
432 startTime = tmp; 433 startTime = tmp;
433 } 434 }
434 // don't set the time if theres no need too 435 // don't set the time if theres no need too
435 if ( ev.type() == Event::AllDay ) { 436 if ( ev.type() == Event::AllDay ) {
436 startTime.setHMS( 0, 0, 0 ); 437 startTime.setHMS( 0, 0, 0 );
437 endTime.setHMS( 23, 59, 59 ); 438 endTime.setHMS( 23, 59, 59 );
438 } 439 }
439 440
440 // adjust start and end times based on timezone 441 // adjust start and end times based on timezone
441 QDateTime start( startDate, startTime ); 442 QDateTime start( startDate, startTime );
442 QDateTime end( endDate, endTime ); 443 QDateTime end( endDate, endTime );
443 time_t start_utc, end_utc; 444 time_t start_utc, end_utc;
444 445
445// qDebug( "tz: %s", timezone->currentZone().latin1() ); 446// qDebug( "tz: %s", timezone->currentZone().latin1() );
446 447
447 // get real timezone 448 // get real timezone
448 QString realTZ; 449 QString realTZ;
449 realTZ = QString::fromLocal8Bit( getenv("TZ") ); 450 realTZ = QString::fromLocal8Bit( getenv("TZ") );
450 451
451 // set timezone 452 // set timezone
452 if ( setenv( "TZ", timezone->currentZone(), true ) != 0 ) 453 if ( setenv( "TZ", timezone->currentZone(), true ) != 0 )
453 qWarning( "There was a problem setting the timezone." ); 454 qWarning( "There was a problem setting the timezone." );
454 455
455 // convert to UTC based on selected TZ (calling tzset internally) 456 // convert to UTC based on selected TZ (calling tzset internally)
456 start_utc = TimeConversion::toUTC( start ); 457 start_utc = TimeConversion::toUTC( start );
457 end_utc = TimeConversion::toUTC( end ); 458 end_utc = TimeConversion::toUTC( end );
458 459
459 // done playing around... put it all back 460 // done playing around... put it all back
460 unsetenv( "TZ" ); 461 unsetenv( "TZ" );
461 if ( !realTZ.isNull() ) 462 if ( !realTZ.isNull() )
462 if ( setenv( "TZ", realTZ, true ) != 0 ) 463 if ( setenv( "TZ", realTZ, true ) != 0 )
463 qWarning( "There was a problem setting the timezone." ); 464 qWarning( "There was a problem setting the timezone." );
464 465
465 // convert UTC to local time (calling tzset internally) 466 // convert UTC to local time (calling tzset internally)
466 ev.setStart( TimeConversion::fromUTC( start_utc ) ); 467 ev.setStart( TimeConversion::fromUTC( start_utc ) );
467 ev.setEnd( TimeConversion::fromUTC( end_utc ) ); 468 ev.setEnd( TimeConversion::fromUTC( end_utc ) );
468 469
469 // we only have one type of sound at the moment... LOUD!!! 470 // we only have one type of sound at the moment... LOUD!!!
470 if ( comboSound->currentItem() != 0 ) 471 if ( comboSound->currentItem() != 0 )
471 st = Event::Loud; 472 st = Event::Loud;
472 else 473 else
473 st = Event::Silent; 474 st = Event::Silent;
474 ev.setAlarm( checkAlarm->isChecked(), spinAlarm->value(), st ); 475 ev.setAlarm( checkAlarm->isChecked(), spinAlarm->value(), st );
475 if ( rp.type != Event::NoRepeat ) 476 if ( rp.type != Event::NoRepeat )
476 ev.setRepeat( TRUE, rp ); 477 ev.setRepeat( TRUE, rp );
477 ev.setNotes( noteStr ); 478 ev.setNotes( noteStr );
478 479
479 //cout << "Start: " << comboStart->currentText() << endl; 480 //cout << "Start: " << comboStart->currentText() << endl;
480 481
481 return ev; 482 return ev;
482} 483}
483 484
484void DateEntry::setRepeatLabel() 485void DateEntry::setRepeatLabel()
485{ 486{
486 487
487 switch( rp.type ) { 488 switch( rp.type ) {
488 case Event::Daily: 489 case Event::Daily:
489 cmdRepeat->setText( tr("Daily...") ); 490 cmdRepeat->setText( tr("Daily...") );
490 break; 491 break;
491 case Event::Weekly: 492 case Event::Weekly:
492 cmdRepeat->setText( tr("Weekly...") ); 493 cmdRepeat->setText( tr("Weekly...") );
493 break; 494 break;
494 case Event::MonthlyDay: 495 case Event::MonthlyDay:
495 case Event::MonthlyDate: 496 case Event::MonthlyDate:
496 cmdRepeat->setText( tr("Monthly...") ); 497 cmdRepeat->setText( tr("Monthly...") );
497 break; 498 break;
498 case Event::Yearly: 499 case Event::Yearly:
499 cmdRepeat->setText( tr("Yearly...") ); 500 cmdRepeat->setText( tr("Yearly...") );
500 break; 501 break;
501 default: 502 default:
502 cmdRepeat->setText( tr("No Repeat...") ); 503 cmdRepeat->setText( tr("No Repeat...") );
503 } 504 }
504} 505}
505 506
506void DateEntry::setAlarmEnabled( bool alarmPreset, int presetTime, Event::SoundTypeChoice sound ) 507void DateEntry::setAlarmEnabled( bool alarmPreset, int presetTime, Event::SoundTypeChoice sound )
507{ 508{
508 checkAlarm->setChecked( alarmPreset ); 509 checkAlarm->setChecked( alarmPreset );
509 spinAlarm->setValue( presetTime ); 510 spinAlarm->setValue( presetTime );
510 if ( sound != Event::Silent ) 511 if ( sound != Event::Silent )
511 comboSound->setCurrentItem( 1 ); 512 comboSound->setCurrentItem( 1 );
512 else 513 else
513 comboSound->setCurrentItem( 0 ); 514 comboSound->setCurrentItem( 0 );
514} 515}
515 516
516void DateEntry::initCombos() 517void DateEntry::initCombos()
517{ 518{
518 /* 519 /*
519 comboStart->clear(); 520 comboStart->clear();
520 comboEnd->clear(); 521 comboEnd->clear();
521 if ( ampm ) { 522 if ( ampm ) {
522 for ( int i = 0; i < 24; i++ ) { 523 for ( int i = 0; i < 24; i++ ) {
523 if ( i == 0 ) { 524 if ( i == 0 ) {
524 comboStart->insertItem( "12:00 AM" ); 525 comboStart->insertItem( "12:00 AM" );
525 comboStart->insertItem( "12:30 AM" ); 526 comboStart->insertItem( "12:30 AM" );
526 comboEnd->insertItem( "12:00 AM" ); 527 comboEnd->insertItem( "12:00 AM" );
527 comboEnd->insertItem( "12:30 AM" ); 528 comboEnd->insertItem( "12:30 AM" );
528 } else if ( i == 12 ) { 529 } else if ( i == 12 ) {
529 comboStart->insertItem( "12:00 PM" ); 530 comboStart->insertItem( "12:00 PM" );
530 comboStart->insertItem( "12:30 PM" ); 531 comboStart->insertItem( "12:30 PM" );
531 comboEnd->insertItem( "12:00 PM" ); 532 comboEnd->insertItem( "12:00 PM" );
532 comboEnd->insertItem( "12:30 PM" ); 533 comboEnd->insertItem( "12:30 PM" );
533 } else if ( i > 12 ) { 534 } else if ( i > 12 ) {
534 comboStart->insertItem( QString::number( i - 12 ) + ":00 PM" ); 535 comboStart->insertItem( QString::number( i - 12 ) + ":00 PM" );
535 comboStart->insertItem( QString::number( i - 12 ) + ":30 PM" ); 536 comboStart->insertItem( QString::number( i - 12 ) + ":30 PM" );
536 comboEnd->insertItem( QString::number( i - 12 ) + ":00 PM" ); 537 comboEnd->insertItem( QString::number( i - 12 ) + ":00 PM" );
537 comboEnd->insertItem( QString::number( i - 12 ) + ":30 PM" ); 538 comboEnd->insertItem( QString::number( i - 12 ) + ":30 PM" );
538 } else { 539 } else {
539 comboStart->insertItem( QString::number( i) + ":00 AM" ); 540 comboStart->insertItem( QString::number( i) + ":00 AM" );
540 comboStart->insertItem( QString::number( i ) + ":30 AM" ); 541 comboStart->insertItem( QString::number( i ) + ":30 AM" );
541 comboEnd->insertItem( QString::number( i ) + ":00 AM" ); 542 comboEnd->insertItem( QString::number( i ) + ":00 AM" );
542 comboEnd->insertItem( QString::number( i ) + ":30 AM" ); 543 comboEnd->insertItem( QString::number( i ) + ":30 AM" );
543 } 544 }
544 } 545 }
545 } else { 546 } else {
546 for ( int i = 0; i < 24; i++ ) { 547 for ( int i = 0; i < 24; i++ ) {
547 if ( i < 10 ) { 548 if ( i < 10 ) {
548 comboStart->insertItem( QString("0") 549 comboStart->insertItem( QString("0")
549 + QString::number(i) + ":00" ); 550 + QString::number(i) + ":00" );
550 comboStart->insertItem( QString("0") 551 comboStart->insertItem( QString("0")
551 + QString::number(i) + ":30" ); 552 + QString::number(i) + ":30" );
552 comboEnd->insertItem( QString("0") 553 comboEnd->insertItem( QString("0")
553 + QString::number(i) + ":00" ); 554 + QString::number(i) + ":00" );
554 comboEnd->insertItem( QString("0") 555 comboEnd->insertItem( QString("0")
555 + QString::number(i) + ":30" ); 556 + QString::number(i) + ":30" );
556 } else { 557 } else {
557 comboStart->insertItem( QString::number(i) + ":00" ); 558 comboStart->insertItem( QString::number(i) + ":00" );
558 comboStart->insertItem( QString::number(i) + ":30" ); 559 comboStart->insertItem( QString::number(i) + ":30" );
559 comboEnd->insertItem( QString::number(i) + ":00" ); 560 comboEnd->insertItem( QString::number(i) + ":00" );
560 comboEnd->insertItem( QString::number(i) + ":30" ); 561 comboEnd->insertItem( QString::number(i) + ":30" );
561 } 562 }
562 } 563 }
563 } 564 }
564 */ 565 */
565} 566}
566 567
567void DateEntry::slotChangeClock( bool whichClock ) 568void DateEntry::slotChangeClock( bool whichClock )
568{ 569{
569 ampm = whichClock; 570 ampm = whichClock;
570 initCombos(); 571 initCombos();
571 setDates( QDateTime( startDate, startTime ), QDateTime( endDate, endTime ) ); 572 setDates( QDateTime( startDate, startTime ), QDateTime( endDate, endTime ) );
572} 573}
573 574