-rw-r--r-- | korganizer/komonthview.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index 6294b98..0ef5ae4 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp | |||
@@ -1114,128 +1114,132 @@ void KOMonthView::computeLayoutWeek() | |||
1114 | { | 1114 | { |
1115 | 1115 | ||
1116 | int daysToShow; | 1116 | int daysToShow; |
1117 | bool combinedSatSun = false; | 1117 | bool combinedSatSun = false; |
1118 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { | 1118 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { |
1119 | daysToShow = 6; | 1119 | daysToShow = 6; |
1120 | combinedSatSun = true; | 1120 | combinedSatSun = true; |
1121 | } | 1121 | } |
1122 | int tWid = topLevelWidget()->size().width(); | 1122 | int tWid = topLevelWidget()->size().width(); |
1123 | int tHei = topLevelWidget()->size().height(); | 1123 | int tHei = topLevelWidget()->size().height(); |
1124 | 1124 | ||
1125 | int wid = size().width();//e | 1125 | int wid = size().width();//e |
1126 | int hei = size().height()-1; | 1126 | int hei = size().height()-1; |
1127 | 1127 | ||
1128 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) | 1128 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) |
1129 | return; | 1129 | return; |
1130 | 1130 | ||
1131 | if ( wid < hei ) | 1131 | if ( wid < hei ) |
1132 | daysToShow = 2; | 1132 | daysToShow = 2; |
1133 | else | 1133 | else |
1134 | daysToShow = 3; | 1134 | daysToShow = 3; |
1135 | mShowSatSunComp = true; | 1135 | mShowSatSunComp = true; |
1136 | combinedSatSun = true; | 1136 | combinedSatSun = true; |
1137 | 1137 | ||
1138 | //qDebug("KOMonthView::computeLayout()------------------------------------ "); | 1138 | //qDebug("KOMonthView::computeLayout()------------------------------------ "); |
1139 | QFontMetrics fm ( mWeekLabels[0]->font() ); | 1139 | QFontMetrics fm ( mWeekLabels[0]->font() ); |
1140 | int weeklabelwid = fm.width( "888" ); | 1140 | int weeklabelwid = fm.width( "888" ); |
1141 | wid -= weeklabelwid; | 1141 | wid -= weeklabelwid; |
1142 | 1142 | ||
1143 | int colWid = wid / daysToShow; | 1143 | int colWid = wid / daysToShow; |
1144 | int lastCol = wid - ( colWid*6 ); | 1144 | int lastCol = wid - ( colWid*6 ); |
1145 | int dayLabelHei = mDayLabels[0]->sizeHint().height(); | 1145 | int dayLabelHei = mDayLabels[0]->sizeHint().height(); |
1146 | int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); | 1146 | int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); |
1147 | int colModulo = wid % daysToShow; | 1147 | int colModulo = wid % daysToShow; |
1148 | int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; | 1148 | int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; |
1149 | //qDebug("rowmod %d ", rowModulo); | 1149 | //qDebug("rowmod %d ", rowModulo); |
1150 | int i; | 1150 | int i; |
1151 | int x,y,w,h; | 1151 | int x,y,w,h; |
1152 | x= 0; | 1152 | x= 0; |
1153 | y= 0; | 1153 | y= 0; |
1154 | w = colWid; | 1154 | w = colWid; |
1155 | h = dayLabelHei ; | 1155 | h = dayLabelHei ; |
1156 | for ( i = 0; i < 7; i++) { | 1156 | for ( i = 0; i < 7; i++) { |
1157 | if ( i && !( i % daysToShow) && i < 6) { | 1157 | if ( i && !( i % daysToShow) && i < 6) { |
1158 | y += hei/(5-daysToShow); | 1158 | y += hei/(5-daysToShow); |
1159 | x = 0; | 1159 | x = 0; |
1160 | w = colWid; | 1160 | w = colWid; |
1161 | } | 1161 | } |
1162 | if ( i == daysToShow-colModulo ) | 1162 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { |
1163 | ++w; | 1163 | ++w; |
1164 | } | ||
1164 | if ( i >= 5 ) { | 1165 | if ( i >= 5 ) { |
1165 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2+1,h); | 1166 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2+w%2,h); |
1166 | x -= w/2 ; | 1167 | x -= (w/2 ); |
1167 | } | 1168 | } |
1168 | else | 1169 | else |
1169 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); | 1170 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); |
1170 | x += w; | 1171 | x += w; |
1171 | } | 1172 | } |
1172 | x= 0; | 1173 | x= 0; |
1173 | y= dayLabelHei; | 1174 | y= dayLabelHei; |
1174 | w = colWid; | 1175 | w = colWid; |
1175 | h = cellHei; | 1176 | h = cellHei; |
1176 | for ( i = 0; i < mCells.count(); ++i) { | 1177 | for ( i = 0; i < mCells.count(); ++i) { |
1177 | if ( i > 6 ) { | 1178 | if ( i > 6 ) { |
1178 | mCells[i]->hide(); | 1179 | mCells[i]->hide(); |
1179 | continue; | 1180 | continue; |
1180 | } | 1181 | } |
1181 | 1182 | ||
1182 | w = colWid; | 1183 | w = colWid; |
1183 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { | 1184 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { |
1184 | ++w; | 1185 | ++w; |
1185 | } | 1186 | } |
1186 | if ( i == (daysToShow-1-rowModulo)*7) | 1187 | if ( i == (daysToShow-1-rowModulo)*7) |
1187 | ++h; | 1188 | ++h; |
1188 | 1189 | ||
1189 | if ( i >= 5 ) { | 1190 | if ( i >= 5 ) { |
1190 | if ( i ==5 ) { | 1191 | if ( i ==5 ) { |
1191 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); | 1192 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); |
1192 | x -= w ;y += h/2; | 1193 | x -= w ;y += h/2; |
1193 | } else { | 1194 | } else { |
1195 | if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) { | ||
1196 | ++w; | ||
1197 | } | ||
1194 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); | 1198 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); |
1195 | y -= h/2; | 1199 | y -= h/2; |
1196 | } | 1200 | } |
1197 | } else | 1201 | } else |
1198 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 1202 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
1199 | 1203 | ||
1200 | 1204 | ||
1201 | x += w; | 1205 | x += w; |
1202 | if ( x + w/2 > wid ) { | 1206 | if ( x + w/2 > wid ) { |
1203 | x = 0; | 1207 | x = 0; |
1204 | y += h+dayLabelHei ; | 1208 | y += h+dayLabelHei ; |
1205 | } | 1209 | } |
1206 | } | 1210 | } |
1207 | y= dayLabelHei; | 1211 | y= dayLabelHei; |
1208 | h = cellHei ; | 1212 | h = cellHei ; |
1209 | mWeekLabels[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); | 1213 | mWeekLabels[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); |
1210 | for ( i = 1; i < 6; i++) { | 1214 | for ( i = 1; i < 6; i++) { |
1211 | mWeekLabels[i]->hide(); | 1215 | mWeekLabels[i]->hide(); |
1212 | } | 1216 | } |
1213 | mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); | 1217 | mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); |
1214 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); | 1218 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); |
1215 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); | 1219 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); |
1216 | mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ; | 1220 | mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ; |
1217 | updateDayLabels(); | 1221 | updateDayLabels(); |
1218 | bool forceUpdate = !updatePossible; | 1222 | bool forceUpdate = !updatePossible; |
1219 | updatePossible = true; | 1223 | updatePossible = true; |
1220 | mWeekLabels[mNumWeeks]->setText( i18n("M")); | 1224 | mWeekLabels[mNumWeeks]->setText( i18n("M")); |
1221 | if ( forceUpdate ) | 1225 | if ( forceUpdate ) |
1222 | updateView(); | 1226 | updateView(); |
1223 | } | 1227 | } |
1224 | void KOMonthView::computeLayout() | 1228 | void KOMonthView::computeLayout() |
1225 | { | 1229 | { |
1226 | // select the appropriate heading string size. E.g. "Wednesday" or "Wed". | 1230 | // select the appropriate heading string size. E.g. "Wednesday" or "Wed". |
1227 | // note this only changes the text if the requested size crosses the | 1231 | // note this only changes the text if the requested size crosses the |
1228 | // threshold between big enough to support the full name and not big | 1232 | // threshold between big enough to support the full name and not big |
1229 | // enough. | 1233 | // enough. |
1230 | if ( mShowWeekView ){ | 1234 | if ( mShowWeekView ){ |
1231 | computeLayoutWeek(); | 1235 | computeLayoutWeek(); |
1232 | return; | 1236 | return; |
1233 | } | 1237 | } |
1234 | int daysToShow = 7; | 1238 | int daysToShow = 7; |
1235 | bool combinedSatSun = false; | 1239 | bool combinedSatSun = false; |
1236 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { | 1240 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { |
1237 | daysToShow = 6; | 1241 | daysToShow = 6; |
1238 | combinedSatSun = true; | 1242 | combinedSatSun = true; |
1239 | } | 1243 | } |
1240 | int tWid = topLevelWidget()->size().width(); | 1244 | int tWid = topLevelWidget()->size().width(); |
1241 | int tHei = topLevelWidget()->size().height(); | 1245 | int tHei = topLevelWidget()->size().height(); |