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
@@ -151,193 +151,194 @@ void DateEntry::setDates( const QDateTime& s, const QDateTime& e )
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 );