author | zautrix <zautrix> | 2005-08-22 16:28:08 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-08-22 16:28:08 (UTC) |
commit | 18780cc2342097b343ee2fa50c649f425ddaed34 (patch) (unidiff) | |
tree | 6ea015c45835e96451cede982ac79a518141dd29 | |
parent | 4a5e2a487ee162c1e3d5ea0d1c8d4bd14a65efb9 (diff) | |
download | kdepimpi-18780cc2342097b343ee2fa50c649f425ddaed34.zip kdepimpi-18780cc2342097b343ee2fa50c649f425ddaed34.tar.gz kdepimpi-18780cc2342097b343ee2fa50c649f425ddaed34.tar.bz2 |
fix for the lonng agenda float fix
-rw-r--r-- | korganizer/koagenda.cpp | 4 | ||||
-rw-r--r-- | korganizer/koagendaitem.cpp | 8 | ||||
-rw-r--r-- | korganizer/koagendaitem.h | 2 | ||||
-rw-r--r-- | korganizer/koagendaview.cpp | 1 |
4 files changed, 8 insertions, 7 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp index 796d633..d9d1283 100644 --- a/korganizer/koagenda.cpp +++ b/korganizer/koagenda.cpp | |||
@@ -1071,1215 +1071,1215 @@ void KOAgenda::endItemAction() | |||
1071 | while ( placeItem ) { | 1071 | while ( placeItem ) { |
1072 | oldconflictItems = placeItem->conflictItems(); | 1072 | oldconflictItems = placeItem->conflictItems(); |
1073 | for ( item=oldconflictItems.first(); item != 0; | 1073 | for ( item=oldconflictItems.first(); item != 0; |
1074 | item=oldconflictItems.next() ) { | 1074 | item=oldconflictItems.next() ) { |
1075 | placeSubCells(item); | 1075 | placeSubCells(item); |
1076 | } | 1076 | } |
1077 | placeSubCells( placeItem ); | 1077 | placeSubCells( placeItem ); |
1078 | placeItem = placeItem->nextMultiItem(); | 1078 | placeItem = placeItem->nextMultiItem(); |
1079 | 1079 | ||
1080 | } | 1080 | } |
1081 | placeItem = modifiedItem; | 1081 | placeItem = modifiedItem; |
1082 | while ( placeItem ) { | 1082 | while ( placeItem ) { |
1083 | oldconflictItems = placeItem->conflictItems(); | 1083 | oldconflictItems = placeItem->conflictItems(); |
1084 | for ( item=oldconflictItems.first(); item != 0; | 1084 | for ( item=oldconflictItems.first(); item != 0; |
1085 | item=oldconflictItems.next() ) { | 1085 | item=oldconflictItems.next() ) { |
1086 | globalFlagBlockAgendaItemUpdate = 0; | 1086 | globalFlagBlockAgendaItemUpdate = 0; |
1087 | item->repaintMe(); | 1087 | item->repaintMe(); |
1088 | globalFlagBlockAgendaItemUpdate = 1; | 1088 | globalFlagBlockAgendaItemUpdate = 1; |
1089 | item->repaint(false); | 1089 | item->repaint(false); |
1090 | } | 1090 | } |
1091 | placeItem = placeItem->nextMultiItem(); | 1091 | placeItem = placeItem->nextMultiItem(); |
1092 | } | 1092 | } |
1093 | /* | 1093 | /* |
1094 | 1094 | ||
1095 | oldconflictItems = modifiedItem->conflictItems(); | 1095 | oldconflictItems = modifiedItem->conflictItems(); |
1096 | for ( item=oldconflictItems.first(); item != 0; | 1096 | for ( item=oldconflictItems.first(); item != 0; |
1097 | item=oldconflictItems.next() ) { | 1097 | item=oldconflictItems.next() ) { |
1098 | globalFlagBlockAgendaItemUpdate = 0; | 1098 | globalFlagBlockAgendaItemUpdate = 0; |
1099 | item->paintMe(false); | 1099 | item->paintMe(false); |
1100 | globalFlagBlockAgendaItemUpdate = 1; | 1100 | globalFlagBlockAgendaItemUpdate = 1; |
1101 | item->repaint(false); | 1101 | item->repaint(false); |
1102 | } | 1102 | } |
1103 | */ | 1103 | */ |
1104 | 1104 | ||
1105 | 1105 | ||
1106 | } | 1106 | } |
1107 | 1107 | ||
1108 | } | 1108 | } |
1109 | if ( mActionItem ) | 1109 | if ( mActionItem ) |
1110 | emit incidenceSelected( mActionItem->incidence() ); | 1110 | emit incidenceSelected( mActionItem->incidence() ); |
1111 | mScrollUpTimer.stop(); | 1111 | mScrollUpTimer.stop(); |
1112 | mScrollDownTimer.stop(); | 1112 | mScrollDownTimer.stop(); |
1113 | setCursor( arrowCursor ); | 1113 | setCursor( arrowCursor ); |
1114 | mActionItem = 0; | 1114 | mActionItem = 0; |
1115 | mActionType = NOP; | 1115 | mActionType = NOP; |
1116 | mItemMoved = 0; | 1116 | mItemMoved = 0; |
1117 | 1117 | ||
1118 | } | 1118 | } |
1119 | 1119 | ||
1120 | void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos) | 1120 | void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos) |
1121 | { | 1121 | { |
1122 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; | 1122 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; |
1123 | // QPoint point = viewport()->mapToGlobal(viewportPos); | 1123 | // QPoint point = viewport()->mapToGlobal(viewportPos); |
1124 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; | 1124 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; |
1125 | // point = clipper()->mapFromGlobal(point); | 1125 | // point = clipper()->mapFromGlobal(point); |
1126 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; | 1126 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; |
1127 | 1127 | ||
1128 | int x,y; | 1128 | int x,y; |
1129 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 1129 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
1130 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; | 1130 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; |
1131 | int gx,gy; | 1131 | int gx,gy; |
1132 | contentsToGrid(x,y,gx,gy); | 1132 | contentsToGrid(x,y,gx,gy); |
1133 | 1133 | ||
1134 | // Change cursor to resize cursor if appropriate | 1134 | // Change cursor to resize cursor if appropriate |
1135 | if (mAllDayMode) { | 1135 | if (mAllDayMode) { |
1136 | int gridDistanceX = (x - gx * mGridSpacingX); | 1136 | int gridDistanceX = (x - gx * mGridSpacingX); |
1137 | if (gridDistanceX < mResizeBorderWidth && | 1137 | if (gridDistanceX < mResizeBorderWidth && |
1138 | moveItem->cellX() == gx) { | 1138 | moveItem->cellX() == gx) { |
1139 | setCursor(sizeHorCursor); | 1139 | setCursor(sizeHorCursor); |
1140 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && | 1140 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && |
1141 | moveItem->cellXWidth() == gx) { | 1141 | moveItem->cellXWidth() == gx) { |
1142 | setCursor(sizeHorCursor); | 1142 | setCursor(sizeHorCursor); |
1143 | } else { | 1143 | } else { |
1144 | setCursor(arrowCursor); | 1144 | setCursor(arrowCursor); |
1145 | } | 1145 | } |
1146 | } else { | 1146 | } else { |
1147 | int gridDistanceY = (y - gy * mGridSpacingY); | 1147 | int gridDistanceY = (y - gy * mGridSpacingY); |
1148 | if (gridDistanceY < mResizeBorderWidth && | 1148 | if (gridDistanceY < mResizeBorderWidth && |
1149 | moveItem->cellYTop() == gy && | 1149 | moveItem->cellYTop() == gy && |
1150 | !moveItem->firstMultiItem()) { | 1150 | !moveItem->firstMultiItem()) { |
1151 | setCursor(sizeVerCursor); | 1151 | setCursor(sizeVerCursor); |
1152 | } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth && | 1152 | } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth && |
1153 | moveItem->cellYBottom() == gy && | 1153 | moveItem->cellYBottom() == gy && |
1154 | !moveItem->lastMultiItem()) { | 1154 | !moveItem->lastMultiItem()) { |
1155 | setCursor(sizeVerCursor); | 1155 | setCursor(sizeVerCursor); |
1156 | } else { | 1156 | } else { |
1157 | setCursor(arrowCursor); | 1157 | setCursor(arrowCursor); |
1158 | } | 1158 | } |
1159 | } | 1159 | } |
1160 | } | 1160 | } |
1161 | 1161 | ||
1162 | 1162 | ||
1163 | /* | 1163 | /* |
1164 | Place item in cell and take care that multiple items using the same cell do | 1164 | Place item in cell and take care that multiple items using the same cell do |
1165 | not overlap. This method is not yet optimal. It doesn´t use the maximum space | 1165 | not overlap. This method is not yet optimal. It doesn´t use the maximum space |
1166 | it can get in all cases. | 1166 | it can get in all cases. |
1167 | At the moment the method has a bug: When an item is placed only the sub cell | 1167 | At the moment the method has a bug: When an item is placed only the sub cell |
1168 | widths of the items are changed, which are within the Y region the item to | 1168 | widths of the items are changed, which are within the Y region the item to |
1169 | place spans. When the sub cell width change of one of this items affects a | 1169 | place spans. When the sub cell width change of one of this items affects a |
1170 | cell, where other items are, which do not overlap in Y with the item to place, | 1170 | cell, where other items are, which do not overlap in Y with the item to place, |
1171 | the display gets corrupted, although the corruption looks quite nice. | 1171 | the display gets corrupted, although the corruption looks quite nice. |
1172 | */ | 1172 | */ |
1173 | void KOAgenda::placeSubCells(KOAgendaItem *placeItem) | 1173 | void KOAgenda::placeSubCells(KOAgendaItem *placeItem) |
1174 | { | 1174 | { |
1175 | 1175 | ||
1176 | QPtrList<KOAgendaItem> conflictItems; | 1176 | QPtrList<KOAgendaItem> conflictItems; |
1177 | int maxSubCells = 0; | 1177 | int maxSubCells = 0; |
1178 | QIntDict<KOAgendaItem> subCellDict(7); | 1178 | QIntDict<KOAgendaItem> subCellDict(7); |
1179 | 1179 | ||
1180 | KOAgendaItem *item; | 1180 | KOAgendaItem *item; |
1181 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1181 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1182 | if (item != placeItem) { | 1182 | if (item != placeItem) { |
1183 | if (placeItem->cellX() <= item->cellXWidth() && | 1183 | if (placeItem->cellX() <= item->cellXWidth() && |
1184 | placeItem->cellXWidth() >= item->cellX()) { | 1184 | placeItem->cellXWidth() >= item->cellX()) { |
1185 | if ((placeItem->cellYTop() <= item->cellYBottom()) && | 1185 | if ((placeItem->cellYTop() <= item->cellYBottom()) && |
1186 | (placeItem->cellYBottom() >= item->cellYTop())) { | 1186 | (placeItem->cellYBottom() >= item->cellYTop())) { |
1187 | conflictItems.append(item); | 1187 | conflictItems.append(item); |
1188 | if (item->subCells() > maxSubCells) | 1188 | if (item->subCells() > maxSubCells) |
1189 | maxSubCells = item->subCells(); | 1189 | maxSubCells = item->subCells(); |
1190 | subCellDict.insert(item->subCell(),item); | 1190 | subCellDict.insert(item->subCell(),item); |
1191 | } | 1191 | } |
1192 | } | 1192 | } |
1193 | } | 1193 | } |
1194 | } | 1194 | } |
1195 | 1195 | ||
1196 | if (conflictItems.count() > 0) { | 1196 | if (conflictItems.count() > 0) { |
1197 | // Look for unused sub cell and insert item | 1197 | // Look for unused sub cell and insert item |
1198 | int i; | 1198 | int i; |
1199 | for(i=0;i<maxSubCells;++i) { | 1199 | for(i=0;i<maxSubCells;++i) { |
1200 | if (!subCellDict.find(i)) { | 1200 | if (!subCellDict.find(i)) { |
1201 | placeItem->setSubCell(i); | 1201 | placeItem->setSubCell(i); |
1202 | break; | 1202 | break; |
1203 | } | 1203 | } |
1204 | } | 1204 | } |
1205 | if (i == maxSubCells) { | 1205 | if (i == maxSubCells) { |
1206 | placeItem->setSubCell(maxSubCells); | 1206 | placeItem->setSubCell(maxSubCells); |
1207 | maxSubCells++; // add new item to number of sub cells | 1207 | maxSubCells++; // add new item to number of sub cells |
1208 | } | 1208 | } |
1209 | 1209 | ||
1210 | // Prepare for sub cell geometry adjustment | 1210 | // Prepare for sub cell geometry adjustment |
1211 | int newSubCellWidth; | 1211 | int newSubCellWidth; |
1212 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells; | 1212 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells; |
1213 | else newSubCellWidth = mGridSpacingX / maxSubCells; | 1213 | else newSubCellWidth = mGridSpacingX / maxSubCells; |
1214 | conflictItems.append(placeItem); | 1214 | conflictItems.append(placeItem); |
1215 | 1215 | ||
1216 | 1216 | ||
1217 | // Adjust sub cell geometry of all direct conflict items | 1217 | // Adjust sub cell geometry of all direct conflict items |
1218 | for ( item=conflictItems.first(); item != 0; | 1218 | for ( item=conflictItems.first(); item != 0; |
1219 | item=conflictItems.next() ) { | 1219 | item=conflictItems.next() ) { |
1220 | item->setSubCells(maxSubCells); | 1220 | item->setSubCells(maxSubCells); |
1221 | int diff = 0; | 1221 | int diff = 0; |
1222 | if (mAllDayMode) { | 1222 | if (mAllDayMode) { |
1223 | diff = item->resizeMe( mGridSpacingX, item->cellWidth() * mGridSpacingX, newSubCellWidth); | 1223 | diff = item->resizeMe( mGridSpacingX, item->cellWidth() * mGridSpacingX, newSubCellWidth); |
1224 | } else { | 1224 | } else { |
1225 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); | 1225 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); |
1226 | } | 1226 | } |
1227 | int x,y; | 1227 | int x,y; |
1228 | gridToContents(item->cellX(),item->cellYTop(),x,y); | 1228 | gridToContents(item->cellX(),item->cellYTop(),x,y); |
1229 | if (mAllDayMode) { | 1229 | if (mAllDayMode) { |
1230 | y += item->subCell() * newSubCellWidth; | 1230 | y += item->subCell() * newSubCellWidth; |
1231 | } else { | 1231 | } else { |
1232 | x += item->subCell() * newSubCellWidth; | 1232 | x += item->subCell() * newSubCellWidth; |
1233 | } | 1233 | } |
1234 | moveChild(item,x+diff,y); | 1234 | moveChild(item,x+diff,y); |
1235 | // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y); | 1235 | // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y); |
1236 | //item->updateItem(); | 1236 | //item->updateItem(); |
1237 | } | 1237 | } |
1238 | // Adjust sub cell geometry of all conflict items of all conflict items | 1238 | // Adjust sub cell geometry of all conflict items of all conflict items |
1239 | for ( item=conflictItems.first(); item != 0; | 1239 | for ( item=conflictItems.first(); item != 0; |
1240 | item=conflictItems.next() ) { | 1240 | item=conflictItems.next() ) { |
1241 | if ( placeItem != item ) { | 1241 | if ( placeItem != item ) { |
1242 | KOAgendaItem *item2; | 1242 | KOAgendaItem *item2; |
1243 | QPtrList<KOAgendaItem> conflictItems2 = item->conflictItems(); | 1243 | QPtrList<KOAgendaItem> conflictItems2 = item->conflictItems(); |
1244 | for ( item2=conflictItems2.first(); item2 != 0; | 1244 | for ( item2=conflictItems2.first(); item2 != 0; |
1245 | item2=conflictItems2.next() ) { | 1245 | item2=conflictItems2.next() ) { |
1246 | if ( item2->subCells() != maxSubCells) { | 1246 | if ( item2->subCells() != maxSubCells) { |
1247 | item2->setSubCells(maxSubCells); | 1247 | item2->setSubCells(maxSubCells); |
1248 | int diff = 0; | 1248 | int diff = 0; |
1249 | if (mAllDayMode) { | 1249 | if (mAllDayMode) { |
1250 | diff = item2->resizeMe(mGridSpacingX, item2->cellWidth() * mGridSpacingX, newSubCellWidth); | 1250 | diff = item2->resizeMe(mGridSpacingX, item2->cellWidth() * mGridSpacingX, newSubCellWidth); |
1251 | } else { | 1251 | } else { |
1252 | item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY); | 1252 | item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY); |
1253 | } | 1253 | } |
1254 | int x,y; | 1254 | int x,y; |
1255 | gridToContents(item2->cellX(),item2->cellYTop(),x,y); | 1255 | gridToContents(item2->cellX(),item2->cellYTop(),x,y); |
1256 | if (mAllDayMode) { | 1256 | if (mAllDayMode) { |
1257 | y += item2->subCell() * newSubCellWidth; | 1257 | y += item2->subCell() * newSubCellWidth; |
1258 | } else { | 1258 | } else { |
1259 | x += item2->subCell() * newSubCellWidth; | 1259 | x += item2->subCell() * newSubCellWidth; |
1260 | } | 1260 | } |
1261 | moveChild(item2,x+diff,y); | 1261 | moveChild(item2,x+diff,y); |
1262 | //qDebug("setttttt %d %s",maxSubCells, item2->text().latin1() ); | 1262 | //qDebug("setttttt %d %s",maxSubCells, item2->text().latin1() ); |
1263 | } | 1263 | } |
1264 | } | 1264 | } |
1265 | } | 1265 | } |
1266 | } | 1266 | } |
1267 | } else { | 1267 | } else { |
1268 | placeItem->setSubCell(0); | 1268 | placeItem->setSubCell(0); |
1269 | placeItem->setSubCells(1); | 1269 | placeItem->setSubCells(1); |
1270 | int diff = 0; | 1270 | int diff = 0; |
1271 | if (mAllDayMode) diff = placeItem->resizeMe( mGridSpacingX, placeItem->width(),mGridSpacingY); | 1271 | if (mAllDayMode) diff = placeItem->resizeMe( mGridSpacingX, placeItem->width(),mGridSpacingY); |
1272 | else placeItem->resize(mGridSpacingX,placeItem->height()); | 1272 | else placeItem->resize(mGridSpacingX,placeItem->height()); |
1273 | int x,y; | 1273 | int x,y; |
1274 | gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y); | 1274 | gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y); |
1275 | moveChild(placeItem,x+diff,y); | 1275 | moveChild(placeItem,x+diff,y); |
1276 | } | 1276 | } |
1277 | placeItem->setConflictItems(conflictItems); | 1277 | placeItem->setConflictItems(conflictItems); |
1278 | // for ( item=conflictItems.first(); item != 0; | 1278 | // for ( item=conflictItems.first(); item != 0; |
1279 | // item=conflictItems.next() ) { | 1279 | // item=conflictItems.next() ) { |
1280 | // //item->updateItem(); | 1280 | // //item->updateItem(); |
1281 | // //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); | 1281 | // //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); |
1282 | // } | 1282 | // } |
1283 | // placeItem->updateItem(); | 1283 | // placeItem->updateItem(); |
1284 | } | 1284 | } |
1285 | 1285 | ||
1286 | void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) | 1286 | void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) |
1287 | { | 1287 | { |
1288 | if ( globalFlagBlockAgenda ) | 1288 | if ( globalFlagBlockAgenda ) |
1289 | return; | 1289 | return; |
1290 | 1290 | ||
1291 | if ( mInvalidPixmap ) { | 1291 | if ( mInvalidPixmap ) { |
1292 | mInvalidPixmap = false; | 1292 | mInvalidPixmap = false; |
1293 | qDebug("KO: dc Upsizing Pixmaps %s", QDateTime::currentDateTime().toString().latin1()); | 1293 | qDebug("KO: dc Upsizing Pixmaps %s", QDateTime::currentDateTime().toString().latin1()); |
1294 | computeSizes(); | 1294 | computeSizes(); |
1295 | emit updateViewSignal(); | 1295 | emit updateViewSignal(); |
1296 | return; | 1296 | return; |
1297 | } | 1297 | } |
1298 | //qDebug("KOAgenda::drawContents %s", QDateTime::currentDateTime().toString().latin1()); | 1298 | //qDebug("KOAgenda::drawContents %s", QDateTime::currentDateTime().toString().latin1()); |
1299 | if ( ! mAllDayMode ) { | 1299 | if ( ! mAllDayMode ) { |
1300 | // currently not working for | 1300 | // currently not working for |
1301 | 1301 | ||
1302 | //qDebug("KOAgenda::drawContents "); | 1302 | //qDebug("KOAgenda::drawContents "); |
1303 | #if 0 | 1303 | #if 0 |
1304 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) { | 1304 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) { |
1305 | qDebug("WAU "); | 1305 | qDebug("WAU "); |
1306 | drawContentsToPainter(); | 1306 | drawContentsToPainter(); |
1307 | } | 1307 | } |
1308 | #endif | 1308 | #endif |
1309 | QPaintDevice* pd = p->device(); | 1309 | QPaintDevice* pd = p->device(); |
1310 | p->end(); | 1310 | p->end(); |
1311 | int vx, vy; | 1311 | int vx, vy; |
1312 | int selectionX = KOGlobals::self()->reverseLayout() ? | 1312 | int selectionX = KOGlobals::self()->reverseLayout() ? |
1313 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : | 1313 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : |
1314 | mSelectionCellX * mGridSpacingX; | 1314 | mSelectionCellX * mGridSpacingX; |
1315 | contentsToViewport ( cx, cy, vx,vy); | 1315 | contentsToViewport ( cx, cy, vx,vy); |
1316 | //qDebug(" %d %d %d %d %d", cx, cy, cw,ch,mGridSpacingX-1) ; | 1316 | //qDebug(" %d %d %d %d %d", cx, cy, cw,ch,mGridSpacingX-1) ; |
1317 | 1317 | ||
1318 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) { | 1318 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) { |
1319 | if ( mGridSpacingX == cw && mSelectionHeight > 0 && ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1319 | if ( mGridSpacingX == cw && mSelectionHeight > 0 && ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1320 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) ) { | 1320 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) ) { |
1321 | 1321 | ||
1322 | int vxSel, vySel; | 1322 | int vxSel, vySel; |
1323 | contentsToViewport ( selectionX, mSelectionYTop, vxSel,vySel); | 1323 | contentsToViewport ( selectionX, mSelectionYTop, vxSel,vySel); |
1324 | int off = mSelectionHeight; | 1324 | int off = mSelectionHeight; |
1325 | if ( vySel < 0 ) | 1325 | if ( vySel < 0 ) |
1326 | off += vySel; | 1326 | off += vySel; |
1327 | //qDebug("OFF %d %d %d", off,vySel, vy ); | 1327 | //qDebug("OFF %d %d %d", off,vySel, vy ); |
1328 | bitBlt ( pd, vx, vy+off, &mPaintPixmap, cx, cy+off, cw , ch-off ,CopyROP); | 1328 | bitBlt ( pd, vx, vy+off, &mPaintPixmap, cx, cy+off, cw , ch-off ,CopyROP); |
1329 | } else { | 1329 | } else { |
1330 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); | 1330 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); |
1331 | } | 1331 | } |
1332 | } | 1332 | } |
1333 | if ( mSelectionHeight > 0 ) { | 1333 | if ( mSelectionHeight > 0 ) { |
1334 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); | 1334 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); |
1335 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1335 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1336 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { | 1336 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { |
1337 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); | 1337 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); |
1338 | // bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); | 1338 | // bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); |
1339 | int hei = mSelectionHeight; | 1339 | int hei = mSelectionHeight; |
1340 | int offset = 0; | 1340 | int offset = 0; |
1341 | while ( hei > 0 ) { | 1341 | while ( hei > 0 ) { |
1342 | int p_hei = 5; | 1342 | int p_hei = 5; |
1343 | if ( hei < 5 ) p_hei = hei; | 1343 | if ( hei < 5 ) p_hei = hei; |
1344 | hei -= 5; | 1344 | hei -= 5; |
1345 | bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP); | 1345 | bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP); |
1346 | offset += 5; | 1346 | offset += 5; |
1347 | } | 1347 | } |
1348 | } | 1348 | } |
1349 | } | 1349 | } |
1350 | p->begin( pd ); | 1350 | p->begin( pd ); |
1351 | } else { | 1351 | } else { |
1352 | #if 0 | 1352 | #if 0 |
1353 | qDebug("mCurPixWid %d %d ",mCurPixWid, contentsWidth() ); | 1353 | qDebug("mCurPixWid %d %d ",mCurPixWid, contentsWidth() ); |
1354 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) { | 1354 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) { |
1355 | qDebug("WAUWAU "); | 1355 | qDebug("WAUWAU "); |
1356 | drawContentsToPainter(); | 1356 | drawContentsToPainter(); |
1357 | } | 1357 | } |
1358 | #endif | 1358 | #endif |
1359 | QPaintDevice* pd = p->device(); | 1359 | QPaintDevice* pd = p->device(); |
1360 | p->end(); | 1360 | p->end(); |
1361 | int vx, vy; | 1361 | int vx, vy; |
1362 | int selectionX = KOGlobals::self()->reverseLayout() ? | 1362 | int selectionX = KOGlobals::self()->reverseLayout() ? |
1363 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : | 1363 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : |
1364 | mSelectionCellX * mGridSpacingX; | 1364 | mSelectionCellX * mGridSpacingX; |
1365 | contentsToViewport ( cx, cy, vx,vy); | 1365 | contentsToViewport ( cx, cy, vx,vy); |
1366 | // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ; | 1366 | // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ; |
1367 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) | 1367 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) |
1368 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); | 1368 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); |
1369 | 1369 | ||
1370 | if ( mSelectionHeight > 0 ) { | 1370 | if ( mSelectionHeight > 0 ) { |
1371 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); | 1371 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); |
1372 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1372 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1373 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { | 1373 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { |
1374 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); | 1374 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); |
1375 | //bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); | 1375 | //bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); |
1376 | int hei = mSelectionHeight; | 1376 | int hei = mSelectionHeight; |
1377 | int offset = 0; | 1377 | int offset = 0; |
1378 | while ( hei > 0 ) { | 1378 | while ( hei > 0 ) { |
1379 | int p_hei = 5; | 1379 | int p_hei = 5; |
1380 | if ( hei < 5 ) p_hei = hei; | 1380 | if ( hei < 5 ) p_hei = hei; |
1381 | hei -= 5; | 1381 | hei -= 5; |
1382 | bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP); | 1382 | bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP); |
1383 | offset += 5; | 1383 | offset += 5; |
1384 | } | 1384 | } |
1385 | } | 1385 | } |
1386 | } | 1386 | } |
1387 | p->begin( pd ); | 1387 | p->begin( pd ); |
1388 | } | 1388 | } |
1389 | 1389 | ||
1390 | } | 1390 | } |
1391 | 1391 | ||
1392 | void KOAgenda::finishUpdate() | 1392 | void KOAgenda::finishUpdate() |
1393 | { | 1393 | { |
1394 | 1394 | ||
1395 | KOAgendaItem *item; | 1395 | KOAgendaItem *item; |
1396 | globalFlagBlockAgendaItemPaint = 1; | 1396 | globalFlagBlockAgendaItemPaint = 1; |
1397 | // Adjust sub cell geometry of all conflict items of all conflict items of all conflict items ... of the conflict item with the max number of conflictitems | 1397 | // Adjust sub cell geometry of all conflict items of all conflict items of all conflict items ... of the conflict item with the max number of conflictitems |
1398 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1398 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1399 | if ( !item->checkLayout() ) { | 1399 | if ( !item->checkLayout() ) { |
1400 | //qDebug(" conflictitem found "); | 1400 | //qDebug(" conflictitem found "); |
1401 | int newSubCellWidth; | 1401 | int newSubCellWidth; |
1402 | int diff = 0; | 1402 | int diff = 0; |
1403 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / item->subCells(); | 1403 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / item->subCells(); |
1404 | else newSubCellWidth = mGridSpacingX / item->subCells(); | 1404 | else newSubCellWidth = mGridSpacingX / item->subCells(); |
1405 | 1405 | ||
1406 | if (mAllDayMode) { | 1406 | if (mAllDayMode) { |
1407 | diff = item->resizeMe(mGridSpacingX, item->cellWidth() * mGridSpacingX, newSubCellWidth); | 1407 | diff = item->resizeMe(mGridSpacingX, item->cellWidth() * mGridSpacingX, newSubCellWidth); |
1408 | } else { | 1408 | } else { |
1409 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); | 1409 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); |
1410 | } | 1410 | } |
1411 | int x,y; | 1411 | int x,y; |
1412 | gridToContents(item->cellX(),item->cellYTop(),x,y); | 1412 | gridToContents(item->cellX(),item->cellYTop(),x,y); |
1413 | if (mAllDayMode) { | 1413 | if (mAllDayMode) { |
1414 | y += item->subCell() * newSubCellWidth; | 1414 | y += item->subCell() * newSubCellWidth; |
1415 | } else { | 1415 | } else { |
1416 | x += item->subCell() * newSubCellWidth; | 1416 | x += item->subCell() * newSubCellWidth; |
1417 | } | 1417 | } |
1418 | moveChild(item,x+diff,y); | 1418 | moveChild(item,x+diff,y); |
1419 | } | 1419 | } |
1420 | } | 1420 | } |
1421 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1421 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1422 | if ( !item->isVisible() ) | 1422 | if ( !item->isVisible() ) |
1423 | item->show(); | 1423 | item->show(); |
1424 | 1424 | ||
1425 | } | 1425 | } |
1426 | globalFlagBlockAgendaItemUpdate = 0; | 1426 | globalFlagBlockAgendaItemUpdate = 0; |
1427 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1427 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1428 | item->repaintMe( ); | 1428 | item->repaintMe( ); |
1429 | } | 1429 | } |
1430 | globalFlagBlockAgendaItemUpdate = 1; | 1430 | globalFlagBlockAgendaItemUpdate = 1; |
1431 | qApp->processEvents(); | 1431 | qApp->processEvents(); |
1432 | globalFlagBlockAgendaItemPaint = 0; | 1432 | globalFlagBlockAgendaItemPaint = 0; |
1433 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1433 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1434 | item->repaint( false ); | 1434 | item->repaint( false ); |
1435 | } | 1435 | } |
1436 | marcus_bains(); | 1436 | marcus_bains(); |
1437 | } | 1437 | } |
1438 | 1438 | ||
1439 | /* | 1439 | /* |
1440 | Draw grid in the background of the agenda. | 1440 | Draw grid in the background of the agenda. |
1441 | */ | 1441 | */ |
1442 | void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch) | 1442 | void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch) |
1443 | { | 1443 | { |
1444 | 1444 | ||
1445 | 1445 | ||
1446 | if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask ) | 1446 | if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask ) |
1447 | return; | 1447 | return; |
1448 | if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 ) | 1448 | if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 ) |
1449 | return; | 1449 | return; |
1450 | int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight(); | 1450 | int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight(); |
1451 | if ( ch < 1 ) | 1451 | if ( ch < 1 ) |
1452 | ch = 1; | 1452 | ch = 1; |
1453 | if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) { | 1453 | if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) { |
1454 | mPaintPixmap.resize( contentsWidth()+42, ch ); | 1454 | mPaintPixmap.resize( contentsWidth()+42, ch ); |
1455 | } | 1455 | } |
1456 | mCurPixWid = contentsWidth(); | 1456 | mCurPixWid = contentsWidth(); |
1457 | mCurPixHei = ch; | 1457 | mCurPixHei = ch; |
1458 | if ( mHighlightPixmap.width() < mGridSpacingX-1 ) { | 1458 | if ( mHighlightPixmap.width() < mGridSpacingX-1 ) { |
1459 | mHighlightPixmap.resize( mGridSpacingX-1, 5 ); | 1459 | mHighlightPixmap.resize( mGridSpacingX-1, 5 ); |
1460 | mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor ); | 1460 | mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor ); |
1461 | } | 1461 | } |
1462 | mPixPainter.begin( &mPaintPixmap) ; | 1462 | mPixPainter.begin( &mPaintPixmap) ; |
1463 | //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() ); | 1463 | //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() ); |
1464 | QPainter * p ; | 1464 | QPainter * p ; |
1465 | if (paint == 0) { | 1465 | if (paint == 0) { |
1466 | mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor); | 1466 | mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor); |
1467 | p = &mPixPainter; | 1467 | p = &mPixPainter; |
1468 | } | 1468 | } |
1469 | else | 1469 | else |
1470 | p = paint ; | 1470 | p = paint ; |
1471 | // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch); | 1471 | // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch); |
1472 | 1472 | ||
1473 | //--cx;++cw; | 1473 | //--cx;++cw; |
1474 | int lGridSpacingY = mGridSpacingY*2; | 1474 | int lGridSpacingY = mGridSpacingY*2; |
1475 | uint selDay; | 1475 | uint selDay; |
1476 | QDate curDate = QDate::currentDate(); | 1476 | QDate curDate = QDate::currentDate(); |
1477 | if ( !backgroundOnly ) { | 1477 | if ( !backgroundOnly ) { |
1478 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) | 1478 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) |
1479 | { | 1479 | { |
1480 | if ( mSelectedDates[selDay] == curDate && KOPrefs::instance()->mHighlightCurrentDay) { | 1480 | if ( mSelectedDates[selDay] == curDate && KOPrefs::instance()->mHighlightCurrentDay) { |
1481 | int x1 = cx; | 1481 | int x1 = cx; |
1482 | int y1 = 0; | 1482 | int y1 = 0; |
1483 | if (y1 < cy) y1 = cy; | 1483 | if (y1 < cy) y1 = cy; |
1484 | int x2 = cx+cw-1; | 1484 | int x2 = cx+cw-1; |
1485 | int y2 = contentsHeight(); | 1485 | int y2 = contentsHeight(); |
1486 | if (y2 > cy+ch-1) y2=cy+ch-1; | 1486 | if (y2 > cy+ch-1) y2=cy+ch-1; |
1487 | if (x2 >= x1 && y2 >= y1) { | 1487 | if (x2 >= x1 && y2 >= y1) { |
1488 | int gxStart = selDay; | 1488 | int gxStart = selDay; |
1489 | //int gxEnd = gxStart ; | 1489 | //int gxEnd = gxStart ; |
1490 | int xStart = KOGlobals::self()->reverseLayout() ? | 1490 | int xStart = KOGlobals::self()->reverseLayout() ? |
1491 | (mColumns - 1 - gxStart)*mGridSpacingX : | 1491 | (mColumns - 1 - gxStart)*mGridSpacingX : |
1492 | gxStart*mGridSpacingX; | 1492 | gxStart*mGridSpacingX; |
1493 | if (xStart < x1) xStart = x1; | 1493 | if (xStart < x1) xStart = x1; |
1494 | int xEnd = KOGlobals::self()->reverseLayout() ? | 1494 | int xEnd = KOGlobals::self()->reverseLayout() ? |
1495 | (mColumns - gxStart)*mGridSpacingX-1 : | 1495 | (mColumns - gxStart)*mGridSpacingX-1 : |
1496 | (gxStart+1)*mGridSpacingX-1; | 1496 | (gxStart+1)*mGridSpacingX-1; |
1497 | if (xEnd > x2) xEnd = x2; | 1497 | if (xEnd > x2) xEnd = x2; |
1498 | if ( KOPrefs::instance()->mUseHighlightLightColor ) | 1498 | if ( KOPrefs::instance()->mUseHighlightLightColor ) |
1499 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1499 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1500 | KOPrefs::instance()->mAgendaBgColor.light()); | 1500 | KOPrefs::instance()->mAgendaBgColor.light()); |
1501 | else | 1501 | else |
1502 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1502 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1503 | KOPrefs::instance()->mAgendaBgColor.dark()); | 1503 | KOPrefs::instance()->mAgendaBgColor.dark()); |
1504 | 1504 | ||
1505 | } | 1505 | } |
1506 | } | 1506 | } |
1507 | } | 1507 | } |
1508 | } | 1508 | } |
1509 | // Highlight working hours | 1509 | // Highlight working hours |
1510 | 1510 | ||
1511 | if ( !backgroundOnly ) | 1511 | if ( !backgroundOnly ) |
1512 | if (mWorkingHoursEnable) { | 1512 | if (mWorkingHoursEnable) { |
1513 | int x1 = cx; | 1513 | int x1 = cx; |
1514 | int y1 = mWorkingHoursYTop; | 1514 | int y1 = mWorkingHoursYTop; |
1515 | if (y1 < cy) y1 = cy; | 1515 | if (y1 < cy) y1 = cy; |
1516 | int x2 = cx+cw-1; | 1516 | int x2 = cx+cw-1; |
1517 | // int x2 = mGridSpacingX * 5 - 1; | 1517 | // int x2 = mGridSpacingX * 5 - 1; |
1518 | // if (x2 > cx+cw-1) x2 = cx + cw - 1; | 1518 | // if (x2 > cx+cw-1) x2 = cx + cw - 1; |
1519 | int y2 = mWorkingHoursYBottom; | 1519 | int y2 = mWorkingHoursYBottom; |
1520 | if (y2 > cy+ch-1) y2=cy+ch-1; | 1520 | if (y2 > cy+ch-1) y2=cy+ch-1; |
1521 | 1521 | ||
1522 | if (x2 >= x1 && y2 >= y1) { | 1522 | if (x2 >= x1 && y2 >= y1) { |
1523 | // qDebug("x1 %d mGridSpacingX %d ", x1, mGridSpacingX ); | 1523 | // qDebug("x1 %d mGridSpacingX %d ", x1, mGridSpacingX ); |
1524 | int gxStart = x1/mGridSpacingX; | 1524 | int gxStart = x1/mGridSpacingX; |
1525 | int gxEnd = x2/mGridSpacingX; | 1525 | int gxEnd = x2/mGridSpacingX; |
1526 | while(gxStart <= gxEnd) { | 1526 | while(gxStart <= gxEnd) { |
1527 | if (gxStart < int(mHolidayMask->count()) && | 1527 | if (gxStart < int(mHolidayMask->count()) && |
1528 | !mHolidayMask->at(gxStart)) { | 1528 | !mHolidayMask->at(gxStart)) { |
1529 | int xStart = KOGlobals::self()->reverseLayout() ? | 1529 | int xStart = KOGlobals::self()->reverseLayout() ? |
1530 | (mColumns - 1 - gxStart)*mGridSpacingX : | 1530 | (mColumns - 1 - gxStart)*mGridSpacingX : |
1531 | gxStart*mGridSpacingX; | 1531 | gxStart*mGridSpacingX; |
1532 | if (xStart < x1) xStart = x1; | 1532 | if (xStart < x1) xStart = x1; |
1533 | int xEnd = KOGlobals::self()->reverseLayout() ? | 1533 | int xEnd = KOGlobals::self()->reverseLayout() ? |
1534 | (mColumns - gxStart)*mGridSpacingX-1 : | 1534 | (mColumns - gxStart)*mGridSpacingX-1 : |
1535 | (gxStart+1)*mGridSpacingX-1; | 1535 | (gxStart+1)*mGridSpacingX-1; |
1536 | if (xEnd > x2) xEnd = x2; | 1536 | if (xEnd > x2) xEnd = x2; |
1537 | if ( mSelectedDates[gxStart] == curDate && KOPrefs::instance()->mHighlightCurrentDay ) { | 1537 | if ( mSelectedDates[gxStart] == curDate && KOPrefs::instance()->mHighlightCurrentDay ) { |
1538 | if ( KOPrefs::instance()->mUseHighlightLightColor ) | 1538 | if ( KOPrefs::instance()->mUseHighlightLightColor ) |
1539 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1539 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1540 | KOPrefs::instance()->mWorkingHoursColor.light()); | 1540 | KOPrefs::instance()->mWorkingHoursColor.light()); |
1541 | else | 1541 | else |
1542 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1542 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1543 | KOPrefs::instance()->mWorkingHoursColor.dark()); | 1543 | KOPrefs::instance()->mWorkingHoursColor.dark()); |
1544 | } else { | 1544 | } else { |
1545 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1545 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1546 | KOPrefs::instance()->mWorkingHoursColor); | 1546 | KOPrefs::instance()->mWorkingHoursColor); |
1547 | } | 1547 | } |
1548 | } | 1548 | } |
1549 | ++gxStart; | 1549 | ++gxStart; |
1550 | } | 1550 | } |
1551 | } | 1551 | } |
1552 | } | 1552 | } |
1553 | /* | 1553 | /* |
1554 | int selectionX = KOGlobals::self()->reverseLayout() ? | 1554 | int selectionX = KOGlobals::self()->reverseLayout() ? |
1555 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : | 1555 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : |
1556 | mSelectionCellX * mGridSpacingX; | 1556 | mSelectionCellX * mGridSpacingX; |
1557 | 1557 | ||
1558 | // Draw selection | 1558 | // Draw selection |
1559 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1559 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1560 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { | 1560 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { |
1561 | // TODO: paint only part within cx,cy,cw,ch | 1561 | // TODO: paint only part within cx,cy,cw,ch |
1562 | p->fillRect( selectionX, mSelectionYTop, mGridSpacingX, | 1562 | p->fillRect( selectionX, mSelectionYTop, mGridSpacingX, |
1563 | mSelectionHeight, KOPrefs::instance()->mHighlightColor ); | 1563 | mSelectionHeight, KOPrefs::instance()->mHighlightColor ); |
1564 | } | 1564 | } |
1565 | */ | 1565 | */ |
1566 | // Draw vertical lines of grid | 1566 | // Draw vertical lines of grid |
1567 | 1567 | ||
1568 | int x = ((int)(cx/mGridSpacingX))*mGridSpacingX; | 1568 | int x = ((int)(cx/mGridSpacingX))*mGridSpacingX; |
1569 | if ( mGridSpacingX > 0 ) { | 1569 | if ( mGridSpacingX > 0 ) { |
1570 | while (x < cx + cw) { | 1570 | while (x < cx + cw) { |
1571 | p->drawLine(x,cy,x,cy+ch); | 1571 | p->drawLine(x,cy,x,cy+ch); |
1572 | x+=mGridSpacingX; | 1572 | x+=mGridSpacingX; |
1573 | } | 1573 | } |
1574 | } | 1574 | } |
1575 | // Draw horizontal lines of grid | 1575 | // Draw horizontal lines of grid |
1576 | int y = ((int)(cy/lGridSpacingY))*lGridSpacingY; | 1576 | int y = ((int)(cy/lGridSpacingY))*lGridSpacingY; |
1577 | if ( lGridSpacingY > 0 ) { | 1577 | if ( lGridSpacingY > 0 ) { |
1578 | while (y < cy + ch) { | 1578 | while (y < cy + ch) { |
1579 | p->setPen( SolidLine ); | 1579 | p->setPen( SolidLine ); |
1580 | p->drawLine(cx,y,cx+cw,y); | 1580 | p->drawLine(cx,y,cx+cw,y); |
1581 | y+=lGridSpacingY; | 1581 | y+=lGridSpacingY; |
1582 | p->setPen( DotLine ); | 1582 | p->setPen( DotLine ); |
1583 | p->drawLine(cx,y,cx+cw,y); | 1583 | p->drawLine(cx,y,cx+cw,y); |
1584 | y+=lGridSpacingY; | 1584 | y+=lGridSpacingY; |
1585 | } | 1585 | } |
1586 | p->setPen( SolidLine ); | 1586 | p->setPen( SolidLine ); |
1587 | } | 1587 | } |
1588 | mPixPainter.end() ; | 1588 | mPixPainter.end() ; |
1589 | } | 1589 | } |
1590 | 1590 | ||
1591 | /* | 1591 | /* |
1592 | Convert srcollview contents coordinates to agenda grid coordinates. | 1592 | Convert srcollview contents coordinates to agenda grid coordinates. |
1593 | */ | 1593 | */ |
1594 | void KOAgenda::contentsToGrid (int x, int y, int& gx, int& gy) | 1594 | void KOAgenda::contentsToGrid (int x, int y, int& gx, int& gy) |
1595 | { | 1595 | { |
1596 | gx = KOGlobals::self()->reverseLayout() ? mColumns - 1 - x/mGridSpacingX : | 1596 | gx = KOGlobals::self()->reverseLayout() ? mColumns - 1 - x/mGridSpacingX : |
1597 | x/mGridSpacingX; | 1597 | x/mGridSpacingX; |
1598 | gy = y/mGridSpacingY; | 1598 | gy = y/mGridSpacingY; |
1599 | } | 1599 | } |
1600 | 1600 | ||
1601 | /* | 1601 | /* |
1602 | Convert agenda grid coordinates to scrollview contents coordinates. | 1602 | Convert agenda grid coordinates to scrollview contents coordinates. |
1603 | */ | 1603 | */ |
1604 | void KOAgenda::gridToContents (int gx, int gy, int& x, int& y) | 1604 | void KOAgenda::gridToContents (int gx, int gy, int& x, int& y) |
1605 | { | 1605 | { |
1606 | x = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - gx)*mGridSpacingX: | 1606 | x = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - gx)*mGridSpacingX: |
1607 | gx*mGridSpacingX; | 1607 | gx*mGridSpacingX; |
1608 | y = gy*mGridSpacingY; | 1608 | y = gy*mGridSpacingY; |
1609 | } | 1609 | } |
1610 | 1610 | ||
1611 | 1611 | ||
1612 | /* | 1612 | /* |
1613 | Return Y coordinate corresponding to time. Coordinates are rounded to fit into | 1613 | Return Y coordinate corresponding to time. Coordinates are rounded to fit into |
1614 | the grid. | 1614 | the grid. |
1615 | */ | 1615 | */ |
1616 | int KOAgenda::timeToY(const QTime &time) | 1616 | int KOAgenda::timeToY(const QTime &time) |
1617 | { | 1617 | { |
1618 | int minutesPerCell = 24 * 60 / mRows; | 1618 | int minutesPerCell = 24 * 60 / mRows; |
1619 | int timeMinutes = time.hour() * 60 + time.minute(); | 1619 | int timeMinutes = time.hour() * 60 + time.minute(); |
1620 | int Y = (timeMinutes + (minutesPerCell / 2)) / minutesPerCell; | 1620 | int Y = (timeMinutes + (minutesPerCell / 2)) / minutesPerCell; |
1621 | return Y; | 1621 | return Y; |
1622 | } | 1622 | } |
1623 | 1623 | ||
1624 | 1624 | ||
1625 | /* | 1625 | /* |
1626 | Return time corresponding to cell y coordinate. Coordinates are rounded to | 1626 | Return time corresponding to cell y coordinate. Coordinates are rounded to |
1627 | fit into the grid. | 1627 | fit into the grid. |
1628 | */ | 1628 | */ |
1629 | QTime KOAgenda::gyToTime(int gy) | 1629 | QTime KOAgenda::gyToTime(int gy) |
1630 | { | 1630 | { |
1631 | 1631 | ||
1632 | int secondsPerCell = 24 * 60 * 60/ mRows; | 1632 | int secondsPerCell = 24 * 60 * 60/ mRows; |
1633 | 1633 | ||
1634 | int timeSeconds = secondsPerCell * gy; | 1634 | int timeSeconds = secondsPerCell * gy; |
1635 | 1635 | ||
1636 | QTime time( 0, 0, 0 ); | 1636 | QTime time( 0, 0, 0 ); |
1637 | if ( timeSeconds < 24 * 60 * 60 ) { | 1637 | if ( timeSeconds < 24 * 60 * 60 ) { |
1638 | time = time.addSecs(timeSeconds); | 1638 | time = time.addSecs(timeSeconds); |
1639 | } else { | 1639 | } else { |
1640 | time.setHMS( 23, 59, 59 ); | 1640 | time.setHMS( 23, 59, 59 ); |
1641 | } | 1641 | } |
1642 | 1642 | ||
1643 | return time; | 1643 | return time; |
1644 | } | 1644 | } |
1645 | 1645 | ||
1646 | void KOAgenda::setStartHour(int startHour) | 1646 | void KOAgenda::setStartHour(int startHour) |
1647 | { | 1647 | { |
1648 | int startCell = startHour * mRows / 24; | 1648 | int startCell = startHour * mRows / 24; |
1649 | setContentsPos(0,startCell * gridSpacingY()); | 1649 | setContentsPos(0,startCell * gridSpacingY()); |
1650 | } | 1650 | } |
1651 | QTime KOAgenda::getEndTime() | 1651 | QTime KOAgenda::getEndTime() |
1652 | { | 1652 | { |
1653 | int tim = (contentsY ()+viewport()->height())*24/contentsHeight (); | 1653 | int tim = (contentsY ()+viewport()->height())*24/contentsHeight (); |
1654 | if ( tim > 23 ) | 1654 | if ( tim > 23 ) |
1655 | return QTime ( 23,59,59); | 1655 | return QTime ( 23,59,59); |
1656 | return QTime ( tim,0,0); | 1656 | return QTime ( tim,0,0); |
1657 | } | 1657 | } |
1658 | void KOAgenda::hideUnused() | 1658 | void KOAgenda::hideUnused() |
1659 | { | 1659 | { |
1660 | // experimental only | 1660 | // experimental only |
1661 | // return; | 1661 | // return; |
1662 | KOAgendaItem *item; | 1662 | KOAgendaItem *item; |
1663 | for ( item=mUnusedItems.first(); item != 0; item=mUnusedItems.next() ) { | 1663 | for ( item=mUnusedItems.first(); item != 0; item=mUnusedItems.next() ) { |
1664 | item->hide(); | 1664 | item->hide(); |
1665 | } | 1665 | } |
1666 | } | 1666 | } |
1667 | 1667 | ||
1668 | 1668 | ||
1669 | KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view) | 1669 | KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view) |
1670 | { | 1670 | { |
1671 | 1671 | ||
1672 | KOAgendaItem *fi; | 1672 | KOAgendaItem *fi; |
1673 | for ( fi=mUnusedItems.first(); fi != 0; fi=mUnusedItems.next() ) { | 1673 | for ( fi=mUnusedItems.first(); fi != 0; fi=mUnusedItems.next() ) { |
1674 | if ( fi->incidence() == event ) { | 1674 | if ( fi->incidence() == event ) { |
1675 | mUnusedItems.remove(); | 1675 | mUnusedItems.remove(); |
1676 | fi->init( event, qd ); | 1676 | fi->init( event, qd ); |
1677 | return fi; | 1677 | return fi; |
1678 | } | 1678 | } |
1679 | } | 1679 | } |
1680 | fi=mUnusedItems.first(); | 1680 | fi=mUnusedItems.first(); |
1681 | if ( fi ) { | 1681 | if ( fi ) { |
1682 | mUnusedItems.remove(); | 1682 | mUnusedItems.remove(); |
1683 | fi->init( event, qd ); | 1683 | fi->init( event, qd ); |
1684 | return fi; | 1684 | return fi; |
1685 | } | 1685 | } |
1686 | // qDebug("new KOAgendaItem "); | 1686 | // qDebug("new KOAgendaItem "); |
1687 | 1687 | ||
1688 | KOAgendaItem* agendaItem = new KOAgendaItem( event, qd, view, mAllDayMode ); | 1688 | KOAgendaItem* agendaItem = new KOAgendaItem( event, qd, view, mAllDayMode ); |
1689 | agendaItem->installEventFilter(this); | 1689 | agendaItem->installEventFilter(this); |
1690 | addChild(agendaItem,0,0); | 1690 | addChild(agendaItem,0,0); |
1691 | return agendaItem; | 1691 | return agendaItem; |
1692 | } | 1692 | } |
1693 | KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo ) | 1693 | KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo ) |
1694 | { | 1694 | { |
1695 | KOAgendaItem *item; | 1695 | KOAgendaItem *item; |
1696 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1696 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1697 | if ( item->incidence() == todo ) { | 1697 | if ( item->incidence() == todo ) { |
1698 | mItems.remove(); | 1698 | mItems.remove(); |
1699 | return item; | 1699 | return item; |
1700 | } | 1700 | } |
1701 | } | 1701 | } |
1702 | return 0; | 1702 | return 0; |
1703 | } | 1703 | } |
1704 | 1704 | ||
1705 | 1705 | ||
1706 | void KOAgenda::updateTodo( Todo * todo, int days, bool remove) | 1706 | void KOAgenda::updateTodo( Todo * todo, int days, bool remove) |
1707 | { | 1707 | { |
1708 | // ( todo->hasCompletedDate() && todo->completed().date() == currentDate )|| | 1708 | // ( todo->hasCompletedDate() && todo->completed().date() == currentDate )|| |
1709 | KOAgendaItem *item; | 1709 | KOAgendaItem *item; |
1710 | item = getItemForTodo ( todo ); | 1710 | item = getItemForTodo ( todo ); |
1711 | //qDebug("KOAgenda::updateTodo %d %d %d %d", this, todo, days, remove); | 1711 | //qDebug("KOAgenda::updateTodo %d %d %d %d", this, todo, days, remove); |
1712 | if ( item ) { | 1712 | if ( item ) { |
1713 | blockSignals( true ); | 1713 | blockSignals( true ); |
1714 | //qDebug("item found "); | 1714 | //qDebug("item found "); |
1715 | item->hide(); | 1715 | item->hide(); |
1716 | item->setCellX(-2, -1 ); | 1716 | item->setCellX(-2, -1 ); |
1717 | item->select(false); | 1717 | item->select(false); |
1718 | mUnusedItems.append( item ); | 1718 | mUnusedItems.append( item ); |
1719 | mItems.remove( item ); | 1719 | mItems.remove( item ); |
1720 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); | 1720 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); |
1721 | KOAgendaItem *itemit; | 1721 | KOAgendaItem *itemit; |
1722 | //globalFlagBlockAgendaItemPaint = 1; | 1722 | //globalFlagBlockAgendaItemPaint = 1; |
1723 | for ( itemit=oldconflictItems.first(); itemit != 0; | 1723 | for ( itemit=oldconflictItems.first(); itemit != 0; |
1724 | itemit=oldconflictItems.next() ) { | 1724 | itemit=oldconflictItems.next() ) { |
1725 | if ( itemit != item ) | 1725 | if ( itemit != item ) |
1726 | placeSubCells(itemit); | 1726 | placeSubCells(itemit); |
1727 | } | 1727 | } |
1728 | qApp->processEvents(); | 1728 | qApp->processEvents(); |
1729 | //globalFlagBlockAgendaItemPaint = 0; | 1729 | //globalFlagBlockAgendaItemPaint = 0; |
1730 | for ( itemit=oldconflictItems.first(); itemit != 0; | 1730 | for ( itemit=oldconflictItems.first(); itemit != 0; |
1731 | itemit=oldconflictItems.next() ) { | 1731 | itemit=oldconflictItems.next() ) { |
1732 | globalFlagBlockAgendaItemUpdate = 0; | 1732 | globalFlagBlockAgendaItemUpdate = 0; |
1733 | if ( itemit != item ) | 1733 | if ( itemit != item ) |
1734 | itemit->repaintMe(); | 1734 | itemit->repaintMe(); |
1735 | globalFlagBlockAgendaItemUpdate = 1; | 1735 | globalFlagBlockAgendaItemUpdate = 1; |
1736 | //qDebug("sigleshot "); | 1736 | //qDebug("sigleshot "); |
1737 | QTimer::singleShot( 0, itemit, SLOT ( repaintItem() )); | 1737 | QTimer::singleShot( 0, itemit, SLOT ( repaintItem() )); |
1738 | //itemit->repaint( false ); repaintItem() | 1738 | //itemit->repaint( false ); repaintItem() |
1739 | } | 1739 | } |
1740 | blockSignals( false ); | 1740 | blockSignals( false ); |
1741 | } | 1741 | } |
1742 | if ( remove ) { | 1742 | if ( remove ) { |
1743 | //qDebug("remove****************************************** "); | 1743 | //qDebug("remove****************************************** "); |
1744 | return; | 1744 | return; |
1745 | } | 1745 | } |
1746 | if ( todo->hasCompletedDate() && !KOPrefs::instance()->mShowCompletedTodoInAgenda ) | 1746 | if ( todo->hasCompletedDate() && !KOPrefs::instance()->mShowCompletedTodoInAgenda ) |
1747 | return; | 1747 | return; |
1748 | //qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ "); | 1748 | //qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ "); |
1749 | QDate currentDate = QDate::currentDate(); | 1749 | QDate currentDate = QDate::currentDate(); |
1750 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < currentDate)&& ( KOPrefs::instance()->mShowTodoInAgenda ); | 1750 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < currentDate)&& ( KOPrefs::instance()->mShowTodoInAgenda ); |
1751 | QDateTime dt; | 1751 | QDateTime dt; |
1752 | if ( todo->hasCompletedDate() ) | 1752 | if ( todo->hasCompletedDate() ) |
1753 | dt = todo->completed(); | 1753 | dt = todo->completed(); |
1754 | else | 1754 | else |
1755 | dt = todo->dtDue(); | 1755 | dt = todo->dtDue(); |
1756 | if ( overdue ) { | 1756 | if ( overdue ) { |
1757 | days += todo->dtDue().date().daysTo( currentDate ); | 1757 | days += todo->dtDue().date().daysTo( currentDate ); |
1758 | } | 1758 | } |
1759 | else | 1759 | else |
1760 | currentDate = dt.date(); | 1760 | currentDate = dt.date(); |
1761 | 1761 | ||
1762 | if (( todo->doesFloat() || overdue) && !todo->hasCompletedDate() ) { | 1762 | if (( todo->doesFloat() || overdue) && !todo->hasCompletedDate() ) { |
1763 | if ( ! mAllDayMode ) return; | 1763 | if ( ! mAllDayMode ) return; |
1764 | // aldayagenda | 1764 | // aldayagenda |
1765 | globalFlagBlockAgendaItemPaint = 1; | 1765 | globalFlagBlockAgendaItemPaint = 1; |
1766 | item = insertAllDayItem(todo, currentDate,days, days); | 1766 | item = insertAllDayItem(todo, currentDate,days, days); |
1767 | item->show(); | 1767 | item->show(); |
1768 | 1768 | ||
1769 | } | 1769 | } |
1770 | else { | 1770 | else { |
1771 | if ( mAllDayMode ) return; | 1771 | if ( mAllDayMode ) return; |
1772 | // mAgenda | 1772 | // mAgenda |
1773 | globalFlagBlockAgendaItemPaint = 1; | 1773 | globalFlagBlockAgendaItemPaint = 1; |
1774 | int endY = timeToY(dt.time()) - 1; | 1774 | int endY = timeToY(dt.time()) - 1; |
1775 | int hi = 12/KOPrefs::instance()->mHourSize; | 1775 | int hi = 12/KOPrefs::instance()->mHourSize; |
1776 | int startY = endY - 1-hi; | 1776 | int startY = endY - 1-hi; |
1777 | item = insertItem(todo,currentDate,days,startY,endY); | 1777 | item = insertItem(todo,currentDate,days,startY,endY); |
1778 | item->show(); | 1778 | item->show(); |
1779 | } | 1779 | } |
1780 | qApp->processEvents(); | 1780 | qApp->processEvents(); |
1781 | globalFlagBlockAgendaItemPaint = 0; | 1781 | globalFlagBlockAgendaItemPaint = 0; |
1782 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); | 1782 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); |
1783 | KOAgendaItem *itemit; | 1783 | KOAgendaItem *itemit; |
1784 | for ( itemit=oldconflictItems.first(); itemit != 0; | 1784 | for ( itemit=oldconflictItems.first(); itemit != 0; |
1785 | itemit=oldconflictItems.next() ) { | 1785 | itemit=oldconflictItems.next() ) { |
1786 | globalFlagBlockAgendaItemUpdate = 0; | 1786 | globalFlagBlockAgendaItemUpdate = 0; |
1787 | itemit->repaintMe(); | 1787 | itemit->repaintMe(); |
1788 | globalFlagBlockAgendaItemUpdate = 1; | 1788 | globalFlagBlockAgendaItemUpdate = 1; |
1789 | itemit->repaint(); | 1789 | itemit->repaint(); |
1790 | } | 1790 | } |
1791 | globalFlagBlockAgendaItemUpdate = 0; | 1791 | globalFlagBlockAgendaItemUpdate = 0; |
1792 | item->repaintMe(); | 1792 | item->repaintMe(); |
1793 | globalFlagBlockAgendaItemUpdate = 1; | 1793 | globalFlagBlockAgendaItemUpdate = 1; |
1794 | item->repaint(); | 1794 | item->repaint(); |
1795 | } | 1795 | } |
1796 | /* | 1796 | /* |
1797 | Insert KOAgendaItem into agenda. | 1797 | Insert KOAgendaItem into agenda. |
1798 | */ | 1798 | */ |
1799 | KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom) | 1799 | KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom) |
1800 | { | 1800 | { |
1801 | if (mAllDayMode) { | 1801 | if (mAllDayMode) { |
1802 | qDebug("KOAgenda: calling insertItem in all-day mode is illegal. "); | 1802 | qDebug("KOAgenda: calling insertItem in all-day mode is illegal. "); |
1803 | return 0; | 1803 | return 0; |
1804 | } | 1804 | } |
1805 | 1805 | ||
1806 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); | 1806 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); |
1807 | //agendaItem->setFrameStyle(WinPanel|Raised); | 1807 | //agendaItem->setFrameStyle(WinPanel|Raised); |
1808 | 1808 | ||
1809 | int YSize = YBottom - YTop + 1; | 1809 | int YSize = YBottom - YTop + 1; |
1810 | if (YSize < 0) { | 1810 | if (YSize < 0) { |
1811 | YSize = 1; | 1811 | YSize = 1; |
1812 | } | 1812 | } |
1813 | int iheight = mGridSpacingY * YSize; | 1813 | int iheight = mGridSpacingY * YSize; |
1814 | 1814 | ||
1815 | agendaItem->resize(mGridSpacingX,iheight ); | 1815 | agendaItem->resize(mGridSpacingX,iheight ); |
1816 | agendaItem->setCellXY(X,YTop,YBottom); | 1816 | agendaItem->setCellXY(X,YTop,YBottom); |
1817 | agendaItem->setCellXWidth(X); | 1817 | agendaItem->setCellXWidth(X); |
1818 | 1818 | ||
1819 | //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY); | 1819 | //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY); |
1820 | mItems.append(agendaItem); | 1820 | mItems.append(agendaItem); |
1821 | 1821 | ||
1822 | placeSubCells(agendaItem); | 1822 | placeSubCells(agendaItem); |
1823 | 1823 | ||
1824 | //agendaItem->show(); | 1824 | //agendaItem->show(); |
1825 | 1825 | ||
1826 | 1826 | ||
1827 | return agendaItem; | 1827 | return agendaItem; |
1828 | } | 1828 | } |
1829 | 1829 | ||
1830 | 1830 | ||
1831 | /* | 1831 | /* |
1832 | Insert all-day KOAgendaItem into agenda. | 1832 | Insert all-day KOAgendaItem into agenda. |
1833 | */ | 1833 | */ |
1834 | KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd) | 1834 | KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd) |
1835 | { | 1835 | { |
1836 | if (!mAllDayMode) { | 1836 | if (!mAllDayMode) { |
1837 | return 0; | 1837 | return 0; |
1838 | } | 1838 | } |
1839 | 1839 | //qDebug("insertallday %s -- %d - %d ",qd.toString().latin1(), XBegin, XEnd ); | |
1840 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); | 1840 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); |
1841 | 1841 | ||
1842 | agendaItem->setCellXY(XBegin,0,0); | 1842 | agendaItem->setCellXY(XBegin,0,0); |
1843 | agendaItem->setCellXWidth(XEnd); | 1843 | agendaItem->setCellXWidth(XEnd); |
1844 | agendaItem->resizeMe(mGridSpacingX, mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY); | 1844 | agendaItem->resizeMe(mGridSpacingX, mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY, true ); |
1845 | 1845 | ||
1846 | //addChild(agendaItem,XBegin*mGridSpacingX,0); | 1846 | //addChild(agendaItem,XBegin*mGridSpacingX,0); |
1847 | mItems.append(agendaItem); | 1847 | mItems.append(agendaItem); |
1848 | 1848 | ||
1849 | placeSubCells(agendaItem); | 1849 | placeSubCells(agendaItem); |
1850 | 1850 | ||
1851 | //agendaItem->show(); | 1851 | //agendaItem->show(); |
1852 | 1852 | ||
1853 | return agendaItem; | 1853 | return agendaItem; |
1854 | } | 1854 | } |
1855 | 1855 | ||
1856 | 1856 | ||
1857 | void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, | 1857 | void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, |
1858 | int YTop,int YBottom) | 1858 | int YTop,int YBottom) |
1859 | { | 1859 | { |
1860 | if (mAllDayMode) { | 1860 | if (mAllDayMode) { |
1861 | ; | 1861 | ; |
1862 | return; | 1862 | return; |
1863 | } | 1863 | } |
1864 | 1864 | ||
1865 | int cellX,cellYTop,cellYBottom; | 1865 | int cellX,cellYTop,cellYBottom; |
1866 | QString newtext; | 1866 | QString newtext; |
1867 | int width = XEnd - XBegin + 1; | 1867 | int width = XEnd - XBegin + 1; |
1868 | int count = 0; | 1868 | int count = 0; |
1869 | KOAgendaItem *current = 0; | 1869 | KOAgendaItem *current = 0; |
1870 | QPtrList<KOAgendaItem> multiItems; | 1870 | QPtrList<KOAgendaItem> multiItems; |
1871 | for (cellX = XBegin;cellX <= XEnd;++cellX) { | 1871 | for (cellX = XBegin;cellX <= XEnd;++cellX) { |
1872 | if (cellX == XBegin) cellYTop = YTop; | 1872 | if (cellX == XBegin) cellYTop = YTop; |
1873 | else cellYTop = 0; | 1873 | else cellYTop = 0; |
1874 | if (cellX == XEnd) cellYBottom = YBottom; | 1874 | if (cellX == XEnd) cellYBottom = YBottom; |
1875 | else cellYBottom = rows() - 1; | 1875 | else cellYBottom = rows() - 1; |
1876 | newtext = QString("(%1/%2): ").arg(++count).arg(width); | 1876 | newtext = QString("(%1/%2): ").arg(++count).arg(width); |
1877 | newtext.append(event->summary()); | 1877 | newtext.append(event->summary()); |
1878 | current = insertItem(event,qd,cellX,cellYTop,cellYBottom); | 1878 | current = insertItem(event,qd,cellX,cellYTop,cellYBottom); |
1879 | current->setText(newtext); | 1879 | current->setText(newtext); |
1880 | multiItems.append(current); | 1880 | multiItems.append(current); |
1881 | } | 1881 | } |
1882 | 1882 | ||
1883 | KOAgendaItem *next = 0; | 1883 | KOAgendaItem *next = 0; |
1884 | KOAgendaItem *last = multiItems.last(); | 1884 | KOAgendaItem *last = multiItems.last(); |
1885 | KOAgendaItem *first = multiItems.first(); | 1885 | KOAgendaItem *first = multiItems.first(); |
1886 | KOAgendaItem *setFirst,*setLast; | 1886 | KOAgendaItem *setFirst,*setLast; |
1887 | current = first; | 1887 | current = first; |
1888 | while (current) { | 1888 | while (current) { |
1889 | next = multiItems.next(); | 1889 | next = multiItems.next(); |
1890 | if (current == first) setFirst = 0; | 1890 | if (current == first) setFirst = 0; |
1891 | else setFirst = first; | 1891 | else setFirst = first; |
1892 | if (current == last) setLast = 0; | 1892 | if (current == last) setLast = 0; |
1893 | else setLast = last; | 1893 | else setLast = last; |
1894 | 1894 | ||
1895 | current->setMultiItem(setFirst,next,setLast); | 1895 | current->setMultiItem(setFirst,next,setLast); |
1896 | current = next; | 1896 | current = next; |
1897 | } | 1897 | } |
1898 | } | 1898 | } |
1899 | 1899 | ||
1900 | 1900 | ||
1901 | //QSizePolicy KOAgenda::sizePolicy() const | 1901 | //QSizePolicy KOAgenda::sizePolicy() const |
1902 | //{ | 1902 | //{ |
1903 | // Thought this would make the all-day event agenda minimum size and the | 1903 | // Thought this would make the all-day event agenda minimum size and the |
1904 | // normal agenda take the remaining space. But it doesn´t work. The QSplitter | 1904 | // normal agenda take the remaining space. But it doesn´t work. The QSplitter |
1905 | // don´t seem to think that an Expanding widget needs more space than a | 1905 | // don´t seem to think that an Expanding widget needs more space than a |
1906 | // Preferred one. | 1906 | // Preferred one. |
1907 | // But it doesn´t hurt, so it stays. | 1907 | // But it doesn´t hurt, so it stays. |
1908 | // if (mAllDayMode) { | 1908 | // if (mAllDayMode) { |
1909 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred); | 1909 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred); |
1910 | // } else { | 1910 | // } else { |
1911 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); | 1911 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); |
1912 | // } | 1912 | // } |
1913 | //} | 1913 | //} |
1914 | void KOAgenda::finishResize ( ) | 1914 | void KOAgenda::finishResize ( ) |
1915 | { | 1915 | { |
1916 | //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) "); | 1916 | //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) "); |
1917 | if ( globalFlagBlockAgenda == 0 ) { | 1917 | if ( globalFlagBlockAgenda == 0 ) { |
1918 | finishUpdate(); | 1918 | finishUpdate(); |
1919 | //qDebug("finishUpdate() called "); | 1919 | //qDebug("finishUpdate() called "); |
1920 | } | 1920 | } |
1921 | } | 1921 | } |
1922 | /* | 1922 | /* |
1923 | Overridden from QScrollView to provide proper resizing of KOAgendaItems. | 1923 | Overridden from QScrollView to provide proper resizing of KOAgendaItems. |
1924 | */ | 1924 | */ |
1925 | void KOAgenda::resizeEvent ( QResizeEvent *ev ) | 1925 | void KOAgenda::resizeEvent ( QResizeEvent *ev ) |
1926 | { | 1926 | { |
1927 | mSelectionHeight = 0; | 1927 | mSelectionHeight = 0; |
1928 | mResizeTimer.start( 150 , true ); | 1928 | mResizeTimer.start( 150 , true ); |
1929 | computeSizes(); | 1929 | computeSizes(); |
1930 | QScrollView::resizeEvent( ev ); | 1930 | QScrollView::resizeEvent( ev ); |
1931 | return; | 1931 | return; |
1932 | 1932 | ||
1933 | } | 1933 | } |
1934 | void KOAgenda::computeSizes() | 1934 | void KOAgenda::computeSizes() |
1935 | { | 1935 | { |
1936 | if ( globalFlagBlockStartup ) | 1936 | if ( globalFlagBlockStartup ) |
1937 | return; | 1937 | return; |
1938 | int frameOffset = frameWidth() * 2 +1; | 1938 | int frameOffset = frameWidth() * 2 +1; |
1939 | if (mAllDayMode) { | 1939 | if (mAllDayMode) { |
1940 | mGridSpacingX = (width()-frameOffset) / mColumns; | 1940 | mGridSpacingX = (width()-frameOffset) / mColumns; |
1941 | mGridSpacingY = height() - 2 * frameWidth() - 1; | 1941 | mGridSpacingY = height() - 2 * frameWidth() - 1; |
1942 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1); | 1942 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1); |
1943 | // mGridSpacingY = height(); | 1943 | // mGridSpacingY = height(); |
1944 | // resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 1944 | // resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
1945 | 1945 | ||
1946 | KOAgendaItem *item; | 1946 | KOAgendaItem *item; |
1947 | int subCellWidth; | 1947 | int subCellWidth; |
1948 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1948 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1949 | subCellWidth = mGridSpacingY / item->subCells(); | 1949 | subCellWidth = mGridSpacingY / item->subCells(); |
1950 | int diff = 0; | 1950 | int diff = 0; |
1951 | diff = item->resizeMe(mGridSpacingX ,mGridSpacingX * item->cellWidth(),subCellWidth); | 1951 | diff = item->resizeMe(mGridSpacingX ,mGridSpacingX * item->cellWidth(),subCellWidth); |
1952 | moveChild(item,(KOGlobals::self()->reverseLayout() ? | 1952 | moveChild(item,(KOGlobals::self()->reverseLayout() ? |
1953 | (mColumns - 1 - item->cellX()) * mGridSpacingX : | 1953 | (mColumns - 1 - item->cellX()) * mGridSpacingX : |
1954 | item->cellX() * mGridSpacingX) + diff, | 1954 | item->cellX() * mGridSpacingX) + diff, |
1955 | item->subCell() * subCellWidth); | 1955 | item->subCell() * subCellWidth); |
1956 | } | 1956 | } |
1957 | KOPrefs::instance()->mAllDaySize = mGridSpacingY; | 1957 | KOPrefs::instance()->mAllDaySize = mGridSpacingY; |
1958 | } else { | 1958 | } else { |
1959 | mGridSpacingX = (width() - verticalScrollBar()->width()-frameOffset)/mColumns; | 1959 | mGridSpacingX = (width() - verticalScrollBar()->width()-frameOffset)/mColumns; |
1960 | if (height() > mGridSpacingY * mRows + 1 ) { | 1960 | if (height() > mGridSpacingY * mRows + 1 ) { |
1961 | KOPrefs::instance()->mHourSize = ((height())/mRows)+1; | 1961 | KOPrefs::instance()->mHourSize = ((height())/mRows)+1; |
1962 | mGridSpacingY = KOPrefs::instance()->mHourSize ; | 1962 | mGridSpacingY = KOPrefs::instance()->mHourSize ; |
1963 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 1963 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
1964 | emit resizedSignal(); | 1964 | emit resizedSignal(); |
1965 | } else | 1965 | } else |
1966 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 1966 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
1967 | KOAgendaItem *item; | 1967 | KOAgendaItem *item; |
1968 | int subCellWidth; | 1968 | int subCellWidth; |
1969 | 1969 | ||
1970 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1970 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1971 | subCellWidth = mGridSpacingX / item->subCells(); | 1971 | subCellWidth = mGridSpacingX / item->subCells(); |
1972 | item->resize(subCellWidth,item->height()); | 1972 | item->resize(subCellWidth,item->height()); |
1973 | moveChild(item,(KOGlobals::self()->reverseLayout() ? | 1973 | moveChild(item,(KOGlobals::self()->reverseLayout() ? |
1974 | (mColumns - 1 - item->cellX()) * mGridSpacingX : | 1974 | (mColumns - 1 - item->cellX()) * mGridSpacingX : |
1975 | item->cellX() * mGridSpacingX) + | 1975 | item->cellX() * mGridSpacingX) + |
1976 | item->subCell() * subCellWidth,childY(item)); | 1976 | item->subCell() * subCellWidth,childY(item)); |
1977 | } | 1977 | } |
1978 | } | 1978 | } |
1979 | int cw = contentsWidth(); | 1979 | int cw = contentsWidth(); |
1980 | int ch = contentsHeight(); | 1980 | int ch = contentsHeight(); |
1981 | if ( mAllDayMode ) { | 1981 | if ( mAllDayMode ) { |
1982 | QPixmap* paintPixAll = KOAgendaItem::paintPixAllday(); | 1982 | QPixmap* paintPixAll = KOAgendaItem::paintPixAllday(); |
1983 | if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 ) { | 1983 | if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 ) { |
1984 | //qDebug("paintPixAll->resize "); | 1984 | //qDebug("paintPixAll->resize "); |
1985 | paintPixAll->resize( cw, ch ); | 1985 | paintPixAll->resize( cw, ch ); |
1986 | } | 1986 | } |
1987 | } else { | 1987 | } else { |
1988 | QPixmap* paintPix = KOAgendaItem::paintPix(); | 1988 | QPixmap* paintPix = KOAgendaItem::paintPix(); |
1989 | if ( paintPix->width() < cw || paintPix->height() < ch ) { | 1989 | if ( paintPix->width() < cw || paintPix->height() < ch ) { |
1990 | //qDebug("paintPix->resize "); | 1990 | //qDebug("paintPix->resize "); |
1991 | paintPix->resize( cw , ch ); | 1991 | paintPix->resize( cw , ch ); |
1992 | } | 1992 | } |
1993 | } | 1993 | } |
1994 | 1994 | ||
1995 | checkScrollBoundaries(); | 1995 | checkScrollBoundaries(); |
1996 | drawContentsToPainter(); | 1996 | drawContentsToPainter(); |
1997 | viewport()->repaint(false); | 1997 | viewport()->repaint(false); |
1998 | } | 1998 | } |
1999 | 1999 | ||
2000 | void KOAgenda::scrollUp() | 2000 | void KOAgenda::scrollUp() |
2001 | { | 2001 | { |
2002 | scrollBy(0,-mScrollOffset); | 2002 | scrollBy(0,-mScrollOffset); |
2003 | } | 2003 | } |
2004 | 2004 | ||
2005 | 2005 | ||
2006 | void KOAgenda::scrollDown() | 2006 | void KOAgenda::scrollDown() |
2007 | { | 2007 | { |
2008 | scrollBy(0,mScrollOffset); | 2008 | scrollBy(0,mScrollOffset); |
2009 | } | 2009 | } |
2010 | 2010 | ||
2011 | void KOAgenda::popupAlarm() | 2011 | void KOAgenda::popupAlarm() |
2012 | { | 2012 | { |
2013 | if (!mClickedItem) { | 2013 | if (!mClickedItem) { |
2014 | qDebug("KOAgenda::popupAlarm() called without having a clicked item "); | 2014 | qDebug("KOAgenda::popupAlarm() called without having a clicked item "); |
2015 | return; | 2015 | return; |
2016 | } | 2016 | } |
2017 | // TODO: deal correctly with multiple alarms | 2017 | // TODO: deal correctly with multiple alarms |
2018 | Alarm* alarm; | 2018 | Alarm* alarm; |
2019 | QPtrList<Alarm> list(mClickedItem->incidence()->alarms()); | 2019 | QPtrList<Alarm> list(mClickedItem->incidence()->alarms()); |
2020 | for(alarm=list.first();alarm;alarm=list.next()) { | 2020 | for(alarm=list.first();alarm;alarm=list.next()) { |
2021 | alarm->toggleAlarm(); | 2021 | alarm->toggleAlarm(); |
2022 | } | 2022 | } |
2023 | emit itemModified( mClickedItem , KOGlobals::EVENTEDITED ); | 2023 | emit itemModified( mClickedItem , KOGlobals::EVENTEDITED ); |
2024 | mClickedItem->paintMe( true ); | 2024 | mClickedItem->paintMe( true ); |
2025 | mClickedItem->repaint( false ); | 2025 | mClickedItem->repaint( false ); |
2026 | } | 2026 | } |
2027 | 2027 | ||
2028 | /* | 2028 | /* |
2029 | Calculates the minimum width | 2029 | Calculates the minimum width |
2030 | */ | 2030 | */ |
2031 | int KOAgenda::minimumWidth() const | 2031 | int KOAgenda::minimumWidth() const |
2032 | { | 2032 | { |
2033 | // TODO:: develop a way to dynamically determine the minimum width | 2033 | // TODO:: develop a way to dynamically determine the minimum width |
2034 | int min = 100; | 2034 | int min = 100; |
2035 | 2035 | ||
2036 | return min; | 2036 | return min; |
2037 | } | 2037 | } |
2038 | 2038 | ||
2039 | void KOAgenda::updateConfig() | 2039 | void KOAgenda::updateConfig() |
2040 | { | 2040 | { |
2041 | if ( viewport()->backgroundColor() != KOPrefs::instance()->mAgendaBgColor) | 2041 | if ( viewport()->backgroundColor() != KOPrefs::instance()->mAgendaBgColor) |
2042 | viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor); | 2042 | viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor); |
2043 | if ( mAllDayMode ) { | 2043 | if ( mAllDayMode ) { |
2044 | mGridSpacingY = height() - 1 ;// KOPrefs::instance()->mAllDaySize; | 2044 | mGridSpacingY = height() - 1 ;// KOPrefs::instance()->mAllDaySize; |
2045 | //mGridSpacingY = KOPrefs::instance()->mAllDaySize; | 2045 | //mGridSpacingY = KOPrefs::instance()->mAllDaySize; |
2046 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY+1 ); | 2046 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY+1 ); |
2047 | // setMaximumHeight( mGridSpacingY+1 ); | 2047 | // setMaximumHeight( mGridSpacingY+1 ); |
2048 | viewport()->repaint( false ); | 2048 | viewport()->repaint( false ); |
2049 | //setFixedHeight( mGridSpacingY+1 ); | 2049 | //setFixedHeight( mGridSpacingY+1 ); |
2050 | //qDebug("KOPrefs:aaaaa:instance()->mAllDaySize %d ", KOPrefs::instance()->mAllDaySize); | 2050 | //qDebug("KOPrefs:aaaaa:instance()->mAllDaySize %d ", KOPrefs::instance()->mAllDaySize); |
2051 | } | 2051 | } |
2052 | else { | 2052 | else { |
2053 | mGridSpacingY = KOPrefs::instance()->mHourSize; | 2053 | mGridSpacingY = KOPrefs::instance()->mHourSize; |
2054 | calculateWorkingHours(); | 2054 | calculateWorkingHours(); |
2055 | } | 2055 | } |
2056 | } | 2056 | } |
2057 | 2057 | ||
2058 | void KOAgenda::checkScrollBoundaries() | 2058 | void KOAgenda::checkScrollBoundaries() |
2059 | { | 2059 | { |
2060 | // Invalidate old values to force update | 2060 | // Invalidate old values to force update |
2061 | mOldLowerScrollValue = -1; | 2061 | mOldLowerScrollValue = -1; |
2062 | mOldUpperScrollValue = -1; | 2062 | mOldUpperScrollValue = -1; |
2063 | 2063 | ||
2064 | checkScrollBoundaries(verticalScrollBar()->value()); | 2064 | checkScrollBoundaries(verticalScrollBar()->value()); |
2065 | } | 2065 | } |
2066 | 2066 | ||
2067 | void KOAgenda::checkScrollBoundaries(int v) | 2067 | void KOAgenda::checkScrollBoundaries(int v) |
2068 | { | 2068 | { |
2069 | if ( mGridSpacingY == 0 ) | 2069 | if ( mGridSpacingY == 0 ) |
2070 | return; | 2070 | return; |
2071 | int yMin = v/mGridSpacingY; | 2071 | int yMin = v/mGridSpacingY; |
2072 | int yMax = (v+visibleHeight())/mGridSpacingY; | 2072 | int yMax = (v+visibleHeight())/mGridSpacingY; |
2073 | 2073 | ||
2074 | // kdDebug() << "--- yMin: " << yMin << " yMax: " << yMax << endl; | 2074 | // kdDebug() << "--- yMin: " << yMin << " yMax: " << yMax << endl; |
2075 | 2075 | ||
2076 | if (yMin != mOldLowerScrollValue) { | 2076 | if (yMin != mOldLowerScrollValue) { |
2077 | mOldLowerScrollValue = yMin; | 2077 | mOldLowerScrollValue = yMin; |
2078 | emit lowerYChanged(yMin); | 2078 | emit lowerYChanged(yMin); |
2079 | } | 2079 | } |
2080 | if (yMax != mOldUpperScrollValue) { | 2080 | if (yMax != mOldUpperScrollValue) { |
2081 | mOldUpperScrollValue = yMax; | 2081 | mOldUpperScrollValue = yMax; |
2082 | emit upperYChanged(yMax); | 2082 | emit upperYChanged(yMax); |
2083 | } | 2083 | } |
2084 | } | 2084 | } |
2085 | 2085 | ||
2086 | void KOAgenda::deselectItem() | 2086 | void KOAgenda::deselectItem() |
2087 | { | 2087 | { |
2088 | if (mSelectedItem.isNull()) return; | 2088 | if (mSelectedItem.isNull()) return; |
2089 | mSelectedItem->select(false); | 2089 | mSelectedItem->select(false); |
2090 | mSelectedItem = 0; | 2090 | mSelectedItem = 0; |
2091 | } | 2091 | } |
2092 | 2092 | ||
2093 | void KOAgenda::selectItem(KOAgendaItem *item) | 2093 | void KOAgenda::selectItem(KOAgendaItem *item) |
2094 | { | 2094 | { |
2095 | if ((KOAgendaItem *)mSelectedItem == item) return; | 2095 | if ((KOAgendaItem *)mSelectedItem == item) return; |
2096 | deselectItem(); | 2096 | deselectItem(); |
2097 | if (item == 0) { | 2097 | if (item == 0) { |
2098 | emit incidenceSelected( 0 ); | 2098 | emit incidenceSelected( 0 ); |
2099 | return; | 2099 | return; |
2100 | } | 2100 | } |
2101 | mSelectedItem = item; | 2101 | mSelectedItem = item; |
2102 | mSelectedItem->select(); | 2102 | mSelectedItem->select(); |
2103 | emit incidenceSelected( mSelectedItem->incidence() ); | 2103 | emit incidenceSelected( mSelectedItem->incidence() ); |
2104 | } | 2104 | } |
2105 | 2105 | ||
2106 | // This function seems never be called. | 2106 | // This function seems never be called. |
2107 | void KOAgenda::keyPressEvent( QKeyEvent *kev ) | 2107 | void KOAgenda::keyPressEvent( QKeyEvent *kev ) |
2108 | { | 2108 | { |
2109 | switch(kev->key()) { | 2109 | switch(kev->key()) { |
2110 | case Key_PageDown: | 2110 | case Key_PageDown: |
2111 | verticalScrollBar()->addPage(); | 2111 | verticalScrollBar()->addPage(); |
2112 | break; | 2112 | break; |
2113 | case Key_PageUp: | 2113 | case Key_PageUp: |
2114 | verticalScrollBar()->subtractPage(); | 2114 | verticalScrollBar()->subtractPage(); |
2115 | break; | 2115 | break; |
2116 | case Key_Down: | 2116 | case Key_Down: |
2117 | verticalScrollBar()->addLine(); | 2117 | verticalScrollBar()->addLine(); |
2118 | break; | 2118 | break; |
2119 | case Key_Up: | 2119 | case Key_Up: |
2120 | verticalScrollBar()->subtractLine(); | 2120 | verticalScrollBar()->subtractLine(); |
2121 | break; | 2121 | break; |
2122 | default: | 2122 | default: |
2123 | ; | 2123 | ; |
2124 | } | 2124 | } |
2125 | } | 2125 | } |
2126 | 2126 | ||
2127 | void KOAgenda::calculateWorkingHours() | 2127 | void KOAgenda::calculateWorkingHours() |
2128 | { | 2128 | { |
2129 | // mWorkingHoursEnable = KOPrefs::instance()->mEnableWorkingHours; | 2129 | // mWorkingHoursEnable = KOPrefs::instance()->mEnableWorkingHours; |
2130 | mWorkingHoursEnable = !mAllDayMode; | 2130 | mWorkingHoursEnable = !mAllDayMode; |
2131 | 2131 | ||
2132 | mWorkingHoursYTop = mGridSpacingY * | 2132 | mWorkingHoursYTop = mGridSpacingY * |
2133 | KOPrefs::instance()->mWorkingHoursStart * 4; | 2133 | KOPrefs::instance()->mWorkingHoursStart * 4; |
2134 | mWorkingHoursYBottom = mGridSpacingY * | 2134 | mWorkingHoursYBottom = mGridSpacingY * |
2135 | KOPrefs::instance()->mWorkingHoursEnd * 4 - 1; | 2135 | KOPrefs::instance()->mWorkingHoursEnd * 4 - 1; |
2136 | } | 2136 | } |
2137 | 2137 | ||
2138 | 2138 | ||
2139 | DateList KOAgenda::dateList() const | 2139 | DateList KOAgenda::dateList() const |
2140 | { | 2140 | { |
2141 | return mSelectedDates; | 2141 | return mSelectedDates; |
2142 | } | 2142 | } |
2143 | 2143 | ||
2144 | void KOAgenda::setDateList(const DateList &selectedDates) | 2144 | void KOAgenda::setDateList(const DateList &selectedDates) |
2145 | { | 2145 | { |
2146 | mSelectedDates = selectedDates; | 2146 | mSelectedDates = selectedDates; |
2147 | } | 2147 | } |
2148 | 2148 | ||
2149 | void KOAgenda::setHolidayMask(QMemArray<bool> *mask) | 2149 | void KOAgenda::setHolidayMask(QMemArray<bool> *mask) |
2150 | { | 2150 | { |
2151 | mHolidayMask = mask; | 2151 | mHolidayMask = mask; |
2152 | 2152 | ||
2153 | /* | 2153 | /* |
2154 | kdDebug() << "HolidayMask: "; | 2154 | kdDebug() << "HolidayMask: "; |
2155 | for(uint i=0;i<mask->count();++i) { | 2155 | for(uint i=0;i<mask->count();++i) { |
2156 | kdDebug() << (mask->at(i) ? "*" : "o"); | 2156 | kdDebug() << (mask->at(i) ? "*" : "o"); |
2157 | } | 2157 | } |
2158 | kdDebug() << endl; | 2158 | kdDebug() << endl; |
2159 | */ | 2159 | */ |
2160 | } | 2160 | } |
2161 | 2161 | ||
2162 | void KOAgenda::contentsMousePressEvent ( QMouseEvent *event ) | 2162 | void KOAgenda::contentsMousePressEvent ( QMouseEvent *event ) |
2163 | { | 2163 | { |
2164 | 2164 | ||
2165 | QScrollView::contentsMousePressEvent(event); | 2165 | QScrollView::contentsMousePressEvent(event); |
2166 | } | 2166 | } |
2167 | 2167 | ||
2168 | void KOAgenda::storePosition() | 2168 | void KOAgenda::storePosition() |
2169 | { | 2169 | { |
2170 | //mContentPosition | 2170 | //mContentPosition |
2171 | int max = mGridSpacingY*4*24; | 2171 | int max = mGridSpacingY*4*24; |
2172 | if ( contentsY() < 5 && max > viewport()->height()*3/2 ) | 2172 | if ( contentsY() < 5 && max > viewport()->height()*3/2 ) |
2173 | mContentPosition = 0; | 2173 | mContentPosition = 0; |
2174 | else if ( contentsY() + viewport()->height() > max - 5 && max > viewport()->height()*3/2) | 2174 | else if ( contentsY() + viewport()->height() > max - 5 && max > viewport()->height()*3/2) |
2175 | mContentPosition = -1.0; | 2175 | mContentPosition = -1.0; |
2176 | else | 2176 | else |
2177 | mContentPosition = ((float) max)/ ((float)(contentsY()+ ( viewport()->height()/2))); | 2177 | mContentPosition = ((float) max)/ ((float)(contentsY()+ ( viewport()->height()/2))); |
2178 | //qDebug("mContentPosition %f %d %d %d",mContentPosition , max, contentsY() ,viewport()->height()); | 2178 | //qDebug("mContentPosition %f %d %d %d",mContentPosition , max, contentsY() ,viewport()->height()); |
2179 | 2179 | ||
2180 | } | 2180 | } |
2181 | void KOAgenda::restorePosition() | 2181 | void KOAgenda::restorePosition() |
2182 | { | 2182 | { |
2183 | int posY; | 2183 | int posY; |
2184 | int max = mGridSpacingY*4*24; | 2184 | int max = mGridSpacingY*4*24; |
2185 | if ( mContentPosition < 0 ) | 2185 | if ( mContentPosition < 0 ) |
2186 | posY = max-viewport()->height(); | 2186 | posY = max-viewport()->height(); |
2187 | else | 2187 | else |
2188 | if ( mContentPosition == 0 ) | 2188 | if ( mContentPosition == 0 ) |
2189 | posY = 0; | 2189 | posY = 0; |
2190 | else | 2190 | else |
2191 | posY = (int) ((max/mContentPosition)-(viewport()->height()/2)); | 2191 | posY = (int) ((max/mContentPosition)-(viewport()->height()/2)); |
2192 | setContentsPos (0, posY ); | 2192 | setContentsPos (0, posY ); |
2193 | //qDebug("posY %d hei %d", posY, max); | 2193 | //qDebug("posY %d hei %d", posY, max); |
2194 | 2194 | ||
2195 | } | 2195 | } |
2196 | void KOAgenda::moveChild( QWidget *w, int x , int y ) | 2196 | void KOAgenda::moveChild( QWidget *w, int x , int y ) |
2197 | { | 2197 | { |
2198 | ++x; | 2198 | ++x; |
2199 | QScrollView::moveChild( w, x , y ); | 2199 | QScrollView::moveChild( w, x , y ); |
2200 | } | 2200 | } |
2201 | #include <qmessagebox.h> | 2201 | #include <qmessagebox.h> |
2202 | #ifdef DESKTOP_VERSION | 2202 | #ifdef DESKTOP_VERSION |
2203 | #include <qprinter.h> | 2203 | #include <qprinter.h> |
2204 | #include <qpainter.h> | 2204 | #include <qpainter.h> |
2205 | #include <qpaintdevicemetrics.h> | 2205 | #include <qpaintdevicemetrics.h> |
2206 | 2206 | ||
2207 | #endif | 2207 | #endif |
2208 | void KOAgenda::printSelection() | 2208 | void KOAgenda::printSelection() |
2209 | { | 2209 | { |
2210 | #ifdef DESKTOP_VERSION | 2210 | #ifdef DESKTOP_VERSION |
2211 | if ( mStartCellY == mCurrentCellY ) { | 2211 | if ( mStartCellY == mCurrentCellY ) { |
2212 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 2212 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
2213 | i18n("Nothing selected!\n\nThis prints the full width of the Agenda view as you see it!\n\nTo determine the vertical range of the printing, please select\na vertical range (with the left mouse button down) in one column. "), | 2213 | i18n("Nothing selected!\n\nThis prints the full width of the Agenda view as you see it!\n\nTo determine the vertical range of the printing, please select\na vertical range (with the left mouse button down) in one column. "), |
2214 | i18n("OK"), 0, 0, | 2214 | i18n("OK"), 0, 0, |
2215 | 0, 1 ); | 2215 | 0, 1 ); |
2216 | return; | 2216 | return; |
2217 | } | 2217 | } |
2218 | 2218 | ||
2219 | float dx, dy; | 2219 | float dx, dy; |
2220 | int x,y,w,h; | 2220 | int x,y,w,h; |
2221 | x= 0; | 2221 | x= 0; |
2222 | w= contentsWidth()+2; | 2222 | w= contentsWidth()+2; |
2223 | // h= contentsHeight(); | 2223 | // h= contentsHeight(); |
2224 | y = mGridSpacingY*mStartCellY; | 2224 | y = mGridSpacingY*mStartCellY; |
2225 | h = mGridSpacingY*(mCurrentCellY+1)-y+2; | 2225 | h = mGridSpacingY*(mCurrentCellY+1)-y+2; |
2226 | 2226 | ||
2227 | //return; | 2227 | //return; |
2228 | QPrinter* printer = new QPrinter(); | 2228 | QPrinter* printer = new QPrinter(); |
2229 | if ( !printer->setup()) { | 2229 | if ( !printer->setup()) { |
2230 | delete printer; | 2230 | delete printer; |
2231 | return; | 2231 | return; |
2232 | } | 2232 | } |
2233 | QPainter p( printer ); | 2233 | QPainter p( printer ); |
2234 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( printer ); | 2234 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( printer ); |
2235 | QString date = i18n("Date range: ")+KGlobal::locale()->formatDate( mSelectedDates.first() )+" - "+KGlobal::locale()->formatDate( mSelectedDates.last() ); | 2235 | QString date = i18n("Date range: ")+KGlobal::locale()->formatDate( mSelectedDates.first() )+" - "+KGlobal::locale()->formatDate( mSelectedDates.last() ); |
2236 | //date += " --- printing time: " + KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), true ); | 2236 | //date += " --- printing time: " + KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), true ); |
2237 | int hei = p.boundingRect(0,0, 5, 5, Qt::AlignLeft, date ).height(); | 2237 | int hei = p.boundingRect(0,0, 5, 5, Qt::AlignLeft, date ).height(); |
2238 | // p.drawText( 0, 0, date ); | 2238 | // p.drawText( 0, 0, date ); |
2239 | int offset = m.width()/8; | 2239 | int offset = m.width()/8; |
2240 | // compute the scale | 2240 | // compute the scale |
2241 | dx = ((float) m.width()-offset) / (float)w; | 2241 | dx = ((float) m.width()-offset) / (float)w; |
2242 | dy = (float)(m.height() - ( 2 * hei )-offset ) / (float)h; | 2242 | dy = (float)(m.height() - ( 2 * hei )-offset ) / (float)h; |
2243 | float scale; | 2243 | float scale; |
2244 | // scale to fit the width or height of the paper | 2244 | // scale to fit the width or height of the paper |
2245 | if ( dx < dy ) | 2245 | if ( dx < dy ) |
2246 | scale = dx; | 2246 | scale = dx; |
2247 | else | 2247 | else |
2248 | scale = dy; | 2248 | scale = dy; |
2249 | // set the scale | 2249 | // set the scale |
2250 | p.drawText( (int) (offset* scale), (int) (offset* scale*3/4), date ); | 2250 | p.drawText( (int) (offset* scale), (int) (offset* scale*3/4), date ); |
2251 | 2251 | ||
2252 | uint selDay; | 2252 | uint selDay; |
2253 | float widOffset = ((float) m.width()-offset) / ((float)(mSelectedDates.count())); | 2253 | float widOffset = ((float) m.width()-offset) / ((float)(mSelectedDates.count())); |
2254 | float startX = 1; | 2254 | float startX = 1; |
2255 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) | 2255 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) |
2256 | { | 2256 | { |
2257 | QString text = KGlobal::locale()->formatDate( mSelectedDates[selDay],true ); | 2257 | QString text = KGlobal::locale()->formatDate( mSelectedDates[selDay],true ); |
2258 | p.setClipRect((int) (offset* scale+startX) , 0, (int) (widOffset-4), (int) (offset* scale+(2*hei* scale)) ); | 2258 | p.setClipRect((int) (offset* scale+startX) , 0, (int) (widOffset-4), (int) (offset* scale+(2*hei* scale)) ); |
2259 | p.drawText( (int) (offset* scale+startX), (int) ((offset+hei)* scale), text ); | 2259 | p.drawText( (int) (offset* scale+startX), (int) ((offset+hei)* scale), text ); |
2260 | startX += widOffset; | 2260 | startX += widOffset; |
2261 | 2261 | ||
2262 | } | 2262 | } |
2263 | p.translate( (int) (offset* scale),(int) (offset* scale+ (-y * scale)+(2*hei* scale))); | 2263 | p.translate( (int) (offset* scale),(int) (offset* scale+ (-y * scale)+(2*hei* scale))); |
2264 | p.scale( scale, scale ); | 2264 | p.scale( scale, scale ); |
2265 | p.setClipRect( (int) (offset* scale), (int) (offset* scale+(2*hei* scale)), (int) (w*scale), (int) (h*scale) ); | 2265 | p.setClipRect( (int) (offset* scale), (int) (offset* scale+(2*hei* scale)), (int) (w*scale), (int) (h*scale) ); |
2266 | // now printing with y offset: 2 hei | 2266 | // now printing with y offset: 2 hei |
2267 | // p.translate( 0, -y*scale); | 2267 | // p.translate( 0, -y*scale); |
2268 | 2268 | ||
2269 | drawContentsToPainter(&p, true ); | 2269 | drawContentsToPainter(&p, true ); |
2270 | globalFlagBlockAgendaItemUpdate = false; | 2270 | globalFlagBlockAgendaItemUpdate = false; |
2271 | KOAgendaItem *item; | 2271 | KOAgendaItem *item; |
2272 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 2272 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
2273 | item->select(false); | 2273 | item->select(false); |
2274 | item->paintMe( false, &p ); | 2274 | item->paintMe( false, &p ); |
2275 | } | 2275 | } |
2276 | globalFlagBlockAgendaItemUpdate = true; | 2276 | globalFlagBlockAgendaItemUpdate = true; |
2277 | p.end(); | 2277 | p.end(); |
2278 | delete printer; | 2278 | delete printer; |
2279 | #else | 2279 | #else |
2280 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 2280 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
2281 | i18n("Not supported \non PDA!\n"), | 2281 | i18n("Not supported \non PDA!\n"), |
2282 | i18n("OK"), 0, 0, | 2282 | i18n("OK"), 0, 0, |
2283 | 0, 1 ); | 2283 | 0, 1 ); |
2284 | #endif | 2284 | #endif |
2285 | } | 2285 | } |
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp index 7a685d8..81681df 100644 --- a/korganizer/koagendaitem.cpp +++ b/korganizer/koagendaitem.cpp | |||
@@ -1,868 +1,870 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <qlabel.h> | 20 | #include <qlabel.h> |
21 | #include <qlayout.h> | 21 | #include <qlayout.h> |
22 | #include <qhbox.h> | 22 | #include <qhbox.h> |
23 | #include <qvbox.h> | 23 | #include <qvbox.h> |
24 | #include <qtooltip.h> | 24 | #include <qtooltip.h> |
25 | #include <qwhatsthis.h> | 25 | #include <qwhatsthis.h> |
26 | #include <qdragobject.h> | 26 | #include <qdragobject.h> |
27 | #include <qdrawutil.h> | 27 | #include <qdrawutil.h> |
28 | #include <qpainter.h> | 28 | #include <qpainter.h> |
29 | 29 | ||
30 | #include <kiconloader.h> | 30 | #include <kiconloader.h> |
31 | #include <kdebug.h> | 31 | #include <kdebug.h> |
32 | #include <kglobal.h> | 32 | #include <kglobal.h> |
33 | #include <klocale.h> | 33 | #include <klocale.h> |
34 | #ifndef DESKTOP_VERSION | 34 | #ifndef DESKTOP_VERSION |
35 | #include <qpe/qpeapplication.h> | 35 | #include <qpe/qpeapplication.h> |
36 | #define AGENDA_ICON_SIZE 5 | 36 | #define AGENDA_ICON_SIZE 5 |
37 | #else | 37 | #else |
38 | #include <qapplication.h> | 38 | #include <qapplication.h> |
39 | #define AGENDA_ICON_SIZE 7 | 39 | #define AGENDA_ICON_SIZE 7 |
40 | #endif | 40 | #endif |
41 | #include <libkcal/icaldrag.h> | 41 | #include <libkcal/icaldrag.h> |
42 | #include <libkcal/vcaldrag.h> | 42 | #include <libkcal/vcaldrag.h> |
43 | #include <libkcal/kincidenceformatter.h> | 43 | #include <libkcal/kincidenceformatter.h> |
44 | extern int globalFlagBlockAgenda; | 44 | extern int globalFlagBlockAgenda; |
45 | extern int globalFlagBlockAgendaItemPaint; | 45 | extern int globalFlagBlockAgendaItemPaint; |
46 | extern int globalFlagBlockAgendaItemUpdate; | 46 | extern int globalFlagBlockAgendaItemUpdate; |
47 | 47 | ||
48 | #include "koprefs.h" | 48 | #include "koprefs.h" |
49 | 49 | ||
50 | #include "koagendaitem.h" | 50 | #include "koagendaitem.h" |
51 | //#include "koagendaitem.moc" | 51 | //#include "koagendaitem.moc" |
52 | 52 | ||
53 | 53 | ||
54 | //-------------------------------------------------------------------------- | 54 | //-------------------------------------------------------------------------- |
55 | 55 | ||
56 | QToolTipGroup *KOAgendaItem::mToolTipGroup = 0; | 56 | QToolTipGroup *KOAgendaItem::mToolTipGroup = 0; |
57 | 57 | ||
58 | //-------------------------------------------------------------------------- | 58 | //-------------------------------------------------------------------------- |
59 | 59 | ||
60 | class KOAgendaItemWhatsThis :public QWhatsThis | 60 | class KOAgendaItemWhatsThis :public QWhatsThis |
61 | { | 61 | { |
62 | public: | 62 | public: |
63 | KOAgendaItemWhatsThis( KOAgendaItem* view ) : QWhatsThis( view ),_view (view) { }; | 63 | KOAgendaItemWhatsThis( KOAgendaItem* view ) : QWhatsThis( view ),_view (view) { }; |
64 | 64 | ||
65 | protected: | 65 | protected: |
66 | virtual QString text( const QPoint& ) | 66 | virtual QString text( const QPoint& ) |
67 | { | 67 | { |
68 | return _view->getWhatsThisText() ; | 68 | return _view->getWhatsThisText() ; |
69 | } | 69 | } |
70 | private: | 70 | private: |
71 | KOAgendaItem * _view; | 71 | KOAgendaItem * _view; |
72 | }; | 72 | }; |
73 | 73 | ||
74 | KOAgendaItem::KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent,bool allday, | 74 | KOAgendaItem::KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent,bool allday, |
75 | const char *name,WFlags) : | 75 | const char *name,WFlags) : |
76 | QWidget(parent, name), mIncidence(incidence), mDate(qd) | 76 | QWidget(parent, name), mIncidence(incidence), mDate(qd) |
77 | { | 77 | { |
78 | #ifndef DESKTOP_VERSION | 78 | #ifndef DESKTOP_VERSION |
79 | //QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); | 79 | //QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); |
80 | #endif | 80 | #endif |
81 | mKOAgendaItemWhatsThis = new KOAgendaItemWhatsThis(this); | 81 | mKOAgendaItemWhatsThis = new KOAgendaItemWhatsThis(this); |
82 | int wflags = getWFlags() |WRepaintNoErase;// WResizeNoErase | 82 | int wflags = getWFlags() |WRepaintNoErase;// WResizeNoErase |
83 | setWFlags ( wflags); | 83 | setWFlags ( wflags); |
84 | mAllDay = allday; | 84 | mAllDay = allday; |
85 | init ( incidence, qd ); | 85 | init ( incidence, qd ); |
86 | //setMouseTracking(true); | 86 | //setMouseTracking(true); |
87 | //setAcceptDrops(true); | 87 | //setAcceptDrops(true); |
88 | xPaintCoord = -1; | 88 | xPaintCoord = -1; |
89 | yPaintCoord = -1; | 89 | yPaintCoord = -1; |
90 | } | 90 | } |
91 | QString KOAgendaItem::getWhatsThisText() | 91 | QString KOAgendaItem::getWhatsThisText() |
92 | { | 92 | { |
93 | if ( mIncidence ) | 93 | if ( mIncidence ) |
94 | return KIncidenceFormatter::instance()->getFormattedText( mIncidence, | 94 | return KIncidenceFormatter::instance()->getFormattedText( mIncidence, |
95 | KOPrefs::instance()->mWTshowDetails, | 95 | KOPrefs::instance()->mWTshowDetails, |
96 | KOPrefs::instance()->mWTshowCreated, | 96 | KOPrefs::instance()->mWTshowCreated, |
97 | KOPrefs::instance()->mWTshowChanged); | 97 | KOPrefs::instance()->mWTshowChanged); |
98 | return "KOAgendaItem::getWhatsThisText()::internal error"; | 98 | return "KOAgendaItem::getWhatsThisText()::internal error"; |
99 | } | 99 | } |
100 | 100 | ||
101 | void KOAgendaItem::initColor () | 101 | void KOAgendaItem::initColor () |
102 | { | 102 | { |
103 | if ( (mIncidence->typeID() == todoID ) && | 103 | if ( (mIncidence->typeID() == todoID ) && |
104 | ( !((static_cast<Todo*>(mIncidence))->isCompleted()) && | 104 | ( !((static_cast<Todo*>(mIncidence))->isCompleted()) && |
105 | ((static_cast<Todo*>(mIncidence))->dtDue().date() <= QDate::currentDate()) ) ) { | 105 | ((static_cast<Todo*>(mIncidence))->dtDue().date() <= QDate::currentDate()) ) ) { |
106 | if ( (static_cast<Todo*>(mIncidence))->dtDue() < QDateTime::currentDateTime().date()) | 106 | if ( (static_cast<Todo*>(mIncidence))->dtDue() < QDateTime::currentDateTime().date()) |
107 | mBackgroundColor = KOPrefs::instance()->mTodoOverdueColor ; | 107 | mBackgroundColor = KOPrefs::instance()->mTodoOverdueColor ; |
108 | else | 108 | else |
109 | mBackgroundColor = KOPrefs::instance()->mTodoDueTodayColor; | 109 | mBackgroundColor = KOPrefs::instance()->mTodoDueTodayColor; |
110 | } | 110 | } |
111 | else { | 111 | else { |
112 | QStringList categories = mIncidence->categories(); | 112 | QStringList categories = mIncidence->categories(); |
113 | QString cat = categories.first(); | 113 | QString cat = categories.first(); |
114 | if (cat.isEmpty()) { | 114 | if (cat.isEmpty()) { |
115 | if ( (mIncidence->typeID() == todoID ) &&((static_cast<Todo*>(mIncidence))->isCompleted()) ) | 115 | if ( (mIncidence->typeID() == todoID ) &&((static_cast<Todo*>(mIncidence))->isCompleted()) ) |
116 | mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; | 116 | mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; |
117 | else | 117 | else |
118 | mBackgroundColor =KOPrefs::instance()->defaultColor( mIncidence->calID() ); | 118 | mBackgroundColor =KOPrefs::instance()->defaultColor( mIncidence->calID() ); |
119 | } else { | 119 | } else { |
120 | mBackgroundColor = *KOPrefs::instance()->categoryColor(cat); | 120 | mBackgroundColor = *KOPrefs::instance()->categoryColor(cat); |
121 | if ( (mIncidence->typeID() == todoID ) &&((static_cast<Todo*>(mIncidence))->isCompleted()) ) { | 121 | if ( (mIncidence->typeID() == todoID ) &&((static_cast<Todo*>(mIncidence))->isCompleted()) ) { |
122 | if ( mBackgroundColor == KOPrefs::instance()->mEventColor ) | 122 | if ( mBackgroundColor == KOPrefs::instance()->mEventColor ) |
123 | mBackgroundColor = KOPrefs::instance()->mTodoDoneColor; | 123 | mBackgroundColor = KOPrefs::instance()->mTodoDoneColor; |
124 | } | 124 | } |
125 | } | 125 | } |
126 | 126 | ||
127 | } | 127 | } |
128 | 128 | ||
129 | QColor BackgroundColor ( mBackgroundColor ); | 129 | QColor BackgroundColor ( mBackgroundColor ); |
130 | if ( mIncidence->calID() > 1 ) { | 130 | if ( mIncidence->calID() > 1 ) { |
131 | //BackgroundColor = KOPrefs::instance()->defaultColor( mIncidence->calID() ); | 131 | //BackgroundColor = KOPrefs::instance()->defaultColor( mIncidence->calID() ); |
132 | } | 132 | } |
133 | mColorGroup = QColorGroup( BackgroundColor.light(), | 133 | mColorGroup = QColorGroup( BackgroundColor.light(), |
134 | BackgroundColor.dark(),BackgroundColor.light(), | 134 | BackgroundColor.dark(),BackgroundColor.light(), |
135 | BackgroundColor.dark(),BackgroundColor, black, BackgroundColor) ; | 135 | BackgroundColor.dark(),BackgroundColor, black, BackgroundColor) ; |
136 | setBackgroundColor( mBackgroundColor ); | 136 | setBackgroundColor( mBackgroundColor ); |
137 | mWhiteText = (mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue() < 250); | 137 | mWhiteText = (mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue() < 250); |
138 | } | 138 | } |
139 | void KOAgendaItem::init ( Incidence *incidence, QDate qd ) | 139 | void KOAgendaItem::init ( Incidence *incidence, QDate qd ) |
140 | { | 140 | { |
141 | mIncidence = incidence; | 141 | mIncidence = incidence; |
142 | mDate = qd; | 142 | mDate = qd; |
143 | mFirstMultiItem = 0; | 143 | mFirstMultiItem = 0; |
144 | mNextMultiItem = 0; | 144 | mNextMultiItem = 0; |
145 | mLastMultiItem = 0; | 145 | mLastMultiItem = 0; |
146 | computeText(); | 146 | computeText(); |
147 | initColor(); | 147 | initColor(); |
148 | mConflictItems.clear(); | 148 | mConflictItems.clear(); |
149 | setCellXY(0,0,1); | 149 | setCellXY(0,0,1); |
150 | setCellXWidth(0); | 150 | setCellXWidth(0); |
151 | setSubCell(0); | 151 | setSubCell(0); |
152 | setSubCells(1); | 152 | setSubCells(1); |
153 | setMultiItem(0,0,0); | 153 | setMultiItem(0,0,0); |
154 | startMove(); | 154 | startMove(); |
155 | mSelected = true; | 155 | mSelected = true; |
156 | select(false); | 156 | select(false); |
157 | QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont); | 157 | QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont); |
158 | mFontPixelSize = fontinf.height();; | 158 | mFontPixelSize = fontinf.height();; |
159 | hide(); | 159 | hide(); |
160 | xPaintCoord = -1; | 160 | xPaintCoord = -1; |
161 | yPaintCoord = -1; | 161 | yPaintCoord = -1; |
162 | } | 162 | } |
163 | 163 | ||
164 | 164 | ||
165 | KOAgendaItem::~KOAgendaItem() | 165 | KOAgendaItem::~KOAgendaItem() |
166 | { | 166 | { |
167 | #if QT_VERSION >= 0x030000 | 167 | #if QT_VERSION >= 0x030000 |
168 | 168 | ||
169 | #else | 169 | #else |
170 | delete mKOAgendaItemWhatsThis; | 170 | delete mKOAgendaItemWhatsThis; |
171 | #endif | 171 | #endif |
172 | 172 | ||
173 | } | 173 | } |
174 | 174 | ||
175 | void KOAgendaItem::recreateIncidence() | 175 | void KOAgendaItem::recreateIncidence() |
176 | { | 176 | { |
177 | #if 0 | 177 | #if 0 |
178 | Incidence* newInc = mIncidence->clone(); | 178 | Incidence* newInc = mIncidence->clone(); |
179 | newInc->recreate(); | 179 | newInc->recreate(); |
180 | if ( mIncidence->doesRecur() ) { | 180 | if ( mIncidence->doesRecur() ) { |
181 | mIncidence->addExDate( mDate ); | 181 | mIncidence->addExDate( mDate ); |
182 | newInc->recurrence()->unsetRecurs(); | 182 | newInc->recurrence()->unsetRecurs(); |
183 | int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd()); | 183 | int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd()); |
184 | QTime tim = mIncidence->dtStart().time(); | 184 | QTime tim = mIncidence->dtStart().time(); |
185 | newInc->setDtStart( QDateTime(mDate, tim) ); | 185 | newInc->setDtStart( QDateTime(mDate, tim) ); |
186 | ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); | 186 | ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); |
187 | } | 187 | } |
188 | #endif | 188 | #endif |
189 | mIncidence = mIncidence->recreateCloneException( mDate ); | 189 | mIncidence = mIncidence->recreateCloneException( mDate ); |
190 | } | 190 | } |
191 | bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout) | 191 | bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout) |
192 | { | 192 | { |
193 | int size = AGENDA_ICON_SIZE; | 193 | int size = AGENDA_ICON_SIZE; |
194 | 194 | ||
195 | int yOff = 0; | 195 | int yOff = 0; |
196 | int xOff = 0; | 196 | int xOff = 0; |
197 | int x = pos().x(); | 197 | int x = pos().x(); |
198 | 198 | ||
199 | if ( x < 0 ) x = 0; | 199 | if ( x < 0 ) x = 0; |
200 | x += 3; | 200 | x += 3; |
201 | int y; | 201 | int y; |
202 | if ( mAllDay ) | 202 | if ( mAllDay ) |
203 | y = pos().y()+3; | 203 | y = pos().y()+3; |
204 | else | 204 | else |
205 | y = mCellYTop * ( height() / cellHeight() ) +3; | 205 | y = mCellYTop * ( height() / cellHeight() ) +3; |
206 | 206 | ||
207 | 207 | ||
208 | if ( mIncidence->calID() > 1 ) { | 208 | if ( mIncidence->calID() > 1 ) { |
209 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, KOPrefs::instance()->defaultColor( mIncidence->calID() ) ); | 209 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, KOPrefs::instance()->defaultColor( mIncidence->calID() ) ); |
210 | p->drawRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x-1, yOff*( 1 +AGENDA_ICON_SIZE)+y-1, AGENDA_ICON_SIZE+2, AGENDA_ICON_SIZE+2 ); | 210 | p->drawRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x-1, yOff*( 1 +AGENDA_ICON_SIZE)+y-1, AGENDA_ICON_SIZE+2, AGENDA_ICON_SIZE+2 ); |
211 | if ( horLayout ){ | 211 | if ( horLayout ){ |
212 | ++xOff; | 212 | ++xOff; |
213 | ++x; | 213 | ++x; |
214 | } | 214 | } |
215 | else { | 215 | else { |
216 | ++yOff; | 216 | ++yOff; |
217 | ++y; | 217 | ++y; |
218 | } | 218 | } |
219 | } | 219 | } |
220 | if (mIncidence->cancelled() && height() < 20 ) { | 220 | if (mIncidence->cancelled() && height() < 20 ) { |
221 | int xpos = xOff*( 1 +AGENDA_ICON_SIZE )+x; | 221 | int xpos = xOff*( 1 +AGENDA_ICON_SIZE )+x; |
222 | int ypos = yOff*( 1 +AGENDA_ICON_SIZE)+y; | 222 | int ypos = yOff*( 1 +AGENDA_ICON_SIZE)+y; |
223 | p->drawLine( xpos, ypos, xpos+AGENDA_ICON_SIZE-1, ypos+AGENDA_ICON_SIZE-1 ); | 223 | p->drawLine( xpos, ypos, xpos+AGENDA_ICON_SIZE-1, ypos+AGENDA_ICON_SIZE-1 ); |
224 | p->drawLine( xpos, ypos+AGENDA_ICON_SIZE-1, xpos+AGENDA_ICON_SIZE-1, ypos ); | 224 | p->drawLine( xpos, ypos+AGENDA_ICON_SIZE-1, xpos+AGENDA_ICON_SIZE-1, ypos ); |
225 | if ( horLayout ) | 225 | if ( horLayout ) |
226 | ++xOff; | 226 | ++xOff; |
227 | else | 227 | else |
228 | ++yOff; | 228 | ++yOff; |
229 | } | 229 | } |
230 | if (mIncidence->isAlarmEnabled() && mIncidence->alarmEnabled()) { | 230 | if (mIncidence->isAlarmEnabled() && mIncidence->alarmEnabled()) { |
231 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, red ); | 231 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, red ); |
232 | if ( horLayout ) | 232 | if ( horLayout ) |
233 | ++xOff; | 233 | ++xOff; |
234 | else | 234 | else |
235 | ++yOff; | 235 | ++yOff; |
236 | } | 236 | } |
237 | if (mIncidence->doesRecur()) { | 237 | if (mIncidence->doesRecur()) { |
238 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, blue ); | 238 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, blue ); |
239 | if ( horLayout ) | 239 | if ( horLayout ) |
240 | ++xOff; | 240 | ++xOff; |
241 | else | 241 | else |
242 | ++yOff; | 242 | ++yOff; |
243 | } | 243 | } |
244 | if (mIncidence->description().length() > 0) { | 244 | if (mIncidence->description().length() > 0) { |
245 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkGreen ); | 245 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkGreen ); |
246 | if ( horLayout ) | 246 | if ( horLayout ) |
247 | ++xOff; | 247 | ++xOff; |
248 | else | 248 | else |
249 | ++yOff; | 249 | ++yOff; |
250 | } | 250 | } |
251 | if (mIncidence->isReadOnly()) { | 251 | if (mIncidence->isReadOnly()) { |
252 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, white ); | 252 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, white ); |
253 | if ( horLayout ) | 253 | if ( horLayout ) |
254 | ++xOff; | 254 | ++xOff; |
255 | else | 255 | else |
256 | ++yOff; | 256 | ++yOff; |
257 | } | 257 | } |
258 | 258 | ||
259 | if (mIncidence->attendeeCount()>0) { | 259 | if (mIncidence->attendeeCount()>0) { |
260 | 260 | ||
261 | if (mIncidence->organizer() == KOPrefs::instance()->email()) { | 261 | if (mIncidence->organizer() == KOPrefs::instance()->email()) { |
262 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, black ); | 262 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, black ); |
263 | if ( horLayout ) | 263 | if ( horLayout ) |
264 | ++xOff; | 264 | ++xOff; |
265 | else | 265 | else |
266 | ++yOff; | 266 | ++yOff; |
267 | } else { | 267 | } else { |
268 | Attendee *me = mIncidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 268 | Attendee *me = mIncidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
269 | if (me!=0) { | 269 | if (me!=0) { |
270 | 270 | ||
271 | 271 | ||
272 | } else { | 272 | } else { |
273 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, yellow ); | 273 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, yellow ); |
274 | if ( horLayout ) | 274 | if ( horLayout ) |
275 | ++xOff; | 275 | ++xOff; |
276 | else | 276 | else |
277 | ++yOff; | 277 | ++yOff; |
278 | 278 | ||
279 | } | 279 | } |
280 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkYellow ); | 280 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkYellow ); |
281 | if ( horLayout ) | 281 | if ( horLayout ) |
282 | ++xOff; | 282 | ++xOff; |
283 | else | 283 | else |
284 | ++yOff; | 284 | ++yOff; |
285 | 285 | ||
286 | } | 286 | } |
287 | 287 | ||
288 | } | 288 | } |
289 | return ( yOff || xOff ); | 289 | return ( yOff || xOff ); |
290 | } | 290 | } |
291 | 291 | ||
292 | 292 | ||
293 | void KOAgendaItem::select(bool selected) | 293 | void KOAgendaItem::select(bool selected) |
294 | { | 294 | { |
295 | //qDebug("select %d %d",firstMultiItem(), nextMultiItem() ); | 295 | //qDebug("select %d %d",firstMultiItem(), nextMultiItem() ); |
296 | if (mSelected == selected) return; | 296 | if (mSelected == selected) return; |
297 | mSelected = selected; | 297 | mSelected = selected; |
298 | if ( ! isVisible() ) | 298 | if ( ! isVisible() ) |
299 | return; | 299 | return; |
300 | if ( firstMultiItem() ) | 300 | if ( firstMultiItem() ) |
301 | firstMultiItem()->select( selected ); | 301 | firstMultiItem()->select( selected ); |
302 | if ( !firstMultiItem() && nextMultiItem() ) { | 302 | if ( !firstMultiItem() && nextMultiItem() ) { |
303 | KOAgendaItem * placeItem = nextMultiItem(); | 303 | KOAgendaItem * placeItem = nextMultiItem(); |
304 | while ( placeItem ) { | 304 | while ( placeItem ) { |
305 | placeItem->select( selected ); | 305 | placeItem->select( selected ); |
306 | placeItem = placeItem->nextMultiItem(); | 306 | placeItem = placeItem->nextMultiItem(); |
307 | } | 307 | } |
308 | } | 308 | } |
309 | globalFlagBlockAgendaItemUpdate = 0; | 309 | globalFlagBlockAgendaItemUpdate = 0; |
310 | paintMe( selected ); | 310 | paintMe( selected ); |
311 | globalFlagBlockAgendaItemUpdate = 1; | 311 | globalFlagBlockAgendaItemUpdate = 1; |
312 | repaint( false ); | 312 | repaint( false ); |
313 | } | 313 | } |
314 | 314 | ||
315 | 315 | ||
316 | /* | 316 | /* |
317 | The eventFilter has to filter the mouse events of the agenda item childs. The | 317 | The eventFilter has to filter the mouse events of the agenda item childs. The |
318 | events are fed into the event handling method of KOAgendaItem. This allows the | 318 | events are fed into the event handling method of KOAgendaItem. This allows the |
319 | KOAgenda to handle the KOAgendaItems by using an eventFilter. | 319 | KOAgenda to handle the KOAgendaItems by using an eventFilter. |
320 | */ | 320 | */ |
321 | bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e ) | 321 | bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e ) |
322 | { | 322 | { |
323 | if (e->type() == QEvent::MouseButtonPress || | 323 | if (e->type() == QEvent::MouseButtonPress || |
324 | e->type() == QEvent::MouseButtonDblClick || | 324 | e->type() == QEvent::MouseButtonDblClick || |
325 | e->type() == QEvent::MouseButtonRelease || | 325 | e->type() == QEvent::MouseButtonRelease || |
326 | e->type() == QEvent::MouseMove) { | 326 | e->type() == QEvent::MouseMove) { |
327 | QMouseEvent *me = (QMouseEvent *)e; | 327 | QMouseEvent *me = (QMouseEvent *)e; |
328 | QPoint itemPos = this->mapFromGlobal(((QWidget *)object)-> | 328 | QPoint itemPos = this->mapFromGlobal(((QWidget *)object)-> |
329 | mapToGlobal(me->pos())); | 329 | mapToGlobal(me->pos())); |
330 | QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state()); | 330 | QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state()); |
331 | return event(&returnEvent); | 331 | return event(&returnEvent); |
332 | } else { | 332 | } else { |
333 | return false; | 333 | return false; |
334 | } | 334 | } |
335 | } | 335 | } |
336 | void KOAgendaItem::repaintMe( ) | 336 | void KOAgendaItem::repaintMe( ) |
337 | { | 337 | { |
338 | paintMe ( mSelected ); | 338 | paintMe ( mSelected ); |
339 | } | 339 | } |
340 | void KOAgendaItem::paintMe( bool selected, QPainter* paint ) | 340 | void KOAgendaItem::paintMe( bool selected, QPainter* paint ) |
341 | { | 341 | { |
342 | if ( globalFlagBlockAgendaItemUpdate && ! selected) | 342 | if ( globalFlagBlockAgendaItemUpdate && ! selected) |
343 | return; | 343 | return; |
344 | QPainter pa; | 344 | QPainter pa; |
345 | 345 | ||
346 | if ( mSelected ) { | 346 | if ( mSelected ) { |
347 | pa.begin( this ); | 347 | pa.begin( this ); |
348 | } else { | 348 | } else { |
349 | if ( mAllDay ) | 349 | if ( mAllDay ) |
350 | pa.begin( paintPixAllday() ); | 350 | pa.begin( paintPixAllday() ); |
351 | else | 351 | else |
352 | pa.begin( paintPix() ); | 352 | pa.begin( paintPix() ); |
353 | } | 353 | } |
354 | int x, yy, w, h; | 354 | int x, yy, w, h; |
355 | float nfh = 7.0; | 355 | float nfh = 7.0; |
356 | x = pos().x(); w = width(); h = height (); | 356 | x = pos().x(); w = width(); h = height (); |
357 | if ( mAllDay ) | 357 | if ( mAllDay ) |
358 | yy = y(); | 358 | yy = y(); |
359 | else | 359 | else |
360 | yy = mCellYTop * ( height() / cellHeight() ); | 360 | yy = mCellYTop * ( height() / cellHeight() ); |
361 | if ( mSelected ) { | 361 | if ( mSelected ) { |
362 | pa.translate( -x, -yy ); | 362 | pa.translate( -x, -yy ); |
363 | } | 363 | } |
364 | xPaintCoord= x; | 364 | xPaintCoord= x; |
365 | yPaintCoord = yy; | 365 | yPaintCoord = yy; |
366 | wPaintCoord = width(); | 366 | wPaintCoord = width(); |
367 | hPaintCoord = height(); | 367 | hPaintCoord = height(); |
368 | //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height()); | 368 | //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height()); |
369 | if ( paint == 0 ) | 369 | if ( paint == 0 ) |
370 | paint = &pa; | 370 | paint = &pa; |
371 | bool horLayout = ( w < h ); | 371 | bool horLayout = ( w < h ); |
372 | int maxhei = mFontPixelSize+4; | 372 | int maxhei = mFontPixelSize+4; |
373 | if ( horLayout ) | 373 | if ( horLayout ) |
374 | maxhei += AGENDA_ICON_SIZE -4; | 374 | maxhei += AGENDA_ICON_SIZE -4; |
375 | bool small = ( h < maxhei ); | 375 | bool small = ( h < maxhei ); |
376 | if ( ! small ) | 376 | if ( ! small ) |
377 | paint->setFont(KOPrefs::instance()->mAgendaViewFont); | 377 | paint->setFont(KOPrefs::instance()->mAgendaViewFont); |
378 | else { | 378 | else { |
379 | QFont f = KOPrefs::instance()->mAgendaViewFont; | 379 | QFont f = KOPrefs::instance()->mAgendaViewFont; |
380 | f.setBold( false ); | 380 | f.setBold( false ); |
381 | int fh = f.pointSize(); | 381 | int fh = f.pointSize(); |
382 | nfh = (((float)height())/(float)(mFontPixelSize+4))*fh; | 382 | nfh = (((float)height())/(float)(mFontPixelSize+4))*fh; |
383 | if ( nfh < 6 ) | 383 | if ( nfh < 6 ) |
384 | nfh = 6; | 384 | nfh = 6; |
385 | f.setPointSize( nfh ); | 385 | f.setPointSize( nfh ); |
386 | paint->setFont(f); | 386 | paint->setFont(f); |
387 | } | 387 | } |
388 | paint->fillRect ( x, yy, w, h, mBackgroundColor ); | 388 | paint->fillRect ( x, yy, w, h, mBackgroundColor ); |
389 | static const QPixmap completedPxmp = SmallIcon("greenhook16"); | 389 | static const QPixmap completedPxmp = SmallIcon("greenhook16"); |
390 | static const QPixmap overduePxmp = SmallIcon("redcross16"); | 390 | static const QPixmap overduePxmp = SmallIcon("redcross16"); |
391 | if ( mIncidence->typeID() == todoID ) { | 391 | if ( mIncidence->typeID() == todoID ) { |
392 | Todo* tempTodo = static_cast<Todo*>(mIncidence); | 392 | Todo* tempTodo = static_cast<Todo*>(mIncidence); |
393 | int xx = pos().x()+(width()-completedPxmp.width()-3 ); | 393 | int xx = pos().x()+(width()-completedPxmp.width()-3 ); |
394 | int yyy = yy+3; | 394 | int yyy = yy+3; |
395 | if ( tempTodo->isCompleted() ) | 395 | if ( tempTodo->isCompleted() ) |
396 | paint->drawPixmap ( xx, yyy, completedPxmp ); | 396 | paint->drawPixmap ( xx, yyy, completedPxmp ); |
397 | else { | 397 | else { |
398 | paint->drawPixmap ( xx, yyy, overduePxmp ); | 398 | paint->drawPixmap ( xx, yyy, overduePxmp ); |
399 | 399 | ||
400 | } | 400 | } |
401 | } | 401 | } |
402 | bool addIcon = false; | 402 | bool addIcon = false; |
403 | if ( ! small || w > 3 * h || h > 3* w ) | 403 | if ( ! small || w > 3 * h || h > 3* w ) |
404 | addIcon = updateIcons( paint, horLayout ); | 404 | addIcon = updateIcons( paint, horLayout ); |
405 | 405 | ||
406 | //qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0); | 406 | //qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0); |
407 | qDrawWinPanel (paint, x, yy, w, h, mColorGroup, selected ,0); | 407 | qDrawWinPanel (paint, x, yy, w, h, mColorGroup, selected ,0); |
408 | //qDebug("draw rect %d %d %d %d ",x, yy, w, h ); | 408 | //qDebug("draw rect %d %d %d %d ",x, yy, w, h ); |
409 | if ( ! small ) { | 409 | if ( ! small ) { |
410 | x += 3; yy += 3;w -= 6; h-= 5; | 410 | x += 3; yy += 3;w -= 6; h-= 5; |
411 | } else { | 411 | } else { |
412 | x += 2; yy += 1;w -= 4; h-= 4; | 412 | x += 2; yy += 1;w -= 4; h-= 4; |
413 | if ( nfh < 6.01 ) { | 413 | if ( nfh < 6.01 ) { |
414 | yy -= 2; | 414 | yy -= 2; |
415 | h += 4; | 415 | h += 4; |
416 | } | 416 | } |
417 | else | 417 | else |
418 | if ( nfh < h -2 ) | 418 | if ( nfh < h -2 ) |
419 | ++yy; | 419 | ++yy; |
420 | } | 420 | } |
421 | int align; | 421 | int align; |
422 | #ifndef DESKTOP_VERSION | 422 | #ifndef DESKTOP_VERSION |
423 | align = ( AlignLeft|WordBreak|AlignTop); | 423 | align = ( AlignLeft|WordBreak|AlignTop); |
424 | #else | 424 | #else |
425 | align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop); | 425 | align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop); |
426 | #endif | 426 | #endif |
427 | if ( addIcon ) { | 427 | if ( addIcon ) { |
428 | if ( ! horLayout ) { | 428 | if ( ! horLayout ) { |
429 | x += AGENDA_ICON_SIZE+3; | 429 | x += AGENDA_ICON_SIZE+3; |
430 | w -= (AGENDA_ICON_SIZE+3); | 430 | w -= (AGENDA_ICON_SIZE+3); |
431 | } | 431 | } |
432 | else { | 432 | else { |
433 | yy+= AGENDA_ICON_SIZE+2; | 433 | yy+= AGENDA_ICON_SIZE+2; |
434 | h -=(AGENDA_ICON_SIZE+3); | 434 | h -=(AGENDA_ICON_SIZE+3); |
435 | } | 435 | } |
436 | } | 436 | } |
437 | if ( mWhiteText ) | 437 | if ( mWhiteText ) |
438 | paint->setPen ( white); | 438 | paint->setPen ( white); |
439 | if ( x < 0 ) { | 439 | if ( x < 0 ) { |
440 | w = w+x-3; | 440 | w = w+x-3; |
441 | x = 3; | 441 | x = 3; |
442 | if ( !horLayout && addIcon ) | 442 | if ( !horLayout && addIcon ) |
443 | x += AGENDA_ICON_SIZE+3; | 443 | x += AGENDA_ICON_SIZE+3; |
444 | if ( w > parentWidget()->width() ){ | 444 | if ( w > parentWidget()->width() ){ |
445 | w = parentWidget()->width() - 6; | 445 | w = parentWidget()->width() - 6; |
446 | #ifndef DESKTOP_VERSION | 446 | #ifndef DESKTOP_VERSION |
447 | align = ( AlignHCenter|WordBreak|AlignTop); | 447 | align = ( AlignHCenter|WordBreak|AlignTop); |
448 | #else | 448 | #else |
449 | align = ( AlignHCenter|BreakAnywhere|WordBreak|AlignTop); | 449 | align = ( AlignHCenter|BreakAnywhere|WordBreak|AlignTop); |
450 | #endif | 450 | #endif |
451 | 451 | ||
452 | } | 452 | } |
453 | } | 453 | } |
454 | QRect dr; | 454 | QRect dr; |
455 | if ( w + x > parentWidget()->width() ) | 455 | if ( w + x > parentWidget()->width() ) |
456 | w = parentWidget()->width()-x; | 456 | w = parentWidget()->width()-x; |
457 | paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr ); | 457 | paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr ); |
458 | //qDebug("%d %d %d %d ", x, yy, w, h ); | 458 | //qDebug("%d %d %d %d ", x, yy, w, h ); |
459 | if ( mIncidence->cancelled() ){ | 459 | if ( mIncidence->cancelled() ){ |
460 | 460 | ||
461 | 461 | ||
462 | small = ( height() < 20 ); | 462 | small = ( height() < 20 ); |
463 | 463 | ||
464 | if ( ! small ) { | 464 | if ( ! small ) { |
465 | QFontMetrics fm ( paint->font() ); | 465 | QFontMetrics fm ( paint->font() ); |
466 | paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2); | 466 | paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2); |
467 | } | 467 | } |
468 | 468 | ||
469 | } | 469 | } |
470 | pa.end(); | 470 | pa.end(); |
471 | 471 | ||
472 | } | 472 | } |
473 | 473 | ||
474 | QPixmap * KOAgendaItem::paintPix() | 474 | QPixmap * KOAgendaItem::paintPix() |
475 | { | 475 | { |
476 | static QPixmap* mPaintPix = 0; | 476 | static QPixmap* mPaintPix = 0; |
477 | if ( ! mPaintPix ) { | 477 | if ( ! mPaintPix ) { |
478 | int w = QApplication::desktop()->width(); | 478 | int w = QApplication::desktop()->width(); |
479 | int h = QApplication::desktop()->height(); | 479 | int h = QApplication::desktop()->height(); |
480 | mPaintPix = new QPixmap(w,h); | 480 | mPaintPix = new QPixmap(w,h); |
481 | } | 481 | } |
482 | return mPaintPix ; | 482 | return mPaintPix ; |
483 | } | 483 | } |
484 | QPixmap * KOAgendaItem::paintPixAllday() | 484 | QPixmap * KOAgendaItem::paintPixAllday() |
485 | { | 485 | { |
486 | static QPixmap* mPaintPixA = 0; | 486 | static QPixmap* mPaintPixA = 0; |
487 | if ( ! mPaintPixA ) { | 487 | if ( ! mPaintPixA ) { |
488 | int w = QApplication::desktop()->width(); | 488 | int w = QApplication::desktop()->width(); |
489 | int h = QApplication::desktop()->height()/5; | 489 | int h = QApplication::desktop()->height()/5; |
490 | mPaintPixA = new QPixmap(w,h); | 490 | mPaintPixA = new QPixmap(w,h); |
491 | } | 491 | } |
492 | return mPaintPixA ; | 492 | return mPaintPixA ; |
493 | } | 493 | } |
494 | 494 | ||
495 | void KOAgendaItem::repaintItem() | 495 | void KOAgendaItem::repaintItem() |
496 | { | 496 | { |
497 | globalFlagBlockAgendaItemPaint = 0; | 497 | globalFlagBlockAgendaItemPaint = 0; |
498 | globalFlagBlockAgenda = 0; | 498 | globalFlagBlockAgenda = 0; |
499 | repaint( false ); | 499 | repaint( false ); |
500 | } | 500 | } |
501 | void KOAgendaItem::paintEvent ( QPaintEvent *e ) | 501 | void KOAgendaItem::paintEvent ( QPaintEvent *e ) |
502 | { | 502 | { |
503 | 503 | ||
504 | if ( globalFlagBlockAgendaItemPaint ) | 504 | if ( globalFlagBlockAgendaItemPaint ) |
505 | return; | 505 | return; |
506 | if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 ) | 506 | if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 ) |
507 | return; | 507 | return; |
508 | int yy; | 508 | int yy; |
509 | if ( mAllDay ) | 509 | if ( mAllDay ) |
510 | yy = y(); | 510 | yy = y(); |
511 | else | 511 | else |
512 | yy = mCellYTop * ( height() / cellHeight() ); | 512 | yy = mCellYTop * ( height() / cellHeight() ); |
513 | int xx = x(); | 513 | int xx = x(); |
514 | 514 | ||
515 | if ( xPaintCoord != xx || yPaintCoord != yy || | 515 | if ( xPaintCoord != xx || yPaintCoord != yy || |
516 | wPaintCoord != width() || hPaintCoord != height()) { | 516 | wPaintCoord != width() || hPaintCoord != height()) { |
517 | xPaintCoord= xx; | 517 | xPaintCoord= xx; |
518 | yPaintCoord = yy; | 518 | yPaintCoord = yy; |
519 | wPaintCoord = width(); | 519 | wPaintCoord = width(); |
520 | hPaintCoord = height(); | 520 | hPaintCoord = height(); |
521 | globalFlagBlockAgendaItemUpdate = 0; | 521 | globalFlagBlockAgendaItemUpdate = 0; |
522 | paintMe( mSelected ); | 522 | paintMe( mSelected ); |
523 | //qDebug("calling paintMe "); | 523 | //qDebug("calling paintMe "); |
524 | globalFlagBlockAgendaItemUpdate = 1; | 524 | globalFlagBlockAgendaItemUpdate = 1; |
525 | if ( mSelected ) | 525 | if ( mSelected ) |
526 | return; | 526 | return; |
527 | } | 527 | } |
528 | int rx, ry, rw, rh; | 528 | int rx, ry, rw, rh; |
529 | rx = e->rect().x(); | 529 | rx = e->rect().x(); |
530 | ry = e->rect().y(); | 530 | ry = e->rect().y(); |
531 | rw = e->rect().width(); | 531 | rw = e->rect().width(); |
532 | rh = e->rect().height(); | 532 | rh = e->rect().height(); |
533 | //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height()); | 533 | //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height()); |
534 | 534 | ||
535 | QPixmap* paintFrom ; | 535 | QPixmap* paintFrom ; |
536 | if ( mSelected ) { | 536 | if ( mSelected ) { |
537 | paintMe( mSelected ); | 537 | paintMe( mSelected ); |
538 | return; | 538 | return; |
539 | } else { | 539 | } else { |
540 | if ( mAllDay ) | 540 | if ( mAllDay ) |
541 | paintFrom = paintPixAllday(); | 541 | paintFrom = paintPixAllday(); |
542 | else | 542 | else |
543 | paintFrom = paintPix(); | 543 | paintFrom = paintPix(); |
544 | } | 544 | } |
545 | xx += rx; | 545 | xx += rx; |
546 | 546 | ||
547 | if ( xx < 0 ) { | 547 | if ( xx < 0 ) { |
548 | rw = rw + xx; | 548 | rw = rw + xx; |
549 | rx -= xx; | 549 | rx -= xx; |
550 | xx = 0; | 550 | xx = 0; |
551 | if ( rw <= 1 ) { | 551 | if ( rw <= 1 ) { |
552 | //qDebug("KOAgendaItem::Width1 <= 1 (%d). Returning. %s",rw,mDisplayedText.latin1()); | 552 | //qDebug("KOAgendaItem::Width1 <= 1 (%d). Returning. %s",rw,mDisplayedText.latin1()); |
553 | return; | 553 | return; |
554 | } | 554 | } |
555 | } | 555 | } |
556 | if ( paintFrom->width() < xx+rw ) { | 556 | if ( paintFrom->width() < xx+rw ) { |
557 | rw = paintFrom->width() - xx; | 557 | rw = paintFrom->width() - xx; |
558 | if ( rw <= 1 ) { | 558 | if ( rw <= 1 ) { |
559 | //qDebug("KOAgendaItem::Width2 <= 1 (%d). Returning.%s ",rw,mDisplayedText.latin1() ); | 559 | //qDebug("KOAgendaItem::Width2 <= 1 (%d). Returning.%s ",rw,mDisplayedText.latin1() ); |
560 | return; | 560 | return; |
561 | } | 561 | } |
562 | } | 562 | } |
563 | //qDebug("%d %d %d %d %d %d %d",rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh); | 563 | //qDebug("%d %d %d %d %d %d %d",rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh); |
564 | bitBlt (this, rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh ,CopyROP); | 564 | bitBlt (this, rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh ,CopyROP); |
565 | } | 565 | } |
566 | void KOAgendaItem::computeText() | 566 | void KOAgendaItem::computeText() |
567 | { | 567 | { |
568 | mDisplayedText = mIncidence->summary(); | 568 | mDisplayedText = mIncidence->summary(); |
569 | if ( (mIncidence->typeID() == todoID ) ) { | 569 | if ( (mIncidence->typeID() == todoID ) ) { |
570 | if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) { | 570 | if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) { |
571 | if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() ) | 571 | if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() ) |
572 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")"; | 572 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")"; |
573 | else if ( !(mIncidence->doesFloat())) | 573 | else if ( !(mIncidence->doesFloat())) |
574 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")"; | 574 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")"; |
575 | } | 575 | } |
576 | } else { | 576 | } else { |
577 | if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda) | 577 | if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda) |
578 | mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + " - " + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ; | 578 | mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + " - " + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ; |
579 | 579 | ||
580 | if ( mAllDay ) { | 580 | if ( mAllDay ) { |
581 | if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) { | 581 | if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) { |
582 | if ( mIncidence->doesRecur() ) { | 582 | if ( mIncidence->doesRecur() ) { |
583 | mDisplayedText += " (" + mIncidence->recurrence()->recurrenceText() + ")"; | 583 | mDisplayedText += " (" + mIncidence->recurrence()->recurrenceText() + ")"; |
584 | } else { | 584 | } else { |
585 | mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ; | 585 | int dur = 1+ (static_cast<Event*>(mIncidence))->dtStart().date().daysTo( (static_cast<Event*>(mIncidence))->dtEnd().date() ); |
586 | mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) + " ("+QString::number( dur )+i18n(" days") +")" ; | ||
586 | } | 587 | } |
587 | } | 588 | } |
588 | } | 589 | } |
589 | } | 590 | } |
590 | 591 | ||
591 | if ( !mIncidence->location().isEmpty() ) { | 592 | if ( !mIncidence->location().isEmpty() ) { |
592 | if ( mAllDay ) | 593 | if ( mAllDay ) |
593 | mDisplayedText += " ("; | 594 | mDisplayedText += " ("; |
594 | else | 595 | else |
595 | mDisplayedText += "\n("; | 596 | mDisplayedText += "\n("; |
596 | mDisplayedText += mIncidence->location() +")"; | 597 | mDisplayedText += mIncidence->location() +")"; |
597 | } | 598 | } |
598 | #ifdef DESKTOP_VERSION | 599 | #ifdef DESKTOP_VERSION |
599 | QString tipText = mIncidence->summary(); | 600 | QString tipText = mIncidence->summary(); |
600 | if ( !mIncidence->doesFloat() ) { | 601 | if ( !mIncidence->doesFloat() ) { |
601 | if ( mIncidence->typeID() == eventID ) { | 602 | if ( mIncidence->typeID() == eventID ) { |
602 | if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) { | 603 | if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) { |
603 | tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr(); | 604 | tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr(); |
604 | tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr(); | 605 | tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr(); |
605 | } | 606 | } |
606 | else { | 607 | else { |
607 | tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr(); | 608 | tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr(); |
608 | tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr(); | 609 | tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr(); |
609 | } | 610 | } |
610 | } | 611 | } |
611 | else if ( mIncidence->typeID() == todoID ) { | 612 | else if ( mIncidence->typeID() == todoID ) { |
612 | if (mIncidence->hasStartDate()) | 613 | if (mIncidence->hasStartDate()) |
613 | tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr(); | 614 | tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr(); |
614 | if (((Todo*)mIncidence)->hasDueDate()) | 615 | if (((Todo*)mIncidence)->hasDueDate()) |
615 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr(); | 616 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr(); |
616 | } | 617 | } |
617 | } else if ( mIncidence->typeID() == todoID ) { | 618 | } else if ( mIncidence->typeID() == todoID ) { |
618 | if (mIncidence->hasStartDate()) | 619 | if (mIncidence->hasStartDate()) |
619 | tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr(); | 620 | tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr(); |
620 | if (((Todo*)mIncidence)->hasDueDate()) | 621 | if (((Todo*)mIncidence)->hasDueDate()) |
621 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr(); | 622 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr(); |
622 | } | 623 | } |
623 | 624 | ||
624 | if (!mIncidence->location().isEmpty()) { | 625 | if (!mIncidence->location().isEmpty()) { |
625 | tipText += "\n"+i18n("Location: ")+mIncidence->location(); | 626 | tipText += "\n"+i18n("Location: ")+mIncidence->location(); |
626 | } | 627 | } |
627 | QToolTip::add(this,tipText,toolTipGroup(),""); | 628 | QToolTip::add(this,tipText,toolTipGroup(),""); |
628 | #endif | 629 | #endif |
629 | } | 630 | } |
630 | void KOAgendaItem::updateItem() | 631 | void KOAgendaItem::updateItem() |
631 | { | 632 | { |
632 | computeText(); | 633 | computeText(); |
633 | 634 | ||
634 | //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y()); | 635 | //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y()); |
635 | paintMe( mSelected ); | 636 | paintMe( mSelected ); |
636 | repaint( false); | 637 | repaint( false); |
637 | } | 638 | } |
638 | 639 | ||
639 | void KOAgendaItem::resizeEvent ( QResizeEvent *ev ) | 640 | void KOAgendaItem::resizeEvent ( QResizeEvent *ev ) |
640 | { | 641 | { |
641 | //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1()); | 642 | //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1()); |
642 | paintMe( mSelected ); | 643 | paintMe( mSelected ); |
643 | repaint( false ); | 644 | repaint( false ); |
644 | } | 645 | } |
645 | 646 | ||
646 | /* | 647 | /* |
647 | Return height of item in units of agenda cells | 648 | Return height of item in units of agenda cells |
648 | */ | 649 | */ |
649 | int KOAgendaItem::cellHeight() | 650 | int KOAgendaItem::cellHeight() |
650 | { | 651 | { |
651 | int ret = mCellYBottom - mCellYTop + 1; | 652 | int ret = mCellYBottom - mCellYTop + 1; |
652 | if ( ret <= 0 ) { | 653 | if ( ret <= 0 ) { |
653 | ret = 1; | 654 | ret = 1; |
654 | mCellYBottom = 0; | 655 | mCellYBottom = 0; |
655 | mCellYTop = 0; | 656 | mCellYTop = 0; |
656 | } | 657 | } |
657 | return ret; | 658 | return ret; |
658 | } | 659 | } |
659 | // it may be that allday agenda items have a needed width > 32000 | 660 | // it may be that allday agenda items have a needed width > 32000 |
660 | // this code is to fix this problem | 661 | // this code is to fix this problem |
661 | int KOAgendaItem::resizeMe( int grid, int wid, int hei ) | 662 | int KOAgendaItem::resizeMe( int grid, int wid, int hei, bool invalidWidth ) |
662 | { | 663 | { |
663 | int diff = 0; | 664 | int diff = 0; |
664 | if ( mCellX < -3 && mAllDay ) { | 665 | if ( mCellX < -3 && mAllDay ) { |
665 | diff = (mCellX + 3) * -grid; | 666 | diff = (mCellX + 3) * -grid; |
666 | //qDebug("%s: cellX %d diff %d wid %d grid %d ", mDisplayedText.latin1(), mCellX, diff, wid, grid); | 667 | //qDebug("%s: cellX %d diff %d wid %d grid %d ", mDisplayedText.latin1(), mCellX, diff, wid, grid); |
667 | if ( diff >= wid ) { | 668 | if ( diff >= wid ) { |
668 | // qDebug("KOAgendaItem::resizeMe: diff >= wid: diff %d wid %d ", diff, wid); | 669 | // qDebug("KOAgendaItem::resizeMe: diff >= wid: diff %d wid %d ", diff, wid); |
669 | //diff = 0; | 670 | //diff = 0; |
670 | } | 671 | } |
671 | } | 672 | } |
672 | if ( wid == width() || diff >= wid ) | 673 | if ( (!invalidWidth && wid == width() ) || diff >= wid ) |
673 | resize( wid, hei ); | 674 | resize( wid, hei ); |
674 | else | 675 | else |
675 | resize( wid - diff, hei ); | 676 | resize( wid - diff, hei ); |
677 | //qDebug("wid %d x %d ", width(), x()); | ||
676 | return diff; | 678 | return diff; |
677 | } | 679 | } |
678 | /* | 680 | /* |
679 | Return height of item in units of agenda cells | 681 | Return height of item in units of agenda cells |
680 | */ | 682 | */ |
681 | int KOAgendaItem::cellWidth() | 683 | int KOAgendaItem::cellWidth() |
682 | { | 684 | { |
683 | return mCellXWidth - mCellX + 1; | 685 | return mCellXWidth - mCellX + 1; |
684 | } | 686 | } |
685 | 687 | ||
686 | void KOAgendaItem::setItemDate(QDate qd) | 688 | void KOAgendaItem::setItemDate(QDate qd) |
687 | { | 689 | { |
688 | mDate = qd; | 690 | mDate = qd; |
689 | } | 691 | } |
690 | 692 | ||
691 | void KOAgendaItem::setCellXY(int X, int YTop, int YBottom) | 693 | void KOAgendaItem::setCellXY(int X, int YTop, int YBottom) |
692 | { | 694 | { |
693 | mCellX = X; | 695 | mCellX = X; |
694 | mCellYTop = YTop; | 696 | mCellYTop = YTop; |
695 | mCellYBottom = YBottom; | 697 | mCellYBottom = YBottom; |
696 | } | 698 | } |
697 | 699 | ||
698 | void KOAgendaItem::setCellXWidth(int xwidth) | 700 | void KOAgendaItem::setCellXWidth(int xwidth) |
699 | { | 701 | { |
700 | mCellXWidth = xwidth; | 702 | mCellXWidth = xwidth; |
701 | } | 703 | } |
702 | 704 | ||
703 | void KOAgendaItem::setCellX(int XLeft, int XRight) | 705 | void KOAgendaItem::setCellX(int XLeft, int XRight) |
704 | { | 706 | { |
705 | mCellX = XLeft; | 707 | mCellX = XLeft; |
706 | mCellXWidth = XRight; | 708 | mCellXWidth = XRight; |
707 | } | 709 | } |
708 | 710 | ||
709 | void KOAgendaItem::setCellY(int YTop, int YBottom) | 711 | void KOAgendaItem::setCellY(int YTop, int YBottom) |
710 | { | 712 | { |
711 | mCellYTop = YTop; | 713 | mCellYTop = YTop; |
712 | mCellYBottom = YBottom; | 714 | mCellYBottom = YBottom; |
713 | } | 715 | } |
714 | 716 | ||
715 | void KOAgendaItem::setSubCell(int subCell) | 717 | void KOAgendaItem::setSubCell(int subCell) |
716 | { | 718 | { |
717 | mSubCell = subCell; | 719 | mSubCell = subCell; |
718 | } | 720 | } |
719 | 721 | ||
720 | void KOAgendaItem::setSubCells(int subCells) | 722 | void KOAgendaItem::setSubCells(int subCells) |
721 | { | 723 | { |
722 | mSubCells = subCells; | 724 | mSubCells = subCells; |
723 | } | 725 | } |
724 | 726 | ||
725 | void KOAgendaItem::setMultiItem(KOAgendaItem *first,KOAgendaItem *next, | 727 | void KOAgendaItem::setMultiItem(KOAgendaItem *first,KOAgendaItem *next, |
726 | KOAgendaItem *last) | 728 | KOAgendaItem *last) |
727 | { | 729 | { |
728 | mFirstMultiItem = first; | 730 | mFirstMultiItem = first; |
729 | mNextMultiItem = next; | 731 | mNextMultiItem = next; |
730 | mLastMultiItem = last; | 732 | mLastMultiItem = last; |
731 | } | 733 | } |
732 | 734 | ||
733 | void KOAgendaItem::startMove() | 735 | void KOAgendaItem::startMove() |
734 | { | 736 | { |
735 | mStartCellX = mCellX; | 737 | mStartCellX = mCellX; |
736 | mStartCellXWidth = mCellXWidth; | 738 | mStartCellXWidth = mCellXWidth; |
737 | mStartCellYTop = mCellYTop; | 739 | mStartCellYTop = mCellYTop; |
738 | mStartCellYBottom = mCellYBottom; | 740 | mStartCellYBottom = mCellYBottom; |
739 | } | 741 | } |
740 | 742 | ||
741 | void KOAgendaItem::resetMove() | 743 | void KOAgendaItem::resetMove() |
742 | { | 744 | { |
743 | mCellX = mStartCellX; | 745 | mCellX = mStartCellX; |
744 | mCellXWidth = mStartCellXWidth; | 746 | mCellXWidth = mStartCellXWidth; |
745 | mCellYTop = mStartCellYTop; | 747 | mCellYTop = mStartCellYTop; |
746 | mCellYBottom = mStartCellYBottom; | 748 | mCellYBottom = mStartCellYBottom; |
747 | } | 749 | } |
748 | 750 | ||
749 | void KOAgendaItem::moveRelative(int dx, int dy) | 751 | void KOAgendaItem::moveRelative(int dx, int dy) |
750 | { | 752 | { |
751 | int newX = cellX() + dx; | 753 | int newX = cellX() + dx; |
752 | int newXWidth = cellXWidth() + dx; | 754 | int newXWidth = cellXWidth() + dx; |
753 | int newYTop = cellYTop() + dy; | 755 | int newYTop = cellYTop() + dy; |
754 | int newYBottom = cellYBottom() + dy; | 756 | int newYBottom = cellYBottom() + dy; |
755 | setCellXY(newX,newYTop,newYBottom); | 757 | setCellXY(newX,newYTop,newYBottom); |
756 | setCellXWidth(newXWidth); | 758 | setCellXWidth(newXWidth); |
757 | } | 759 | } |
758 | 760 | ||
759 | void KOAgendaItem::expandTop(int dy) | 761 | void KOAgendaItem::expandTop(int dy) |
760 | { | 762 | { |
761 | int newYTop = cellYTop() + dy; | 763 | int newYTop = cellYTop() + dy; |
762 | int newYBottom = cellYBottom(); | 764 | int newYBottom = cellYBottom(); |
763 | if (newYTop > newYBottom) newYTop = newYBottom; | 765 | if (newYTop > newYBottom) newYTop = newYBottom; |
764 | setCellY(newYTop, newYBottom); | 766 | setCellY(newYTop, newYBottom); |
765 | } | 767 | } |
766 | 768 | ||
767 | void KOAgendaItem::expandBottom(int dy) | 769 | void KOAgendaItem::expandBottom(int dy) |
768 | { | 770 | { |
769 | int newYTop = cellYTop(); | 771 | int newYTop = cellYTop(); |
770 | int newYBottom = cellYBottom() + dy; | 772 | int newYBottom = cellYBottom() + dy; |
771 | if (newYBottom < newYTop) newYBottom = newYTop; | 773 | if (newYBottom < newYTop) newYBottom = newYTop; |
772 | setCellY(newYTop, newYBottom); | 774 | setCellY(newYTop, newYBottom); |
773 | } | 775 | } |
774 | 776 | ||
775 | void KOAgendaItem::expandLeft(int dx) | 777 | void KOAgendaItem::expandLeft(int dx) |
776 | { | 778 | { |
777 | int newX = cellX() + dx; | 779 | int newX = cellX() + dx; |
778 | int newXWidth = cellXWidth(); | 780 | int newXWidth = cellXWidth(); |
779 | if (newX > newXWidth) newX = newXWidth; | 781 | if (newX > newXWidth) newX = newXWidth; |
780 | setCellX(newX,newXWidth); | 782 | setCellX(newX,newXWidth); |
781 | } | 783 | } |
782 | 784 | ||
783 | void KOAgendaItem::expandRight(int dx) | 785 | void KOAgendaItem::expandRight(int dx) |
784 | { | 786 | { |
785 | int newX = cellX(); | 787 | int newX = cellX(); |
786 | int newXWidth = cellXWidth() + dx; | 788 | int newXWidth = cellXWidth() + dx; |
787 | if (newXWidth < newX) newXWidth = newX; | 789 | if (newXWidth < newX) newXWidth = newX; |
788 | setCellX(newX,newXWidth); | 790 | setCellX(newX,newXWidth); |
789 | } | 791 | } |
790 | 792 | ||
791 | QToolTipGroup *KOAgendaItem::toolTipGroup() | 793 | QToolTipGroup *KOAgendaItem::toolTipGroup() |
792 | { | 794 | { |
793 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); | 795 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); |
794 | return mToolTipGroup; | 796 | return mToolTipGroup; |
795 | } | 797 | } |
796 | 798 | ||
797 | void KOAgendaItem::dragEnterEvent( QDragEnterEvent *e ) | 799 | void KOAgendaItem::dragEnterEvent( QDragEnterEvent *e ) |
798 | { | 800 | { |
799 | #ifndef KORG_NODND | 801 | #ifndef KORG_NODND |
800 | if ( ICalDrag::canDecode( e ) || VCalDrag::canDecode( e ) || | 802 | if ( ICalDrag::canDecode( e ) || VCalDrag::canDecode( e ) || |
801 | !QTextDrag::canDecode( e ) ) { | 803 | !QTextDrag::canDecode( e ) ) { |
802 | e->ignore(); | 804 | e->ignore(); |
803 | return; | 805 | return; |
804 | } | 806 | } |
805 | e->accept(); | 807 | e->accept(); |
806 | #endif | 808 | #endif |
807 | } | 809 | } |
808 | 810 | ||
809 | void KOAgendaItem::dropEvent( QDropEvent *e ) | 811 | void KOAgendaItem::dropEvent( QDropEvent *e ) |
810 | { | 812 | { |
811 | #ifndef KORG_NODND | 813 | #ifndef KORG_NODND |
812 | QString text; | 814 | QString text; |
813 | if(QTextDrag::decode(e,text)) | 815 | if(QTextDrag::decode(e,text)) |
814 | { | 816 | { |
815 | kdDebug() << "Dropped : " << text << endl; | 817 | kdDebug() << "Dropped : " << text << endl; |
816 | QStringList emails = QStringList::split(",",text); | 818 | QStringList emails = QStringList::split(",",text); |
817 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { | 819 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { |
818 | kdDebug() << " Email: " << (*it) << endl; | 820 | kdDebug() << " Email: " << (*it) << endl; |
819 | int pos = (*it).find("<"); | 821 | int pos = (*it).find("<"); |
820 | QString name = (*it).left(pos); | 822 | QString name = (*it).left(pos); |
821 | QString email = (*it).mid(pos); | 823 | QString email = (*it).mid(pos); |
822 | if (!email.isEmpty()) { | 824 | if (!email.isEmpty()) { |
823 | mIncidence->addAttendee(new Attendee(name,email)); | 825 | mIncidence->addAttendee(new Attendee(name,email)); |
824 | } | 826 | } |
825 | } | 827 | } |
826 | } | 828 | } |
827 | #endif | 829 | #endif |
828 | } | 830 | } |
829 | 831 | ||
830 | 832 | ||
831 | QPtrList<KOAgendaItem> KOAgendaItem::conflictItems() | 833 | QPtrList<KOAgendaItem> KOAgendaItem::conflictItems() |
832 | { | 834 | { |
833 | return mConflictItems; | 835 | return mConflictItems; |
834 | } | 836 | } |
835 | 837 | ||
836 | void KOAgendaItem::setConflictItems(QPtrList<KOAgendaItem> ci) | 838 | void KOAgendaItem::setConflictItems(QPtrList<KOAgendaItem> ci) |
837 | { | 839 | { |
838 | mConflictItems = ci; | 840 | mConflictItems = ci; |
839 | KOAgendaItem *item; | 841 | KOAgendaItem *item; |
840 | for ( item=mConflictItems.first(); item != 0; | 842 | for ( item=mConflictItems.first(); item != 0; |
841 | item=mConflictItems.next() ) { | 843 | item=mConflictItems.next() ) { |
842 | item->addConflictItem(this); | 844 | item->addConflictItem(this); |
843 | } | 845 | } |
844 | } | 846 | } |
845 | 847 | ||
846 | void KOAgendaItem::addConflictItem(KOAgendaItem *ci) | 848 | void KOAgendaItem::addConflictItem(KOAgendaItem *ci) |
847 | { | 849 | { |
848 | if (mConflictItems.find(ci)<0) | 850 | if (mConflictItems.find(ci)<0) |
849 | mConflictItems.append(ci); | 851 | mConflictItems.append(ci); |
850 | } | 852 | } |
851 | 853 | ||
852 | bool KOAgendaItem::checkLayout() | 854 | bool KOAgendaItem::checkLayout() |
853 | { | 855 | { |
854 | if ( !mConflictItems.count() ) | 856 | if ( !mConflictItems.count() ) |
855 | return true; | 857 | return true; |
856 | int max = 0; | 858 | int max = 0; |
857 | KOAgendaItem *item; | 859 | KOAgendaItem *item; |
858 | for ( item=mConflictItems.first(); item != 0; | 860 | for ( item=mConflictItems.first(); item != 0; |
859 | item=mConflictItems.next() ) { | 861 | item=mConflictItems.next() ) { |
860 | if ( item->subCells() > max ) | 862 | if ( item->subCells() > max ) |
861 | max = item->subCells(); | 863 | max = item->subCells(); |
862 | } | 864 | } |
863 | if ( max > subCells() ) { | 865 | if ( max > subCells() ) { |
864 | setSubCells( max ); | 866 | setSubCells( max ); |
865 | return false; | 867 | return false; |
866 | } | 868 | } |
867 | return true; | 869 | return true; |
868 | } | 870 | } |
diff --git a/korganizer/koagendaitem.h b/korganizer/koagendaitem.h index 97acd4c..37d89a6 100644 --- a/korganizer/koagendaitem.h +++ b/korganizer/koagendaitem.h | |||
@@ -1,167 +1,167 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | #ifndef KOAGENDAITEM_H | 19 | #ifndef KOAGENDAITEM_H |
20 | #define KOAGENDAITEM_H | 20 | #define KOAGENDAITEM_H |
21 | 21 | ||
22 | #include <qframe.h> | 22 | #include <qframe.h> |
23 | #include <qlabel.h> | 23 | #include <qlabel.h> |
24 | #include <qpixmap.h> | 24 | #include <qpixmap.h> |
25 | #include <qdatetime.h> | 25 | #include <qdatetime.h> |
26 | #include <qpalette.h> | 26 | #include <qpalette.h> |
27 | 27 | ||
28 | #include <libkcal/incidence.h> | 28 | #include <libkcal/incidence.h> |
29 | 29 | ||
30 | class KOAgendaItemWhatsThis; | 30 | class KOAgendaItemWhatsThis; |
31 | class QToolTipGroup; | 31 | class QToolTipGroup; |
32 | class QDragEnterEvent; | 32 | class QDragEnterEvent; |
33 | class QDropEvent; | 33 | class QDropEvent; |
34 | 34 | ||
35 | using namespace KCal; | 35 | using namespace KCal; |
36 | 36 | ||
37 | /* | 37 | /* |
38 | The KOAgendaItem has to make sure that it receives all mouse events, which are | 38 | The KOAgendaItem has to make sure that it receives all mouse events, which are |
39 | to be used for dragging and resizing. That means it has to be installed as | 39 | to be used for dragging and resizing. That means it has to be installed as |
40 | eventfiler for its children, if it has children, and it has to pass mouse | 40 | eventfiler for its children, if it has children, and it has to pass mouse |
41 | events from the cildren to itself. See eventFilter(). | 41 | events from the cildren to itself. See eventFilter(). |
42 | */ | 42 | */ |
43 | class KOAgendaItem : public QWidget | 43 | class KOAgendaItem : public QWidget |
44 | { | 44 | { |
45 | Q_OBJECT | 45 | Q_OBJECT |
46 | public: | 46 | public: |
47 | KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent, bool allday, const char *name=0, | 47 | KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent, bool allday, const char *name=0, |
48 | WFlags f=0 ); | 48 | WFlags f=0 ); |
49 | ~KOAgendaItem(); | 49 | ~KOAgendaItem(); |
50 | QString getWhatsThisText(); | 50 | QString getWhatsThisText(); |
51 | void init ( Incidence *incidence, QDate qd ); | 51 | void init ( Incidence *incidence, QDate qd ); |
52 | int cellX() { return mCellX; } | 52 | int cellX() { return mCellX; } |
53 | int cellXWidth() { return mCellXWidth; } | 53 | int cellXWidth() { return mCellXWidth; } |
54 | int cellYTop() { return mCellYTop; } | 54 | int cellYTop() { return mCellYTop; } |
55 | int cellYBottom() { return mCellYBottom; } | 55 | int cellYBottom() { return mCellYBottom; } |
56 | int cellHeight(); | 56 | int cellHeight(); |
57 | int cellWidth(); | 57 | int cellWidth(); |
58 | int subCell() { return mSubCell; } | 58 | int subCell() { return mSubCell; } |
59 | int subCells() { return mSubCells; } | 59 | int subCells() { return mSubCells; } |
60 | 60 | ||
61 | void setCellXY(int X, int YTop, int YBottom); | 61 | void setCellXY(int X, int YTop, int YBottom); |
62 | void setCellY(int YTop, int YBottom); | 62 | void setCellY(int YTop, int YBottom); |
63 | void setCellX(int XLeft, int XRight); | 63 | void setCellX(int XLeft, int XRight); |
64 | void setCellXWidth(int xwidth); | 64 | void setCellXWidth(int xwidth); |
65 | void setSubCell(int subCell); | 65 | void setSubCell(int subCell); |
66 | void setSubCells(int subCells); | 66 | void setSubCells(int subCells); |
67 | 67 | ||
68 | /** Start movement */ | 68 | /** Start movement */ |
69 | void startMove(); | 69 | void startMove(); |
70 | /** Reset to original values */ | 70 | /** Reset to original values */ |
71 | void resetMove(); | 71 | void resetMove(); |
72 | 72 | ||
73 | void moveRelative(int dx,int dy); | 73 | void moveRelative(int dx,int dy); |
74 | void expandTop(int dy); | 74 | void expandTop(int dy); |
75 | void expandBottom(int dy); | 75 | void expandBottom(int dy); |
76 | void expandLeft(int dx); | 76 | void expandLeft(int dx); |
77 | void expandRight(int dx); | 77 | void expandRight(int dx); |
78 | int mLastMoveXPos; | 78 | int mLastMoveXPos; |
79 | 79 | ||
80 | void setMultiItem(KOAgendaItem *first,KOAgendaItem *next, | 80 | void setMultiItem(KOAgendaItem *first,KOAgendaItem *next, |
81 | KOAgendaItem *last); | 81 | KOAgendaItem *last); |
82 | KOAgendaItem *firstMultiItem() { return mFirstMultiItem; } | 82 | KOAgendaItem *firstMultiItem() { return mFirstMultiItem; } |
83 | KOAgendaItem *nextMultiItem() { return mNextMultiItem; } | 83 | KOAgendaItem *nextMultiItem() { return mNextMultiItem; } |
84 | KOAgendaItem *lastMultiItem() { return mLastMultiItem; } | 84 | KOAgendaItem *lastMultiItem() { return mLastMultiItem; } |
85 | 85 | ||
86 | Incidence *incidence() const { return mIncidence; } | 86 | Incidence *incidence() const { return mIncidence; } |
87 | QDate itemDate() { return mDate; } | 87 | QDate itemDate() { return mDate; } |
88 | 88 | ||
89 | /** Update the date of this item's occurence (not in the event) */ | 89 | /** Update the date of this item's occurence (not in the event) */ |
90 | void setItemDate(QDate qd); | 90 | void setItemDate(QDate qd); |
91 | 91 | ||
92 | void setText ( const QString & text ) { mDisplayedText = text; } | 92 | void setText ( const QString & text ) { mDisplayedText = text; } |
93 | QString text () { return mDisplayedText; } | 93 | QString text () { return mDisplayedText; } |
94 | 94 | ||
95 | virtual bool eventFilter ( QObject *, QEvent * ); | 95 | virtual bool eventFilter ( QObject *, QEvent * ); |
96 | 96 | ||
97 | static QToolTipGroup *toolTipGroup(); | 97 | static QToolTipGroup *toolTipGroup(); |
98 | 98 | ||
99 | QPtrList<KOAgendaItem> conflictItems(); | 99 | QPtrList<KOAgendaItem> conflictItems(); |
100 | void setConflictItems(QPtrList<KOAgendaItem>); | 100 | void setConflictItems(QPtrList<KOAgendaItem>); |
101 | void addConflictItem(KOAgendaItem *ci); | 101 | void addConflictItem(KOAgendaItem *ci); |
102 | void paintMe( bool, QPainter* painter = 0 ); | 102 | void paintMe( bool, QPainter* painter = 0 ); |
103 | void repaintMe(); | 103 | void repaintMe(); |
104 | static QPixmap * paintPix(); | 104 | static QPixmap * paintPix(); |
105 | static QPixmap * paintPixAllday(); | 105 | static QPixmap * paintPixAllday(); |
106 | void updateItem(); | 106 | void updateItem(); |
107 | void computeText(); | 107 | void computeText(); |
108 | void recreateIncidence(); | 108 | void recreateIncidence(); |
109 | bool checkLayout(); | 109 | bool checkLayout(); |
110 | void initColor (); | 110 | void initColor (); |
111 | bool isAllDay() { return mAllDay; } | 111 | bool isAllDay() { return mAllDay; } |
112 | int resizeMe( int grid, int wid, int hei ); | 112 | int resizeMe( int grid, int wid, int hei, bool invalidHei = false ); |
113 | public slots: | 113 | public slots: |
114 | bool updateIcons( QPainter *, bool ); | 114 | bool updateIcons( QPainter *, bool ); |
115 | void select(bool=true); | 115 | void select(bool=true); |
116 | void repaintItem(); | 116 | void repaintItem(); |
117 | 117 | ||
118 | protected: | 118 | protected: |
119 | void dragEnterEvent(QDragEnterEvent *e); | 119 | void dragEnterEvent(QDragEnterEvent *e); |
120 | void dropEvent(QDropEvent *e); | 120 | void dropEvent(QDropEvent *e); |
121 | void paintEvent ( QPaintEvent * ); | 121 | void paintEvent ( QPaintEvent * ); |
122 | void resizeEvent ( QResizeEvent *ev ); | 122 | void resizeEvent ( QResizeEvent *ev ); |
123 | 123 | ||
124 | private: | 124 | private: |
125 | KOAgendaItemWhatsThis* mKOAgendaItemWhatsThis; | 125 | KOAgendaItemWhatsThis* mKOAgendaItemWhatsThis; |
126 | bool mAllDay; | 126 | bool mAllDay; |
127 | bool mWhiteText; | 127 | bool mWhiteText; |
128 | int mCellX; | 128 | int mCellX; |
129 | int mCellXWidth; | 129 | int mCellXWidth; |
130 | int mCellYTop,mCellYBottom; | 130 | int mCellYTop,mCellYBottom; |
131 | int mSubCell; // subcell number of this item | 131 | int mSubCell; // subcell number of this item |
132 | int mSubCells; // Total number of subcells in cell of this item | 132 | int mSubCells; // Total number of subcells in cell of this item |
133 | int xPaintCoord; | 133 | int xPaintCoord; |
134 | int yPaintCoord; | 134 | int yPaintCoord; |
135 | int wPaintCoord; | 135 | int wPaintCoord; |
136 | int hPaintCoord; | 136 | int hPaintCoord; |
137 | // Variables to remember start position | 137 | // Variables to remember start position |
138 | int mStartCellX; | 138 | int mStartCellX; |
139 | int mStartCellXWidth; | 139 | int mStartCellXWidth; |
140 | int mStartCellYTop,mStartCellYBottom; | 140 | int mStartCellYTop,mStartCellYBottom; |
141 | int mLastMovePos; | 141 | int mLastMovePos; |
142 | 142 | ||
143 | // Multi item pointers | 143 | // Multi item pointers |
144 | KOAgendaItem *mFirstMultiItem; | 144 | KOAgendaItem *mFirstMultiItem; |
145 | KOAgendaItem *mNextMultiItem; | 145 | KOAgendaItem *mNextMultiItem; |
146 | KOAgendaItem *mLastMultiItem; | 146 | KOAgendaItem *mLastMultiItem; |
147 | 147 | ||
148 | int mFontPixelSize; | 148 | int mFontPixelSize; |
149 | Incidence *mIncidence; // corresponding event or todo | 149 | Incidence *mIncidence; // corresponding event or todo |
150 | QDate mDate; //date this events occurs (for recurrence) | 150 | QDate mDate; //date this events occurs (for recurrence) |
151 | //void showIcon( QLabel*, int ); | 151 | //void showIcon( QLabel*, int ); |
152 | //QLabel *mTodoIconLabel; | 152 | //QLabel *mTodoIconLabel; |
153 | //QLabel *mItemLabel; | 153 | //QLabel *mItemLabel; |
154 | //QWidget *mIconBox; | 154 | //QWidget *mIconBox; |
155 | //QLabel *mIconAlarm,*mIconRecur,*mIconReadonly; | 155 | //QLabel *mIconAlarm,*mIconRecur,*mIconReadonly; |
156 | //QLabel *mIconReply,*mIconGroup,*mIconOrganizer; | 156 | //QLabel *mIconReply,*mIconGroup,*mIconOrganizer; |
157 | //QLabel *mIconMoreInfo; | 157 | //QLabel *mIconMoreInfo; |
158 | static QToolTipGroup *mToolTipGroup; | 158 | static QToolTipGroup *mToolTipGroup; |
159 | 159 | ||
160 | QColor mBackgroundColor; | 160 | QColor mBackgroundColor; |
161 | QColorGroup mColorGroup; | 161 | QColorGroup mColorGroup; |
162 | QString mDisplayedText; | 162 | QString mDisplayedText; |
163 | bool mSelected; | 163 | bool mSelected; |
164 | QPtrList<KOAgendaItem> mConflictItems; | 164 | QPtrList<KOAgendaItem> mConflictItems; |
165 | }; | 165 | }; |
166 | 166 | ||
167 | #endif // KOAGENDAITEM_H | 167 | #endif // KOAGENDAITEM_H |
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index 1cf03a0..d8a2134 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp | |||
@@ -470,1222 +470,1221 @@ KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : | |||
470 | 470 | ||
471 | #endif | 471 | #endif |
472 | connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), | 472 | connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), |
473 | mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *))); | 473 | mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *))); |
474 | 474 | ||
475 | connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), | 475 | connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), |
476 | mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *))); | 476 | mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *))); |
477 | 477 | ||
478 | connect(mAllAgendaPopup,SIGNAL(categoryChanged(Incidence *)), | 478 | connect(mAllAgendaPopup,SIGNAL(categoryChanged(Incidence *)), |
479 | this,SLOT(categoryChanged(Incidence *))); | 479 | this,SLOT(categoryChanged(Incidence *))); |
480 | 480 | ||
481 | 481 | ||
482 | mAgenda->setPopup( mAllAgendaPopup ); | 482 | mAgenda->setPopup( mAllAgendaPopup ); |
483 | mAllDayAgenda->setPopup( mAllAgendaPopup ); | 483 | mAllDayAgenda->setPopup( mAllAgendaPopup ); |
484 | // make connections between dependent widgets | 484 | // make connections between dependent widgets |
485 | mTimeLabels->setAgenda(mAgenda); | 485 | mTimeLabels->setAgenda(mAgenda); |
486 | 486 | ||
487 | // Update widgets to reflect user preferences | 487 | // Update widgets to reflect user preferences |
488 | // updateConfig(); | 488 | // updateConfig(); |
489 | 489 | ||
490 | // createDayLabels(); | 490 | // createDayLabels(); |
491 | 491 | ||
492 | // these blank widgets make the All Day Event box line up with the agenda | 492 | // these blank widgets make the All Day Event box line up with the agenda |
493 | dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); | 493 | dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); |
494 | dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); | 494 | dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); |
495 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); | 495 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); |
496 | 496 | ||
497 | // Scrolling | 497 | // Scrolling |
498 | connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), | 498 | connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), |
499 | mTimeLabels, SLOT(positionChanged())); | 499 | mTimeLabels, SLOT(positionChanged())); |
500 | connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), | 500 | connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), |
501 | SLOT(setContentsPos(int))); | 501 | SLOT(setContentsPos(int))); |
502 | 502 | ||
503 | connect(mAgenda,SIGNAL(showDateView( int, int)),SLOT(slotShowDateView( int, int ))); | 503 | connect(mAgenda,SIGNAL(showDateView( int, int)),SLOT(slotShowDateView( int, int ))); |
504 | connect(mAllDayAgenda,SIGNAL(showDateView( int, int )), SLOT(slotShowDateView( int, int ) )); | 504 | connect(mAllDayAgenda,SIGNAL(showDateView( int, int )), SLOT(slotShowDateView( int, int ) )); |
505 | 505 | ||
506 | // Create/Show/Edit/Delete Event | 506 | // Create/Show/Edit/Delete Event |
507 | connect(mAgenda,SIGNAL(newEventSignal(int,int)), | 507 | connect(mAgenda,SIGNAL(newEventSignal(int,int)), |
508 | SLOT(newEvent(int,int))); | 508 | SLOT(newEvent(int,int))); |
509 | connect(mAgenda,SIGNAL(newTodoSignal(int,int)), | 509 | connect(mAgenda,SIGNAL(newTodoSignal(int,int)), |
510 | SLOT(newTodo(int,int))); | 510 | SLOT(newTodo(int,int))); |
511 | connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), | 511 | connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), |
512 | SLOT(newEvent(int,int,int,int))); | 512 | SLOT(newEvent(int,int,int,int))); |
513 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), | 513 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), |
514 | SLOT(newEventAllDay(int,int))); | 514 | SLOT(newEventAllDay(int,int))); |
515 | connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), | 515 | connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), |
516 | SLOT(newTodoAllDay(int,int))); | 516 | SLOT(newTodoAllDay(int,int))); |
517 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), | 517 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), |
518 | SLOT(newEventAllDay(int,int))); | 518 | SLOT(newEventAllDay(int,int))); |
519 | connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), | 519 | connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), |
520 | SLOT(newTimeSpanSelected(int,int,int,int))); | 520 | SLOT(newTimeSpanSelected(int,int,int,int))); |
521 | connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), | 521 | connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), |
522 | SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); | 522 | SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); |
523 | connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); | 523 | connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); |
524 | connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); | 524 | connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); |
525 | 525 | ||
526 | connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), | 526 | connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), |
527 | SIGNAL(editIncidenceSignal(Incidence *))); | 527 | SIGNAL(editIncidenceSignal(Incidence *))); |
528 | connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), | 528 | connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), |
529 | SIGNAL(editIncidenceSignal(Incidence *))); | 529 | SIGNAL(editIncidenceSignal(Incidence *))); |
530 | connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), | 530 | connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), |
531 | SIGNAL(showIncidenceSignal(Incidence *))); | 531 | SIGNAL(showIncidenceSignal(Incidence *))); |
532 | connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), | 532 | connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), |
533 | SIGNAL(showIncidenceSignal(Incidence *))); | 533 | SIGNAL(showIncidenceSignal(Incidence *))); |
534 | connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), | 534 | connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), |
535 | SIGNAL(deleteIncidenceSignal(Incidence *))); | 535 | SIGNAL(deleteIncidenceSignal(Incidence *))); |
536 | connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), | 536 | connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), |
537 | SIGNAL(deleteIncidenceSignal(Incidence *))); | 537 | SIGNAL(deleteIncidenceSignal(Incidence *))); |
538 | 538 | ||
539 | connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), | 539 | connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), |
540 | SLOT(updateEventDates(KOAgendaItem *, int ))); | 540 | SLOT(updateEventDates(KOAgendaItem *, int ))); |
541 | connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), | 541 | connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), |
542 | SLOT(updateEventDates(KOAgendaItem *, int))); | 542 | SLOT(updateEventDates(KOAgendaItem *, int))); |
543 | 543 | ||
544 | // event indicator update | 544 | // event indicator update |
545 | connect(mAgenda,SIGNAL(lowerYChanged(int)), | 545 | connect(mAgenda,SIGNAL(lowerYChanged(int)), |
546 | SLOT(updateEventIndicatorTop(int))); | 546 | SLOT(updateEventIndicatorTop(int))); |
547 | connect(mAgenda,SIGNAL(upperYChanged(int)), | 547 | connect(mAgenda,SIGNAL(upperYChanged(int)), |
548 | SLOT(updateEventIndicatorBottom(int))); | 548 | SLOT(updateEventIndicatorBottom(int))); |
549 | // drag signals | 549 | // drag signals |
550 | /* | 550 | /* |
551 | connect(mAgenda,SIGNAL(startDragSignal(Event *)), | 551 | connect(mAgenda,SIGNAL(startDragSignal(Event *)), |
552 | SLOT(startDrag(Event *))); | 552 | SLOT(startDrag(Event *))); |
553 | connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), | 553 | connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), |
554 | SLOT(startDrag(Event *))); | 554 | SLOT(startDrag(Event *))); |
555 | */ | 555 | */ |
556 | // synchronize selections | 556 | // synchronize selections |
557 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 557 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
558 | mAllDayAgenda, SLOT( deselectItem() ) ); | 558 | mAllDayAgenda, SLOT( deselectItem() ) ); |
559 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 559 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
560 | mAgenda, SLOT( deselectItem() ) ); | 560 | mAgenda, SLOT( deselectItem() ) ); |
561 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 561 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
562 | SIGNAL( incidenceSelected( Incidence * ) ) ); | 562 | SIGNAL( incidenceSelected( Incidence * ) ) ); |
563 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 563 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
564 | SIGNAL( incidenceSelected( Incidence * ) ) ); | 564 | SIGNAL( incidenceSelected( Incidence * ) ) ); |
565 | connect( mAgenda, SIGNAL( resizedSignal() ), | 565 | connect( mAgenda, SIGNAL( resizedSignal() ), |
566 | SLOT( updateConfig( ) ) ); | 566 | SLOT( updateConfig( ) ) ); |
567 | connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), | 567 | connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), |
568 | SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); | 568 | SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); |
569 | connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), | 569 | connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), |
570 | SLOT( addToCalSlot(Incidence * , Incidence *) ) ); | 570 | SLOT( addToCalSlot(Incidence * , Incidence *) ) ); |
571 | // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); | 571 | // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); |
572 | //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); | 572 | //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); |
573 | 573 | ||
574 | connect( mAllDayAgenda, SIGNAL( signalClearSelection() ),mAgenda, SLOT( slotClearSelection()) ); | 574 | connect( mAllDayAgenda, SIGNAL( signalClearSelection() ),mAgenda, SLOT( slotClearSelection()) ); |
575 | connect( mAgenda, SIGNAL( signalClearSelection() ),mAllDayAgenda, SLOT( slotClearSelection()) ); | 575 | connect( mAgenda, SIGNAL( signalClearSelection() ),mAllDayAgenda, SLOT( slotClearSelection()) ); |
576 | #ifndef DESKTOP_VERSION | 576 | #ifndef DESKTOP_VERSION |
577 | connect( mAllDayAgenda, SIGNAL( updateViewSignal() ),this, SLOT( fillAgenda()) ); | 577 | connect( mAllDayAgenda, SIGNAL( updateViewSignal() ),this, SLOT( fillAgenda()) ); |
578 | connect( mAgenda, SIGNAL( updateViewSignal() ), this, SLOT( fillAgenda()) ); | 578 | connect( mAgenda, SIGNAL( updateViewSignal() ), this, SLOT( fillAgenda()) ); |
579 | connect( mAllDayAgenda, SIGNAL( sendPing() ),this, SLOT( startIdleTimeout()) ); | 579 | connect( mAllDayAgenda, SIGNAL( sendPing() ),this, SLOT( startIdleTimeout()) ); |
580 | connect( mAgenda, SIGNAL( sendPing() ), this, SLOT( startIdleTimeout()) ); | 580 | connect( mAgenda, SIGNAL( sendPing() ), this, SLOT( startIdleTimeout()) ); |
581 | mIdleTimer = new QTimer ( this );; | 581 | mIdleTimer = new QTimer ( this );; |
582 | connect(mIdleTimer,SIGNAL(timeout()),SLOT(slotIdleTimeout())); | 582 | connect(mIdleTimer,SIGNAL(timeout()),SLOT(slotIdleTimeout())); |
583 | #endif | 583 | #endif |
584 | } | 584 | } |
585 | void KOAgendaView::startIdleTimeout() | 585 | void KOAgendaView::startIdleTimeout() |
586 | { | 586 | { |
587 | #ifndef DESKTOP_VERSION | 587 | #ifndef DESKTOP_VERSION |
588 | mIdleStart = QDateTime::currentDateTime(); | 588 | mIdleStart = QDateTime::currentDateTime(); |
589 | mIdleTimer->start( IDLETIMEOUT * 1000 ); | 589 | mIdleTimer->start( IDLETIMEOUT * 1000 ); |
590 | #endif | 590 | #endif |
591 | } | 591 | } |
592 | void KOAgendaView::slotIdleTimeout() | 592 | void KOAgendaView::slotIdleTimeout() |
593 | { | 593 | { |
594 | #ifndef DESKTOP_VERSION | 594 | #ifndef DESKTOP_VERSION |
595 | //qDebug("SECS TO %d ",mIdleStart.secsTo( QDateTime::currentDateTime() ) ); | 595 | //qDebug("SECS TO %d ",mIdleStart.secsTo( QDateTime::currentDateTime() ) ); |
596 | int secsfromstart = mIdleStart.secsTo( QDateTime::currentDateTime() ); | 596 | int secsfromstart = mIdleStart.secsTo( QDateTime::currentDateTime() ); |
597 | mIdleTimer->stop(); | 597 | mIdleTimer->stop(); |
598 | bool isActice = topLevelWidget()->isActiveWindow(); | 598 | bool isActice = topLevelWidget()->isActiveWindow(); |
599 | //qDebug("KO: Active Window %d %d", isActice, isVisible()); | 599 | //qDebug("KO: Active Window %d %d", isActice, isVisible()); |
600 | // we do nothing if we wake up from a suspend | 600 | // we do nothing if we wake up from a suspend |
601 | if ( secsfromstart > IDLETIMEOUT + 30 && isActice ) { | 601 | if ( secsfromstart > IDLETIMEOUT + 30 && isActice ) { |
602 | qDebug("KO: Wakeup from suspend "); | 602 | qDebug("KO: Wakeup from suspend "); |
603 | startIdleTimeout(); | 603 | startIdleTimeout(); |
604 | return; | 604 | return; |
605 | } | 605 | } |
606 | qDebug("KO: Downsizing Pixmaps %s",QDateTime::currentDateTime().toString().latin1()); | 606 | qDebug("KO: Downsizing Pixmaps %s",QDateTime::currentDateTime().toString().latin1()); |
607 | mAgenda->shrinkPixmap(); | 607 | mAgenda->shrinkPixmap(); |
608 | mAllDayAgenda->shrinkPixmap(); | 608 | mAllDayAgenda->shrinkPixmap(); |
609 | KOAgendaItem::paintPix()->resize( 20,20); | 609 | KOAgendaItem::paintPix()->resize( 20,20); |
610 | KOAgendaItem::paintPixAllday()->resize( 20,20); | 610 | KOAgendaItem::paintPixAllday()->resize( 20,20); |
611 | #endif | 611 | #endif |
612 | 612 | ||
613 | } | 613 | } |
614 | void KOAgendaView::toggleAllDay() | 614 | void KOAgendaView::toggleAllDay() |
615 | { | 615 | { |
616 | if ( mSplitterAgenda->firstHandle() ) | 616 | if ( mSplitterAgenda->firstHandle() ) |
617 | mSplitterAgenda->firstHandle()->toggle(); | 617 | mSplitterAgenda->firstHandle()->toggle(); |
618 | } | 618 | } |
619 | void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) | 619 | void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) |
620 | { | 620 | { |
621 | calendar()->addIncidence( inc ); | 621 | calendar()->addIncidence( inc ); |
622 | 622 | ||
623 | if ( incOld ) { | 623 | if ( incOld ) { |
624 | if ( incOld->typeID() == todoID ) | 624 | if ( incOld->typeID() == todoID ) |
625 | emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); | 625 | emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); |
626 | else | 626 | else |
627 | emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); | 627 | emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); |
628 | } | 628 | } |
629 | 629 | ||
630 | } | 630 | } |
631 | void KOAgendaView::categoryChanged(Incidence * inc) | 631 | void KOAgendaView::categoryChanged(Incidence * inc) |
632 | { | 632 | { |
633 | mAgenda->categoryChanged( inc ); | 633 | mAgenda->categoryChanged( inc ); |
634 | mAllDayAgenda->categoryChanged( inc ); | 634 | mAllDayAgenda->categoryChanged( inc ); |
635 | } | 635 | } |
636 | KOAgendaView::~KOAgendaView() | 636 | KOAgendaView::~KOAgendaView() |
637 | { | 637 | { |
638 | delete mAllAgendaPopup; | 638 | delete mAllAgendaPopup; |
639 | //delete mAllDayAgendaPopup; | 639 | //delete mAllDayAgendaPopup; |
640 | delete KOAgendaItem::paintPix(); | 640 | delete KOAgendaItem::paintPix(); |
641 | delete KOAgendaItem::paintPixAllday(); | 641 | delete KOAgendaItem::paintPixAllday(); |
642 | } | 642 | } |
643 | void KOAgendaView::resizeEvent( QResizeEvent* e ) | 643 | void KOAgendaView::resizeEvent( QResizeEvent* e ) |
644 | { | 644 | { |
645 | //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); | 645 | //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); |
646 | bool uc = false; | 646 | bool uc = false; |
647 | int ow = e->oldSize().width(); | 647 | int ow = e->oldSize().width(); |
648 | int oh = e->oldSize().height(); | 648 | int oh = e->oldSize().height(); |
649 | int w = e->size().width(); | 649 | int w = e->size().width(); |
650 | int h = e->size().height(); | 650 | int h = e->size().height(); |
651 | if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { | 651 | if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { |
652 | if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) | 652 | if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) |
653 | uc = true; | 653 | uc = true; |
654 | //qDebug("view changed %d %d %d %d ", ow, oh , w , h); | 654 | //qDebug("view changed %d %d %d %d ", ow, oh , w , h); |
655 | } | 655 | } |
656 | mUpcomingWidth = e->size().width() ; | 656 | mUpcomingWidth = e->size().width() ; |
657 | if ( mBlockUpdating || uc ) { | 657 | if ( mBlockUpdating || uc ) { |
658 | mBlockUpdating = false; | 658 | mBlockUpdating = false; |
659 | //mAgenda->setMinimumSize(800 , 600 ); | 659 | //mAgenda->setMinimumSize(800 , 600 ); |
660 | //qDebug("mAgenda->resize+++++++++++++++ "); | 660 | //qDebug("mAgenda->resize+++++++++++++++ "); |
661 | updateConfig(); | 661 | updateConfig(); |
662 | //qDebug("KOAgendaView::Updating now possible "); | 662 | //qDebug("KOAgendaView::Updating now possible "); |
663 | } else | 663 | } else |
664 | createDayLabels(); | 664 | createDayLabels(); |
665 | //qDebug("resizeEvent end "); | 665 | //qDebug("resizeEvent end "); |
666 | 666 | ||
667 | } | 667 | } |
668 | void KOAgendaView::slotDaylabelClicked( int num ) | 668 | void KOAgendaView::slotDaylabelClicked( int num ) |
669 | { | 669 | { |
670 | 670 | ||
671 | QDate firstDate = mSelectedDates.first(); | 671 | QDate firstDate = mSelectedDates.first(); |
672 | if ( num == -1 ) | 672 | if ( num == -1 ) |
673 | emit showDateView( 6, firstDate ); | 673 | emit showDateView( 6, firstDate ); |
674 | else if (num >= 0 ) { | 674 | else if (num >= 0 ) { |
675 | if ( mSelectedDates.count() == 1) | 675 | if ( mSelectedDates.count() == 1) |
676 | emit showDateView( 9, firstDate.addDays( num ) ); | 676 | emit showDateView( 9, firstDate.addDays( num ) ); |
677 | else | 677 | else |
678 | emit showDateView( 3, firstDate.addDays( num ) ); | 678 | emit showDateView( 3, firstDate.addDays( num ) ); |
679 | } | 679 | } |
680 | else | 680 | else |
681 | showDateView( 10, firstDate.addDays(1) ); | 681 | showDateView( 10, firstDate.addDays(1) ); |
682 | } | 682 | } |
683 | 683 | ||
684 | KOAgendaButton* KOAgendaView::getNewDaylabel() | 684 | KOAgendaButton* KOAgendaView::getNewDaylabel() |
685 | { | 685 | { |
686 | 686 | ||
687 | KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); | 687 | KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); |
688 | connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); | 688 | connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); |
689 | mDayLabelsList.append( dayLabel ); | 689 | mDayLabelsList.append( dayLabel ); |
690 | mLayoutDayLabels->addWidget(dayLabel); | 690 | mLayoutDayLabels->addWidget(dayLabel); |
691 | return dayLabel ; | 691 | return dayLabel ; |
692 | } | 692 | } |
693 | 693 | ||
694 | void KOAgendaView::createDayLabels() | 694 | void KOAgendaView::createDayLabels() |
695 | { | 695 | { |
696 | 696 | ||
697 | if ( mBlockUpdating || globalFlagBlockLabel == 1) { | 697 | if ( mBlockUpdating || globalFlagBlockLabel == 1) { |
698 | // qDebug(" KOAgendaView::createDayLabels() blocked "); | 698 | // qDebug(" KOAgendaView::createDayLabels() blocked "); |
699 | return; | 699 | return; |
700 | 700 | ||
701 | } | 701 | } |
702 | int newHight; | 702 | int newHight; |
703 | if ( !mSelectedDates.count()) | 703 | if ( !mSelectedDates.count()) |
704 | return; | 704 | return; |
705 | 705 | ||
706 | // ### Before deleting and recreating we could check if mSelectedDates changed... | 706 | // ### Before deleting and recreating we could check if mSelectedDates changed... |
707 | // It would remove some flickering and gain speed (since this is called by | 707 | // It would remove some flickering and gain speed (since this is called by |
708 | // each updateView() call) | 708 | // each updateView() call) |
709 | 709 | ||
710 | int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2; | 710 | int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2; |
711 | mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); | 711 | mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); |
712 | if ( maxWid < 20 ) | 712 | if ( maxWid < 20 ) |
713 | maxWid = 20; | 713 | maxWid = 20; |
714 | 714 | ||
715 | QFont dlf = KOPrefs::instance()->mTimeLabelsFont; | 715 | QFont dlf = KOPrefs::instance()->mTimeLabelsFont; |
716 | QFontMetrics fm ( dlf ); | 716 | QFontMetrics fm ( dlf ); |
717 | dlf.setBold( true ); | 717 | dlf.setBold( true ); |
718 | int selCount = mSelectedDates.count(); | 718 | int selCount = mSelectedDates.count(); |
719 | int widModulo = maxWid - (mAgenda->gridSpacingX() * selCount)+1; | 719 | int widModulo = maxWid - (mAgenda->gridSpacingX() * selCount)+1; |
720 | QString dayTest = "Mon 20"; | 720 | QString dayTest = "Mon 20"; |
721 | //QString dayTest = "Mon 20"; | 721 | //QString dayTest = "Mon 20"; |
722 | int wid = fm.width( dayTest ); | 722 | int wid = fm.width( dayTest ); |
723 | //maxWid -= ( selCount * 3 ); //working for QLabels | 723 | //maxWid -= ( selCount * 3 ); //working for QLabels |
724 | if ( QApplication::desktop()->width() <= 320 ) | 724 | if ( QApplication::desktop()->width() <= 320 ) |
725 | maxWid -= ( selCount * 3 ); //working for QPushButton | 725 | maxWid -= ( selCount * 3 ); //working for QPushButton |
726 | else | 726 | else |
727 | maxWid -= ( selCount * 4 ); //working for QPushButton | 727 | maxWid -= ( selCount * 4 ); //working for QPushButton |
728 | if ( maxWid < 0 ) | 728 | if ( maxWid < 0 ) |
729 | maxWid = 20; | 729 | maxWid = 20; |
730 | int needWid = wid * selCount; | 730 | int needWid = wid * selCount; |
731 | //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); | 731 | //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); |
732 | //if ( needWid > maxWid ) | 732 | //if ( needWid > maxWid ) |
733 | // qDebug("DAYLABELS TOOOOOOO BIG "); | 733 | // qDebug("DAYLABELS TOOOOOOO BIG "); |
734 | while ( needWid > maxWid ) { | 734 | while ( needWid > maxWid ) { |
735 | dayTest = dayTest.left( dayTest.length() - 1 ); | 735 | dayTest = dayTest.left( dayTest.length() - 1 ); |
736 | wid = fm.width( dayTest ); | 736 | wid = fm.width( dayTest ); |
737 | needWid = wid * selCount; | 737 | needWid = wid * selCount; |
738 | } | 738 | } |
739 | int maxLen = dayTest.length(); | 739 | int maxLen = dayTest.length(); |
740 | int fontPoint = dlf.pointSize(); | 740 | int fontPoint = dlf.pointSize(); |
741 | if ( maxLen < 2 ) { | 741 | if ( maxLen < 2 ) { |
742 | int fontPoint = dlf.pointSize(); | 742 | int fontPoint = dlf.pointSize(); |
743 | while ( fontPoint > 4 ) { | 743 | while ( fontPoint > 4 ) { |
744 | --fontPoint; | 744 | --fontPoint; |
745 | dlf.setPointSize( fontPoint ); | 745 | dlf.setPointSize( fontPoint ); |
746 | QFontMetrics f( dlf ); | 746 | QFontMetrics f( dlf ); |
747 | wid = f.width( "30" ); | 747 | wid = f.width( "30" ); |
748 | needWid = wid * selCount; | 748 | needWid = wid * selCount; |
749 | if ( needWid < maxWid ) | 749 | if ( needWid < maxWid ) |
750 | break; | 750 | break; |
751 | } | 751 | } |
752 | maxLen = 2; | 752 | maxLen = 2; |
753 | } | 753 | } |
754 | //qDebug("Max len %d ", dayTest.length() ); | 754 | //qDebug("Max len %d ", dayTest.length() ); |
755 | if ( !KOPrefs::instance()->mTimeLabelsFont.bold() ) | 755 | if ( !KOPrefs::instance()->mTimeLabelsFont.bold() ) |
756 | dlf.setBold( false ); | 756 | dlf.setBold( false ); |
757 | QFontMetrics tempF( dlf ); | 757 | QFontMetrics tempF( dlf ); |
758 | newHight = tempF.height(); | 758 | newHight = tempF.height(); |
759 | mDayLabels->setFont( dlf ); | 759 | mDayLabels->setFont( dlf ); |
760 | // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; | 760 | // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; |
761 | // mLayoutDayLabels->addSpacing(mTimeLabels->width()); | 761 | // mLayoutDayLabels->addSpacing(mTimeLabels->width()); |
762 | //mLayoutDayLabels->addSpacing( 2 ); | 762 | //mLayoutDayLabels->addSpacing( 2 ); |
763 | // QFont lFont = dlf; | 763 | // QFont lFont = dlf; |
764 | bool appendLabels = false; | 764 | bool appendLabels = false; |
765 | KOAgendaButton *dayLabel; | 765 | KOAgendaButton *dayLabel; |
766 | dayLabel = mDayLabelsList.first(); | 766 | dayLabel = mDayLabelsList.first(); |
767 | if ( !dayLabel ) { | 767 | if ( !dayLabel ) { |
768 | appendLabels = true; | 768 | appendLabels = true; |
769 | dayLabel = getNewDaylabel(); | 769 | dayLabel = getNewDaylabel(); |
770 | } | 770 | } |
771 | dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() ); | 771 | dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() ); |
772 | dayLabel->setFont( dlf ); | 772 | dayLabel->setFont( dlf ); |
773 | dayLabel->setNum( -1 ); | 773 | dayLabel->setNum( -1 ); |
774 | //dayLabel->setAlignment(QLabel::AlignHCenter); | 774 | //dayLabel->setAlignment(QLabel::AlignHCenter); |
775 | 775 | ||
776 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); | 776 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); |
777 | dayLabel->show(); | 777 | dayLabel->show(); |
778 | DateList::ConstIterator dit; | 778 | DateList::ConstIterator dit; |
779 | bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); | 779 | bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); |
780 | int counter = -1; | 780 | int counter = -1; |
781 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { | 781 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { |
782 | ++counter; | 782 | ++counter; |
783 | QDate date = *dit; | 783 | QDate date = *dit; |
784 | // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); | 784 | // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); |
785 | if ( ! appendLabels ) { | 785 | if ( ! appendLabels ) { |
786 | dayLabel = mDayLabelsList.next(); | 786 | dayLabel = mDayLabelsList.next(); |
787 | if ( !dayLabel ) | 787 | if ( !dayLabel ) |
788 | appendLabels = true; | 788 | appendLabels = true; |
789 | } | 789 | } |
790 | if ( appendLabels ) { | 790 | if ( appendLabels ) { |
791 | dayLabel = getNewDaylabel(); | 791 | dayLabel = getNewDaylabel(); |
792 | } | 792 | } |
793 | dayLabel->setMinimumWidth( 1 ); | 793 | dayLabel->setMinimumWidth( 1 ); |
794 | dayLabel->setMaximumWidth( 10240 ); | 794 | dayLabel->setMaximumWidth( 10240 ); |
795 | dayLabel->setFont( dlf ); | 795 | dayLabel->setFont( dlf ); |
796 | dayLabel->show(); | 796 | dayLabel->show(); |
797 | dayLabel->setAutoRepeat( false ); | 797 | dayLabel->setAutoRepeat( false ); |
798 | dayLabel->setNum( counter ); | 798 | dayLabel->setNum( counter ); |
799 | QString str; | 799 | QString str; |
800 | int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); | 800 | int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); |
801 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); | 801 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); |
802 | switch ( maxLen ) { | 802 | switch ( maxLen ) { |
803 | case 2: | 803 | case 2: |
804 | str = QString::number( date.day() ); | 804 | str = QString::number( date.day() ); |
805 | break; | 805 | break; |
806 | 806 | ||
807 | case 3: | 807 | case 3: |
808 | str = dayName.left( 1 ) +QString::number( date.day()); | 808 | str = dayName.left( 1 ) +QString::number( date.day()); |
809 | 809 | ||
810 | break; | 810 | break; |
811 | case 4: | 811 | case 4: |
812 | str = dayName.left( 1 ) + " " +QString::number( date.day()); | 812 | str = dayName.left( 1 ) + " " +QString::number( date.day()); |
813 | 813 | ||
814 | break; | 814 | break; |
815 | case 5: | 815 | case 5: |
816 | str = dayName.left( 2 ) + " " +QString::number( date.day()); | 816 | str = dayName.left( 2 ) + " " +QString::number( date.day()); |
817 | 817 | ||
818 | break; | 818 | break; |
819 | case 6: | 819 | case 6: |
820 | str = dayName.left( 3 ) + " " +QString::number( date.day()); | 820 | str = dayName.left( 3 ) + " " +QString::number( date.day()); |
821 | break; | 821 | break; |
822 | 822 | ||
823 | default: | 823 | default: |
824 | break; | 824 | break; |
825 | } | 825 | } |
826 | if ( oneday ) { | 826 | if ( oneday ) { |
827 | QString addString; | 827 | QString addString; |
828 | if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) | 828 | if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) |
829 | addString = i18n("Today"); | 829 | addString = i18n("Today"); |
830 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) | 830 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) |
831 | addString = i18n("Tomorrow"); | 831 | addString = i18n("Tomorrow"); |
832 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) | 832 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) |
833 | addString = i18n("Yesterday"); | 833 | addString = i18n("Yesterday"); |
834 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) | 834 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) |
835 | addString = i18n("Day before yesterday"); | 835 | addString = i18n("Day before yesterday"); |
836 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) | 836 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) |
837 | addString = i18n("Day after tomorrow"); | 837 | addString = i18n("Day after tomorrow"); |
838 | if ( !addString.isEmpty() ) { | 838 | if ( !addString.isEmpty() ) { |
839 | if ( QApplication::desktop()->width() < 640 ) | 839 | if ( QApplication::desktop()->width() < 640 ) |
840 | str = addString+", " + str; | 840 | str = addString+", " + str; |
841 | else | 841 | else |
842 | str = addString+", "+ KGlobal::locale()->formatDate( date, false); | 842 | str = addString+", "+ KGlobal::locale()->formatDate( date, false); |
843 | } else { | 843 | } else { |
844 | str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer); | 844 | str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer); |
845 | } | 845 | } |
846 | } | 846 | } |
847 | dayLabel->setText(str); | 847 | dayLabel->setText(str); |
848 | //dayLabel->setAlignment(QLabel::AlignHCenter); | 848 | //dayLabel->setAlignment(QLabel::AlignHCenter); |
849 | if (date == QDate::currentDate()) { | 849 | if (date == QDate::currentDate()) { |
850 | QFont bFont = dlf; | 850 | QFont bFont = dlf; |
851 | bFont.setBold( true ); | 851 | bFont.setBold( true ); |
852 | dayLabel->setFont(bFont); | 852 | dayLabel->setFont(bFont); |
853 | } | 853 | } |
854 | //dayLayout->addWidget(dayLabel); | 854 | //dayLayout->addWidget(dayLabel); |
855 | 855 | ||
856 | #ifndef KORG_NOPLUGINS | 856 | #ifndef KORG_NOPLUGINS |
857 | CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); | 857 | CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); |
858 | CalendarDecoration *it; | 858 | CalendarDecoration *it; |
859 | for(it = cds.first(); it; it = cds.next()) { | 859 | for(it = cds.first(); it; it = cds.next()) { |
860 | QString text = it->shortText( date ); | 860 | QString text = it->shortText( date ); |
861 | if ( !text.isEmpty() ) { | 861 | if ( !text.isEmpty() ) { |
862 | QLabel *label = new QLabel(text,mDayLabels); | 862 | QLabel *label = new QLabel(text,mDayLabels); |
863 | label->setAlignment(AlignCenter); | 863 | label->setAlignment(AlignCenter); |
864 | dayLayout->addWidget(label); | 864 | dayLayout->addWidget(label); |
865 | } | 865 | } |
866 | } | 866 | } |
867 | 867 | ||
868 | for(it = cds.first(); it; it = cds.next()) { | 868 | for(it = cds.first(); it; it = cds.next()) { |
869 | QWidget *wid = it->smallWidget(mDayLabels,date); | 869 | QWidget *wid = it->smallWidget(mDayLabels,date); |
870 | if ( wid ) { | 870 | if ( wid ) { |
871 | // wid->setHeight(20); | 871 | // wid->setHeight(20); |
872 | dayLayout->addWidget(wid); | 872 | dayLayout->addWidget(wid); |
873 | } | 873 | } |
874 | } | 874 | } |
875 | #endif | 875 | #endif |
876 | } | 876 | } |
877 | if ( ! appendLabels ) { | 877 | if ( ! appendLabels ) { |
878 | dayLabel = mDayLabelsList.next(); | 878 | dayLabel = mDayLabelsList.next(); |
879 | if ( !dayLabel ) | 879 | if ( !dayLabel ) |
880 | appendLabels = true; | 880 | appendLabels = true; |
881 | } | 881 | } |
882 | if ( appendLabels ) { | 882 | if ( appendLabels ) { |
883 | dayLabel = getNewDaylabel(); | 883 | dayLabel = getNewDaylabel(); |
884 | } | 884 | } |
885 | //dayLabel->hide();//test only | 885 | //dayLabel->hide();//test only |
886 | 886 | ||
887 | dayLabel->setText(">"); | 887 | dayLabel->setText(">"); |
888 | dayLabel->setFont( dlf ); | 888 | dayLabel->setFont( dlf ); |
889 | dayLabel->setAutoRepeat( true ); | 889 | dayLabel->setAutoRepeat( true ); |
890 | dayLabel->show(); | 890 | dayLabel->show(); |
891 | dayLabel->setNum( -2 ); | 891 | dayLabel->setNum( -2 ); |
892 | dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ widModulo ); | 892 | dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ widModulo ); |
893 | 893 | ||
894 | //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); | 894 | //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); |
895 | if ( !appendLabels ) { | 895 | if ( !appendLabels ) { |
896 | dayLabel = mDayLabelsList.next(); | 896 | dayLabel = mDayLabelsList.next(); |
897 | while ( dayLabel ) { | 897 | while ( dayLabel ) { |
898 | //qDebug("!dayLabel %d",dayLabel ); | 898 | //qDebug("!dayLabel %d",dayLabel ); |
899 | dayLabel->hide(); | 899 | dayLabel->hide(); |
900 | dayLabel = mDayLabelsList.next(); | 900 | dayLabel = mDayLabelsList.next(); |
901 | } | 901 | } |
902 | } | 902 | } |
903 | 903 | ||
904 | mDayLabelsFrame->setFixedHeight( newHight + 4 ); | 904 | mDayLabelsFrame->setFixedHeight( newHight + 4 ); |
905 | } | 905 | } |
906 | 906 | ||
907 | int KOAgendaView::maxDatesHint() | 907 | int KOAgendaView::maxDatesHint() |
908 | { | 908 | { |
909 | // Not sure about the max number of events, so return 0 for now. | 909 | // Not sure about the max number of events, so return 0 for now. |
910 | return 0; | 910 | return 0; |
911 | } | 911 | } |
912 | 912 | ||
913 | int KOAgendaView::currentDateCount() | 913 | int KOAgendaView::currentDateCount() |
914 | { | 914 | { |
915 | return mSelectedDates.count(); | 915 | return mSelectedDates.count(); |
916 | } | 916 | } |
917 | 917 | ||
918 | QPtrList<Incidence> KOAgendaView::selectedIncidences() | 918 | QPtrList<Incidence> KOAgendaView::selectedIncidences() |
919 | { | 919 | { |
920 | QPtrList<Incidence> selected; | 920 | QPtrList<Incidence> selected; |
921 | Incidence *incidence; | 921 | Incidence *incidence; |
922 | 922 | ||
923 | incidence = mAgenda->selectedIncidence(); | 923 | incidence = mAgenda->selectedIncidence(); |
924 | if (incidence) selected.append(incidence); | 924 | if (incidence) selected.append(incidence); |
925 | 925 | ||
926 | incidence = mAllDayAgenda->selectedIncidence(); | 926 | incidence = mAllDayAgenda->selectedIncidence(); |
927 | if (incidence) selected.append(incidence); | 927 | if (incidence) selected.append(incidence); |
928 | 928 | ||
929 | return selected; | 929 | return selected; |
930 | } | 930 | } |
931 | 931 | ||
932 | DateList KOAgendaView::selectedDates() | 932 | DateList KOAgendaView::selectedDates() |
933 | { | 933 | { |
934 | DateList selected; | 934 | DateList selected; |
935 | QDate qd; | 935 | QDate qd; |
936 | 936 | ||
937 | qd = mAgenda->selectedIncidenceDate(); | 937 | qd = mAgenda->selectedIncidenceDate(); |
938 | if (qd.isValid()) selected.append(qd); | 938 | if (qd.isValid()) selected.append(qd); |
939 | 939 | ||
940 | qd = mAllDayAgenda->selectedIncidenceDate(); | 940 | qd = mAllDayAgenda->selectedIncidenceDate(); |
941 | if (qd.isValid()) selected.append(qd); | 941 | if (qd.isValid()) selected.append(qd); |
942 | 942 | ||
943 | return selected; | 943 | return selected; |
944 | } | 944 | } |
945 | 945 | ||
946 | 946 | ||
947 | void KOAgendaView::updateView() | 947 | void KOAgendaView::updateView() |
948 | { | 948 | { |
949 | if ( mBlockUpdating ) | 949 | if ( mBlockUpdating ) |
950 | return; | 950 | return; |
951 | // kdDebug() << "KOAgendaView::updateView()" << endl; | 951 | // kdDebug() << "KOAgendaView::updateView()" << endl; |
952 | fillAgenda(); | 952 | fillAgenda(); |
953 | 953 | ||
954 | } | 954 | } |
955 | 955 | ||
956 | 956 | ||
957 | /* | 957 | /* |
958 | Update configuration settings for the agenda view. This method is not | 958 | Update configuration settings for the agenda view. This method is not |
959 | complete. | 959 | complete. |
960 | */ | 960 | */ |
961 | void KOAgendaView::updateConfig() | 961 | void KOAgendaView::updateConfig() |
962 | { | 962 | { |
963 | if ( mBlockUpdating ) | 963 | if ( mBlockUpdating ) |
964 | return; | 964 | return; |
965 | if ( mAgenda->height() > 96 * KOPrefs::instance()->mHourSize ) { | 965 | if ( mAgenda->height() > 96 * KOPrefs::instance()->mHourSize ) { |
966 | int old = KOPrefs::instance()->mHourSize; | 966 | int old = KOPrefs::instance()->mHourSize; |
967 | KOPrefs::instance()->mHourSize = mAgenda->height()/96 +1; | 967 | KOPrefs::instance()->mHourSize = mAgenda->height()/96 +1; |
968 | //qDebug("KOPrefs::instance()->mHourSize adjusted %d to %d ", old,KOPrefs::instance()->mHourSize ); | 968 | //qDebug("KOPrefs::instance()->mHourSize adjusted %d to %d ", old,KOPrefs::instance()->mHourSize ); |
969 | } | 969 | } |
970 | 970 | ||
971 | 971 | ||
972 | // update config for children | 972 | // update config for children |
973 | mTimeLabels->updateConfig(); | 973 | mTimeLabels->updateConfig(); |
974 | mAgenda->storePosition(); | 974 | mAgenda->storePosition(); |
975 | mAgenda->updateConfig(); | 975 | mAgenda->updateConfig(); |
976 | mAllDayAgenda->updateConfig(); | 976 | mAllDayAgenda->updateConfig(); |
977 | // widget synchronization | 977 | // widget synchronization |
978 | //TODO: find a better way, maybe signal/slot | 978 | //TODO: find a better way, maybe signal/slot |
979 | mTimeLabels->positionChanged(); | 979 | mTimeLabels->positionChanged(); |
980 | 980 | ||
981 | // for some reason, this needs to be called explicitly | 981 | // for some reason, this needs to be called explicitly |
982 | mTimeLabels->repaint(); | 982 | mTimeLabels->repaint(); |
983 | 983 | ||
984 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); | 984 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); |
985 | 985 | ||
986 | // ToolTips displaying summary of events | 986 | // ToolTips displaying summary of events |
987 | KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() | 987 | KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() |
988 | ->mEnableToolTips); | 988 | ->mEnableToolTips); |
989 | 989 | ||
990 | //setHolidayMasks(); | 990 | //setHolidayMasks(); |
991 | 991 | ||
992 | //createDayLabels(); called by via updateView(); | 992 | //createDayLabels(); called by via updateView(); |
993 | mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); | 993 | mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); |
994 | updateView(); | 994 | updateView(); |
995 | mAgenda->restorePosition(); | 995 | mAgenda->restorePosition(); |
996 | } | 996 | } |
997 | 997 | ||
998 | 998 | ||
999 | void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) | 999 | void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) |
1000 | { | 1000 | { |
1001 | 1001 | ||
1002 | 1002 | ||
1003 | int xxx = item->cellX(); | 1003 | int xxx = item->cellX(); |
1004 | //qDebug("KOAgendaView::updateEventDates %d %d %d %d %d", xxx, mMinY.at(xxx),mMaxY.at(xxx),item->cellYTop(),item->cellYBottom() ); | 1004 | //qDebug("KOAgendaView::updateEventDates %d %d %d %d %d", xxx, mMinY.at(xxx),mMaxY.at(xxx),item->cellYTop(),item->cellYBottom() ); |
1005 | if ( xxx >= 0 && xxx < mMinY.count() && !item->isAllDay() ) { | 1005 | if ( xxx >= 0 && xxx < mMinY.count() && !item->isAllDay() ) { |
1006 | if ( mMinY.at(xxx) > item->cellYTop() ) | 1006 | if ( mMinY.at(xxx) > item->cellYTop() ) |
1007 | mMinY.at(xxx) = item->cellYTop(); | 1007 | mMinY.at(xxx) = item->cellYTop(); |
1008 | if ( mMaxY.at(xxx) < item->cellYBottom() ) | 1008 | if ( mMaxY.at(xxx) < item->cellYBottom() ) |
1009 | mMaxY.at(xxx) = item->cellYBottom(); | 1009 | mMaxY.at(xxx) = item->cellYBottom(); |
1010 | } | 1010 | } |
1011 | QDateTime startDt,endDt; | 1011 | QDateTime startDt,endDt; |
1012 | QDate startDate; | 1012 | QDate startDate; |
1013 | int lenInSecs; | 1013 | int lenInSecs; |
1014 | // if ( type == KOAgenda::RESIZETOP ) | 1014 | // if ( type == KOAgenda::RESIZETOP ) |
1015 | // qDebug("RESIZETOP "); | 1015 | // qDebug("RESIZETOP "); |
1016 | // if ( type == KOAgenda::RESIZEBOTTOM ) | 1016 | // if ( type == KOAgenda::RESIZEBOTTOM ) |
1017 | // qDebug("RESIZEBOTTOM "); | 1017 | // qDebug("RESIZEBOTTOM "); |
1018 | // if ( type == KOAgenda::MOVE ) | 1018 | // if ( type == KOAgenda::MOVE ) |
1019 | // qDebug("MOVE "); | 1019 | // qDebug("MOVE "); |
1020 | if ( item->incidence()->typeID() == eventID ) { | 1020 | if ( item->incidence()->typeID() == eventID ) { |
1021 | startDt =item->incidence()->dtStart(); | 1021 | startDt =item->incidence()->dtStart(); |
1022 | endDt = item->incidence()->dtEnd(); | 1022 | endDt = item->incidence()->dtEnd(); |
1023 | lenInSecs = startDt.secsTo( endDt ); | 1023 | lenInSecs = startDt.secsTo( endDt ); |
1024 | } | 1024 | } |
1025 | 1025 | ||
1026 | // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); | 1026 | // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); |
1027 | 1027 | ||
1028 | if ( item->incidence()->typeID()== todoID && item->mLastMoveXPos > 0 ) { | 1028 | if ( item->incidence()->typeID()== todoID && item->mLastMoveXPos > 0 ) { |
1029 | startDate = mSelectedDates[item->mLastMoveXPos]; | 1029 | startDate = mSelectedDates[item->mLastMoveXPos]; |
1030 | } else { | 1030 | } else { |
1031 | if (item->cellX() < 0) { | 1031 | if (item->cellX() < 0) { |
1032 | startDate = (mSelectedDates.first()).addDays(item->cellX()); | 1032 | startDate = (mSelectedDates.first()).addDays(item->cellX()); |
1033 | } else { | 1033 | } else { |
1034 | startDate = mSelectedDates[item->cellX()]; | 1034 | startDate = mSelectedDates[item->cellX()]; |
1035 | } | 1035 | } |
1036 | } | 1036 | } |
1037 | startDt.setDate(startDate); | 1037 | startDt.setDate(startDate); |
1038 | 1038 | ||
1039 | if (item->incidence()->doesFloat()) { | 1039 | if (item->incidence()->doesFloat()) { |
1040 | endDt.setDate(startDate.addDays(item->cellWidth() - 1)); | 1040 | endDt.setDate(startDate.addDays(item->cellWidth() - 1)); |
1041 | } else { | 1041 | } else { |
1042 | if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) | 1042 | if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) |
1043 | startDt.setTime(mAgenda->gyToTime(item->cellYTop())); | 1043 | startDt.setTime(mAgenda->gyToTime(item->cellYTop())); |
1044 | if ( item->incidence()->typeID() == eventID ) { | 1044 | if ( item->incidence()->typeID() == eventID ) { |
1045 | if ( type == KOAgenda::MOVE ) { | 1045 | if ( type == KOAgenda::MOVE ) { |
1046 | endDt = startDt.addSecs(lenInSecs); | 1046 | endDt = startDt.addSecs(lenInSecs); |
1047 | 1047 | ||
1048 | } else if ( type == KOAgenda::RESIZEBOTTOM ) { | 1048 | } else if ( type == KOAgenda::RESIZEBOTTOM ) { |
1049 | if (item->lastMultiItem()) { | 1049 | if (item->lastMultiItem()) { |
1050 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); | 1050 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); |
1051 | endDt.setDate(startDate. | 1051 | endDt.setDate(startDate. |
1052 | addDays(item->lastMultiItem()->cellX() - item->cellX())); | 1052 | addDays(item->lastMultiItem()->cellX() - item->cellX())); |
1053 | } else { | 1053 | } else { |
1054 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); | 1054 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); |
1055 | endDt.setDate(startDate); | 1055 | endDt.setDate(startDate); |
1056 | } | 1056 | } |
1057 | } | 1057 | } |
1058 | } else { | 1058 | } else { |
1059 | // todo | 1059 | // todo |
1060 | if (item->lastMultiItem()) { | 1060 | if (item->lastMultiItem()) { |
1061 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); | 1061 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); |
1062 | endDt.setDate(startDate. | 1062 | endDt.setDate(startDate. |
1063 | addDays(item->lastMultiItem()->cellX() - item->cellX())); | 1063 | addDays(item->lastMultiItem()->cellX() - item->cellX())); |
1064 | } else { | 1064 | } else { |
1065 | //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); | 1065 | //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); |
1066 | if ( item->cellYBottom() > 0 ) | 1066 | if ( item->cellYBottom() > 0 ) |
1067 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); | 1067 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); |
1068 | else | 1068 | else |
1069 | endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); | 1069 | endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); |
1070 | endDt.setDate(startDate); | 1070 | endDt.setDate(startDate); |
1071 | } | 1071 | } |
1072 | } | 1072 | } |
1073 | } | 1073 | } |
1074 | if ( item->incidence()->typeID() == eventID ) { | 1074 | if ( item->incidence()->typeID() == eventID ) { |
1075 | item->incidence()->setDtStart(startDt); | 1075 | item->incidence()->setDtStart(startDt); |
1076 | (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); | 1076 | (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); |
1077 | } else if ( item->incidence()->typeID() == todoID ) { | 1077 | } else if ( item->incidence()->typeID() == todoID ) { |
1078 | Todo* to = static_cast<Todo*>(item->incidence()); | 1078 | Todo* to = static_cast<Todo*>(item->incidence()); |
1079 | 1079 | ||
1080 | to->setDtDue(endDt); | 1080 | to->setDtDue(endDt); |
1081 | if ( to->hasStartDate() ) { | 1081 | if ( to->hasStartDate() ) { |
1082 | if (to->dtStart() >= to->dtDue() ) | 1082 | if (to->dtStart() >= to->dtDue() ) |
1083 | to->setDtStart(to->dtDue().addDays( -2 )); | 1083 | to->setDtStart(to->dtDue().addDays( -2 )); |
1084 | } | 1084 | } |
1085 | 1085 | ||
1086 | } | 1086 | } |
1087 | //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); | 1087 | //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); |
1088 | item->incidence()->setRevision(item->incidence()->revision()+1); | 1088 | item->incidence()->setRevision(item->incidence()->revision()+1); |
1089 | item->setItemDate(startDt.date()); | 1089 | item->setItemDate(startDt.date()); |
1090 | //item->updateItem(); | 1090 | //item->updateItem(); |
1091 | if ( item->incidence()->typeID() == todoID ) { | 1091 | if ( item->incidence()->typeID() == todoID ) { |
1092 | emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); | 1092 | emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); |
1093 | 1093 | ||
1094 | } | 1094 | } |
1095 | else | 1095 | else |
1096 | emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); | 1096 | emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); |
1097 | item->updateItem(); | 1097 | item->updateItem(); |
1098 | } | 1098 | } |
1099 | 1099 | ||
1100 | void KOAgendaView::showDates( const QDate &start, const QDate &end ) | 1100 | void KOAgendaView::showDates( const QDate &start, const QDate &end ) |
1101 | { | 1101 | { |
1102 | // kdDebug() << "KOAgendaView::selectDates" << endl; | 1102 | // kdDebug() << "KOAgendaView::selectDates" << endl; |
1103 | 1103 | ||
1104 | mSelectedDates.clear(); | 1104 | mSelectedDates.clear(); |
1105 | // qDebug("KOAgendaView::showDates "); | 1105 | // qDebug("KOAgendaView::showDates "); |
1106 | QDate d = start; | 1106 | QDate d = start; |
1107 | while (d <= end) { | 1107 | while (d <= end) { |
1108 | mSelectedDates.append(d); | 1108 | mSelectedDates.append(d); |
1109 | d = d.addDays( 1 ); | 1109 | d = d.addDays( 1 ); |
1110 | } | 1110 | } |
1111 | 1111 | ||
1112 | // and update the view | 1112 | // and update the view |
1113 | fillAgenda(); | 1113 | fillAgenda(); |
1114 | } | 1114 | } |
1115 | 1115 | ||
1116 | 1116 | ||
1117 | void KOAgendaView::showEvents(QPtrList<Event>) | 1117 | void KOAgendaView::showEvents(QPtrList<Event>) |
1118 | { | 1118 | { |
1119 | kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; | 1119 | kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; |
1120 | } | 1120 | } |
1121 | 1121 | ||
1122 | void KOAgendaView::changeEventDisplay(Event *, int) | 1122 | void KOAgendaView::changeEventDisplay(Event *, int) |
1123 | { | 1123 | { |
1124 | // qDebug("KOAgendaView::changeEventDisplay "); | 1124 | // qDebug("KOAgendaView::changeEventDisplay "); |
1125 | // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; | 1125 | // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; |
1126 | // this should be re-written to be MUCH smarter. Right now we | 1126 | // this should be re-written to be MUCH smarter. Right now we |
1127 | // are just playing dumb. | 1127 | // are just playing dumb. |
1128 | fillAgenda(); | 1128 | fillAgenda(); |
1129 | } | 1129 | } |
1130 | 1130 | ||
1131 | void KOAgendaView::fillAgenda(const QDate &) | 1131 | void KOAgendaView::fillAgenda(const QDate &) |
1132 | { | 1132 | { |
1133 | // qDebug("KOAgendaView::fillAgenda "); | 1133 | // qDebug("KOAgendaView::fillAgenda "); |
1134 | fillAgenda(); | 1134 | fillAgenda(); |
1135 | } | 1135 | } |
1136 | 1136 | ||
1137 | void KOAgendaView::fillAgenda() | 1137 | void KOAgendaView::fillAgenda() |
1138 | { | 1138 | { |
1139 | if ( globalFlagBlockStartup ) | 1139 | if ( globalFlagBlockStartup ) |
1140 | return; | 1140 | return; |
1141 | if ( globalFlagBlockAgenda == 1 ) | 1141 | if ( globalFlagBlockAgenda == 1 ) |
1142 | return; | 1142 | return; |
1143 | static bool onlyOne = false; | 1143 | static bool onlyOne = false; |
1144 | if ( onlyOne ) | 1144 | if ( onlyOne ) |
1145 | return; | 1145 | return; |
1146 | onlyOne = true; | 1146 | onlyOne = true; |
1147 | //if ( globalFlagBlockAgenda == 2 ) | 1147 | //if ( globalFlagBlockAgenda == 2 ) |
1148 | //globalFlagBlockAgenda = 0; | 1148 | //globalFlagBlockAgenda = 0; |
1149 | // globalFlagBlockPainting = false; | 1149 | // globalFlagBlockPainting = false; |
1150 | if ( globalFlagBlockAgenda == 0 ) | 1150 | if ( globalFlagBlockAgenda == 0 ) |
1151 | globalFlagBlockAgenda = 1; | 1151 | globalFlagBlockAgenda = 1; |
1152 | // clearView(); | 1152 | // clearView(); |
1153 | //qDebug("fillAgenda()++++ "); | 1153 | //qDebug("fillAgenda()++++ "); |
1154 | globalFlagBlockAgendaItemPaint = 1; | 1154 | globalFlagBlockAgendaItemPaint = 1; |
1155 | 1155 | ||
1156 | mAllDayAgenda->changeColumns(mSelectedDates.count()); | 1156 | mAllDayAgenda->changeColumns(mSelectedDates.count()); |
1157 | mAgenda->changeColumns(mSelectedDates.count()); | 1157 | mAgenda->changeColumns(mSelectedDates.count()); |
1158 | qApp->processEvents(); | 1158 | qApp->processEvents(); |
1159 | mEventIndicatorTop->changeColumns(mSelectedDates.count()); | 1159 | mEventIndicatorTop->changeColumns(mSelectedDates.count()); |
1160 | mEventIndicatorBottom->changeColumns(mSelectedDates.count()); | 1160 | mEventIndicatorBottom->changeColumns(mSelectedDates.count()); |
1161 | setHolidayMasks(); | 1161 | setHolidayMasks(); |
1162 | 1162 | ||
1163 | mMinY.resize(mSelectedDates.count()); | 1163 | mMinY.resize(mSelectedDates.count()); |
1164 | mMaxY.resize(mSelectedDates.count()); | 1164 | mMaxY.resize(mSelectedDates.count()); |
1165 | 1165 | ||
1166 | QPtrList<Event> dayEvents; | 1166 | QPtrList<Event> dayEvents; |
1167 | 1167 | ||
1168 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. | 1168 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. |
1169 | // Therefore, gtodoset all of them. | 1169 | // Therefore, gtodoset all of them. |
1170 | QPtrList<Todo> todos = calendar()->todos(); | 1170 | QPtrList<Todo> todos = calendar()->todos(); |
1171 | 1171 | ||
1172 | mAgenda->setDateList(mSelectedDates); | 1172 | mAgenda->setDateList(mSelectedDates); |
1173 | 1173 | ||
1174 | QDate today = QDate::currentDate(); | 1174 | QDate today = QDate::currentDate(); |
1175 | 1175 | ||
1176 | DateList::ConstIterator dit; | 1176 | DateList::ConstIterator dit; |
1177 | int curCol = 0; | 1177 | int curCol = 0; |
1178 | int maxCol = mSelectedDates.count()-1; | 1178 | int maxCol = mSelectedDates.count()-1; |
1179 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { | 1179 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { |
1180 | QDate currentDate = *dit; | 1180 | QDate currentDate = *dit; |
1181 | // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() | 1181 | // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() |
1182 | // << endl; | 1182 | // << endl; |
1183 | 1183 | ||
1184 | dayEvents = calendar()->events(currentDate,false); | 1184 | dayEvents = calendar()->events(currentDate,false); |
1185 | 1185 | ||
1186 | // Default values, which can never be reached | 1186 | // Default values, which can never be reached |
1187 | mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; | 1187 | mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; |
1188 | mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; | 1188 | mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; |
1189 | 1189 | ||
1190 | unsigned int numEvent; | 1190 | unsigned int numEvent; |
1191 | //qDebug("+++++NUMEVENT %d", dayEvents.count()); | 1191 | //qDebug("+++++NUMEVENT %d", dayEvents.count()); |
1192 | for(numEvent=0;numEvent<dayEvents.count();++numEvent) { | 1192 | for(numEvent=0;numEvent<dayEvents.count();++numEvent) { |
1193 | Event *event = dayEvents.at(numEvent); | 1193 | Event *event = dayEvents.at(numEvent); |
1194 | if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) | 1194 | if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) |
1195 | if ( event->uid().left(15) == QString("last-syncEvent-") ) | 1195 | if ( event->uid().left(15) == QString("last-syncEvent-") ) |
1196 | continue; | 1196 | continue; |
1197 | // kdDebug() << " Event: " << event->summary() << endl; | 1197 | // kdDebug() << " Event: " << event->summary() << endl; |
1198 | 1198 | ||
1199 | int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; | 1199 | int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; |
1200 | int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; | 1200 | int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; |
1201 | 1201 | ||
1202 | // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; | 1202 | // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; |
1203 | 1203 | ||
1204 | if (event->doesFloat()) { | 1204 | if (event->doesFloat()) { |
1205 | if (event->doesRecur()) { | 1205 | if (event->doesRecur()) { |
1206 | if (event->isMultiDay() ) { | 1206 | if (event->isMultiDay() ) { |
1207 | endX = endX - beginX;// endX is now number of days | 1207 | endX = endX - beginX;// endX is now number of days |
1208 | if ( event->recursOn( currentDate ) ) { | 1208 | if ( event->recursOn( currentDate ) ) { |
1209 | endX += curCol; | 1209 | endX += curCol; |
1210 | beginX = curCol; | 1210 | beginX = curCol; |
1211 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); | 1211 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); |
1212 | } else { | 1212 | } else { |
1213 | //qDebug("days endX %d curCol %d max Col %d %s",endX ,curCol, maxCol, currentDate.toString().latin1()); | 1213 | //qDebug("days endX %d curCol %d max Col %d %s",endX ,curCol, maxCol, currentDate.toString().latin1()); |
1214 | if ( curCol == maxCol && maxCol+1 < endX ) { | 1214 | if ( curCol == maxCol && maxCol+1 < endX ) { |
1215 | int i; | 1215 | int i; |
1216 | for ( i = 1; i< endX; ++i ) { | 1216 | for ( i = 1; i< endX; ++i ) { |
1217 | if ( event->recursOn( currentDate.addDays( -i ) ) ) | 1217 | if ( event->recursOn( currentDate.addDays( -i ) ) ) |
1218 | break; | 1218 | break; |
1219 | } | 1219 | } |
1220 | if ( i > maxCol ) { | 1220 | if ( i > maxCol ) { |
1221 | mAllDayAgenda->insertAllDayItem(event,currentDate,0,curCol); | 1221 | mAllDayAgenda->insertAllDayItem(event,currentDate,0,curCol); |
1222 | //qDebug("BINGO "); | 1222 | //qDebug("BINGO "); |
1223 | } | 1223 | } |
1224 | 1224 | ||
1225 | } else { | 1225 | } else { |
1226 | QDate dateit = currentDate.addDays( -endX ); | 1226 | QDate dateit = currentDate.addDays( -endX ); |
1227 | if ( event->recursOn( dateit ) ) { | 1227 | if ( event->recursOn( dateit ) ) { |
1228 | //qDebug("found %d %d %d %s", endX,curCol, curCol-endX ,dateit.toString().latin1() ); | 1228 | //qDebug("found %d %d %d %s", endX,curCol, curCol-endX ,dateit.toString().latin1() ); |
1229 | if ( curCol-endX < 0 ) { | 1229 | if ( curCol-endX < 0 ) { |
1230 | mAllDayAgenda->insertAllDayItem(event,currentDate,0,curCol); | 1230 | mAllDayAgenda->insertAllDayItem(event,currentDate,0,curCol); |
1231 | } | 1231 | } |
1232 | } | 1232 | } |
1233 | } | 1233 | } |
1234 | } | 1234 | } |
1235 | } else { | 1235 | } else { |
1236 | mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); | 1236 | mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); |
1237 | } | 1237 | } |
1238 | |||
1239 | } else { | 1238 | } else { |
1240 | if (beginX <= 0 && curCol == 0) { | 1239 | if (beginX <= 0 && curCol == 0) { |
1241 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); | 1240 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); |
1242 | } else if (beginX == curCol) { | 1241 | } else if (beginX == curCol) { |
1243 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); | 1242 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); |
1244 | } | 1243 | } |
1245 | } | 1244 | } |
1246 | } else if (event->isMultiDay()) { | 1245 | } else if (event->isMultiDay()) { |
1247 | if ( event->doesRecur () ) { | 1246 | if ( event->doesRecur () ) { |
1248 | QDate dateit = currentDate; | 1247 | QDate dateit = currentDate; |
1249 | int count = 0; | 1248 | int count = 0; |
1250 | int max = event->dtStart().daysTo( event->dtEnd() ) +2; | 1249 | int max = event->dtStart().daysTo( event->dtEnd() ) +2; |
1251 | while (! event->recursOn( dateit ) && count <= max ) { | 1250 | while (! event->recursOn( dateit ) && count <= max ) { |
1252 | ++count; | 1251 | ++count; |
1253 | dateit = dateit.addDays( -1 ); | 1252 | dateit = dateit.addDays( -1 ); |
1254 | } | 1253 | } |
1255 | bool ok; | 1254 | bool ok; |
1256 | QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); | 1255 | QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); |
1257 | if ( ok ) | 1256 | if ( ok ) |
1258 | { | 1257 | { |
1259 | int secs = event->dtStart().secsTo( event->dtEnd() ); | 1258 | int secs = event->dtStart().secsTo( event->dtEnd() ); |
1260 | QDateTime nextOcend =nextOcstart.addSecs( secs ); ; | 1259 | QDateTime nextOcend =nextOcstart.addSecs( secs ); ; |
1261 | beginX = currentDate.daysTo(nextOcstart.date()) + curCol; | 1260 | beginX = currentDate.daysTo(nextOcstart.date()) + curCol; |
1262 | endX = currentDate.daysTo(nextOcend.date()) + curCol; | 1261 | endX = currentDate.daysTo(nextOcend.date()) + curCol; |
1263 | 1262 | ||
1264 | } | 1263 | } |
1265 | } | 1264 | } |
1266 | int startY = mAgenda->timeToY(event->dtStart().time()); | 1265 | int startY = mAgenda->timeToY(event->dtStart().time()); |
1267 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; | 1266 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; |
1268 | //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); | 1267 | //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); |
1269 | if ((beginX <= 0 && curCol == 0) || beginX == curCol) { | 1268 | if ((beginX <= 0 && curCol == 0) || beginX == curCol) { |
1270 | //qDebug("insert!!! "); | 1269 | //qDebug("insert!!! "); |
1271 | mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); | 1270 | mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); |
1272 | } | 1271 | } |
1273 | if (beginX == curCol) { | 1272 | if (beginX == curCol) { |
1274 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); | 1273 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); |
1275 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; | 1274 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; |
1276 | } else if (endX == curCol) { | 1275 | } else if (endX == curCol) { |
1277 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); | 1276 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); |
1278 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; | 1277 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; |
1279 | } else { | 1278 | } else { |
1280 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); | 1279 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); |
1281 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); | 1280 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); |
1282 | } | 1281 | } |
1283 | } else { | 1282 | } else { |
1284 | int startY = mAgenda->timeToY(event->dtStart().time()); | 1283 | int startY = mAgenda->timeToY(event->dtStart().time()); |
1285 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; | 1284 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; |
1286 | if (endY < startY) endY = startY; | 1285 | if (endY < startY) endY = startY; |
1287 | mAgenda->insertItem(event,currentDate,curCol,startY,endY); | 1286 | mAgenda->insertItem(event,currentDate,curCol,startY,endY); |
1288 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; | 1287 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; |
1289 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; | 1288 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; |
1290 | } | 1289 | } |
1291 | } | 1290 | } |
1292 | // ---------- [display Todos -------------- | 1291 | // ---------- [display Todos -------------- |
1293 | unsigned int numTodo; | 1292 | unsigned int numTodo; |
1294 | for (numTodo = 0; numTodo < todos.count(); ++numTodo) { | 1293 | for (numTodo = 0; numTodo < todos.count(); ++numTodo) { |
1295 | Todo *todo = todos.at(numTodo); | 1294 | Todo *todo = todos.at(numTodo); |
1296 | 1295 | ||
1297 | if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date | 1296 | if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date |
1298 | if ( todo->hasCompletedDate() && !KOPrefs::instance()->mShowCompletedTodoInAgenda ) continue; | 1297 | if ( todo->hasCompletedDate() && !KOPrefs::instance()->mShowCompletedTodoInAgenda ) continue; |
1299 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. | 1298 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. |
1300 | // Already completed items can be displayed on their original due date | 1299 | // Already completed items can be displayed on their original due date |
1301 | //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda | 1300 | //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda |
1302 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; | 1301 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; |
1303 | bool fillIn = false; | 1302 | bool fillIn = false; |
1304 | if ( todo->hasCompletedDate() && todo->completed().date() == currentDate ) | 1303 | if ( todo->hasCompletedDate() && todo->completed().date() == currentDate ) |
1305 | fillIn = true; | 1304 | fillIn = true; |
1306 | if ( ! fillIn && !todo->hasCompletedDate() ) | 1305 | if ( ! fillIn && !todo->hasCompletedDate() ) |
1307 | fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue); | 1306 | fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue); |
1308 | if ( fillIn ) { | 1307 | if ( fillIn ) { |
1309 | if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue | 1308 | if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue |
1310 | if ( KOPrefs::instance()->mShowTodoInAgenda ) | 1309 | if ( KOPrefs::instance()->mShowTodoInAgenda ) |
1311 | mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); | 1310 | mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); |
1312 | } | 1311 | } |
1313 | else { | 1312 | else { |
1314 | QDateTime dt; | 1313 | QDateTime dt; |
1315 | if ( todo->hasCompletedDate() ) | 1314 | if ( todo->hasCompletedDate() ) |
1316 | dt = todo->completed(); | 1315 | dt = todo->completed(); |
1317 | else | 1316 | else |
1318 | dt = todo->dtDue();; | 1317 | dt = todo->dtDue();; |
1319 | 1318 | ||
1320 | 1319 | ||
1321 | int endY = mAgenda->timeToY(dt.time()) - 1; | 1320 | int endY = mAgenda->timeToY(dt.time()) - 1; |
1322 | int hi = (18/KOPrefs::instance()->mHourSize); | 1321 | int hi = (18/KOPrefs::instance()->mHourSize); |
1323 | //qDebug("hei %d ",KOPrefs::instance()->mHourSize); | 1322 | //qDebug("hei %d ",KOPrefs::instance()->mHourSize); |
1324 | int startY = endY -hi; | 1323 | int startY = endY -hi; |
1325 | 1324 | ||
1326 | mAgenda->insertItem(todo,currentDate,curCol,startY,endY); | 1325 | mAgenda->insertItem(todo,currentDate,curCol,startY,endY); |
1327 | 1326 | ||
1328 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; | 1327 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; |
1329 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; | 1328 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; |
1330 | } | 1329 | } |
1331 | } | 1330 | } |
1332 | } | 1331 | } |
1333 | // ---------- display Todos] -------------- | 1332 | // ---------- display Todos] -------------- |
1334 | 1333 | ||
1335 | ++curCol; | 1334 | ++curCol; |
1336 | } | 1335 | } |
1337 | mAgenda->hideUnused(); | 1336 | mAgenda->hideUnused(); |
1338 | mAllDayAgenda->hideUnused(); | 1337 | mAllDayAgenda->hideUnused(); |
1339 | mAgenda->checkScrollBoundaries(); | 1338 | mAgenda->checkScrollBoundaries(); |
1340 | deleteSelectedDateTime(); | 1339 | deleteSelectedDateTime(); |
1341 | createDayLabels(); | 1340 | createDayLabels(); |
1342 | emit incidenceSelected( 0 ); | 1341 | emit incidenceSelected( 0 ); |
1343 | 1342 | ||
1344 | if ( globalFlagBlockAgenda == 2 ) { | 1343 | if ( globalFlagBlockAgenda == 2 ) { |
1345 | if ( KOPrefs::instance()->mSetTimeToDayStartAt ) | 1344 | if ( KOPrefs::instance()->mSetTimeToDayStartAt ) |
1346 | setStartHour( KOPrefs::instance()->mDayBegins ); | 1345 | setStartHour( KOPrefs::instance()->mDayBegins ); |
1347 | else if ( KOPrefs::instance()->mCenterOnCurrentTime ) | 1346 | else if ( KOPrefs::instance()->mCenterOnCurrentTime ) |
1348 | setStartHour( QTime::currentTime ().hour() ); | 1347 | setStartHour( QTime::currentTime ().hour() ); |
1349 | } | 1348 | } |
1350 | qApp->processEvents(); | 1349 | qApp->processEvents(); |
1351 | globalFlagBlockAgenda = 0; | 1350 | globalFlagBlockAgenda = 0; |
1352 | mAllDayAgenda->drawContentsToPainter(); | 1351 | mAllDayAgenda->drawContentsToPainter(); |
1353 | mAgenda->drawContentsToPainter(); | 1352 | mAgenda->drawContentsToPainter(); |
1354 | repaintAgenda(); | 1353 | repaintAgenda(); |
1355 | startIdleTimeout(); | 1354 | startIdleTimeout(); |
1356 | onlyOne = false; | 1355 | onlyOne = false; |
1357 | } | 1356 | } |
1358 | void KOAgendaView::repaintAgenda() | 1357 | void KOAgendaView::repaintAgenda() |
1359 | { | 1358 | { |
1360 | mAgenda->viewport()->repaint( false ); | 1359 | mAgenda->viewport()->repaint( false ); |
1361 | mAllDayAgenda->viewport()->repaint( false ); | 1360 | mAllDayAgenda->viewport()->repaint( false ); |
1362 | mAgenda->finishUpdate(); | 1361 | mAgenda->finishUpdate(); |
1363 | mAllDayAgenda->finishUpdate(); | 1362 | mAllDayAgenda->finishUpdate(); |
1364 | } | 1363 | } |
1365 | 1364 | ||
1366 | 1365 | ||
1367 | void KOAgendaView::clearView() | 1366 | void KOAgendaView::clearView() |
1368 | { | 1367 | { |
1369 | mAllDayAgenda->clear(); | 1368 | mAllDayAgenda->clear(); |
1370 | mAgenda->clear(); | 1369 | mAgenda->clear(); |
1371 | } | 1370 | } |
1372 | void KOAgendaView::clearList() | 1371 | void KOAgendaView::clearList() |
1373 | { | 1372 | { |
1374 | clearView(); | 1373 | clearView(); |
1375 | mAllDayAgenda->hideUnused(); | 1374 | mAllDayAgenda->hideUnused(); |
1376 | mAgenda->hideUnused(); | 1375 | mAgenda->hideUnused(); |
1377 | } | 1376 | } |
1378 | 1377 | ||
1379 | void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 1378 | void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
1380 | const QDate &td) | 1379 | const QDate &td) |
1381 | { | 1380 | { |
1382 | #ifndef KORG_NOPRINTER | 1381 | #ifndef KORG_NOPRINTER |
1383 | if (fd == td) | 1382 | if (fd == td) |
1384 | calPrinter->preview(CalPrinter::Day, fd, td); | 1383 | calPrinter->preview(CalPrinter::Day, fd, td); |
1385 | else | 1384 | else |
1386 | calPrinter->preview(CalPrinter::Week, fd, td); | 1385 | calPrinter->preview(CalPrinter::Week, fd, td); |
1387 | #endif | 1386 | #endif |
1388 | } | 1387 | } |
1389 | 1388 | ||
1390 | // void KOAgendaView::updateMovedTodo() | 1389 | // void KOAgendaView::updateMovedTodo() |
1391 | // { | 1390 | // { |
1392 | // // updateConfig(); | 1391 | // // updateConfig(); |
1393 | // // emit updateTodoViews(); | 1392 | // // emit updateTodoViews(); |
1394 | // } | 1393 | // } |
1395 | 1394 | ||
1396 | void KOAgendaView::slotShowDateView( int mode , int d ) | 1395 | void KOAgendaView::slotShowDateView( int mode , int d ) |
1397 | { | 1396 | { |
1398 | if ( d >= mSelectedDates.count() ) { | 1397 | if ( d >= mSelectedDates.count() ) { |
1399 | qDebug("KOAgendaView::slotShowDateView datecounterror %d %d ", d, mSelectedDates.count() ); | 1398 | qDebug("KOAgendaView::slotShowDateView datecounterror %d %d ", d, mSelectedDates.count() ); |
1400 | 1399 | ||
1401 | } else { | 1400 | } else { |
1402 | QDate day = mSelectedDates[d]; | 1401 | QDate day = mSelectedDates[d]; |
1403 | emit showDateView(mode , day ); | 1402 | emit showDateView(mode , day ); |
1404 | } | 1403 | } |
1405 | 1404 | ||
1406 | } | 1405 | } |
1407 | void KOAgendaView::newEvent(int gx, int gy) | 1406 | void KOAgendaView::newEvent(int gx, int gy) |
1408 | { | 1407 | { |
1409 | if (!mSelectedDates.count()) return; | 1408 | if (!mSelectedDates.count()) return; |
1410 | 1409 | ||
1411 | QDate day = mSelectedDates[gx]; | 1410 | QDate day = mSelectedDates[gx]; |
1412 | 1411 | ||
1413 | QTime time = mAgenda->gyToTime(gy); | 1412 | QTime time = mAgenda->gyToTime(gy); |
1414 | QDateTime dt(day,time); | 1413 | QDateTime dt(day,time); |
1415 | // if ( dt < QDateTime::currentDateTime () ) | 1414 | // if ( dt < QDateTime::currentDateTime () ) |
1416 | // dt = QDateTime::currentDateTime ().addSecs( 3600 ); | 1415 | // dt = QDateTime::currentDateTime ().addSecs( 3600 ); |
1417 | emit newEventSignal(dt); | 1416 | emit newEventSignal(dt); |
1418 | } | 1417 | } |
1419 | 1418 | ||
1420 | void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd) | 1419 | void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd) |
1421 | { | 1420 | { |
1422 | if (!mSelectedDates.count()) return; | 1421 | if (!mSelectedDates.count()) return; |
1423 | 1422 | ||
1424 | QDate dayStart = mSelectedDates[gxStart]; | 1423 | QDate dayStart = mSelectedDates[gxStart]; |
1425 | QDate dayEnd = mSelectedDates[gxEnd]; | 1424 | QDate dayEnd = mSelectedDates[gxEnd]; |
1426 | 1425 | ||
1427 | QTime timeStart = mAgenda->gyToTime(gyStart); | 1426 | QTime timeStart = mAgenda->gyToTime(gyStart); |
1428 | QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); | 1427 | QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); |
1429 | 1428 | ||
1430 | QDateTime dtStart(dayStart,timeStart); | 1429 | QDateTime dtStart(dayStart,timeStart); |
1431 | QDateTime dtEnd(dayEnd,timeEnd); | 1430 | QDateTime dtEnd(dayEnd,timeEnd); |
1432 | 1431 | ||
1433 | emit newEventSignal(dtStart,dtEnd); | 1432 | emit newEventSignal(dtStart,dtEnd); |
1434 | } | 1433 | } |
1435 | 1434 | ||
1436 | void KOAgendaView::newEventAllDay(int gx, int ) | 1435 | void KOAgendaView::newEventAllDay(int gx, int ) |
1437 | { | 1436 | { |
1438 | if (!mSelectedDates.count()) return; | 1437 | if (!mSelectedDates.count()) return; |
1439 | 1438 | ||
1440 | QDate day = mSelectedDates[gx]; | 1439 | QDate day = mSelectedDates[gx]; |
1441 | 1440 | ||
1442 | emit newEventSignal(day); | 1441 | emit newEventSignal(day); |
1443 | } | 1442 | } |
1444 | void KOAgendaView::newTodoAllDay(int gx, int ) | 1443 | void KOAgendaView::newTodoAllDay(int gx, int ) |
1445 | { | 1444 | { |
1446 | if (!mSelectedDates.count()) return; | 1445 | if (!mSelectedDates.count()) return; |
1447 | 1446 | ||
1448 | QDateTime day (mSelectedDates[gx] ); | 1447 | QDateTime day (mSelectedDates[gx] ); |
1449 | emit newTodoSignal(day, true); | 1448 | emit newTodoSignal(day, true); |
1450 | } | 1449 | } |
1451 | void KOAgendaView::newTodo(int gx, int gy ) | 1450 | void KOAgendaView::newTodo(int gx, int gy ) |
1452 | { | 1451 | { |
1453 | if (!mSelectedDates.count()) return; | 1452 | if (!mSelectedDates.count()) return; |
1454 | QDate dayStart = mSelectedDates[gx]; | 1453 | QDate dayStart = mSelectedDates[gx]; |
1455 | QTime timeStart = mAgenda->gyToTime(gy); | 1454 | QTime timeStart = mAgenda->gyToTime(gy); |
1456 | QDateTime dt (dayStart,timeStart); | 1455 | QDateTime dt (dayStart,timeStart); |
1457 | emit newTodoSignal( dt, false ); | 1456 | emit newTodoSignal( dt, false ); |
1458 | } | 1457 | } |
1459 | 1458 | ||
1460 | void KOAgendaView::updateEventIndicatorTop(int newY) | 1459 | void KOAgendaView::updateEventIndicatorTop(int newY) |
1461 | { | 1460 | { |
1462 | uint i; | 1461 | uint i; |
1463 | for(i=0;i<mMinY.size();++i) { | 1462 | for(i=0;i<mMinY.size();++i) { |
1464 | if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true); | 1463 | if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true); |
1465 | else mEventIndicatorTop->enableColumn(i,false); | 1464 | else mEventIndicatorTop->enableColumn(i,false); |
1466 | } | 1465 | } |
1467 | 1466 | ||
1468 | mEventIndicatorTop->update(); | 1467 | mEventIndicatorTop->update(); |
1469 | } | 1468 | } |
1470 | 1469 | ||
1471 | void KOAgendaView::updateEventIndicatorBottom(int newY) | 1470 | void KOAgendaView::updateEventIndicatorBottom(int newY) |
1472 | { | 1471 | { |
1473 | uint i; | 1472 | uint i; |
1474 | for(i=0;i<mMaxY.size();++i) { | 1473 | for(i=0;i<mMaxY.size();++i) { |
1475 | if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true); | 1474 | if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true); |
1476 | else mEventIndicatorBottom->enableColumn(i,false); | 1475 | else mEventIndicatorBottom->enableColumn(i,false); |
1477 | } | 1476 | } |
1478 | 1477 | ||
1479 | mEventIndicatorBottom->update(); | 1478 | mEventIndicatorBottom->update(); |
1480 | } | 1479 | } |
1481 | 1480 | ||
1482 | void KOAgendaView::startDrag(Event *event) | 1481 | void KOAgendaView::startDrag(Event *event) |
1483 | { | 1482 | { |
1484 | #ifndef KORG_NODND | 1483 | #ifndef KORG_NODND |
1485 | DndFactory factory( calendar() ); | 1484 | DndFactory factory( calendar() ); |
1486 | ICalDrag *vd = factory.createDrag(event,this); | 1485 | ICalDrag *vd = factory.createDrag(event,this); |
1487 | if (vd->drag()) { | 1486 | if (vd->drag()) { |
1488 | kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl; | 1487 | kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl; |
1489 | } | 1488 | } |
1490 | #endif | 1489 | #endif |
1491 | } | 1490 | } |
1492 | 1491 | ||
1493 | void KOAgendaView::readSettings() | 1492 | void KOAgendaView::readSettings() |
1494 | { | 1493 | { |
1495 | readSettings(KOGlobals::config()); | 1494 | readSettings(KOGlobals::config()); |
1496 | } | 1495 | } |
1497 | 1496 | ||
1498 | void KOAgendaView::readSettings(KConfig *config) | 1497 | void KOAgendaView::readSettings(KConfig *config) |
1499 | { | 1498 | { |
1500 | // kdDebug() << "KOAgendaView::readSettings()" << endl; | 1499 | // kdDebug() << "KOAgendaView::readSettings()" << endl; |
1501 | 1500 | ||
1502 | config->setGroup("Views"); | 1501 | config->setGroup("Views"); |
1503 | 1502 | ||
1504 | //#ifndef KORG_NOSPLITTER | 1503 | //#ifndef KORG_NOSPLITTER |
1505 | QValueList<int> sizes = config->readIntListEntry("Separator AgendaView"); | 1504 | QValueList<int> sizes = config->readIntListEntry("Separator AgendaView"); |
1506 | if (sizes.count() == 2) { | 1505 | if (sizes.count() == 2) { |
1507 | if ( sizes[0] < 20 ) { | 1506 | if ( sizes[0] < 20 ) { |
1508 | sizes[1] = sizes[1] +20 - sizes[0]; | 1507 | sizes[1] = sizes[1] +20 - sizes[0]; |
1509 | sizes[0] = 20; | 1508 | sizes[0] = 20; |
1510 | } | 1509 | } |
1511 | mSplitterAgenda->setSizes(sizes); | 1510 | mSplitterAgenda->setSizes(sizes); |
1512 | // qDebug("read %d %d ",sizes[0],sizes[1] ); | 1511 | // qDebug("read %d %d ",sizes[0],sizes[1] ); |
1513 | } | 1512 | } |
1514 | //#endif | 1513 | //#endif |
1515 | 1514 | ||
1516 | // updateConfig(); | 1515 | // updateConfig(); |
1517 | } | 1516 | } |
1518 | 1517 | ||
1519 | void KOAgendaView::writeSettings(KConfig *config) | 1518 | void KOAgendaView::writeSettings(KConfig *config) |
1520 | { | 1519 | { |
1521 | // kdDebug() << "KOAgendaView::writeSettings()" << endl; | 1520 | // kdDebug() << "KOAgendaView::writeSettings()" << endl; |
1522 | 1521 | ||
1523 | config->setGroup("Views"); | 1522 | config->setGroup("Views"); |
1524 | 1523 | ||
1525 | //#ifndef KORG_NOSPLITTER | 1524 | //#ifndef KORG_NOSPLITTER |
1526 | QValueList<int> list = mSplitterAgenda->sizes(); | 1525 | QValueList<int> list = mSplitterAgenda->sizes(); |
1527 | config->writeEntry("Separator AgendaView",list); | 1526 | config->writeEntry("Separator AgendaView",list); |
1528 | //qDebug("write %d %d ", list[0],list[1] ); | 1527 | //qDebug("write %d %d ", list[0],list[1] ); |
1529 | //#endif | 1528 | //#endif |
1530 | } | 1529 | } |
1531 | 1530 | ||
1532 | void KOAgendaView::setHolidayMasks() | 1531 | void KOAgendaView::setHolidayMasks() |
1533 | { | 1532 | { |
1534 | mHolidayMask.resize(mSelectedDates.count()); | 1533 | mHolidayMask.resize(mSelectedDates.count()); |
1535 | 1534 | ||
1536 | uint i; | 1535 | uint i; |
1537 | for(i=0;i<mSelectedDates.count();++i) { | 1536 | for(i=0;i<mSelectedDates.count();++i) { |
1538 | QDate date = mSelectedDates[i]; | 1537 | QDate date = mSelectedDates[i]; |
1539 | bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6); | 1538 | bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6); |
1540 | bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7); | 1539 | bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7); |
1541 | bool showHoliday = false; | 1540 | bool showHoliday = false; |
1542 | if ( KOPrefs::instance()->mExcludeHolidays ) { | 1541 | if ( KOPrefs::instance()->mExcludeHolidays ) { |
1543 | QPtrList<Event> events = calendar()->events( date, true ); | 1542 | QPtrList<Event> events = calendar()->events( date, true ); |
1544 | Event *event; | 1543 | Event *event; |
1545 | for( event = events.first(); event; event = events.next() ) { | 1544 | for( event = events.first(); event; event = events.next() ) { |
1546 | if ( event->isHoliday()) { | 1545 | if ( event->isHoliday()) { |
1547 | showHoliday = true; | 1546 | showHoliday = true; |
1548 | break; | 1547 | break; |
1549 | } | 1548 | } |
1550 | } | 1549 | } |
1551 | 1550 | ||
1552 | } | 1551 | } |
1553 | 1552 | ||
1554 | #ifndef KORG_NOPLUGINS | 1553 | #ifndef KORG_NOPLUGINS |
1555 | bool showHoliday = KOPrefs::instance()->mExcludeHolidays && | 1554 | bool showHoliday = KOPrefs::instance()->mExcludeHolidays && |
1556 | !KOCore::self()->holiday(date).isEmpty(); | 1555 | !KOCore::self()->holiday(date).isEmpty(); |
1557 | #endif | 1556 | #endif |
1558 | bool showDay = showSaturday || showSunday || showHoliday; | 1557 | bool showDay = showSaturday || showSunday || showHoliday; |
1559 | 1558 | ||
1560 | if (showDay) { | 1559 | if (showDay) { |
1561 | mHolidayMask.at(i) = true; | 1560 | mHolidayMask.at(i) = true; |
1562 | } else { | 1561 | } else { |
1563 | mHolidayMask.at(i) = false; | 1562 | mHolidayMask.at(i) = false; |
1564 | } | 1563 | } |
1565 | } | 1564 | } |
1566 | 1565 | ||
1567 | mAgenda->setHolidayMask(&mHolidayMask); | 1566 | mAgenda->setHolidayMask(&mHolidayMask); |
1568 | mAllDayAgenda->setHolidayMask(&mHolidayMask); | 1567 | mAllDayAgenda->setHolidayMask(&mHolidayMask); |
1569 | } | 1568 | } |
1570 | 1569 | ||
1571 | void KOAgendaView::setContentsPos(int y) | 1570 | void KOAgendaView::setContentsPos(int y) |
1572 | { | 1571 | { |
1573 | mAgenda->setContentsPos(0,y); | 1572 | mAgenda->setContentsPos(0,y); |
1574 | } | 1573 | } |
1575 | 1574 | ||
1576 | void KOAgendaView::clearSelection() | 1575 | void KOAgendaView::clearSelection() |
1577 | { | 1576 | { |
1578 | mAgenda->deselectItem(); | 1577 | mAgenda->deselectItem(); |
1579 | mAllDayAgenda->deselectItem(); | 1578 | mAllDayAgenda->deselectItem(); |
1580 | } | 1579 | } |
1581 | 1580 | ||
1582 | void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart, | 1581 | void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart, |
1583 | int gxEnd, int gyEnd) | 1582 | int gxEnd, int gyEnd) |
1584 | { | 1583 | { |
1585 | mTimeSpanInAllDay = true; | 1584 | mTimeSpanInAllDay = true; |
1586 | newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd); | 1585 | newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd); |
1587 | } | 1586 | } |
1588 | 1587 | ||
1589 | 1588 | ||
1590 | 1589 | ||
1591 | 1590 | ||
1592 | void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart, | 1591 | void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart, |
1593 | int gxEnd, int gyEnd) | 1592 | int gxEnd, int gyEnd) |
1594 | { | 1593 | { |
1595 | if (!mSelectedDates.count()) return; | 1594 | if (!mSelectedDates.count()) return; |
1596 | 1595 | ||
1597 | QDate dayStart = mSelectedDates[gxStart]; | 1596 | QDate dayStart = mSelectedDates[gxStart]; |
1598 | QDate dayEnd = mSelectedDates[gxEnd]; | 1597 | QDate dayEnd = mSelectedDates[gxEnd]; |
1599 | 1598 | ||
1600 | QTime timeStart = mAgenda->gyToTime(gyStart); | 1599 | QTime timeStart = mAgenda->gyToTime(gyStart); |
1601 | QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); | 1600 | QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); |
1602 | 1601 | ||
1603 | QDateTime dtStart(dayStart,timeStart); | 1602 | QDateTime dtStart(dayStart,timeStart); |
1604 | QDateTime dtEnd(dayEnd,timeEnd); | 1603 | QDateTime dtEnd(dayEnd,timeEnd); |
1605 | 1604 | ||
1606 | mTimeSpanBegin = dtStart; | 1605 | mTimeSpanBegin = dtStart; |
1607 | mTimeSpanEnd = dtEnd; | 1606 | mTimeSpanEnd = dtEnd; |
1608 | 1607 | ||
1609 | } | 1608 | } |
1610 | 1609 | ||
1611 | void KOAgendaView::deleteSelectedDateTime() | 1610 | void KOAgendaView::deleteSelectedDateTime() |
1612 | { | 1611 | { |
1613 | mTimeSpanBegin.setDate(QDate()); | 1612 | mTimeSpanBegin.setDate(QDate()); |
1614 | mTimeSpanEnd.setDate(QDate()); | 1613 | mTimeSpanEnd.setDate(QDate()); |
1615 | mTimeSpanInAllDay = false; | 1614 | mTimeSpanInAllDay = false; |
1616 | } | 1615 | } |
1617 | 1616 | ||
1618 | void KOAgendaView::keyPressEvent ( QKeyEvent * e ) | 1617 | void KOAgendaView::keyPressEvent ( QKeyEvent * e ) |
1619 | { | 1618 | { |
1620 | e->ignore(); | 1619 | e->ignore(); |
1621 | } | 1620 | } |
1622 | 1621 | ||
1623 | void KOAgendaView::scrollOneHourUp() | 1622 | void KOAgendaView::scrollOneHourUp() |
1624 | { | 1623 | { |
1625 | 1624 | ||
1626 | mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 ); | 1625 | mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 ); |
1627 | } | 1626 | } |
1628 | void KOAgendaView::scrollOneHourDown() | 1627 | void KOAgendaView::scrollOneHourDown() |
1629 | { | 1628 | { |
1630 | mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 ); | 1629 | mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 ); |
1631 | } | 1630 | } |
1632 | 1631 | ||
1633 | void KOAgendaView::setStartHour( int h ) | 1632 | void KOAgendaView::setStartHour( int h ) |
1634 | { | 1633 | { |
1635 | mAgenda->setStartHour( h ); | 1634 | mAgenda->setStartHour( h ); |
1636 | 1635 | ||
1637 | } | 1636 | } |
1638 | void KOAgendaView::setInitStartHour() | 1637 | void KOAgendaView::setInitStartHour() |
1639 | { | 1638 | { |
1640 | 1639 | ||
1641 | if ( KOPrefs::instance()->mCenterOnCurrentTime ) | 1640 | if ( KOPrefs::instance()->mCenterOnCurrentTime ) |
1642 | setStartHour( QTime::currentTime ().hour() ); | 1641 | setStartHour( QTime::currentTime ().hour() ); |
1643 | else | 1642 | else |
1644 | setStartHour( KOPrefs::instance()->mDayBegins ); | 1643 | setStartHour( KOPrefs::instance()->mDayBegins ); |
1645 | 1644 | ||
1646 | } | 1645 | } |
1647 | 1646 | ||
1648 | 1647 | ||
1649 | void KOAgendaView::updateTodo( Todo * t, int ) | 1648 | void KOAgendaView::updateTodo( Todo * t, int ) |
1650 | { | 1649 | { |
1651 | if ( !isVisible() ) | 1650 | if ( !isVisible() ) |
1652 | return; | 1651 | return; |
1653 | bool remove = false; | 1652 | bool remove = false; |
1654 | bool removeAD = false; | 1653 | bool removeAD = false; |
1655 | QDate da; | 1654 | QDate da; |
1656 | if ( t->hasCompletedDate() ) | 1655 | if ( t->hasCompletedDate() ) |
1657 | da = t->completed().date(); | 1656 | da = t->completed().date(); |
1658 | else | 1657 | else |
1659 | da = t->dtDue().date(); | 1658 | da = t->dtDue().date(); |
1660 | if ( ! t->hasDueDate() && !t->hasCompletedDate() ) { | 1659 | if ( ! t->hasDueDate() && !t->hasCompletedDate() ) { |
1661 | remove = true; | 1660 | remove = true; |
1662 | removeAD = true; | 1661 | removeAD = true; |
1663 | } | 1662 | } |
1664 | else { | 1663 | else { |
1665 | bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ; | 1664 | bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ; |
1666 | if ( overdue && | 1665 | if ( overdue && |
1667 | QDate::currentDate() >= mSelectedDates.first() && | 1666 | QDate::currentDate() >= mSelectedDates.first() && |
1668 | QDate::currentDate() <= mSelectedDates.last()) { | 1667 | QDate::currentDate() <= mSelectedDates.last()) { |
1669 | removeAD = false; | 1668 | removeAD = false; |
1670 | remove = true; | 1669 | remove = true; |
1671 | } | 1670 | } |
1672 | else { | 1671 | else { |
1673 | 1672 | ||
1674 | if ( da < mSelectedDates.first() || | 1673 | if ( da < mSelectedDates.first() || |
1675 | da > mSelectedDates.last() ) { | 1674 | da > mSelectedDates.last() ) { |
1676 | remove = true; | 1675 | remove = true; |
1677 | removeAD = true; | 1676 | removeAD = true; |
1678 | } else { | 1677 | } else { |
1679 | remove = t->doesFloat() && !t->hasCompletedDate(); | 1678 | remove = t->doesFloat() && !t->hasCompletedDate(); |
1680 | removeAD = !remove; | 1679 | removeAD = !remove; |
1681 | } | 1680 | } |
1682 | } | 1681 | } |
1683 | } | 1682 | } |
1684 | int days = mSelectedDates.first().daysTo( da ); | 1683 | int days = mSelectedDates.first().daysTo( da ); |
1685 | //qDebug("daysto %d %d %d", days, remove,removeAD ); | 1684 | //qDebug("daysto %d %d %d", days, remove,removeAD ); |
1686 | mAgenda->updateTodo( t , days, remove); | 1685 | mAgenda->updateTodo( t , days, remove); |
1687 | if ( KOPrefs::instance()->mShowTodoInAgenda ) | 1686 | if ( KOPrefs::instance()->mShowTodoInAgenda ) |
1688 | mAllDayAgenda->updateTodo( t , days, removeAD); | 1687 | mAllDayAgenda->updateTodo( t , days, removeAD); |
1689 | //qDebug("KOAgendaView::updateTodo( Todo *, int ) "); | 1688 | //qDebug("KOAgendaView::updateTodo( Todo *, int ) "); |
1690 | 1689 | ||
1691 | } | 1690 | } |