author | zautrix <zautrix> | 2005-01-05 14:55:14 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-01-05 14:55:14 (UTC) |
commit | 71017beb975666a0f654898ed6a40a5303d567dc (patch) (unidiff) | |
tree | 39f3c0e3c890ee90806e93d9ce9bd9024be11d55 /korganizer | |
parent | df0200487afbfa59b80a79e548d70b5203019003 (diff) | |
download | kdepimpi-71017beb975666a0f654898ed6a40a5303d567dc.zip kdepimpi-71017beb975666a0f654898ed6a40a5303d567dc.tar.gz kdepimpi-71017beb975666a0f654898ed6a40a5303d567dc.tar.bz2 |
minor fixes
-rw-r--r-- | korganizer/koagenda.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp index 6532705..eb3791e 100644 --- a/korganizer/koagenda.cpp +++ b/korganizer/koagenda.cpp | |||
@@ -1050,387 +1050,392 @@ void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) | |||
1050 | { | 1050 | { |
1051 | if ( globalFlagBlockAgenda ) | 1051 | if ( globalFlagBlockAgenda ) |
1052 | return; | 1052 | return; |
1053 | //qDebug("KOAgenda::drawContents "); | 1053 | //qDebug("KOAgenda::drawContents "); |
1054 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) | 1054 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) |
1055 | ;//drawContentsToPainter(); | 1055 | ;//drawContentsToPainter(); |
1056 | 1056 | ||
1057 | QPaintDevice* pd = p->device(); | 1057 | QPaintDevice* pd = p->device(); |
1058 | p->end(); | 1058 | p->end(); |
1059 | int vx, vy; | 1059 | int vx, vy; |
1060 | int selectionX = KOGlobals::self()->reverseLayout() ? | 1060 | int selectionX = KOGlobals::self()->reverseLayout() ? |
1061 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : | 1061 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : |
1062 | mSelectionCellX * mGridSpacingX; | 1062 | mSelectionCellX * mGridSpacingX; |
1063 | contentsToViewport ( cx, cy, vx,vy); | 1063 | contentsToViewport ( cx, cy, vx,vy); |
1064 | // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ; | 1064 | // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ; |
1065 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) | 1065 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) |
1066 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); | 1066 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); |
1067 | 1067 | ||
1068 | if ( mSelectionHeight > 0 ) { | 1068 | if ( mSelectionHeight > 0 ) { |
1069 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); | 1069 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); |
1070 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1070 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1071 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { | 1071 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { |
1072 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); | 1072 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); |
1073 | bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); | 1073 | bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); |
1074 | } | 1074 | } |
1075 | } | 1075 | } |
1076 | //qDebug("btbl "); | 1076 | //qDebug("btbl "); |
1077 | p->begin( pd ); | 1077 | p->begin( pd ); |
1078 | //qDebug("end "); | 1078 | //qDebug("end "); |
1079 | } | 1079 | } |
1080 | 1080 | ||
1081 | void KOAgenda::finishUpdate() | 1081 | void KOAgenda::finishUpdate() |
1082 | { | 1082 | { |
1083 | 1083 | ||
1084 | KOAgendaItem *item; | 1084 | KOAgendaItem *item; |
1085 | globalFlagBlockAgendaItemPaint = 1; | 1085 | globalFlagBlockAgendaItemPaint = 1; |
1086 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1086 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1087 | if ( !item->isVisible() ) | 1087 | if ( !item->isVisible() ) |
1088 | item->show(); | 1088 | item->show(); |
1089 | 1089 | ||
1090 | } | 1090 | } |
1091 | globalFlagBlockAgendaItemUpdate = 0; | 1091 | globalFlagBlockAgendaItemUpdate = 0; |
1092 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1092 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1093 | item->repaintMe( ); | 1093 | item->repaintMe( ); |
1094 | } | 1094 | } |
1095 | globalFlagBlockAgendaItemUpdate = 1; | 1095 | globalFlagBlockAgendaItemUpdate = 1; |
1096 | qApp->processEvents(); | 1096 | qApp->processEvents(); |
1097 | globalFlagBlockAgendaItemPaint = 0; | 1097 | globalFlagBlockAgendaItemPaint = 0; |
1098 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1098 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1099 | item->repaint( false ); | 1099 | item->repaint( false ); |
1100 | } | 1100 | } |
1101 | 1101 | ||
1102 | } | 1102 | } |
1103 | 1103 | ||
1104 | /* | 1104 | /* |
1105 | Draw grid in the background of the agenda. | 1105 | Draw grid in the background of the agenda. |
1106 | */ | 1106 | */ |
1107 | void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch) | 1107 | void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch) |
1108 | { | 1108 | { |
1109 | 1109 | ||
1110 | 1110 | ||
1111 | if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask ) | 1111 | if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask ) |
1112 | return; | 1112 | return; |
1113 | if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 ) | 1113 | if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 ) |
1114 | return; | 1114 | return; |
1115 | int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight(); | 1115 | int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight(); |
1116 | if ( ch < 1 ) | 1116 | if ( ch < 1 ) |
1117 | ch = 1; | 1117 | ch = 1; |
1118 | if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) { | 1118 | if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) { |
1119 | mPaintPixmap.resize( contentsWidth()+42, ch ); | 1119 | mPaintPixmap.resize( contentsWidth()+42, ch ); |
1120 | } | 1120 | } |
1121 | mCurPixWid = contentsWidth(); | 1121 | mCurPixWid = contentsWidth(); |
1122 | mCurPixHei = ch; | 1122 | mCurPixHei = ch; |
1123 | if ( mHighlightPixmap.width() < mGridSpacingX-1 || mHighlightPixmap.height() < ch ) { | 1123 | if ( mHighlightPixmap.width() < mGridSpacingX-1 || mHighlightPixmap.height() < ch ) { |
1124 | mHighlightPixmap.resize( mGridSpacingX-1, ch ); | 1124 | mHighlightPixmap.resize( mGridSpacingX-1, ch ); |
1125 | mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor ); | 1125 | mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor ); |
1126 | } | 1126 | } |
1127 | mPixPainter.begin( &mPaintPixmap) ; | 1127 | mPixPainter.begin( &mPaintPixmap) ; |
1128 | //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() ); | 1128 | //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() ); |
1129 | QPainter * p ; | 1129 | QPainter * p ; |
1130 | if (paint == 0) { | 1130 | if (paint == 0) { |
1131 | mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor); | 1131 | mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor); |
1132 | p = &mPixPainter; | 1132 | p = &mPixPainter; |
1133 | } | 1133 | } |
1134 | else | 1134 | else |
1135 | p = paint ; | 1135 | p = paint ; |
1136 | // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch); | 1136 | // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch); |
1137 | 1137 | ||
1138 | //--cx;++cw; | 1138 | //--cx;++cw; |
1139 | int lGridSpacingY = mGridSpacingY*2; | 1139 | int lGridSpacingY = mGridSpacingY*2; |
1140 | int selDay; | 1140 | int selDay; |
1141 | if ( !backgroundOnly ) | 1141 | if ( !backgroundOnly ) |
1142 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) | 1142 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) |
1143 | { | 1143 | { |
1144 | if ( mSelectedDates[selDay] == QDateTime::currentDateTime ().date() && KOPrefs::instance()->mHighlightCurrentDay) { | 1144 | if ( mSelectedDates[selDay] == QDateTime::currentDateTime ().date() && KOPrefs::instance()->mHighlightCurrentDay) { |
1145 | int x1 = cx; | 1145 | int x1 = cx; |
1146 | int y1 = 0; | 1146 | int y1 = 0; |
1147 | if (y1 < cy) y1 = cy; | 1147 | if (y1 < cy) y1 = cy; |
1148 | int x2 = cx+cw-1; | 1148 | int x2 = cx+cw-1; |
1149 | int y2 = contentsHeight(); | 1149 | int y2 = contentsHeight(); |
1150 | if (y2 > cy+ch-1) y2=cy+ch-1; | 1150 | if (y2 > cy+ch-1) y2=cy+ch-1; |
1151 | if (x2 >= x1 && y2 >= y1) { | 1151 | if (x2 >= x1 && y2 >= y1) { |
1152 | int gxStart = selDay; | 1152 | int gxStart = selDay; |
1153 | int gxEnd = gxStart ; | 1153 | int gxEnd = gxStart ; |
1154 | int xStart = KOGlobals::self()->reverseLayout() ? | 1154 | int xStart = KOGlobals::self()->reverseLayout() ? |
1155 | (mColumns - 1 - gxStart)*mGridSpacingX : | 1155 | (mColumns - 1 - gxStart)*mGridSpacingX : |
1156 | gxStart*mGridSpacingX; | 1156 | gxStart*mGridSpacingX; |
1157 | if (xStart < x1) xStart = x1; | 1157 | if (xStart < x1) xStart = x1; |
1158 | int xEnd = KOGlobals::self()->reverseLayout() ? | 1158 | int xEnd = KOGlobals::self()->reverseLayout() ? |
1159 | (mColumns - gxStart)*mGridSpacingX-1 : | 1159 | (mColumns - gxStart)*mGridSpacingX-1 : |
1160 | (gxStart+1)*mGridSpacingX-1; | 1160 | (gxStart+1)*mGridSpacingX-1; |
1161 | if (xEnd > x2) xEnd = x2; | 1161 | if (xEnd > x2) xEnd = x2; |
1162 | if ( KOPrefs::instance()->mUseHighlightLightColor ) | 1162 | if ( KOPrefs::instance()->mUseHighlightLightColor ) |
1163 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1163 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1164 | KOPrefs::instance()->mAgendaBgColor.light()); | 1164 | KOPrefs::instance()->mAgendaBgColor.light()); |
1165 | else | 1165 | else |
1166 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1166 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1167 | KOPrefs::instance()->mAgendaBgColor.dark()); | 1167 | KOPrefs::instance()->mAgendaBgColor.dark()); |
1168 | 1168 | ||
1169 | } | 1169 | } |
1170 | } | 1170 | } |
1171 | } | 1171 | } |
1172 | // Highlight working hours | 1172 | // Highlight working hours |
1173 | 1173 | ||
1174 | if ( !backgroundOnly ) | 1174 | if ( !backgroundOnly ) |
1175 | if (mWorkingHoursEnable) { | 1175 | if (mWorkingHoursEnable) { |
1176 | int x1 = cx; | 1176 | int x1 = cx; |
1177 | int y1 = mWorkingHoursYTop; | 1177 | int y1 = mWorkingHoursYTop; |
1178 | if (y1 < cy) y1 = cy; | 1178 | if (y1 < cy) y1 = cy; |
1179 | int x2 = cx+cw-1; | 1179 | int x2 = cx+cw-1; |
1180 | // int x2 = mGridSpacingX * 5 - 1; | 1180 | // int x2 = mGridSpacingX * 5 - 1; |
1181 | // if (x2 > cx+cw-1) x2 = cx + cw - 1; | 1181 | // if (x2 > cx+cw-1) x2 = cx + cw - 1; |
1182 | int y2 = mWorkingHoursYBottom; | 1182 | int y2 = mWorkingHoursYBottom; |
1183 | if (y2 > cy+ch-1) y2=cy+ch-1; | 1183 | if (y2 > cy+ch-1) y2=cy+ch-1; |
1184 | 1184 | ||
1185 | if (x2 >= x1 && y2 >= y1) { | 1185 | if (x2 >= x1 && y2 >= y1) { |
1186 | // qDebug("x1 %d mGridSpacingX %d ", x1, mGridSpacingX ); | 1186 | // qDebug("x1 %d mGridSpacingX %d ", x1, mGridSpacingX ); |
1187 | int gxStart = x1/mGridSpacingX; | 1187 | int gxStart = x1/mGridSpacingX; |
1188 | int gxEnd = x2/mGridSpacingX; | 1188 | int gxEnd = x2/mGridSpacingX; |
1189 | while(gxStart <= gxEnd) { | 1189 | while(gxStart <= gxEnd) { |
1190 | if (gxStart < int(mHolidayMask->count()) && | 1190 | if (gxStart < int(mHolidayMask->count()) && |
1191 | !mHolidayMask->at(gxStart)) { | 1191 | !mHolidayMask->at(gxStart)) { |
1192 | int xStart = KOGlobals::self()->reverseLayout() ? | 1192 | int xStart = KOGlobals::self()->reverseLayout() ? |
1193 | (mColumns - 1 - gxStart)*mGridSpacingX : | 1193 | (mColumns - 1 - gxStart)*mGridSpacingX : |
1194 | gxStart*mGridSpacingX; | 1194 | gxStart*mGridSpacingX; |
1195 | if (xStart < x1) xStart = x1; | 1195 | if (xStart < x1) xStart = x1; |
1196 | int xEnd = KOGlobals::self()->reverseLayout() ? | 1196 | int xEnd = KOGlobals::self()->reverseLayout() ? |
1197 | (mColumns - gxStart)*mGridSpacingX-1 : | 1197 | (mColumns - gxStart)*mGridSpacingX-1 : |
1198 | (gxStart+1)*mGridSpacingX-1; | 1198 | (gxStart+1)*mGridSpacingX-1; |
1199 | if (xEnd > x2) xEnd = x2; | 1199 | if (xEnd > x2) xEnd = x2; |
1200 | if ( mSelectedDates[gxStart] == QDateTime::currentDateTime ().date()&& KOPrefs::instance()->mHighlightCurrentDay ) { | 1200 | if ( mSelectedDates[gxStart] == QDateTime::currentDateTime ().date()&& KOPrefs::instance()->mHighlightCurrentDay ) { |
1201 | if ( KOPrefs::instance()->mUseHighlightLightColor ) | 1201 | if ( KOPrefs::instance()->mUseHighlightLightColor ) |
1202 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1202 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1203 | KOPrefs::instance()->mWorkingHoursColor.light()); | 1203 | KOPrefs::instance()->mWorkingHoursColor.light()); |
1204 | else | 1204 | else |
1205 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1205 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1206 | KOPrefs::instance()->mWorkingHoursColor.dark()); | 1206 | KOPrefs::instance()->mWorkingHoursColor.dark()); |
1207 | } else { | 1207 | } else { |
1208 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1208 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1209 | KOPrefs::instance()->mWorkingHoursColor); | 1209 | KOPrefs::instance()->mWorkingHoursColor); |
1210 | } | 1210 | } |
1211 | } | 1211 | } |
1212 | ++gxStart; | 1212 | ++gxStart; |
1213 | } | 1213 | } |
1214 | } | 1214 | } |
1215 | } | 1215 | } |
1216 | /* | 1216 | /* |
1217 | int selectionX = KOGlobals::self()->reverseLayout() ? | 1217 | int selectionX = KOGlobals::self()->reverseLayout() ? |
1218 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : | 1218 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : |
1219 | mSelectionCellX * mGridSpacingX; | 1219 | mSelectionCellX * mGridSpacingX; |
1220 | 1220 | ||
1221 | // Draw selection | 1221 | // Draw selection |
1222 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1222 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1223 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { | 1223 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { |
1224 | // TODO: paint only part within cx,cy,cw,ch | 1224 | // TODO: paint only part within cx,cy,cw,ch |
1225 | p->fillRect( selectionX, mSelectionYTop, mGridSpacingX, | 1225 | p->fillRect( selectionX, mSelectionYTop, mGridSpacingX, |
1226 | mSelectionHeight, KOPrefs::instance()->mHighlightColor ); | 1226 | mSelectionHeight, KOPrefs::instance()->mHighlightColor ); |
1227 | } | 1227 | } |
1228 | */ | 1228 | */ |
1229 | // Draw vertical lines of grid | 1229 | // Draw vertical lines of grid |
1230 | 1230 | ||
1231 | int x = ((int)(cx/mGridSpacingX))*mGridSpacingX; | 1231 | int x = ((int)(cx/mGridSpacingX))*mGridSpacingX; |
1232 | if ( mGridSpacingX > 0 ) { | 1232 | if ( mGridSpacingX > 0 ) { |
1233 | while (x < cx + cw) { | 1233 | while (x < cx + cw) { |
1234 | p->drawLine(x,cy,x,cy+ch); | 1234 | p->drawLine(x,cy,x,cy+ch); |
1235 | x+=mGridSpacingX; | 1235 | x+=mGridSpacingX; |
1236 | } | 1236 | } |
1237 | } | 1237 | } |
1238 | // Draw horizontal lines of grid | 1238 | // Draw horizontal lines of grid |
1239 | int y = ((int)(cy/lGridSpacingY))*lGridSpacingY; | 1239 | int y = ((int)(cy/lGridSpacingY))*lGridSpacingY; |
1240 | if ( lGridSpacingY > 0 ) { | 1240 | if ( lGridSpacingY > 0 ) { |
1241 | while (y < cy + ch) { | 1241 | while (y < cy + ch) { |
1242 | p->setPen( SolidLine ); | ||
1243 | p->drawLine(cx,y,cx+cw,y); | ||
1244 | y+=lGridSpacingY; | ||
1245 | p->setPen( DotLine ); | ||
1242 | p->drawLine(cx,y,cx+cw,y); | 1246 | p->drawLine(cx,y,cx+cw,y); |
1243 | y+=lGridSpacingY; | 1247 | y+=lGridSpacingY; |
1244 | } | 1248 | } |
1249 | p->setPen( SolidLine ); | ||
1245 | } | 1250 | } |
1246 | mPixPainter.end() ; | 1251 | mPixPainter.end() ; |
1247 | } | 1252 | } |
1248 | 1253 | ||
1249 | /* | 1254 | /* |
1250 | Convert srcollview contents coordinates to agenda grid coordinates. | 1255 | Convert srcollview contents coordinates to agenda grid coordinates. |
1251 | */ | 1256 | */ |
1252 | void KOAgenda::contentsToGrid (int x, int y, int& gx, int& gy) | 1257 | void KOAgenda::contentsToGrid (int x, int y, int& gx, int& gy) |
1253 | { | 1258 | { |
1254 | gx = KOGlobals::self()->reverseLayout() ? mColumns - 1 - x/mGridSpacingX : | 1259 | gx = KOGlobals::self()->reverseLayout() ? mColumns - 1 - x/mGridSpacingX : |
1255 | x/mGridSpacingX; | 1260 | x/mGridSpacingX; |
1256 | gy = y/mGridSpacingY; | 1261 | gy = y/mGridSpacingY; |
1257 | } | 1262 | } |
1258 | 1263 | ||
1259 | /* | 1264 | /* |
1260 | Convert agenda grid coordinates to scrollview contents coordinates. | 1265 | Convert agenda grid coordinates to scrollview contents coordinates. |
1261 | */ | 1266 | */ |
1262 | void KOAgenda::gridToContents (int gx, int gy, int& x, int& y) | 1267 | void KOAgenda::gridToContents (int gx, int gy, int& x, int& y) |
1263 | { | 1268 | { |
1264 | x = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - gx)*mGridSpacingX: | 1269 | x = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - gx)*mGridSpacingX: |
1265 | gx*mGridSpacingX; | 1270 | gx*mGridSpacingX; |
1266 | y = gy*mGridSpacingY; | 1271 | y = gy*mGridSpacingY; |
1267 | } | 1272 | } |
1268 | 1273 | ||
1269 | 1274 | ||
1270 | /* | 1275 | /* |
1271 | Return Y coordinate corresponding to time. Coordinates are rounded to fit into | 1276 | Return Y coordinate corresponding to time. Coordinates are rounded to fit into |
1272 | the grid. | 1277 | the grid. |
1273 | */ | 1278 | */ |
1274 | int KOAgenda::timeToY(const QTime &time) | 1279 | int KOAgenda::timeToY(const QTime &time) |
1275 | { | 1280 | { |
1276 | int minutesPerCell = 24 * 60 / mRows; | 1281 | int minutesPerCell = 24 * 60 / mRows; |
1277 | int timeMinutes = time.hour() * 60 + time.minute(); | 1282 | int timeMinutes = time.hour() * 60 + time.minute(); |
1278 | int Y = (timeMinutes + (minutesPerCell / 2)) / minutesPerCell; | 1283 | int Y = (timeMinutes + (minutesPerCell / 2)) / minutesPerCell; |
1279 | return Y; | 1284 | return Y; |
1280 | } | 1285 | } |
1281 | 1286 | ||
1282 | 1287 | ||
1283 | /* | 1288 | /* |
1284 | Return time corresponding to cell y coordinate. Coordinates are rounded to | 1289 | Return time corresponding to cell y coordinate. Coordinates are rounded to |
1285 | fit into the grid. | 1290 | fit into the grid. |
1286 | */ | 1291 | */ |
1287 | QTime KOAgenda::gyToTime(int gy) | 1292 | QTime KOAgenda::gyToTime(int gy) |
1288 | { | 1293 | { |
1289 | 1294 | ||
1290 | int secondsPerCell = 24 * 60 * 60/ mRows; | 1295 | int secondsPerCell = 24 * 60 * 60/ mRows; |
1291 | 1296 | ||
1292 | int timeSeconds = secondsPerCell * gy; | 1297 | int timeSeconds = secondsPerCell * gy; |
1293 | 1298 | ||
1294 | QTime time( 0, 0, 0 ); | 1299 | QTime time( 0, 0, 0 ); |
1295 | if ( timeSeconds < 24 * 60 * 60 ) { | 1300 | if ( timeSeconds < 24 * 60 * 60 ) { |
1296 | time = time.addSecs(timeSeconds); | 1301 | time = time.addSecs(timeSeconds); |
1297 | } else { | 1302 | } else { |
1298 | time.setHMS( 23, 59, 59 ); | 1303 | time.setHMS( 23, 59, 59 ); |
1299 | } | 1304 | } |
1300 | 1305 | ||
1301 | return time; | 1306 | return time; |
1302 | } | 1307 | } |
1303 | 1308 | ||
1304 | void KOAgenda::setStartHour(int startHour) | 1309 | void KOAgenda::setStartHour(int startHour) |
1305 | { | 1310 | { |
1306 | int startCell = startHour * mRows / 24; | 1311 | int startCell = startHour * mRows / 24; |
1307 | setContentsPos(0,startCell * gridSpacingY()); | 1312 | setContentsPos(0,startCell * gridSpacingY()); |
1308 | } | 1313 | } |
1309 | void KOAgenda::hideUnused() | 1314 | void KOAgenda::hideUnused() |
1310 | { | 1315 | { |
1311 | // experimental only | 1316 | // experimental only |
1312 | // return; | 1317 | // return; |
1313 | KOAgendaItem *item; | 1318 | KOAgendaItem *item; |
1314 | for ( item=mUnusedItems.first(); item != 0; item=mUnusedItems.next() ) { | 1319 | for ( item=mUnusedItems.first(); item != 0; item=mUnusedItems.next() ) { |
1315 | item->hide(); | 1320 | item->hide(); |
1316 | } | 1321 | } |
1317 | } | 1322 | } |
1318 | 1323 | ||
1319 | 1324 | ||
1320 | KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view) | 1325 | KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view) |
1321 | { | 1326 | { |
1322 | 1327 | ||
1323 | KOAgendaItem *fi; | 1328 | KOAgendaItem *fi; |
1324 | for ( fi=mUnusedItems.first(); fi != 0; fi=mUnusedItems.next() ) { | 1329 | for ( fi=mUnusedItems.first(); fi != 0; fi=mUnusedItems.next() ) { |
1325 | if ( fi->incidence() == event ) { | 1330 | if ( fi->incidence() == event ) { |
1326 | mUnusedItems.remove(); | 1331 | mUnusedItems.remove(); |
1327 | fi->init( event, qd ); | 1332 | fi->init( event, qd ); |
1328 | return fi; | 1333 | return fi; |
1329 | } | 1334 | } |
1330 | } | 1335 | } |
1331 | fi=mUnusedItems.first(); | 1336 | fi=mUnusedItems.first(); |
1332 | if ( fi ) { | 1337 | if ( fi ) { |
1333 | mUnusedItems.remove(); | 1338 | mUnusedItems.remove(); |
1334 | fi->init( event, qd ); | 1339 | fi->init( event, qd ); |
1335 | return fi; | 1340 | return fi; |
1336 | } | 1341 | } |
1337 | // qDebug("new KOAgendaItem "); | 1342 | // qDebug("new KOAgendaItem "); |
1338 | 1343 | ||
1339 | KOAgendaItem* agendaItem = new KOAgendaItem( event, qd, view, mAllDayMode ); | 1344 | KOAgendaItem* agendaItem = new KOAgendaItem( event, qd, view, mAllDayMode ); |
1340 | agendaItem->installEventFilter(this); | 1345 | agendaItem->installEventFilter(this); |
1341 | addChild(agendaItem,0,0); | 1346 | addChild(agendaItem,0,0); |
1342 | return agendaItem; | 1347 | return agendaItem; |
1343 | } | 1348 | } |
1344 | KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo ) | 1349 | KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo ) |
1345 | { | 1350 | { |
1346 | KOAgendaItem *item; | 1351 | KOAgendaItem *item; |
1347 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1352 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1348 | if ( item->incidence() == todo ) { | 1353 | if ( item->incidence() == todo ) { |
1349 | mItems.remove(); | 1354 | mItems.remove(); |
1350 | return item; | 1355 | return item; |
1351 | } | 1356 | } |
1352 | } | 1357 | } |
1353 | return 0; | 1358 | return 0; |
1354 | } | 1359 | } |
1355 | 1360 | ||
1356 | 1361 | ||
1357 | void KOAgenda::updateTodo( Todo * todo, int days, bool remove) | 1362 | void KOAgenda::updateTodo( Todo * todo, int days, bool remove) |
1358 | { | 1363 | { |
1359 | 1364 | ||
1360 | KOAgendaItem *item; | 1365 | KOAgendaItem *item; |
1361 | item = getItemForTodo ( todo ); | 1366 | item = getItemForTodo ( todo ); |
1362 | //qDebug("KOAgenda::updateTodo %d %d %d %d", this, todo, days, remove); | 1367 | //qDebug("KOAgenda::updateTodo %d %d %d %d", this, todo, days, remove); |
1363 | if ( item ) { | 1368 | if ( item ) { |
1364 | blockSignals( true ); | 1369 | blockSignals( true ); |
1365 | //qDebug("item found "); | 1370 | //qDebug("item found "); |
1366 | item->hide(); | 1371 | item->hide(); |
1367 | item->setCellX(-2, -1 ); | 1372 | item->setCellX(-2, -1 ); |
1368 | item->select(false); | 1373 | item->select(false); |
1369 | mUnusedItems.append( item ); | 1374 | mUnusedItems.append( item ); |
1370 | mItems.remove( item ); | 1375 | mItems.remove( item ); |
1371 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); | 1376 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); |
1372 | KOAgendaItem *itemit; | 1377 | KOAgendaItem *itemit; |
1373 | //globalFlagBlockAgendaItemPaint = 1; | 1378 | //globalFlagBlockAgendaItemPaint = 1; |
1374 | for ( itemit=oldconflictItems.first(); itemit != 0; | 1379 | for ( itemit=oldconflictItems.first(); itemit != 0; |
1375 | itemit=oldconflictItems.next() ) { | 1380 | itemit=oldconflictItems.next() ) { |
1376 | if ( itemit != item ) | 1381 | if ( itemit != item ) |
1377 | placeSubCells(itemit); | 1382 | placeSubCells(itemit); |
1378 | } | 1383 | } |
1379 | qApp->processEvents(); | 1384 | qApp->processEvents(); |
1380 | //globalFlagBlockAgendaItemPaint = 0; | 1385 | //globalFlagBlockAgendaItemPaint = 0; |
1381 | for ( itemit=oldconflictItems.first(); itemit != 0; | 1386 | for ( itemit=oldconflictItems.first(); itemit != 0; |
1382 | itemit=oldconflictItems.next() ) { | 1387 | itemit=oldconflictItems.next() ) { |
1383 | globalFlagBlockAgendaItemUpdate = 0; | 1388 | globalFlagBlockAgendaItemUpdate = 0; |
1384 | if ( itemit != item ) | 1389 | if ( itemit != item ) |
1385 | itemit->repaintMe(); | 1390 | itemit->repaintMe(); |
1386 | globalFlagBlockAgendaItemUpdate = 1; | 1391 | globalFlagBlockAgendaItemUpdate = 1; |
1387 | itemit->repaint(); | 1392 | itemit->repaint(); |
1388 | } | 1393 | } |
1389 | blockSignals( false ); | 1394 | blockSignals( false ); |
1390 | } | 1395 | } |
1391 | if ( remove ) { | 1396 | if ( remove ) { |
1392 | //qDebug("remove****************************************** "); | 1397 | //qDebug("remove****************************************** "); |
1393 | return; | 1398 | return; |
1394 | } | 1399 | } |
1395 | //qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ "); | 1400 | //qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ "); |
1396 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < QDate::currentDate())&& ( KOPrefs::instance()->mShowTodoInAgenda ); | 1401 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < QDate::currentDate())&& ( KOPrefs::instance()->mShowTodoInAgenda ); |
1397 | QDate currentDate; | 1402 | QDate currentDate; |
1398 | if ( overdue ) { | 1403 | if ( overdue ) { |
1399 | currentDate = QDate::currentDate(); | 1404 | currentDate = QDate::currentDate(); |
1400 | days += todo->dtDue().date().daysTo( currentDate ); | 1405 | days += todo->dtDue().date().daysTo( currentDate ); |
1401 | } | 1406 | } |
1402 | else | 1407 | else |
1403 | currentDate = todo->dtDue().date(); | 1408 | currentDate = todo->dtDue().date(); |
1404 | 1409 | ||
1405 | if ( todo->doesFloat() || overdue ) { | 1410 | if ( todo->doesFloat() || overdue ) { |
1406 | if ( ! mAllDayMode ) return; | 1411 | if ( ! mAllDayMode ) return; |
1407 | // aldayagenda | 1412 | // aldayagenda |
1408 | globalFlagBlockAgendaItemPaint = 1; | 1413 | globalFlagBlockAgendaItemPaint = 1; |
1409 | item = insertAllDayItem(todo, currentDate,days, days); | 1414 | item = insertAllDayItem(todo, currentDate,days, days); |
1410 | item->show(); | 1415 | item->show(); |
1411 | 1416 | ||
1412 | } | 1417 | } |
1413 | else { | 1418 | else { |
1414 | if ( mAllDayMode ) return; | 1419 | if ( mAllDayMode ) return; |
1415 | // mAgenda | 1420 | // mAgenda |
1416 | globalFlagBlockAgendaItemPaint = 1; | 1421 | globalFlagBlockAgendaItemPaint = 1; |
1417 | int endY = timeToY(todo->dtDue().time()) - 1; | 1422 | int endY = timeToY(todo->dtDue().time()) - 1; |
1418 | int hi = 12/KOPrefs::instance()->mHourSize; | 1423 | int hi = 12/KOPrefs::instance()->mHourSize; |
1419 | int startY = endY - 1-hi; | 1424 | int startY = endY - 1-hi; |
1420 | item = insertItem(todo,currentDate,days,startY,endY); | 1425 | item = insertItem(todo,currentDate,days,startY,endY); |
1421 | item->show(); | 1426 | item->show(); |
1422 | } | 1427 | } |
1423 | qApp->processEvents(); | 1428 | qApp->processEvents(); |
1424 | globalFlagBlockAgendaItemPaint = 0; | 1429 | globalFlagBlockAgendaItemPaint = 0; |
1425 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); | 1430 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); |
1426 | KOAgendaItem *itemit; | 1431 | KOAgendaItem *itemit; |
1427 | for ( itemit=oldconflictItems.first(); itemit != 0; | 1432 | for ( itemit=oldconflictItems.first(); itemit != 0; |
1428 | itemit=oldconflictItems.next() ) { | 1433 | itemit=oldconflictItems.next() ) { |
1429 | globalFlagBlockAgendaItemUpdate = 0; | 1434 | globalFlagBlockAgendaItemUpdate = 0; |
1430 | itemit->repaintMe(); | 1435 | itemit->repaintMe(); |
1431 | globalFlagBlockAgendaItemUpdate = 1; | 1436 | globalFlagBlockAgendaItemUpdate = 1; |
1432 | itemit->repaint(); | 1437 | itemit->repaint(); |
1433 | } | 1438 | } |
1434 | globalFlagBlockAgendaItemUpdate = 0; | 1439 | globalFlagBlockAgendaItemUpdate = 0; |
1435 | item->repaintMe(); | 1440 | item->repaintMe(); |
1436 | globalFlagBlockAgendaItemUpdate = 1; | 1441 | globalFlagBlockAgendaItemUpdate = 1; |