Diffstat (limited to 'core/pim/datebook/dateentryimpl.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/pim/datebook/dateentryimpl.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/core/pim/datebook/dateentryimpl.cpp b/core/pim/datebook/dateentryimpl.cpp index 018bb5a..57bcd89 100644 --- a/core/pim/datebook/dateentryimpl.cpp +++ b/core/pim/datebook/dateentryimpl.cpp | |||
@@ -1,407 +1,407 @@ | |||
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/tzselect.h> | 27 | #include <qpe/tzselect.h> |
28 | 28 | ||
29 | #include <qlineedit.h> | 29 | #include <qlineedit.h> |
30 | #include <qspinbox.h> | 30 | #include <qspinbox.h> |
31 | 31 | ||
32 | #include <opie/otimepicker.h> | 32 | #include <opie/otimepicker.h> |
33 | #include "onoteedit.h" | 33 | #include "onoteedit.h" |
34 | 34 | ||
35 | #include <stdlib.h> | 35 | #include <stdlib.h> |
36 | #include <stdio.h> | 36 | #include <stdio.h> |
37 | 37 | ||
38 | /* | 38 | /* |
39 | * Constructs a DateEntry which is a child of 'parent', with the | 39 | * Constructs a DateEntry which is a child of 'parent', with the |
40 | * name 'name' and widget flags set to 'f' | 40 | * name 'name' and widget flags set to 'f' |
41 | * | 41 | * |
42 | * The dialog will by default be modeless, unless you set 'modal' to | 42 | * The dialog will by default be modeless, unless you set 'modal' to |
43 | * TRUE to construct a modal dialog. | 43 | * TRUE to construct a modal dialog. |
44 | */ | 44 | */ |
45 | 45 | ||
46 | DateEntry::DateEntry( bool startOnMonday, const QDateTime &start, | 46 | DateEntry::DateEntry( bool startOnMonday, const QDateTime &start, |
47 | const QDateTime &end, bool whichClock, QWidget* parent, | 47 | const QDateTime &end, bool whichClock, QWidget* parent, |
48 | const char* name ) | 48 | const char* name ) |
49 | : DateEntryBase( parent, name ), | 49 | : DateEntryBase( parent, name ), |
50 | ampm( whichClock ), | 50 | ampm( whichClock ), |
51 | startWeekOnMonday( startOnMonday ), | 51 | startWeekOnMonday( startOnMonday ), |
52 | m_showStart(true) | 52 | m_showStart(true) |
53 | { | 53 | { |
54 | init(); | 54 | init(); |
55 | setDates(start,end); | 55 | setDates(start,end); |
56 | setFocusProxy(comboDescription); | 56 | setFocusProxy(comboDescription); |
57 | } | 57 | } |
58 | 58 | ||
59 | bool DateEntry::eventFilter(QObject *obj, QEvent *ev ) | 59 | bool DateEntry::eventFilter(QObject *obj, QEvent *ev ) |
60 | { | 60 | { |
61 | if( ev->type() == QEvent::FocusIn ){ | 61 | if( ev->type() == QEvent::FocusIn ){ |
62 | if( obj == comboStart ){ | 62 | if( obj == comboStart ){ |
63 | timePickerStart->setHour(startTime.hour()); | 63 | timePickerStart->setHour(startTime.hour()); |
64 | timePickerStart->setMinute(startTime.minute()); | 64 | timePickerStart->setMinute(startTime.minute()); |
65 | TimePickerLabel->setText( tr("Start Time" ) ); | 65 | TimePickerLabel->setText( tr("Start Time" ) ); |
66 | m_showStart= true; | 66 | m_showStart= true; |
67 | }else if( obj == comboEnd ){ | 67 | }else if( obj == comboEnd ){ |
68 | timePickerStart->setHour(endTime.hour()); | 68 | timePickerStart->setHour(endTime.hour()); |
69 | timePickerStart->setMinute(endTime.minute()); | 69 | timePickerStart->setMinute(endTime.minute()); |
70 | TimePickerLabel->setText( tr("End Time") ); | 70 | TimePickerLabel->setText( tr("End Time") ); |
71 | m_showStart = false; | 71 | m_showStart = false; |
72 | } | 72 | } |
73 | } else if( ev->type() == QEvent::FocusOut ){ | 73 | } else if( ev->type() == QEvent::FocusOut ){ |
74 | // if( obj == comboEnd ){ | 74 | // if( obj == comboEnd ){ |
75 | // QString s; | 75 | // QString s; |
76 | // s.sprintf("%.2d:%.2d",endTime.hour(), endTime.minute()); | 76 | // s.sprintf("%.2d:%.2d",endTime.hour(), endTime.minute()); |
77 | // comboEnd->setText(s); | 77 | // comboEnd->setText(s); |
78 | // } | 78 | // } |
79 | // else if( obj == comboStart ){ | 79 | // else if( obj == comboStart ){ |
80 | // QString s; | 80 | // QString s; |
81 | // s.sprintf("%.2d:%.2d",startTime.hour(), startTime.minute()); | 81 | // s.sprintf("%.2d:%.2d",startTime.hour(), startTime.minute()); |
82 | // comboStart->setText(s); | 82 | // comboStart->setText(s); |
83 | // } | 83 | // } |
84 | } | 84 | } |
85 | 85 | ||
86 | return false; | 86 | return false; |
87 | } | 87 | } |
88 | 88 | ||
89 | static void addOrPick( QComboBox* combo, const QString& t ) | 89 | static void addOrPick( QComboBox* combo, const QString& t ) |
90 | { | 90 | { |
91 | // Pick an item if one excists | 91 | // Pick an item if one excists |
92 | for (int i=0; i<combo->count(); i++) { | 92 | for (int i=0; i<combo->count(); i++) { |
93 | if ( combo->text(i) == t ) { | 93 | if ( combo->text(i) == t ) { |
94 | combo->setCurrentItem(i); | 94 | combo->setCurrentItem(i); |
95 | return; | 95 | return; |
96 | } | 96 | } |
97 | } | 97 | } |
98 | 98 | ||
99 | // Else add one | 99 | // Else add one |
100 | combo->insertItem(t); | 100 | combo->insertItem(t); |
101 | combo->setCurrentItem(combo->count()-1); | 101 | combo->setCurrentItem(combo->count()-1); |
102 | } | 102 | } |
103 | 103 | ||
104 | DateEntry::DateEntry( bool startOnMonday, const Event &event, bool whichClock, | 104 | DateEntry::DateEntry( bool startOnMonday, const Event &event, bool whichClock, |
105 | QWidget* parent, const char* name ) | 105 | QWidget* parent, const char* name ) |
106 | : DateEntryBase( parent, name ), | 106 | : DateEntryBase( parent, name ), |
107 | ampm( whichClock ), | 107 | ampm( whichClock ), |
108 | startWeekOnMonday( startOnMonday ), | 108 | startWeekOnMonday( startOnMonday ), |
109 | m_showStart(true) | 109 | m_showStart(true) |
110 | 110 | ||
111 | { | 111 | { |
112 | init(); | 112 | init(); |
113 | setDates(event.start(),event.end()); | 113 | setDates(event.start(),event.end()); |
114 | comboCategory->setCategories( event.categories(), "Calendar", tr("Calendar") ); | 114 | comboCategory->setCategories( event.categories(), "Calendar", tr("Calendar") ); |
115 | if(!event.description().isEmpty()) | 115 | if(!event.description().isEmpty()) |
116 | addOrPick( comboDescription, event.description() ); | 116 | addOrPick( comboDescription, event.description() ); |
117 | if(!event.location().isEmpty()) | 117 | if(!event.location().isEmpty()) |
118 | addOrPick( comboLocation, event.location() ); | 118 | addOrPick( comboLocation, event.location() ); |
119 | checkAlarm->setChecked( event.hasAlarm() ); | 119 | checkAlarm->setChecked( event.hasAlarm() ); |
120 | checkAllDay->setChecked( event.type() == Event::AllDay ); | 120 | checkAllDay->setChecked( event.type() == Event::AllDay ); |
121 | if(!event.notes().isEmpty()) noteStr=event.notes(); | 121 | if(!event.notes().isEmpty()) noteStr=event.notes(); |
122 | else noteStr=""; | 122 | else noteStr=""; |
123 | spinAlarm->setValue(event.alarmTime()); | 123 | spinAlarm->setValue(event.alarmTime()); |
124 | if ( event.alarmSound() != Event::Silent ) | 124 | if ( event.alarmSound() != Event::Silent ) |
125 | comboSound->setCurrentItem( 1 ); | 125 | comboSound->setCurrentItem( 1 ); |
126 | if ( event.hasRepeat() ) { | 126 | if ( event.hasRepeat() ) { |
127 | rp = event.repeatPattern(); | 127 | rp = event.repeatPattern(); |
128 | cmdRepeat->setText( tr("Repeat...") ); | 128 | cmdRepeat->setText( tr("Repeat...") ); |
129 | } | 129 | } |
130 | setRepeatLabel(); | 130 | setRepeatLabel(); |
131 | } | 131 | } |
132 | 132 | ||
133 | void DateEntry::setDates( const QDateTime& s, const QDateTime& e ) | 133 | void DateEntry::setDates( const QDateTime& s, const QDateTime& e ) |
134 | { | 134 | { |
135 | startDate = s.date(); | 135 | startDate = s.date(); |
136 | endDate = e.date(); | 136 | endDate = e.date(); |
137 | startTime = s.time(); | 137 | startTime = s.time(); |
138 | endTime = e.time(); | 138 | endTime = e.time(); |
139 | 139 | ||
140 | startDateChanged( s.date().year(), s.date().month(), s.date().day() ); | 140 | startDateChanged( s.date().year(), s.date().month(), s.date().day() ); |
141 | endDateChanged( e.date().year(), e.date().month(), e.date().day() ); | 141 | endDateChanged( e.date().year(), e.date().month(), e.date().day() ); |
142 | 142 | ||
143 | updateTimeEdit(true,true); | 143 | updateTimeEdit(true,true); |
144 | } | 144 | } |
145 | 145 | ||
146 | void DateEntry::updateTimeEdit(bool s, bool e) { | 146 | void DateEntry::updateTimeEdit(bool s, bool e) { |
147 | 147 | ||
148 | // Comboboxes | 148 | // Comboboxes |
149 | QString strStart, strEnd; | 149 | QString strStart, strEnd; |
150 | int shour, ehour; | 150 | int shour, ehour; |
151 | if ( ampm ) { | 151 | if ( ampm ) { |
152 | shour = startTime.hour(); | 152 | shour = startTime.hour(); |
153 | ehour = endTime.hour(); | 153 | ehour = endTime.hour(); |
154 | if ( shour >= 12 ) { | 154 | if ( shour >= 12 ) { |
155 | if ( shour > 12 ) | 155 | if ( shour > 12 ) |
156 | shour -= 12; | 156 | shour -= 12; |
157 | strStart.sprintf( "%d:%02d PM", shour, startTime.minute() ); | 157 | strStart.sprintf( "%d:%02d PM", shour, startTime.minute() ); |
158 | } else { | 158 | } else { |
159 | if ( shour == 0 ) | 159 | if ( shour == 0 ) |
160 | shour = 12; | 160 | shour = 12; |
161 | strStart.sprintf( "%d:%02d AM", shour, startTime.minute() ); | 161 | strStart.sprintf( "%d:%02d AM", shour, startTime.minute() ); |
162 | } | 162 | } |
163 | if ( ehour == 24 && endTime.minute() == 0 ) { | 163 | if ( ehour == 24 && endTime.minute() == 0 ) { |
164 | strEnd = "11:59 PM"; // or "midnight" | 164 | strEnd = "11:59 PM"; // or "midnight" |
165 | } else if ( ehour >= 12 ) { | 165 | } else if ( ehour >= 12 ) { |
166 | if ( ehour > 12 ) | 166 | if ( ehour > 12 ) |
167 | ehour -= 12; | 167 | ehour -= 12; |
168 | strEnd.sprintf( "%d:%02d PM", ehour, endTime.minute() ); | 168 | strEnd.sprintf( "%d:%02d PM", ehour, endTime.minute() ); |
169 | } else { | 169 | } else { |
170 | if ( ehour == 0 ) | 170 | if ( ehour == 0 ) |
171 | ehour = 12; | 171 | ehour = 12; |
172 | strEnd.sprintf( "%d:%02d AM", ehour, endTime.minute() ); | 172 | strEnd.sprintf( "%d:%02d AM", ehour, endTime.minute() ); |
173 | } | 173 | } |
174 | } else { | 174 | } else { |
175 | strStart.sprintf( "%02d:%02d", startTime.hour(), startTime.minute() ); | 175 | strStart.sprintf( "%02d:%02d", startTime.hour(), startTime.minute() ); |
176 | strEnd.sprintf( "%02d:%02d", endTime.hour(), endTime.minute() ); | 176 | strEnd.sprintf( "%02d:%02d", endTime.hour(), endTime.minute() ); |
177 | } | 177 | } |
178 | 178 | ||
179 | if (s) comboStart->setText(strStart); | 179 | if (s) comboStart->setText(strStart); |
180 | if (e) comboEnd->setText(strEnd); | 180 | if (e) comboEnd->setText(strEnd); |
181 | } | 181 | } |
182 | 182 | ||
183 | void DateEntry::init() | 183 | void DateEntry::init() |
184 | { | 184 | { |
185 | comboDescription->setInsertionPolicy(QComboBox::AtCurrent); | 185 | comboDescription->setInsertionPolicy(QComboBox::AtCurrent); |
186 | comboLocation->setInsertionPolicy(QComboBox::AtCurrent); | 186 | comboLocation->setInsertionPolicy(QComboBox::AtCurrent); |
187 | 187 | ||
188 | initCombos(); | 188 | initCombos(); |
189 | QPopupMenu *m1 = new QPopupMenu( this ); | 189 | QPopupMenu *m1 = new QPopupMenu( this ); |
190 | startPicker = new DateBookMonth( m1, 0, TRUE ); | 190 | startPicker = new DateBookMonth( m1, 0, TRUE ); |
191 | m1->insertItem( startPicker ); | 191 | m1->insertItem( startPicker ); |
192 | buttonStart->setPopup( m1 ); | 192 | buttonStart->setPopup( m1 ); |
193 | connect( startPicker, SIGNAL( dateClicked( int, int, int ) ), | 193 | connect( startPicker, SIGNAL( dateClicked(int,int,int) ), |
194 | this, SLOT( startDateChanged( int, int, int ) ) ); | 194 | this, SLOT( startDateChanged(int,int,int) ) ); |
195 | 195 | ||
196 | //Let start button change both start and end dates | 196 | //Let start button change both start and end dates |
197 | connect( startPicker, SIGNAL( dateClicked( int, int, int ) ), | 197 | connect( startPicker, SIGNAL( dateClicked(int,int,int) ), |
198 | this, SLOT( endDateChanged( int, int, int ) ) ); | 198 | this, SLOT( endDateChanged(int,int,int) ) ); |
199 | connect( qApp, SIGNAL( clockChanged( bool ) ), | 199 | connect( qApp, SIGNAL( clockChanged(bool) ), |
200 | this, SLOT( slotChangeClock( bool ) ) ); | 200 | this, SLOT( slotChangeClock(bool) ) ); |
201 | connect( qApp, SIGNAL(weekChanged(bool)), | 201 | connect( qApp, SIGNAL(weekChanged(bool)), |
202 | this, SLOT(slotChangeStartOfWeek(bool)) ); | 202 | this, SLOT(slotChangeStartOfWeek(bool)) ); |
203 | 203 | ||
204 | connect( editNote, SIGNAL(clicked()), | 204 | connect( editNote, SIGNAL(clicked()), |
205 | this, SLOT(slotEditNote()) ); | 205 | this, SLOT(slotEditNote()) ); |
206 | 206 | ||
207 | QPopupMenu *m2 = new QPopupMenu( this ); | 207 | QPopupMenu *m2 = new QPopupMenu( this ); |
208 | endPicker = new DateBookMonth( m2, 0, TRUE ); | 208 | endPicker = new DateBookMonth( m2, 0, TRUE ); |
209 | m2->insertItem( endPicker ); | 209 | m2->insertItem( endPicker ); |
210 | buttonEnd->setPopup( m2 ); | 210 | buttonEnd->setPopup( m2 ); |
211 | connect( endPicker, SIGNAL( dateClicked( int, int, int ) ), | 211 | connect( endPicker, SIGNAL( dateClicked(int,int,int) ), |
212 | this, SLOT( endDateChanged( int, int, int ) ) ); | 212 | this, SLOT( endDateChanged(int,int,int) ) ); |
213 | 213 | ||
214 | connect(timePickerStart, SIGNAL( timeChanged(const QTime &) ), | 214 | connect(timePickerStart, SIGNAL( timeChanged(const QTime&) ), |
215 | this, SLOT( startTimePicked(const QTime &) )); | 215 | this, SLOT( startTimePicked(const QTime&) )); |
216 | // install eventFilters | 216 | // install eventFilters |
217 | comboEnd->installEventFilter( this ); | 217 | comboEnd->installEventFilter( this ); |
218 | comboStart->installEventFilter( this ); | 218 | comboStart->installEventFilter( this ); |
219 | } | 219 | } |
220 | 220 | ||
221 | /* | 221 | /* |
222 | * Destroys the object and frees any allocated resources | 222 | * Destroys the object and frees any allocated resources |
223 | */ | 223 | */ |
224 | DateEntry::~DateEntry() | 224 | DateEntry::~DateEntry() |
225 | { | 225 | { |
226 | // no need to delete child widgets, Qt does it all for us | 226 | // no need to delete child widgets, Qt does it all for us |
227 | //cout << "Del: " << comboStart->currentText() << endl; | 227 | //cout << "Del: " << comboStart->currentText() << endl; |
228 | } | 228 | } |
229 | 229 | ||
230 | /* | 230 | /* |
231 | * public slot | 231 | * public slot |
232 | */ | 232 | */ |
233 | 233 | ||
234 | void DateEntry::slotEditNote() { | 234 | void DateEntry::slotEditNote() { |
235 | QString s; | 235 | QString s; |
236 | s = "<B>"+ TimeString::longDateString( startDate ) + "</B>"; | 236 | s = "<B>"+ TimeString::longDateString( startDate ) + "</B>"; |
237 | // s.sprintf("<B>%d/%d</B> ", startDate.day(), startDate.month()); | 237 | // s.sprintf("<B>%d/%d</B> ", startDate.day(), startDate.month()); |
238 | NoteEntry noteDlg(s+comboDescription->currentText(), noteStr, | 238 | NoteEntry noteDlg(s+comboDescription->currentText(), noteStr, |
239 | this,0,TRUE); | 239 | this,0,TRUE); |
240 | 240 | ||
241 | if ( QPEApplication::execDialog( ¬eDlg ) ) { | 241 | if ( QPEApplication::execDialog( ¬eDlg ) ) { |
242 | noteStr=noteDlg.note->text(); | 242 | noteStr=noteDlg.note->text(); |
243 | } | 243 | } |
244 | 244 | ||
245 | } | 245 | } |
246 | 246 | ||
247 | void DateEntry::endDateChanged( int y, int m, int d ) | 247 | void DateEntry::endDateChanged( int y, int m, int d ) |
248 | { | 248 | { |
249 | endDate.setYMD( y, m, d ); | 249 | endDate.setYMD( y, m, d ); |
250 | if ( endDate < startDate ) { | 250 | if ( endDate < startDate ) { |
251 | endDate = startDate; | 251 | endDate = startDate; |
252 | } | 252 | } |
253 | 253 | ||
254 | buttonEnd->setText( TimeString::shortDate( endDate ) ); | 254 | buttonEnd->setText( TimeString::shortDate( endDate ) ); |
255 | 255 | ||
256 | endPicker->setDate( endDate.year(), endDate.month(), endDate.day() ); | 256 | endPicker->setDate( endDate.year(), endDate.month(), endDate.day() ); |
257 | } | 257 | } |
258 | 258 | ||
259 | static QTime parseTime( const QString& s, bool ampm ) | 259 | static QTime parseTime( const QString& s, bool ampm ) |
260 | { | 260 | { |
261 | QTime tmpTime; | 261 | QTime tmpTime; |
262 | QStringList l = QStringList::split( ':', s ); | 262 | QStringList l = QStringList::split( ':', s ); |
263 | int hour = l[0].toInt(); | 263 | int hour = l[0].toInt(); |
264 | if ( ampm ) { | 264 | if ( ampm ) { |
265 | int i=0; | 265 | int i=0; |
266 | while (i<int(l[1].length()) && l[1][i]>='0' && l[1][i]<='9') | 266 | while (i<int(l[1].length()) && l[1][i]>='0' && l[1][i]<='9') |
267 | i++; | 267 | i++; |
268 | QString digits = l[1].left(i); | 268 | QString digits = l[1].left(i); |
269 | if ( l[1].contains( "PM", FALSE ) ) { | 269 | if ( l[1].contains( "PM", FALSE ) ) { |
270 | if ( hour != 12 ) | 270 | if ( hour != 12 ) |
271 | hour += 12; | 271 | hour += 12; |
272 | } else { | 272 | } else { |
273 | if ( hour == 12 ) | 273 | if ( hour == 12 ) |
274 | hour = 0; | 274 | hour = 0; |
275 | } | 275 | } |
276 | l[1] = digits; | 276 | l[1] = digits; |
277 | } | 277 | } |
278 | int minute = l[1].toInt(); | 278 | int minute = l[1].toInt(); |
279 | if ( minute > 59 ) | 279 | if ( minute > 59 ) |
280 | minute = 59; | 280 | minute = 59; |
281 | else if ( minute < 0 ) | 281 | else if ( minute < 0 ) |
282 | minute = 0; | 282 | minute = 0; |
283 | if ( hour > 23 ) { | 283 | if ( hour > 23 ) { |
284 | hour = 23; | 284 | hour = 23; |
285 | minute = 59; | 285 | minute = 59; |
286 | } else if ( hour < 0 ) | 286 | } else if ( hour < 0 ) |
287 | hour = 0; | 287 | hour = 0; |
288 | tmpTime.setHMS( hour, minute, 0 ); | 288 | tmpTime.setHMS( hour, minute, 0 ); |
289 | return tmpTime; | 289 | return tmpTime; |
290 | } | 290 | } |
291 | 291 | ||
292 | /* | 292 | /* |
293 | * public slot | 293 | * public slot |
294 | */ | 294 | */ |
295 | void DateEntry::endTimeChanged( const QString &s ) | 295 | void DateEntry::endTimeChanged( const QString &s ) |
296 | { | 296 | { |
297 | endTimeChanged( parseTime(s,ampm) ); | 297 | endTimeChanged( parseTime(s,ampm) ); |
298 | } | 298 | } |
299 | 299 | ||
300 | void DateEntry::endTimeChanged( const QTime &t ) { | 300 | void DateEntry::endTimeChanged( const QTime &t ) { |
301 | if ( endDate > startDate || t >= startTime ) { | 301 | if ( endDate > startDate || t >= startTime ) { |
302 | endTime = t; | 302 | endTime = t; |
303 | } else { | 303 | } else { |
304 | endTime = startTime; | 304 | endTime = startTime; |
305 | //comboEnd->setCurrentItem( comboStart->currentItem() ); | 305 | //comboEnd->setCurrentItem( comboStart->currentItem() ); |
306 | } | 306 | } |
307 | timePickerStart->setHour(endTime.hour()); | 307 | timePickerStart->setHour(endTime.hour()); |
308 | timePickerStart->setMinute(endTime.minute()); | 308 | timePickerStart->setMinute(endTime.minute()); |
309 | } | 309 | } |
310 | 310 | ||
311 | /* | 311 | /* |
312 | * public slot | 312 | * public slot |
313 | */ | 313 | */ |
314 | void DateEntry::startDateChanged( int y, int m, int d ) | 314 | void DateEntry::startDateChanged( int y, int m, int d ) |
315 | { | 315 | { |
316 | QDate prev = startDate; | 316 | QDate prev = startDate; |
317 | startDate.setYMD( y, m, d ); | 317 | startDate.setYMD( y, m, d ); |
318 | if ( rp.type == Event::Weekly && | 318 | if ( rp.type == Event::Weekly && |
319 | startDate.dayOfWeek() != prev.dayOfWeek() ) { | 319 | startDate.dayOfWeek() != prev.dayOfWeek() ) { |
320 | // if we change the start of a weekly repeating event | 320 | // if we change the start of a weekly repeating event |
321 | // set the repeating day appropriately | 321 | // set the repeating day appropriately |
322 | char mask = 1 << (prev.dayOfWeek()-1); | 322 | char mask = 1 << (prev.dayOfWeek()-1); |
323 | rp.days &= (~mask); | 323 | rp.days &= (~mask); |
324 | rp.days |= 1 << (startDate.dayOfWeek()-1); | 324 | rp.days |= 1 << (startDate.dayOfWeek()-1); |
325 | } | 325 | } |
326 | 326 | ||
327 | buttonStart->setText( TimeString::shortDate( startDate ) ); | 327 | buttonStart->setText( TimeString::shortDate( startDate ) ); |
328 | 328 | ||
329 | // our pickers must be reset... | 329 | // our pickers must be reset... |
330 | startPicker->setDate( y, m, d ); | 330 | startPicker->setDate( y, m, d ); |
331 | endPicker->setDate( y, m, d ); | 331 | endPicker->setDate( y, m, d ); |
332 | } | 332 | } |
333 | 333 | ||
334 | /* | 334 | /* |
335 | * public slot | 335 | * public slot |
336 | */ | 336 | */ |
337 | void DateEntry::startTimeEdited( const QString &s ) | 337 | void DateEntry::startTimeEdited( const QString &s ) |
338 | { | 338 | { |
339 | startTimeChanged(parseTime(s,ampm)); | 339 | startTimeChanged(parseTime(s,ampm)); |
340 | updateTimeEdit(false,true); | 340 | updateTimeEdit(false,true); |
341 | timePickerStart->setHour(startTime.hour()); | 341 | timePickerStart->setHour(startTime.hour()); |
342 | timePickerStart->setMinute(startTime.minute()); | 342 | timePickerStart->setMinute(startTime.minute()); |
343 | } | 343 | } |
344 | 344 | ||
345 | void DateEntry::startTimeChanged( const QTime &t ) | 345 | void DateEntry::startTimeChanged( const QTime &t ) |
346 | { | 346 | { |
347 | int duration=startTime.secsTo(endTime); | 347 | int duration=startTime.secsTo(endTime); |
348 | startTime = t; | 348 | startTime = t; |
349 | endTime=t.addSecs(duration); | 349 | endTime=t.addSecs(duration); |
350 | } | 350 | } |
351 | void DateEntry::startTimePicked( const QTime &t ) { | 351 | void DateEntry::startTimePicked( const QTime &t ) { |
352 | if(m_showStart ){ | 352 | if(m_showStart ){ |
353 | startTimeChanged(t); | 353 | startTimeChanged(t); |
354 | updateTimeEdit(true,true); | 354 | updateTimeEdit(true,true); |
355 | }else{ | 355 | }else{ |
356 | endTimeChanged(t); | 356 | endTimeChanged(t); |
357 | updateTimeEdit(false, true ); | 357 | updateTimeEdit(false, true ); |
358 | } | 358 | } |
359 | } | 359 | } |
360 | 360 | ||
361 | /* | 361 | /* |
362 | * public slot | 362 | * public slot |
363 | */ | 363 | */ |
364 | void DateEntry::typeChanged( const QString &s ) | 364 | void DateEntry::typeChanged( const QString &s ) |
365 | { | 365 | { |
366 | bool b = s != "All Day"; | 366 | bool b = s != "All Day"; |
367 | buttonStart->setEnabled( b ); | 367 | buttonStart->setEnabled( b ); |
368 | comboStart->setEnabled( b ); | 368 | comboStart->setEnabled( b ); |
369 | comboEnd->setEnabled( b ); | 369 | comboEnd->setEnabled( b ); |
370 | } | 370 | } |
371 | 371 | ||
372 | void DateEntry::slotRepeat() | 372 | void DateEntry::slotRepeat() |
373 | { | 373 | { |
374 | // Work around for compiler Bug.. | 374 | // Work around for compiler Bug.. |
375 | RepeatEntry *e; | 375 | RepeatEntry *e; |
376 | 376 | ||
377 | // it is better in my opinion to just grab this from the mother, | 377 | // it is better in my opinion to just grab this from the mother, |
378 | // since, this dialog doesn't need to keep track of it... | 378 | // since, this dialog doesn't need to keep track of it... |
379 | if ( rp.type != Event::NoRepeat ) | 379 | if ( rp.type != Event::NoRepeat ) |
380 | e = new RepeatEntry( startWeekOnMonday, rp, startDate, this); | 380 | e = new RepeatEntry( startWeekOnMonday, rp, startDate, this); |
381 | else | 381 | else |
382 | e = new RepeatEntry( startWeekOnMonday, startDate, this ); | 382 | e = new RepeatEntry( startWeekOnMonday, startDate, this ); |
383 | 383 | ||
384 | if ( QPEApplication::execDialog( e ) ) { | 384 | if ( QPEApplication::execDialog( e ) ) { |
385 | rp = e->repeatPattern(); | 385 | rp = e->repeatPattern(); |
386 | setRepeatLabel(); | 386 | setRepeatLabel(); |
387 | } | 387 | } |
388 | // deleting sounds like a nice idea... | 388 | // deleting sounds like a nice idea... |
389 | delete e; | 389 | delete e; |
390 | } | 390 | } |
391 | 391 | ||
392 | void DateEntry::slotChangeStartOfWeek( bool onMonday ) | 392 | void DateEntry::slotChangeStartOfWeek( bool onMonday ) |
393 | { | 393 | { |
394 | startWeekOnMonday = onMonday; | 394 | startWeekOnMonday = onMonday; |
395 | } | 395 | } |
396 | 396 | ||
397 | Event DateEntry::event() | 397 | Event DateEntry::event() |
398 | { | 398 | { |
399 | Event ev; | 399 | Event ev; |
400 | Event::SoundTypeChoice st; | 400 | Event::SoundTypeChoice st; |
401 | ev.setDescription( comboDescription->currentText() ); | 401 | ev.setDescription( comboDescription->currentText() ); |
402 | ev.setLocation( comboLocation->currentText() ); | 402 | ev.setLocation( comboLocation->currentText() ); |
403 | ev.setCategories( comboCategory->currentCategories() ); | 403 | ev.setCategories( comboCategory->currentCategories() ); |
404 | ev.setType( checkAllDay->isChecked() ? Event::AllDay : Event::Normal ); | 404 | ev.setType( checkAllDay->isChecked() ? Event::AllDay : Event::Normal ); |
405 | if ( startDate > endDate ) { | 405 | if ( startDate > endDate ) { |
406 | QDate tmp = endDate; | 406 | QDate tmp = endDate; |
407 | endDate = startDate; | 407 | endDate = startDate; |