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