-rw-r--r-- | korganizer/koagendaview.cpp | 130 |
1 files changed, 26 insertions, 104 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index 95388ef..880d399 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp | |||
@@ -121,12 +121,11 @@ void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) | |||
121 | QString suffix = "am"; | 121 | QString suffix = "am"; |
122 | int timeHeight = fm.ascent(); | 122 | int timeHeight = fm.ascent(); |
123 | QFont nFont = p->font(); | 123 | QFont nFont = font(); |
124 | p->setFont( font()); | ||
124 | 125 | ||
125 | if (!KGlobal::locale()->use12Clock()) { | 126 | if (!KGlobal::locale()->use12Clock()) { |
126 | if ( QApplication::desktop()->width() <= 320 ) | ||
127 | suffix = "00"; | 127 | suffix = "00"; |
128 | else | 128 | } else |
129 | suffix = "00"; | 129 | if (cell > 11) suffix = "pm"; |
130 | } | ||
131 | 130 | ||
132 | if ( timeHeight > mCellHeight ) { | 131 | if ( timeHeight > mCellHeight ) { |
@@ -149,15 +148,15 @@ void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) | |||
149 | int sHei = fmS.ascent() ; | 148 | int sHei = fmS.ascent() ; |
150 | //sHei -= (sHei/4-2); | 149 | //sHei -= (sHei/4-2); |
151 | int startW = this->width() - frameWidth()-2; | 150 | int startW = mMiniWidth - frameWidth()-2 ; |
152 | int tw2 = fmS.width(suffix); | 151 | int tw2 = fmS.width(suffix); |
153 | timeHeight = (timeHeight-1) /2 -1; | 152 | timeHeight = (timeHeight-1) /2 -1; |
153 | //testline | ||
154 | //p->drawLine(0,0,0,contentsHeight()); | ||
154 | while (y < cy + ch+mCellHeight) { | 155 | while (y < cy + ch+mCellHeight) { |
155 | p->drawLine(startW-tw2+1 ,y,cw,y); | 156 | p->drawLine(startW-tw2 ,y,cw+2,y); |
156 | hour.setNum(cell); | 157 | hour.setNum(cell); |
157 | // handle 24h and am/pm time formats | 158 | // handle 24h and am/pm time formats |
158 | if (KGlobal::locale()->use12Clock()) { | 159 | if (KGlobal::locale()->use12Clock()) { |
159 | if (cell > 11) suffix = "pm"; | 160 | if (cell == 12) suffix = "pm"; |
160 | else | ||
161 | suffix = "am"; | ||
162 | if (cell == 0) hour.setNum(12); | 161 | if (cell == 0) hour.setNum(12); |
163 | if (cell > 12) hour.setNum(cell - 12); | 162 | if (cell > 12) hour.setNum(cell - 12); |
@@ -166,9 +165,9 @@ void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) | |||
166 | // center and draw the time label | 165 | // center and draw the time label |
167 | int timeWidth = fm.width(hour); | 166 | int timeWidth = fm.width(hour); |
168 | int offset = startW - timeWidth - tw2 ; | 167 | int offset = startW - timeWidth - tw2 -1 ; |
169 | p->setFont( nFont ); | 168 | p->setFont( nFont ); |
170 | p->drawText( offset, y+ timeHeight, hour); | 169 | p->drawText( offset, y+ timeHeight, hour); |
171 | p->setFont( sFont ); | 170 | p->setFont( sFont ); |
172 | offset = startW - tw2+1; | 171 | offset = startW - tw2; |
173 | p->drawText( offset, y -1, suffix); | 172 | p->drawText( offset, y -1, suffix); |
174 | 173 | ||
@@ -181,80 +180,4 @@ void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) | |||
181 | 180 | ||
182 | 181 | ||
183 | #if 0 | ||
184 | mRedrawNeeded = true; | ||
185 | if ( mRedrawNeeded ) { | ||
186 | cx = contentsX() + frameWidth()*2; | ||
187 | cw = contentsWidth() ; | ||
188 | // end of workaround | ||
189 | |||
190 | int cell = ((int)(cy/mCellHeight)); | ||
191 | int y = cell * mCellHeight; | ||
192 | QFontMetrics fm = fontMetrics(); | ||
193 | QString hour; | ||
194 | QString suffix; | ||
195 | int timeHeight = fm.ascent(); | ||
196 | QFont nFont = p->font(); | ||
197 | |||
198 | if (!KGlobal::locale()->use12Clock()) { | ||
199 | if ( QApplication::desktop()->width() <= 320 ) | ||
200 | suffix = ""; | ||
201 | else | ||
202 | suffix = "00"; | ||
203 | } | ||
204 | |||
205 | if ( timeHeight > mCellHeight ) { | ||
206 | timeHeight = mCellHeight-1; | ||
207 | int pointS = nFont.pointSize(); | ||
208 | while ( pointS > 4 ) { | ||
209 | nFont.setPointSize( pointS ); | ||
210 | fm = QFontMetrics( nFont ); | ||
211 | if ( fm.ascent() < mCellHeight ) | ||
212 | break; | ||
213 | -- pointS; | ||
214 | } | ||
215 | fm = QFontMetrics( nFont ); | ||
216 | timeHeight = fm.ascent(); | ||
217 | } | ||
218 | //timeHeight -= (timeHeight/4-2); | ||
219 | QFont sFont = nFont; | ||
220 | sFont.setPointSize( sFont.pointSize()/2 ); | ||
221 | QFontMetrics fmS( sFont ); | ||
222 | int sHei = fmS.ascent() ; | ||
223 | //sHei -= (sHei/4-2); | ||
224 | int startW = this->width() - frameWidth()-2; | ||
225 | int tw2 = fmS.width(suffix); | ||
226 | while (y < cy + ch) { | ||
227 | p->drawLine(cx,y,cw,y); | ||
228 | hour.setNum(cell); | ||
229 | // handle 24h and am/pm time formats | ||
230 | if (KGlobal::locale()->use12Clock()) { | ||
231 | if (cell > 11) suffix = "pm"; | ||
232 | else | ||
233 | suffix = "am"; | ||
234 | if (cell == 0) hour.setNum(12); | ||
235 | if (cell > 12) hour.setNum(cell - 12); | ||
236 | tw2 = fmS.width(suffix); | ||
237 | } | ||
238 | |||
239 | // center and draw the time label | ||
240 | int timeWidth = fm.width(hour); | ||
241 | int offset = startW - timeWidth - tw2 ; | ||
242 | p->setFont( nFont ); | ||
243 | p->drawText( offset, y+ timeHeight, hour); | ||
244 | p->setFont( sFont ); | ||
245 | offset = startW - tw2+1; | ||
246 | p->drawText( offset, y+ sHei, suffix); | ||
247 | |||
248 | // increment indices | ||
249 | y += mCellHeight; | ||
250 | cell++; | ||
251 | } | ||
252 | } else { | ||
253 | //qDebug("NO redraw "); | ||
254 | } | ||
255 | // double buffer not yet implemented | ||
256 | //bitBlt (this, 0, 0, &myPix, 0 ,0,width(), height() ,CopyROP); | ||
257 | //mRedrawNeeded = false; | ||
258 | #endif | ||
259 | } | 182 | } |
260 | 183 | ||
@@ -282,13 +205,11 @@ void TimeLabels::updateConfig() | |||
282 | test = "pm"; | 205 | test = "pm"; |
283 | else { | 206 | else { |
284 | if ( QApplication::desktop()->width() <= 320 ) | 207 | test = "00"; |
285 | test = "00"; | ||
286 | else | ||
287 | test = "00"; | ||
288 | } | 208 | } |
289 | QFont sFont = font(); | 209 | QFont sFont = font(); |
290 | sFont.setPointSize( sFont.pointSize()/2 ); | 210 | sFont.setPointSize( sFont.pointSize()/2 ); |
291 | QFontMetrics fmS( sFont ); | 211 | QFontMetrics fmS( sFont ); |
292 | mMiniWidth += fmS.width( test ) + frameWidth()*2 +4 ; | 212 | mMiniWidth += fmS.width( test ) + frameWidth()*2+4 ; |
213 | qDebug("testwid %d %d", mMiniWidth ,fmS.width( test )); | ||
293 | // update geometry restrictions based on new settings | 214 | // update geometry restrictions based on new settings |
294 | setFixedWidth( mMiniWidth ); | 215 | setFixedWidth( mMiniWidth ); |
@@ -735,4 +656,6 @@ void KOAgendaView::createDayLabels() | |||
735 | } | 656 | } |
736 | int newHight; | 657 | int newHight; |
658 | if ( !mSelectedDates.count()) | ||
659 | return; | ||
737 | 660 | ||
738 | // ### Before deleting and recreating we could check if mSelectedDates changed... | 661 | // ### Before deleting and recreating we could check if mSelectedDates changed... |
@@ -741,8 +664,6 @@ void KOAgendaView::createDayLabels() | |||
741 | 664 | ||
742 | int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2; | 665 | int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2; |
743 | if ( QApplication::desktop()->width() <= 320 ) | ||
744 | maxWid -= 10; | ||
745 | mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); | 666 | mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); |
746 | if ( maxWid < 0 ) | 667 | if ( maxWid < 20 ) |
747 | maxWid = 20; | 668 | maxWid = 20; |
748 | 669 | ||
@@ -750,9 +671,13 @@ void KOAgendaView::createDayLabels() | |||
750 | QFontMetrics fm ( dlf ); | 671 | QFontMetrics fm ( dlf ); |
751 | int selCount = mSelectedDates.count(); | 672 | int selCount = mSelectedDates.count(); |
673 | int widModulo = maxWid - (mAgenda->gridSpacingX() * selCount)+1; | ||
752 | QString dayTest = "Mon 20"; | 674 | QString dayTest = "Mon 20"; |
753 | //QString dayTest = "Mon 20"; | 675 | //QString dayTest = "Mon 20"; |
754 | int wid = fm.width( dayTest ); | 676 | int wid = fm.width( dayTest ); |
755 | //maxWid -= ( selCount * 3 ); //working for QLabels | 677 | //maxWid -= ( selCount * 3 ); //working for QLabels |
756 | maxWid -= ( selCount * 3 ); //working for QPushButton | 678 | if ( QApplication::desktop()->width() <= 320 ) |
679 | maxWid -= ( selCount * 3 ); //working for QPushButton | ||
680 | else | ||
681 | maxWid -= ( selCount * 3 ); //working for QPushButton | ||
757 | if ( maxWid < 0 ) | 682 | if ( maxWid < 0 ) |
758 | maxWid = 20; | 683 | maxWid = 20; |
@@ -913,15 +838,12 @@ void KOAgendaView::createDayLabels() | |||
913 | } | 838 | } |
914 | //dayLabel->hide();//test only | 839 | //dayLabel->hide();//test only |
915 | int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()- (mAgenda->frameWidth()*2) ) % mSelectedDates.count() ; | 840 | |
916 | if ( offset < 0 ) offset = 0; | 841 | dayLabel->setText(">"); |
917 | //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 ); | ||
918 | dayLabel->setText(">");//QString::number ( mSelectedDates.first().month() ) ); | ||
919 | dayLabel->setFont( dlf ); | 842 | dayLabel->setFont( dlf ); |
920 | dayLabel->setAutoRepeat( true ); | 843 | dayLabel->setAutoRepeat( true ); |
921 | dayLabel->show(); | 844 | dayLabel->show(); |
922 | dayLabel->setNum( -2 ); | 845 | dayLabel->setNum( -2 ); |
923 | dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset ); | 846 | dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ widModulo ); |
924 | 847 | ||
925 | //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2); | ||
926 | //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); | 848 | //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); |
927 | if ( !appendLabels ) { | 849 | if ( !appendLabels ) { |