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