summaryrefslogtreecommitdiff
path: root/core/pim/datebook/dateentryimpl.cpp
Unidiff
Diffstat (limited to 'core/pim/datebook/dateentryimpl.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/dateentryimpl.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/core/pim/datebook/dateentryimpl.cpp b/core/pim/datebook/dateentryimpl.cpp
index 018bb5a..57bcd89 100644
--- a/core/pim/datebook/dateentryimpl.cpp
+++ b/core/pim/datebook/dateentryimpl.cpp
@@ -97,215 +97,215 @@ static void addOrPick( QComboBox* combo, const QString& t )
97 } 97 }
98 98
99 // Else add one 99 // Else add one
100 combo->insertItem(t); 100 combo->insertItem(t);
101 combo->setCurrentItem(combo->count()-1); 101 combo->setCurrentItem(combo->count()-1);
102} 102}
103 103
104DateEntry::DateEntry( bool startOnMonday, const Event &event, bool whichClock, 104DateEntry::DateEntry( bool startOnMonday, const Event &event, bool whichClock,
105 QWidget* parent, const char* name ) 105 QWidget* parent, const char* name )
106 : DateEntryBase( parent, name ), 106 : DateEntryBase( parent, name ),
107 ampm( whichClock ), 107 ampm( whichClock ),
108 startWeekOnMonday( startOnMonday ), 108 startWeekOnMonday( startOnMonday ),
109 m_showStart(true) 109 m_showStart(true)
110 110
111{ 111{
112 init(); 112 init();
113 setDates(event.start(),event.end()); 113 setDates(event.start(),event.end());
114 comboCategory->setCategories( event.categories(), "Calendar", tr("Calendar") ); 114 comboCategory->setCategories( event.categories(), "Calendar", tr("Calendar") );
115 if(!event.description().isEmpty()) 115 if(!event.description().isEmpty())
116 addOrPick( comboDescription, event.description() ); 116 addOrPick( comboDescription, event.description() );
117 if(!event.location().isEmpty()) 117 if(!event.location().isEmpty())
118 addOrPick( comboLocation, event.location() ); 118 addOrPick( comboLocation, event.location() );
119 checkAlarm->setChecked( event.hasAlarm() ); 119 checkAlarm->setChecked( event.hasAlarm() );
120 checkAllDay->setChecked( event.type() == Event::AllDay ); 120 checkAllDay->setChecked( event.type() == Event::AllDay );
121 if(!event.notes().isEmpty()) noteStr=event.notes(); 121 if(!event.notes().isEmpty()) noteStr=event.notes();
122 else noteStr=""; 122 else noteStr="";
123 spinAlarm->setValue(event.alarmTime()); 123 spinAlarm->setValue(event.alarmTime());
124 if ( event.alarmSound() != Event::Silent ) 124 if ( event.alarmSound() != Event::Silent )
125 comboSound->setCurrentItem( 1 ); 125 comboSound->setCurrentItem( 1 );
126 if ( event.hasRepeat() ) { 126 if ( event.hasRepeat() ) {
127 rp = event.repeatPattern(); 127 rp = event.repeatPattern();
128 cmdRepeat->setText( tr("Repeat...") ); 128 cmdRepeat->setText( tr("Repeat...") );
129 } 129 }
130 setRepeatLabel(); 130 setRepeatLabel();
131} 131}
132 132
133void DateEntry::setDates( const QDateTime& s, const QDateTime& e ) 133void DateEntry::setDates( const QDateTime& s, const QDateTime& e )
134{ 134{
135 startDate = s.date(); 135 startDate = s.date();
136 endDate = e.date(); 136 endDate = e.date();
137 startTime = s.time(); 137 startTime = s.time();
138 endTime = e.time(); 138 endTime = e.time();
139 139
140 startDateChanged( s.date().year(), s.date().month(), s.date().day() ); 140 startDateChanged( s.date().year(), s.date().month(), s.date().day() );
141 endDateChanged( e.date().year(), e.date().month(), e.date().day() ); 141 endDateChanged( e.date().year(), e.date().month(), e.date().day() );
142 142
143 updateTimeEdit(true,true); 143 updateTimeEdit(true,true);
144} 144}
145 145
146void DateEntry::updateTimeEdit(bool s, bool e) { 146void DateEntry::updateTimeEdit(bool s, bool e) {
147 147
148 // Comboboxes 148 // Comboboxes
149 QString strStart, strEnd; 149 QString strStart, strEnd;
150 int shour, ehour; 150 int shour, ehour;
151 if ( ampm ) { 151 if ( ampm ) {
152 shour = startTime.hour(); 152 shour = startTime.hour();
153 ehour = endTime.hour(); 153 ehour = endTime.hour();
154 if ( shour >= 12 ) { 154 if ( shour >= 12 ) {
155 if ( shour > 12 ) 155 if ( shour > 12 )
156 shour -= 12; 156 shour -= 12;
157 strStart.sprintf( "%d:%02d PM", shour, startTime.minute() ); 157 strStart.sprintf( "%d:%02d PM", shour, startTime.minute() );
158 } else { 158 } else {
159 if ( shour == 0 ) 159 if ( shour == 0 )
160 shour = 12; 160 shour = 12;
161 strStart.sprintf( "%d:%02d AM", shour, startTime.minute() ); 161 strStart.sprintf( "%d:%02d AM", shour, startTime.minute() );
162 } 162 }
163 if ( ehour == 24 && endTime.minute() == 0 ) { 163 if ( ehour == 24 && endTime.minute() == 0 ) {
164 strEnd = "11:59 PM"; // or "midnight" 164 strEnd = "11:59 PM"; // or "midnight"
165 } else if ( ehour >= 12 ) { 165 } else if ( ehour >= 12 ) {
166 if ( ehour > 12 ) 166 if ( ehour > 12 )
167 ehour -= 12; 167 ehour -= 12;
168 strEnd.sprintf( "%d:%02d PM", ehour, endTime.minute() ); 168 strEnd.sprintf( "%d:%02d PM", ehour, endTime.minute() );
169 } else { 169 } else {
170 if ( ehour == 0 ) 170 if ( ehour == 0 )
171 ehour = 12; 171 ehour = 12;
172 strEnd.sprintf( "%d:%02d AM", ehour, endTime.minute() ); 172 strEnd.sprintf( "%d:%02d AM", ehour, endTime.minute() );
173 } 173 }
174 } else { 174 } else {
175 strStart.sprintf( "%02d:%02d", startTime.hour(), startTime.minute() ); 175 strStart.sprintf( "%02d:%02d", startTime.hour(), startTime.minute() );
176 strEnd.sprintf( "%02d:%02d", endTime.hour(), endTime.minute() ); 176 strEnd.sprintf( "%02d:%02d", endTime.hour(), endTime.minute() );
177 } 177 }
178 178
179 if (s) comboStart->setText(strStart); 179 if (s) comboStart->setText(strStart);
180 if (e) comboEnd->setText(strEnd); 180 if (e) comboEnd->setText(strEnd);
181} 181}
182 182
183void DateEntry::init() 183void DateEntry::init()
184{ 184{
185 comboDescription->setInsertionPolicy(QComboBox::AtCurrent); 185 comboDescription->setInsertionPolicy(QComboBox::AtCurrent);
186 comboLocation->setInsertionPolicy(QComboBox::AtCurrent); 186 comboLocation->setInsertionPolicy(QComboBox::AtCurrent);
187 187
188 initCombos(); 188 initCombos();
189 QPopupMenu *m1 = new QPopupMenu( this ); 189 QPopupMenu *m1 = new QPopupMenu( this );
190 startPicker = new DateBookMonth( m1, 0, TRUE ); 190 startPicker = new DateBookMonth( m1, 0, TRUE );
191 m1->insertItem( startPicker ); 191 m1->insertItem( startPicker );
192 buttonStart->setPopup( m1 ); 192 buttonStart->setPopup( m1 );
193 connect( startPicker, SIGNAL( dateClicked( int, int, int ) ), 193 connect( startPicker, SIGNAL( dateClicked(int,int,int) ),
194 this, SLOT( startDateChanged( int, int, int ) ) ); 194 this, SLOT( startDateChanged(int,int,int) ) );
195 195
196 //Let start button change both start and end dates 196 //Let start button change both start and end dates
197 connect( startPicker, SIGNAL( dateClicked( int, int, int ) ), 197 connect( startPicker, SIGNAL( dateClicked(int,int,int) ),
198 this, SLOT( endDateChanged( int, int, int ) ) ); 198 this, SLOT( endDateChanged(int,int,int) ) );
199 connect( qApp, SIGNAL( clockChanged( bool ) ), 199 connect( qApp, SIGNAL( clockChanged(bool) ),
200 this, SLOT( slotChangeClock( bool ) ) ); 200 this, SLOT( slotChangeClock(bool) ) );
201 connect( qApp, SIGNAL(weekChanged(bool)), 201 connect( qApp, SIGNAL(weekChanged(bool)),
202 this, SLOT(slotChangeStartOfWeek(bool)) ); 202 this, SLOT(slotChangeStartOfWeek(bool)) );
203 203
204 connect( editNote, SIGNAL(clicked()), 204 connect( editNote, SIGNAL(clicked()),
205 this, SLOT(slotEditNote()) ); 205 this, SLOT(slotEditNote()) );
206 206
207 QPopupMenu *m2 = new QPopupMenu( this ); 207 QPopupMenu *m2 = new QPopupMenu( this );
208 endPicker = new DateBookMonth( m2, 0, TRUE ); 208 endPicker = new DateBookMonth( m2, 0, TRUE );
209 m2->insertItem( endPicker ); 209 m2->insertItem( endPicker );
210 buttonEnd->setPopup( m2 ); 210 buttonEnd->setPopup( m2 );
211 connect( endPicker, SIGNAL( dateClicked( int, int, int ) ), 211 connect( endPicker, SIGNAL( dateClicked(int,int,int) ),
212 this, SLOT( endDateChanged( int, int, int ) ) ); 212 this, SLOT( endDateChanged(int,int,int) ) );
213 213
214 connect(timePickerStart, SIGNAL( timeChanged(const QTime &) ), 214 connect(timePickerStart, SIGNAL( timeChanged(const QTime&) ),
215 this, SLOT( startTimePicked(const QTime &) )); 215 this, SLOT( startTimePicked(const QTime&) ));
216 // install eventFilters 216 // install eventFilters
217 comboEnd->installEventFilter( this ); 217 comboEnd->installEventFilter( this );
218 comboStart->installEventFilter( this ); 218 comboStart->installEventFilter( this );
219} 219}
220 220
221/* 221/*
222 * Destroys the object and frees any allocated resources 222 * Destroys the object and frees any allocated resources
223 */ 223 */
224DateEntry::~DateEntry() 224DateEntry::~DateEntry()
225{ 225{
226 // no need to delete child widgets, Qt does it all for us 226 // no need to delete child widgets, Qt does it all for us
227 //cout << "Del: " << comboStart->currentText() << endl; 227 //cout << "Del: " << comboStart->currentText() << endl;
228} 228}
229 229
230/* 230/*
231 * public slot 231 * public slot
232 */ 232 */
233 233
234void DateEntry::slotEditNote() { 234void DateEntry::slotEditNote() {
235 QString s; 235 QString s;
236 s = "<B>"+ TimeString::longDateString( startDate ) + "</B>"; 236 s = "<B>"+ TimeString::longDateString( startDate ) + "</B>";
237// s.sprintf("<B>%d/%d</B> ", startDate.day(), startDate.month()); 237// s.sprintf("<B>%d/%d</B> ", startDate.day(), startDate.month());
238 NoteEntry noteDlg(s+comboDescription->currentText(), noteStr, 238 NoteEntry noteDlg(s+comboDescription->currentText(), noteStr,
239 this,0,TRUE); 239 this,0,TRUE);
240 240
241 if ( QPEApplication::execDialog( &noteDlg ) ) { 241 if ( QPEApplication::execDialog( &noteDlg ) ) {
242 noteStr=noteDlg.note->text(); 242 noteStr=noteDlg.note->text();
243 } 243 }
244 244
245} 245}
246 246
247void DateEntry::endDateChanged( int y, int m, int d ) 247void DateEntry::endDateChanged( int y, int m, int d )
248{ 248{
249 endDate.setYMD( y, m, d ); 249 endDate.setYMD( y, m, d );
250 if ( endDate < startDate ) { 250 if ( endDate < startDate ) {
251 endDate = startDate; 251 endDate = startDate;
252 } 252 }
253 253
254 buttonEnd->setText( TimeString::shortDate( endDate ) ); 254 buttonEnd->setText( TimeString::shortDate( endDate ) );
255 255
256 endPicker->setDate( endDate.year(), endDate.month(), endDate.day() ); 256 endPicker->setDate( endDate.year(), endDate.month(), endDate.day() );
257} 257}
258 258
259static QTime parseTime( const QString& s, bool ampm ) 259static QTime parseTime( const QString& s, bool ampm )
260{ 260{
261 QTime tmpTime; 261 QTime tmpTime;
262 QStringList l = QStringList::split( ':', s ); 262 QStringList l = QStringList::split( ':', s );
263 int hour = l[0].toInt(); 263 int hour = l[0].toInt();
264 if ( ampm ) { 264 if ( ampm ) {
265 int i=0; 265 int i=0;
266 while (i<int(l[1].length()) && l[1][i]>='0' && l[1][i]<='9') 266 while (i<int(l[1].length()) && l[1][i]>='0' && l[1][i]<='9')
267 i++; 267 i++;
268 QString digits = l[1].left(i); 268 QString digits = l[1].left(i);
269 if ( l[1].contains( "PM", FALSE ) ) { 269 if ( l[1].contains( "PM", FALSE ) ) {
270 if ( hour != 12 ) 270 if ( hour != 12 )
271 hour += 12; 271 hour += 12;
272 } else { 272 } else {
273 if ( hour == 12 ) 273 if ( hour == 12 )
274 hour = 0; 274 hour = 0;
275 } 275 }
276 l[1] = digits; 276 l[1] = digits;
277 } 277 }
278 int minute = l[1].toInt(); 278 int minute = l[1].toInt();
279 if ( minute > 59 ) 279 if ( minute > 59 )
280 minute = 59; 280 minute = 59;
281 else if ( minute < 0 ) 281 else if ( minute < 0 )
282 minute = 0; 282 minute = 0;
283 if ( hour > 23 ) { 283 if ( hour > 23 ) {
284 hour = 23; 284 hour = 23;
285 minute = 59; 285 minute = 59;
286 } else if ( hour < 0 ) 286 } else if ( hour < 0 )
287 hour = 0; 287 hour = 0;
288 tmpTime.setHMS( hour, minute, 0 ); 288 tmpTime.setHMS( hour, minute, 0 );
289 return tmpTime; 289 return tmpTime;
290} 290}
291 291
292/* 292/*
293 * public slot 293 * public slot
294 */ 294 */
295void DateEntry::endTimeChanged( const QString &s ) 295void DateEntry::endTimeChanged( const QString &s )
296{ 296{
297 endTimeChanged( parseTime(s,ampm) ); 297 endTimeChanged( parseTime(s,ampm) );
298} 298}
299 299
300void DateEntry::endTimeChanged( const QTime &t ) { 300void DateEntry::endTimeChanged( const QTime &t ) {
301 if ( endDate > startDate || t >= startTime ) { 301 if ( endDate > startDate || t >= startTime ) {
302 endTime = t; 302 endTime = t;
303 } else { 303 } else {
304 endTime = startTime; 304 endTime = startTime;
305 //comboEnd->setCurrentItem( comboStart->currentItem() ); 305 //comboEnd->setCurrentItem( comboStart->currentItem() );
306 } 306 }
307 timePickerStart->setHour(endTime.hour()); 307 timePickerStart->setHour(endTime.hour());
308 timePickerStart->setMinute(endTime.minute()); 308 timePickerStart->setMinute(endTime.minute());
309} 309}
310 310
311/* 311/*