author | hakan <hakan> | 2002-03-26 19:05:31 (UTC) |
---|---|---|
committer | hakan <hakan> | 2002-03-26 19:05:31 (UTC) |
commit | 78211642003f70797a5faa1767a5ab2f5f83606f (patch) (unidiff) | |
tree | 703df6b1f8a98dbd00066ab3c21419b7f97e41b4 /core/pim/datebook/dateentryimpl.cpp | |
parent | dbbbe1c0600422e4bd2d6a6aba271476f457ed97 (diff) | |
download | opie-78211642003f70797a5faa1767a5ab2f5f83606f.zip opie-78211642003f70797a5faa1767a5ab2f5f83606f.tar.gz opie-78211642003f70797a5faa1767a5ab2f5f83606f.tar.bz2 |
Added shortcut buttons to set the start time
Diffstat (limited to 'core/pim/datebook/dateentryimpl.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/pim/datebook/dateentryimpl.cpp | 95 |
1 files changed, 61 insertions, 34 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 @@ | |||
41 | 41 | ||
42 | #include "timepicker.h" | ||
43 | |||
42 | #include <stdlib.h> | 44 | #include <stdlib.h> |
@@ -67,2 +69,3 @@ static void addOrPick( QComboBox* combo, const QString& t ) | |||
67 | { | 69 | { |
70 | // Pick an item if one excists | ||
68 | for (int i=0; i<combo->count(); i++) { | 71 | for (int i=0; i<combo->count(); i++) { |
@@ -73,3 +76,6 @@ static void addOrPick( QComboBox* combo, const QString& t ) | |||
73 | } | 76 | } |
74 | combo->setEditText(t); | 77 | |
78 | // Else add one | ||
79 | combo->insertItem(t); | ||
80 | combo->setCurrentItem(combo->count()-1); | ||
75 | } | 81 | } |
@@ -105,6 +111,2 @@ void DateEntry::setDates( const QDateTime& s, const QDateTime& e ) | |||
105 | { | 111 | { |
106 | int shour, | ||
107 | ehour; | ||
108 | QString strStart, | ||
109 | strEnd; | ||
110 | startDate = s.date(); | 112 | startDate = s.date(); |
@@ -114,5 +116,14 @@ void DateEntry::setDates( const QDateTime& s, const QDateTime& e ) | |||
114 | startDateChanged( s.date().year(), s.date().month(), s.date().day() ); | 116 | startDateChanged( s.date().year(), s.date().month(), s.date().day() ); |
117 | endDateChanged( e.date().year(), e.date().month(), e.date().day() ); | ||
118 | updateTimeEdit(true,true); | ||
119 | } | ||
120 | |||
121 | void DateEntry::updateTimeEdit(bool s, bool e) { | ||
122 | |||
123 | // Comboboxes | ||
124 | QString strStart, strEnd; | ||
125 | int shour, ehour; | ||
115 | if ( ampm ) { | 126 | if ( ampm ) { |
116 | shour = s.time().hour(); | 127 | shour = startTime.hour(); |
117 | ehour = e.time().hour(); | 128 | ehour = endTime.hour(); |
118 | if ( shour >= 12 ) { | 129 | if ( shour >= 12 ) { |
@@ -120,3 +131,3 @@ void DateEntry::setDates( const QDateTime& s, const QDateTime& e ) | |||
120 | shour -= 12; | 131 | shour -= 12; |
121 | strStart.sprintf( "%d:%02d PM", shour, s.time().minute() ); | 132 | strStart.sprintf( "%d:%02d PM", shour, startTime.minute() ); |
122 | } else { | 133 | } else { |
@@ -124,5 +135,5 @@ void DateEntry::setDates( const QDateTime& s, const QDateTime& e ) | |||
124 | shour = 12; | 135 | shour = 12; |
125 | strStart.sprintf( "%d:%02d AM", shour, s.time().minute() ); | 136 | strStart.sprintf( "%d:%02d AM", shour, startTime.minute() ); |
126 | } | 137 | } |
127 | if ( ehour == 24 && e.time().minute() == 0 ) { | 138 | if ( ehour == 24 && endTime.minute() == 0 ) { |
128 | strEnd = "11:59 PM"; // or "midnight" | 139 | strEnd = "11:59 PM"; // or "midnight" |
@@ -131,3 +142,3 @@ void DateEntry::setDates( const QDateTime& s, const QDateTime& e ) | |||
131 | ehour -= 12; | 142 | ehour -= 12; |
132 | strEnd.sprintf( "%d:%02d PM", ehour, e.time().minute() ); | 143 | strEnd.sprintf( "%d:%02d PM", ehour, endTime.minute() ); |
133 | } else { | 144 | } else { |
@@ -135,11 +146,11 @@ void DateEntry::setDates( const QDateTime& s, const QDateTime& e ) | |||
135 | ehour = 12; | 146 | ehour = 12; |
136 | strEnd.sprintf( "%d:%02d AM", ehour, e.time().minute() ); | 147 | strEnd.sprintf( "%d:%02d AM", ehour, endTime.minute() ); |
137 | } | 148 | } |
138 | } else { | 149 | } else { |
139 | strStart.sprintf( "%02d:%02d", s.time().hour(), s.time().minute() ); | 150 | strStart.sprintf( "%02d:%02d", startTime.hour(), startTime.minute() ); |
140 | strEnd.sprintf( "%02d:%02d", e.time().hour(), e.time().minute() ); | 151 | strEnd.sprintf( "%02d:%02d", endTime.hour(), endTime.minute() ); |
141 | } | 152 | } |
142 | addOrPick(comboStart, strStart ); | 153 | |
143 | endDateChanged( e.date().year(), e.date().month(), e.date().day() ); | 154 | if (s) comboStart->setText(strStart); |
144 | addOrPick(comboEnd, strEnd ); | 155 | if (e) comboEnd->setText(strEnd); |
145 | } | 156 | } |
@@ -173,2 +184,6 @@ void DateEntry::init() | |||
173 | this, SLOT( endDateChanged( int, int, int ) ) ); | 184 | this, SLOT( endDateChanged( int, int, int ) ) ); |
185 | |||
186 | connect(timePickerStart, SIGNAL( timeChanged(const QTime &) ), | ||
187 | this, SLOT( startTimePicked(const QTime &) )); | ||
188 | editNote->setFixedVisibleLines(3); | ||
174 | } | 189 | } |
@@ -242,4 +257,8 @@ void DateEntry::endTimeChanged( const QString &s ) | |||
242 | endTime = startTime; | 257 | endTime = startTime; |
243 | comboEnd->setCurrentItem( comboStart->currentItem() ); | 258 | //comboEnd->setCurrentItem( comboStart->currentItem() ); |
244 | } | 259 | } |
260 | |||
261 | } | ||
262 | |||
263 | void DateEntry::endTimeChanged( const QTime &t ) { | ||
245 | } | 264 | } |
@@ -272,8 +291,21 @@ void DateEntry::startDateChanged( int y, int m, int d ) | |||
272 | */ | 291 | */ |
273 | void DateEntry::startTimeChanged( int index ) | 292 | void DateEntry::startTimeEdited( const QString &s ) |
274 | { | 293 | { |
275 | startTime = parseTime(comboStart->text(index),ampm); | 294 | startTimeChanged(parseTime(s,ampm)); |
276 | changeEndCombo( index ); | 295 | updateTimeEdit(false,true); |
277 | //cout << "Start: " << comboStart->currentText() << endl; | 296 | timePickerStart->setHour(startTime.hour()); |
297 | timePickerStart->setMinute(startTime.minute()); | ||
278 | } | 298 | } |
299 | |||
300 | void DateEntry::startTimeChanged( const QTime &t ) | ||
301 | { | ||
302 | int duration=startTime.secsTo(endTime); | ||
303 | startTime = t; | ||
304 | endTime=t.addSecs(duration); | ||
305 | } | ||
306 | void DateEntry::startTimePicked( const QTime &t ) { | ||
307 | startTimeChanged(t); | ||
308 | updateTimeEdit(true,true); | ||
309 | } | ||
310 | |||
279 | /* | 311 | /* |
@@ -288,12 +320,2 @@ void DateEntry::typeChanged( const QString &s ) | |||
288 | } | 320 | } |
289 | /* | ||
290 | * public slot | ||
291 | */ | ||
292 | void DateEntry::changeEndCombo( int change ) | ||
293 | { | ||
294 | if ( change + 2 < comboEnd->count() ) | ||
295 | change += 2; | ||
296 | comboEnd->setCurrentItem( change ); | ||
297 | endTimeChanged( comboEnd->currentText() ); | ||
298 | } | ||
299 | 321 | ||
@@ -338,4 +360,7 @@ Event DateEntry::event() | |||
338 | } | 360 | } |
339 | startTime = parseTime( comboStart->currentText(), ampm ); | 361 | |
340 | endTime = parseTime( comboEnd->currentText(), ampm ); | 362 | // This is now done in the changed slots |
363 | // startTime = parseTime( comboStart->text(), ampm ); | ||
364 | //endTime = parseTime( comboEnd->text(), ampm ); | ||
365 | |||
341 | if ( startTime > endTime && endDate == startDate ) { | 366 | if ( startTime > endTime && endDate == startDate ) { |
@@ -429,2 +454,3 @@ void DateEntry::initCombos() | |||
429 | { | 454 | { |
455 | /* | ||
430 | comboStart->clear(); | 456 | comboStart->clear(); |
@@ -474,2 +500,3 @@ void DateEntry::initCombos() | |||
474 | } | 500 | } |
501 | */ | ||
475 | } | 502 | } |