summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/dateentryimpl.cpp24
-rw-r--r--core/pim/datebook/dateentryimpl.h7
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
@@ -8,82 +8,97 @@
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
54DateEntry::DateEntry( bool startOnMonday, const QDateTime &start, 55DateEntry::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
67bool 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
66static void addOrPick( QComboBox* combo, const QString& t ) 81static 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
81DateEntry::DateEntry( bool startOnMonday, const Event &event, bool whichClock, 96DateEntry::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") );
@@ -165,48 +180,51 @@ void DateEntry::init()
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 */
194DateEntry::~DateEntry() 212DateEntry::~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 */
203void DateEntry::endDateChanged( int y, int m, int d ) 221void 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() );
@@ -283,50 +301,56 @@ void DateEntry::startDateChanged( int y, int m, int d )
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 */
292void DateEntry::startTimeEdited( const QString &s ) 310void 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
300void DateEntry::startTimeChanged( const QTime &t ) 318void 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}
306void DateEntry::startTimePicked( const QTime &t ) { 324void 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 */
314void DateEntry::typeChanged( const QString &s ) 338void 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
322void DateEntry::slotRepeat() 346void 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 );
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
@@ -21,54 +21,55 @@
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
29class DateBookMonth; 29class DateBookMonth;
30 30
31class DateEntry : public DateEntryBase 31class DateEntry : public DateEntryBase
32{ 32{
33 Q_OBJECT 33 Q_OBJECT
34 34
35public: 35public:
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 * );
46public slots: 46public 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
59private: 59private:
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