author | zautrix <zautrix> | 2005-04-01 18:10:09 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-04-01 18:10:09 (UTC) |
commit | edc032c21ae3788d02a632ea8066e4ac5a4feedb (patch) (unidiff) | |
tree | 8e59c8dcf1cc3021694025627d36e152f7adc389 /korganizer/koagendaview.cpp | |
parent | 5d88f92b76a760f100384ea5fa6ed143088d19bb (diff) | |
download | kdepimpi-edc032c21ae3788d02a632ea8066e4ac5a4feedb.zip kdepimpi-edc032c21ae3788d02a632ea8066e4ac5a4feedb.tar.gz kdepimpi-edc032c21ae3788d02a632ea8066e4ac5a4feedb.tar.bz2 |
fixes
-rw-r--r-- | korganizer/koagendaview.cpp | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index 218396d..072d464 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp | |||
@@ -109,27 +109,28 @@ void TimeLabels::setCellHeight(int height) | |||
109 | */ | 109 | */ |
110 | void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) | 110 | void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) |
111 | { | 111 | { |
112 | 112 | ||
113 | // if ( globalFlagBlockAgenda ) | 113 | // if ( globalFlagBlockAgenda ) |
114 | // return; | 114 | // return; |
115 | // bug: the parameters cx, cy, cw, ch are the areas that need to be | 115 | // bug: the parameters cx, cy, cw, ch are the areas that need to be |
116 | // redrawn, not the area of the widget. unfortunately, this | 116 | // redrawn, not the area of the widget. unfortunately, this |
117 | // code assumes the latter... | 117 | // code assumes the latter... |
118 | 118 | ||
119 | // now, for a workaround... | 119 | // now, for a workaround... |
120 | // these two assignments fix the weird redraw bug | 120 | // these two assignments fix the weird redraw bug |
121 | mRedrawNeeded = true; | ||
121 | if ( mRedrawNeeded ) { | 122 | if ( mRedrawNeeded ) { |
122 | cx = contentsX() + 2; | 123 | cx = contentsX() + frameWidth()*2; |
123 | cw = contentsWidth() - 2; | 124 | cw = contentsWidth() ; |
124 | // end of workaround | 125 | // end of workaround |
125 | 126 | ||
126 | int cell = ((int)(cy/mCellHeight)); | 127 | int cell = ((int)(cy/mCellHeight)); |
127 | int y = cell * mCellHeight; | 128 | int y = cell * mCellHeight; |
128 | QFontMetrics fm = fontMetrics(); | 129 | QFontMetrics fm = fontMetrics(); |
129 | QString hour; | 130 | QString hour; |
130 | QString suffix; | 131 | QString suffix; |
131 | int tW = fm.width("24:00i"); | 132 | int tW = fm.width("24:00i"); |
132 | int timeHeight = fm.height(); | 133 | int timeHeight = fm.height(); |
133 | //timeHeight -= (timeHeight/4-2); | 134 | //timeHeight -= (timeHeight/4-2); |
134 | int borderWidth = 0; | 135 | int borderWidth = 0; |
135 | QFont nFont = p->font(); | 136 | QFont nFont = p->font(); |
@@ -143,53 +144,53 @@ void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) | |||
143 | int pointS = nFont.pointSize(); | 144 | int pointS = nFont.pointSize(); |
144 | while ( pointS > 4 ) { | 145 | while ( pointS > 4 ) { |
145 | nFont.setPointSize( pointS ); | 146 | nFont.setPointSize( pointS ); |
146 | fm = QFontMetrics( nFont ); | 147 | fm = QFontMetrics( nFont ); |
147 | if ( fm.height() < mCellHeight ) | 148 | if ( fm.height() < mCellHeight ) |
148 | break; | 149 | break; |
149 | -- pointS; | 150 | -- pointS; |
150 | } | 151 | } |
151 | fm = QFontMetrics( nFont ); | 152 | fm = QFontMetrics( nFont ); |
152 | borderWidth = 4; | 153 | borderWidth = 4; |
153 | timeHeight = fm.height(); | 154 | timeHeight = fm.height(); |
154 | } | 155 | } |
155 | timeHeight -= (timeHeight/4-2); | 156 | //timeHeight -= (timeHeight/4-2); |
156 | QFont sFont = nFont; | 157 | QFont sFont = nFont; |
157 | sFont.setPointSize( sFont.pointSize()/2+2 ); | 158 | sFont.setPointSize( sFont.pointSize()/2+2 ); |
158 | QFontMetrics fmS( sFont ); | 159 | QFontMetrics fmS( sFont ); |
159 | int sHei = fmS.height(); | 160 | int sHei = fmS.height(); |
160 | sHei -= (sHei/4-2); | 161 | //sHei -= (sHei/4-2); |
161 | int startW = this->width() - frameWidth(); | 162 | int startW = this->width() - frameWidth()-1; |
162 | while (y < cy + ch) { | 163 | while (y < cy + ch) { |
163 | p->drawLine(cx,y,cx+tW,y); | 164 | p->drawLine(cx,y,cx+tW,y); |
164 | hour.setNum(cell); | 165 | hour.setNum(cell); |
165 | 166 | ||
166 | // handle 24h and am/pm time formats | 167 | // handle 24h and am/pm time formats |
167 | if (KGlobal::locale()->use12Clock()) { | 168 | if (KGlobal::locale()->use12Clock()) { |
168 | if (cell > 11) suffix = "pm"; | 169 | if (cell > 11) suffix = "pm"; |
169 | else | 170 | else |
170 | suffix = "am"; | 171 | suffix = "am"; |
171 | if (cell == 0) hour.setNum(12); | 172 | if (cell == 0) hour.setNum(12); |
172 | if (cell > 12) hour.setNum(cell - 12); | 173 | if (cell > 12) hour.setNum(cell - 12); |
173 | } | 174 | } |
174 | 175 | ||
175 | // center and draw the time label | 176 | // center and draw the time label |
176 | int timeWidth = fm.width(hour+"i"); | 177 | int timeWidth = fm.width(hour); |
177 | int tw2 = fm.width(suffix); | 178 | int tw2 = fm.width(suffix); |
178 | int offset = startW - timeWidth - tw2 ; | 179 | int offset = startW - timeWidth - tw2 ; |
179 | p->setFont( nFont ); | 180 | p->setFont( nFont ); |
180 | p->drawText(cx - borderWidth + offset, y+ timeHeight, hour); | 181 | p->drawText( offset, y+ timeHeight, hour); |
181 | p->setFont( sFont ); | 182 | p->setFont( sFont ); |
182 | offset = startW - tw2-1; | 183 | offset = startW - tw2+1; |
183 | p->drawText(cx - borderWidth + offset, y+ sHei, suffix); | 184 | p->drawText( offset, y+ sHei, suffix); |
184 | 185 | ||
185 | // increment indices | 186 | // increment indices |
186 | y += mCellHeight; | 187 | y += mCellHeight; |
187 | cell++; | 188 | cell++; |
188 | } | 189 | } |
189 | } else { | 190 | } else { |
190 | //qDebug("NO redraw "); | 191 | //qDebug("NO redraw "); |
191 | } | 192 | } |
192 | // double buffer not yet implemented | 193 | // double buffer not yet implemented |
193 | //bitBlt (this, 0, 0, &myPix, 0 ,0,width(), height() ,CopyROP); | 194 | //bitBlt (this, 0, 0, &myPix, 0 ,0,width(), height() ,CopyROP); |
194 | //mRedrawNeeded = false; | 195 | //mRedrawNeeded = false; |
195 | } | 196 | } |
@@ -409,26 +410,25 @@ KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : | |||
409 | QWidget *agendaFrame = new QWidget(mSplitterAgenda); | 410 | QWidget *agendaFrame = new QWidget(mSplitterAgenda); |
410 | agendaFrame->setFocusPolicy(NoFocus); | 411 | agendaFrame->setFocusPolicy(NoFocus); |
411 | 412 | ||
412 | // Create all-day agenda widget | 413 | // Create all-day agenda widget |
413 | mDummyAllDayLeft = new QVBox( mAllDayFrame ); | 414 | mDummyAllDayLeft = new QVBox( mAllDayFrame ); |
414 | 415 | ||
415 | mExpandButton = new QPushButton(mDummyAllDayLeft); | 416 | mExpandButton = new QPushButton(mDummyAllDayLeft); |
416 | mExpandButton->setPixmap( expandPix ); | 417 | mExpandButton->setPixmap( expandPix ); |
417 | int widebut = mExpandButton->sizeHint().width()+4; | 418 | int widebut = mExpandButton->sizeHint().width()+4; |
418 | int heibut = mExpandButton->sizeHint().height()+4; | 419 | int heibut = mExpandButton->sizeHint().height()+4; |
419 | if ( heibut > widebut ) | 420 | if ( heibut > widebut ) |
420 | widebut = heibut ; | 421 | widebut = heibut ; |
421 | if ( QApplication::desktop()->width() < 480 ) | 422 | |
422 | widebut = widebut*3/2; | ||
423 | //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, | 423 | //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, |
424 | // QSizePolicy::Fixed ) ); | 424 | // QSizePolicy::Fixed ) ); |
425 | mExpandButton->setFixedSize( widebut, widebut); | 425 | mExpandButton->setFixedSize( widebut, widebut); |
426 | connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); | 426 | connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); |
427 | mExpandButton->setFocusPolicy(NoFocus); | 427 | mExpandButton->setFocusPolicy(NoFocus); |
428 | mAllDayAgenda = new KOAgenda(1,mAllDayFrame); | 428 | mAllDayAgenda = new KOAgenda(1,mAllDayFrame); |
429 | mAllDayAgenda->setFocusPolicy(NoFocus); | 429 | mAllDayAgenda->setFocusPolicy(NoFocus); |
430 | QLabel *dummyAllDayRight = new QLabel (mAllDayFrame); | 430 | QLabel *dummyAllDayRight = new QLabel (mAllDayFrame); |
431 | 431 | ||
432 | // Create event context menu for all day agenda | 432 | // Create event context menu for all day agenda |
433 | mAllDayAgendaPopup = eventPopup(); | 433 | mAllDayAgendaPopup = eventPopup(); |
434 | connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), | 434 | connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), |
@@ -708,25 +708,25 @@ void KOAgendaView::createDayLabels() | |||
708 | mDayLabels->setFont( dlf ); | 708 | mDayLabels->setFont( dlf ); |
709 | // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; | 709 | // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; |
710 | // mLayoutDayLabels->addSpacing(mTimeLabels->width()); | 710 | // mLayoutDayLabels->addSpacing(mTimeLabels->width()); |
711 | //mLayoutDayLabels->addSpacing( 2 ); | 711 | //mLayoutDayLabels->addSpacing( 2 ); |
712 | // QFont lFont = dlf; | 712 | // QFont lFont = dlf; |
713 | bool appendLabels = false; | 713 | bool appendLabels = false; |
714 | KOAgendaButton *dayLabel; | 714 | KOAgendaButton *dayLabel; |
715 | dayLabel = mDayLabelsList.first(); | 715 | dayLabel = mDayLabelsList.first(); |
716 | if ( !dayLabel ) { | 716 | if ( !dayLabel ) { |
717 | appendLabels = true; | 717 | appendLabels = true; |
718 | dayLabel = getNewDaylabel(); | 718 | dayLabel = getNewDaylabel(); |
719 | } | 719 | } |
720 | dayLabel->setFixedWidth( mTimeLabels->width()+2 ); | 720 | dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() ); |
721 | dayLabel->setFont( dlf ); | 721 | dayLabel->setFont( dlf ); |
722 | dayLabel->setNum( -1 ); | 722 | dayLabel->setNum( -1 ); |
723 | //dayLabel->setAlignment(QLabel::AlignHCenter); | 723 | //dayLabel->setAlignment(QLabel::AlignHCenter); |
724 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); | 724 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); |
725 | dayLabel->show(); | 725 | dayLabel->show(); |
726 | DateList::ConstIterator dit; | 726 | DateList::ConstIterator dit; |
727 | bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); | 727 | bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); |
728 | int counter = -1; | 728 | int counter = -1; |
729 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { | 729 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { |
730 | ++counter; | 730 | ++counter; |
731 | QDate date = *dit; | 731 | QDate date = *dit; |
732 | // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); | 732 | // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); |
@@ -819,26 +819,26 @@ void KOAgendaView::createDayLabels() | |||
819 | } | 819 | } |
820 | #endif | 820 | #endif |
821 | } | 821 | } |
822 | if ( ! appendLabels ) { | 822 | if ( ! appendLabels ) { |
823 | dayLabel = mDayLabelsList.next(); | 823 | dayLabel = mDayLabelsList.next(); |
824 | if ( !dayLabel ) | 824 | if ( !dayLabel ) |
825 | appendLabels = true; | 825 | appendLabels = true; |
826 | } | 826 | } |
827 | if ( appendLabels ) { | 827 | if ( appendLabels ) { |
828 | dayLabel = getNewDaylabel(); | 828 | dayLabel = getNewDaylabel(); |
829 | } | 829 | } |
830 | //dayLabel->hide();//test only | 830 | //dayLabel->hide();//test only |
831 | 831 | qDebug("fremwidd %d ", mAgenda->frameWidth()); | |
832 | int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()-3 ) % mSelectedDates.count() ; | 832 | int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()- (mAgenda->frameWidth()*2) ) % mSelectedDates.count() ; |
833 | if ( offset < 0 ) offset = 0; | 833 | if ( offset < 0 ) offset = 0; |
834 | //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 ); | 834 | //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 ); |
835 | dayLabel->setText(">");//QString::number ( mSelectedDates.first().month() ) ); | 835 | dayLabel->setText(">");//QString::number ( mSelectedDates.first().month() ) ); |
836 | dayLabel->setFont( dlf ); | 836 | dayLabel->setFont( dlf ); |
837 | dayLabel->setAutoRepeat( true ); | 837 | dayLabel->setAutoRepeat( true ); |
838 | dayLabel->show(); | 838 | dayLabel->show(); |
839 | dayLabel->setNum( -2 ); | 839 | dayLabel->setNum( -2 ); |
840 | dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset ); | 840 | dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset ); |
841 | //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2); | 841 | //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2); |
842 | //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); | 842 | //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); |
843 | if ( !appendLabels ) { | 843 | if ( !appendLabels ) { |
844 | dayLabel = mDayLabelsList.next(); | 844 | dayLabel = mDayLabelsList.next(); |