Diffstat (limited to 'core/pim/datebook/dateentryimpl.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/pim/datebook/dateentryimpl.cpp | 97 |
1 files changed, 62 insertions, 35 deletions
diff --git a/core/pim/datebook/dateentryimpl.cpp b/core/pim/datebook/dateentryimpl.cpp index b2e3e3a..1c43363 100644 --- a/core/pim/datebook/dateentryimpl.cpp +++ b/core/pim/datebook/dateentryimpl.cpp @@ -41,2 +41,4 @@ +#include "timepicker.h" + #include <stdlib.h> @@ -62,3 +64,3 @@ DateEntry::DateEntry( bool startOnMonday, const QDateTime &start, setDates(start,end); - setFocusProxy(comboDescription); + setFocusProxy(comboDescription); } @@ -67,2 +69,3 @@ static void addOrPick( QComboBox* combo, const QString& t ) { + // Pick an item if one excists for (int i=0; i<combo->count(); i++) { @@ -73,3 +76,6 @@ static void addOrPick( QComboBox* combo, const QString& t ) } - combo->setEditText(t); + + // Else add one + combo->insertItem(t); + combo->setCurrentItem(combo->count()-1); } @@ -105,6 +111,2 @@ void DateEntry::setDates( const QDateTime& s, const QDateTime& e ) { - int shour, - ehour; - QString strStart, - strEnd; startDate = s.date(); @@ -114,5 +116,14 @@ void DateEntry::setDates( const QDateTime& s, const QDateTime& e ) startDateChanged( s.date().year(), s.date().month(), s.date().day() ); + endDateChanged( e.date().year(), e.date().month(), e.date().day() ); + updateTimeEdit(true,true); +} + +void DateEntry::updateTimeEdit(bool s, bool e) { + + // Comboboxes + QString strStart, strEnd; + int shour, ehour; if ( ampm ) { - shour = s.time().hour(); - ehour = e.time().hour(); + shour = startTime.hour(); + ehour = endTime.hour(); if ( shour >= 12 ) { @@ -120,3 +131,3 @@ void DateEntry::setDates( const QDateTime& s, const QDateTime& e ) shour -= 12; - strStart.sprintf( "%d:%02d PM", shour, s.time().minute() ); + strStart.sprintf( "%d:%02d PM", shour, startTime.minute() ); } else { @@ -124,5 +135,5 @@ void DateEntry::setDates( const QDateTime& s, const QDateTime& e ) shour = 12; - strStart.sprintf( "%d:%02d AM", shour, s.time().minute() ); + strStart.sprintf( "%d:%02d AM", shour, startTime.minute() ); } - if ( ehour == 24 && e.time().minute() == 0 ) { + if ( ehour == 24 && endTime.minute() == 0 ) { strEnd = "11:59 PM"; // or "midnight" @@ -131,3 +142,3 @@ void DateEntry::setDates( const QDateTime& s, const QDateTime& e ) ehour -= 12; - strEnd.sprintf( "%d:%02d PM", ehour, e.time().minute() ); + strEnd.sprintf( "%d:%02d PM", ehour, endTime.minute() ); } else { @@ -135,11 +146,11 @@ void DateEntry::setDates( const QDateTime& s, const QDateTime& e ) ehour = 12; - strEnd.sprintf( "%d:%02d AM", ehour, e.time().minute() ); + strEnd.sprintf( "%d:%02d AM", ehour, endTime.minute() ); } } else { - strStart.sprintf( "%02d:%02d", s.time().hour(), s.time().minute() ); - strEnd.sprintf( "%02d:%02d", e.time().hour(), e.time().minute() ); + strStart.sprintf( "%02d:%02d", startTime.hour(), startTime.minute() ); + strEnd.sprintf( "%02d:%02d", endTime.hour(), endTime.minute() ); } - addOrPick(comboStart, strStart ); - endDateChanged( e.date().year(), e.date().month(), e.date().day() ); - addOrPick(comboEnd, strEnd ); + + if (s) comboStart->setText(strStart); + if (e) comboEnd->setText(strEnd); } @@ -173,2 +184,6 @@ void DateEntry::init() this, SLOT( endDateChanged( int, int, int ) ) ); + + connect(timePickerStart, SIGNAL( timeChanged(const QTime &) ), + this, SLOT( startTimePicked(const QTime &) )); + editNote->setFixedVisibleLines(3); } @@ -242,4 +257,8 @@ void DateEntry::endTimeChanged( const QString &s ) endTime = startTime; - comboEnd->setCurrentItem( comboStart->currentItem() ); + //comboEnd->setCurrentItem( comboStart->currentItem() ); } + +} + +void DateEntry::endTimeChanged( const QTime &t ) { } @@ -272,8 +291,21 @@ void DateEntry::startDateChanged( int y, int m, int d ) */ -void DateEntry::startTimeChanged( int index ) +void DateEntry::startTimeEdited( const QString &s ) { - startTime = parseTime(comboStart->text(index),ampm); - changeEndCombo( index ); - //cout << "Start: " << comboStart->currentText() << endl; + startTimeChanged(parseTime(s,ampm)); + updateTimeEdit(false,true); + timePickerStart->setHour(startTime.hour()); + timePickerStart->setMinute(startTime.minute()); } + +void DateEntry::startTimeChanged( const QTime &t ) +{ + int duration=startTime.secsTo(endTime); + startTime = t; + endTime=t.addSecs(duration); +} +void DateEntry::startTimePicked( const QTime &t ) { + startTimeChanged(t); + updateTimeEdit(true,true); +} + /* @@ -288,12 +320,2 @@ void DateEntry::typeChanged( const QString &s ) } -/* - * public slot - */ -void DateEntry::changeEndCombo( int change ) -{ - if ( change + 2 < comboEnd->count() ) - change += 2; - comboEnd->setCurrentItem( change ); - endTimeChanged( comboEnd->currentText() ); -} @@ -338,4 +360,7 @@ Event DateEntry::event() } - startTime = parseTime( comboStart->currentText(), ampm ); - endTime = parseTime( comboEnd->currentText(), ampm ); + + // This is now done in the changed slots + // startTime = parseTime( comboStart->text(), ampm ); + //endTime = parseTime( comboEnd->text(), ampm ); + if ( startTime > endTime && endDate == startDate ) { @@ -429,2 +454,3 @@ void DateEntry::initCombos() { + /* comboStart->clear(); @@ -474,2 +500,3 @@ void DateEntry::initCombos() } + */ } |