summaryrefslogtreecommitdiffabout
path: root/korganizer
Unidiff
Diffstat (limited to 'korganizer') (more/less context) (show whitespace changes)
-rw-r--r--korganizer/koagendaview.cpp2
-rw-r--r--korganizer/koeditorgeneral.cpp2
2 files changed, 4 insertions, 0 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index b9c7dec..8001c8f 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -90,96 +90,98 @@ TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) :
90 90
91 setHScrollBarMode(AlwaysOff); 91 setHScrollBarMode(AlwaysOff);
92 setVScrollBarMode(AlwaysOff); 92 setVScrollBarMode(AlwaysOff);
93 93
94 resizeContents(50,mRows * mCellHeight); 94 resizeContents(50,mRows * mCellHeight);
95 95
96 viewport()->setBackgroundMode( PaletteBackground ); 96 viewport()->setBackgroundMode( PaletteBackground );
97} 97}
98 98
99void TimeLabels::setCellHeight(int height) 99void TimeLabels::setCellHeight(int height)
100{ 100{
101 mCellHeight = height; 101 mCellHeight = height;
102} 102}
103 103
104/* 104/*
105 Optimization so that only the "dirty" portion of the scroll view 105 Optimization so that only the "dirty" portion of the scroll view
106 is redrawn. Unfortunately, this is not called by default paintEvent() method. 106 is redrawn. Unfortunately, this is not called by default paintEvent() method.
107*/ 107*/
108void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) 108void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch)
109{ 109{
110 110
111 // if ( globalFlagBlockAgenda ) 111 // if ( globalFlagBlockAgenda )
112 // return; 112 // return;
113 // bug: the parameters cx, cy, cw, ch are the areas that need to be 113 // bug: the parameters cx, cy, cw, ch are the areas that need to be
114 // redrawn, not the area of the widget. unfortunately, this 114 // redrawn, not the area of the widget. unfortunately, this
115 // code assumes the latter... 115 // code assumes the latter...
116 116
117 // now, for a workaround... 117 // now, for a workaround...
118 // these two assignments fix the weird redraw bug 118 // these two assignments fix the weird redraw bug
119 cx = contentsX() + 2; 119 cx = contentsX() + 2;
120 cw = contentsWidth() - 2; 120 cw = contentsWidth() - 2;
121 // end of workaround 121 // end of workaround
122 122
123 int cell = ((int)(cy/mCellHeight)); 123 int cell = ((int)(cy/mCellHeight));
124 int y = cell * mCellHeight; 124 int y = cell * mCellHeight;
125 QFontMetrics fm = fontMetrics(); 125 QFontMetrics fm = fontMetrics();
126 QString hour; 126 QString hour;
127 QString suffix; 127 QString suffix;
128 QString fullTime; 128 QString fullTime;
129 int tW = fm.width("24:00i"); 129 int tW = fm.width("24:00i");
130 int timeHeight = fm.height(); 130 int timeHeight = fm.height();
131 timeHeight -= (timeHeight/4-2); 131 timeHeight -= (timeHeight/4-2);
132 int borderWidth = 2; 132 int borderWidth = 2;
133 QFont nFont = p->font(); 133 QFont nFont = p->font();
134 QFont sFont = nFont; 134 QFont sFont = nFont;
135 sFont.setPointSize( sFont.pointSize()/2+2 ); 135 sFont.setPointSize( sFont.pointSize()/2+2 );
136 if (!KGlobal::locale()->use12Clock()) 136 if (!KGlobal::locale()->use12Clock())
137 suffix = "00"; 137 suffix = "00";
138 else
139 borderWidth = 0;
138 QFontMetrics fmS( sFont ); 140 QFontMetrics fmS( sFont );
139 int sHei = fmS.height(); 141 int sHei = fmS.height();
140 if ( timeHeight > mCellHeight ) { 142 if ( timeHeight > mCellHeight ) {
141 timeHeight = mCellHeight-1; 143 timeHeight = mCellHeight-1;
142 sHei -= 2; 144 sHei -= 2;
143 } 145 }
144 146
145 while (y < cy + ch) { 147 while (y < cy + ch) {
146 p->drawLine(cx,y,cx+tW,y); 148 p->drawLine(cx,y,cx+tW,y);
147 hour.setNum(cell); 149 hour.setNum(cell);
148 150
149 // handle 24h and am/pm time formats 151 // handle 24h and am/pm time formats
150 if (KGlobal::locale()->use12Clock()) { 152 if (KGlobal::locale()->use12Clock()) {
151 if (cell > 11) suffix = "pm"; 153 if (cell > 11) suffix = "pm";
152 else 154 else
153 suffix = "am"; 155 suffix = "am";
154 if (cell == 0) hour.setNum(12); 156 if (cell == 0) hour.setNum(12);
155 if (cell > 12) hour.setNum(cell - 12); 157 if (cell > 12) hour.setNum(cell - 12);
156 } 158 }
157 159
158 // create string in format of "XX:XX" or "XXpm/am" 160 // create string in format of "XX:XX" or "XXpm/am"
159 fullTime = hour;// + suffix; 161 fullTime = hour;// + suffix;
160 162
161 // center and draw the time label 163 // center and draw the time label
162 int timeWidth = fm.width(fullTime+"i"); 164 int timeWidth = fm.width(fullTime+"i");
163 int tw2 = fm.width(suffix); 165 int tw2 = fm.width(suffix);
164 int offset = this->width() - timeWidth - tw2; 166 int offset = this->width() - timeWidth - tw2;
165 p->setFont( nFont ); 167 p->setFont( nFont );
166 p->drawText(cx - borderWidth + offset, y+ timeHeight, fullTime); 168 p->drawText(cx - borderWidth + offset, y+ timeHeight, fullTime);
167 p->setFont( sFont ); 169 p->setFont( sFont );
168 offset += timeWidth; 170 offset += timeWidth;
169 p->drawText(cx - borderWidth + offset, y+ sHei, suffix); 171 p->drawText(cx - borderWidth + offset, y+ sHei, suffix);
170 172
171 // increment indices 173 // increment indices
172 y += mCellHeight; 174 y += mCellHeight;
173 cell++; 175 cell++;
174 } 176 }
175} 177}
176 178
177/** 179/**
178 Calculates the minimum width. 180 Calculates the minimum width.
179*/ 181*/
180int TimeLabels::minimumWidth() const 182int TimeLabels::minimumWidth() const
181{ 183{
182 return mMiniWidth; 184 return mMiniWidth;
183} 185}
184 186
185/** updates widget's internal state */ 187/** updates widget's internal state */
diff --git a/korganizer/koeditorgeneral.cpp b/korganizer/koeditorgeneral.cpp
index cf0d4ae..92fcd1c 100644
--- a/korganizer/koeditorgeneral.cpp
+++ b/korganizer/koeditorgeneral.cpp
@@ -342,96 +342,98 @@ void KOEditorGeneral::alarmDisable(bool disable)
342 mAlarmIncrCombo->setEnabled(false); 342 mAlarmIncrCombo->setEnabled(false);
343 } 343 }
344} 344}
345 345
346void KOEditorGeneral::setCategories(const QString &str) 346void KOEditorGeneral::setCategories(const QString &str)
347{ 347{
348 mCategoriesLabel->setText(str); 348 mCategoriesLabel->setText(str);
349} 349}
350 350
351void KOEditorGeneral::setDefaults(bool allDay) 351void KOEditorGeneral::setDefaults(bool allDay)
352{ 352{
353#if 0 353#if 0
354 mOwnerLabel->setText(i18n("Owner: ") + KOPrefs::instance()->fullName()); 354 mOwnerLabel->setText(i18n("Owner: ") + KOPrefs::instance()->fullName());
355#endif 355#endif
356 356
357 mAlarmMessage = i18n("Edit new item"); 357 mAlarmMessage = i18n("Edit new item");
358 enableAlarmEdit( !allDay ); 358 enableAlarmEdit( !allDay );
359 359
360 // TODO: Implement a KPrefsComboItem to solve this in a clean way. 360 // TODO: Implement a KPrefsComboItem to solve this in a clean way.
361 int alarmTime; 361 int alarmTime;
362 int a[] = { 1,5,10,15,30,60,180, 1440 }; 362 int a[] = { 1,5,10,15,30,60,180, 1440 };
363 int index = KOPrefs::instance()->mAlarmTime; 363 int index = KOPrefs::instance()->mAlarmTime;
364 if (index < 0 || index > 7) { 364 if (index < 0 || index > 7) {
365 alarmTime = 15; 365 alarmTime = 15;
366 } else { 366 } else {
367 alarmTime = a[index]; 367 alarmTime = a[index];
368 } 368 }
369 mAlarmButton ->setChecked( false ); 369 mAlarmButton ->setChecked( false );
370 mAlarmTimeEdit->setValue(alarmTime); 370 mAlarmTimeEdit->setValue(alarmTime);
371 mAlarmIncrCombo->setCurrentItem(0); 371 mAlarmIncrCombo->setCurrentItem(0);
372 enableAlarmEdit( false ); 372 enableAlarmEdit( false );
373 //alarmDisable (false); 373 //alarmDisable (false);
374 mSecrecyCombo->setCurrentItem(Incidence::SecrecyPublic); 374 mSecrecyCombo->setCurrentItem(Incidence::SecrecyPublic);
375 mCancelBox->setChecked( false ); 375 mCancelBox->setChecked( false );
376 mSummaryEdit->setEditText(""); 376 mSummaryEdit->setEditText("");
377 mLocationEdit->setEditText(""); 377 mLocationEdit->setEditText("");
378 mDescriptionEdit->setText(""); 378 mDescriptionEdit->setText("");
379 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; 379 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile;
380 setCategories(""); 380 setCategories("");
381} 381}
382void KOEditorGeneral::setSecrecy( int num ) 382void KOEditorGeneral::setSecrecy( int num )
383{ 383{
384 mSecrecyCombo->setCurrentItem(num); 384 mSecrecyCombo->setCurrentItem(num);
385} 385}
386void KOEditorGeneral::readIncidence(Incidence *event) 386void KOEditorGeneral::readIncidence(Incidence *event)
387{ 387{
388 388
389 mAlarmMessage = event->summary(); 389 mAlarmMessage = event->summary();
390 if ( ! event->location().isEmpty() )
391 mAlarmMessage += " ("+event->location()+")";
390 mAlarmIncrCombo->setCurrentItem(0); 392 mAlarmIncrCombo->setCurrentItem(0);
391 mSummaryEdit->setEditText(event->summary()); 393 mSummaryEdit->setEditText(event->summary());
392 mLocationEdit->setEditText(event->location()); 394 mLocationEdit->setEditText(event->location());
393 mDescriptionEdit->setText(event->description()); 395 mDescriptionEdit->setText(event->description());
394 396
395#if 0 397#if 0
396 // organizer information 398 // organizer information
397 mOwnerLabel->setText(i18n("Owner: ") + event->organizer()); 399 mOwnerLabel->setText(i18n("Owner: ") + event->organizer());
398#endif 400#endif
399 401
400 enableAlarmEdit( event->isAlarmEnabled() ); 402 enableAlarmEdit( event->isAlarmEnabled() );
401 //qDebug("KOEditorGeneral::readIncidence(Incidence *event) "); 403 //qDebug("KOEditorGeneral::readIncidence(Incidence *event) ");
402 if(!event->isAlarmEnabled()) { 404 if(!event->isAlarmEnabled()) {
403 // TODO: Implement a KPrefsComboItem to solve this in a clean way. 405 // TODO: Implement a KPrefsComboItem to solve this in a clean way.
404 int alarmTime; 406 int alarmTime;
405 int a[] = { 1,5,10,15,30,60,180, 1440 }; 407 int a[] = { 1,5,10,15,30,60,180, 1440 };
406 int index = KOPrefs::instance()->mAlarmTime; 408 int index = KOPrefs::instance()->mAlarmTime;
407 if (index < 0 || index > 7) { 409 if (index < 0 || index > 7) {
408 alarmTime = 15; 410 alarmTime = 15;
409 } else { 411 } else {
410 alarmTime = a[index]; 412 alarmTime = a[index];
411 } 413 }
412 mAlarmTimeEdit->setValue(alarmTime); 414 mAlarmTimeEdit->setValue(alarmTime);
413 } 415 }
414 mAlarmButton->setChecked( event->isAlarmEnabled() ); 416 mAlarmButton->setChecked( event->isAlarmEnabled() );
415 mSecrecyCombo->setCurrentItem(event->secrecy()); 417 mSecrecyCombo->setCurrentItem(event->secrecy());
416 mCancelBox->setChecked( event->cancelled() ); 418 mCancelBox->setChecked( event->cancelled() );
417 mAlarmProgramButton->setOn(false); 419 mAlarmProgramButton->setOn(false);
418 mAlarmSoundButton->setOn(false); 420 mAlarmSoundButton->setOn(false);
419 421
420 // set up alarm stuff 422 // set up alarm stuff
421 QPtrList<Alarm> alarms = event->alarms(); 423 QPtrList<Alarm> alarms = event->alarms();
422 Alarm* alarm; 424 Alarm* alarm;
423 mAlarmIncrCombo->setCurrentItem(0); 425 mAlarmIncrCombo->setCurrentItem(0);
424 for ( alarm = alarms.first(); alarm; alarm = alarms.next() ) { 426 for ( alarm = alarms.first(); alarm; alarm = alarms.next() ) {
425 int offset; 427 int offset;
426 if ( alarm->hasTime() ) { 428 if ( alarm->hasTime() ) {
427 QDateTime t = alarm->time(); 429 QDateTime t = alarm->time();
428 offset = event->dtStart().secsTo( t ); 430 offset = event->dtStart().secsTo( t );
429 } else { 431 } else {
430 offset = alarm->startOffset().asSeconds(); 432 offset = alarm->startOffset().asSeconds();
431 } 433 }
432 if ( offset != 0 ) { 434 if ( offset != 0 ) {
433 offset = offset / -60; // make minutes 435 offset = offset / -60; // make minutes
434 if (offset % 60 == 0) { // divides evenly into hours? 436 if (offset % 60 == 0) { // divides evenly into hours?
435 offset = offset / 60; 437 offset = offset / 60;
436 mAlarmIncrCombo->setCurrentItem(1); 438 mAlarmIncrCombo->setCurrentItem(1);
437 if (offset % 24 == 0) { // divides evenly into days? 439 if (offset % 24 == 0) { // divides evenly into days?