-rw-r--r-- | korganizer/koagenda.cpp | 31 | ||||
-rw-r--r-- | korganizer/koagendaitem.cpp | 1 |
2 files changed, 30 insertions, 2 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp index a72e470..195b1fa 100644 --- a/korganizer/koagenda.cpp +++ b/korganizer/koagenda.cpp | |||
@@ -890,405 +890,432 @@ void KOAgenda::endItemAction() | |||
890 | item=oldconflictItems.next() ) { | 890 | item=oldconflictItems.next() ) { |
891 | placeSubCells(item); | 891 | placeSubCells(item); |
892 | } | 892 | } |
893 | while ( placeItem ) { | 893 | while ( placeItem ) { |
894 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); | 894 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); |
895 | placeSubCells( placeItem ); | 895 | placeSubCells( placeItem ); |
896 | placeItem = placeItem->nextMultiItem(); | 896 | placeItem = placeItem->nextMultiItem(); |
897 | } | 897 | } |
898 | #endif | 898 | #endif |
899 | 899 | ||
900 | globalFlagBlockAgendaItemPaint = 1; | 900 | globalFlagBlockAgendaItemPaint = 1; |
901 | for ( item=oldconflictItems.first(); item != 0; | 901 | for ( item=oldconflictItems.first(); item != 0; |
902 | item=oldconflictItems.next() ) { | 902 | item=oldconflictItems.next() ) { |
903 | placeSubCells(item); | 903 | placeSubCells(item); |
904 | } | 904 | } |
905 | while ( placeItem ) { | 905 | while ( placeItem ) { |
906 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); | 906 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); |
907 | oldconflictItems = placeItem->conflictItems(); | 907 | oldconflictItems = placeItem->conflictItems(); |
908 | for ( item=oldconflictItems.first(); item != 0; | 908 | for ( item=oldconflictItems.first(); item != 0; |
909 | item=oldconflictItems.next() ) { | 909 | item=oldconflictItems.next() ) { |
910 | placeSubCells(item); | 910 | placeSubCells(item); |
911 | } | 911 | } |
912 | placeSubCells( placeItem ); | 912 | placeSubCells( placeItem ); |
913 | placeItem = placeItem->nextMultiItem(); | 913 | placeItem = placeItem->nextMultiItem(); |
914 | } | 914 | } |
915 | globalFlagBlockAgendaItemPaint = 0; | 915 | globalFlagBlockAgendaItemPaint = 0; |
916 | for ( item=oldconflictItems.first(); item != 0; | 916 | for ( item=oldconflictItems.first(); item != 0; |
917 | item=oldconflictItems.next() ) { | 917 | item=oldconflictItems.next() ) { |
918 | globalFlagBlockAgendaItemUpdate = 0; | 918 | globalFlagBlockAgendaItemUpdate = 0; |
919 | item->repaintMe(); | 919 | item->repaintMe(); |
920 | globalFlagBlockAgendaItemUpdate = 1; | 920 | globalFlagBlockAgendaItemUpdate = 1; |
921 | item->repaint( false ); | 921 | item->repaint( false ); |
922 | } | 922 | } |
923 | placeItem = modifiedItem; | 923 | placeItem = modifiedItem; |
924 | 924 | ||
925 | while ( placeItem ) { | 925 | while ( placeItem ) { |
926 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); | 926 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); |
927 | globalFlagBlockAgendaItemUpdate = 0; | 927 | globalFlagBlockAgendaItemUpdate = 0; |
928 | placeItem->repaintMe(); | 928 | placeItem->repaintMe(); |
929 | globalFlagBlockAgendaItemUpdate = 1; | 929 | globalFlagBlockAgendaItemUpdate = 1; |
930 | placeItem->repaint(false); | 930 | placeItem->repaint(false); |
931 | placeItem = placeItem->nextMultiItem(); | 931 | placeItem = placeItem->nextMultiItem(); |
932 | } | 932 | } |
933 | emit itemModified( modifiedItem, mActionType ); | 933 | emit itemModified( modifiedItem, mActionType ); |
934 | 934 | ||
935 | 935 | ||
936 | placeItem = modifiedItem; | 936 | placeItem = modifiedItem; |
937 | while ( placeItem ) { | 937 | while ( placeItem ) { |
938 | oldconflictItems = placeItem->conflictItems(); | 938 | oldconflictItems = placeItem->conflictItems(); |
939 | for ( item=oldconflictItems.first(); item != 0; | 939 | for ( item=oldconflictItems.first(); item != 0; |
940 | item=oldconflictItems.next() ) { | 940 | item=oldconflictItems.next() ) { |
941 | placeSubCells(item); | 941 | placeSubCells(item); |
942 | } | 942 | } |
943 | placeSubCells( placeItem ); | 943 | placeSubCells( placeItem ); |
944 | placeItem = placeItem->nextMultiItem(); | 944 | placeItem = placeItem->nextMultiItem(); |
945 | 945 | ||
946 | } | 946 | } |
947 | placeItem = modifiedItem; | 947 | placeItem = modifiedItem; |
948 | while ( placeItem ) { | 948 | while ( placeItem ) { |
949 | oldconflictItems = placeItem->conflictItems(); | 949 | oldconflictItems = placeItem->conflictItems(); |
950 | for ( item=oldconflictItems.first(); item != 0; | 950 | for ( item=oldconflictItems.first(); item != 0; |
951 | item=oldconflictItems.next() ) { | 951 | item=oldconflictItems.next() ) { |
952 | globalFlagBlockAgendaItemUpdate = 0; | 952 | globalFlagBlockAgendaItemUpdate = 0; |
953 | item->repaintMe(); | 953 | item->repaintMe(); |
954 | globalFlagBlockAgendaItemUpdate = 1; | 954 | globalFlagBlockAgendaItemUpdate = 1; |
955 | item->repaint(false); | 955 | item->repaint(false); |
956 | } | 956 | } |
957 | placeItem = placeItem->nextMultiItem(); | 957 | placeItem = placeItem->nextMultiItem(); |
958 | } | 958 | } |
959 | /* | 959 | /* |
960 | 960 | ||
961 | oldconflictItems = modifiedItem->conflictItems(); | 961 | oldconflictItems = modifiedItem->conflictItems(); |
962 | for ( item=oldconflictItems.first(); item != 0; | 962 | for ( item=oldconflictItems.first(); item != 0; |
963 | item=oldconflictItems.next() ) { | 963 | item=oldconflictItems.next() ) { |
964 | globalFlagBlockAgendaItemUpdate = 0; | 964 | globalFlagBlockAgendaItemUpdate = 0; |
965 | item->paintMe(false); | 965 | item->paintMe(false); |
966 | globalFlagBlockAgendaItemUpdate = 1; | 966 | globalFlagBlockAgendaItemUpdate = 1; |
967 | item->repaint(false); | 967 | item->repaint(false); |
968 | } | 968 | } |
969 | */ | 969 | */ |
970 | 970 | ||
971 | 971 | ||
972 | } | 972 | } |
973 | 973 | ||
974 | } | 974 | } |
975 | 975 | ||
976 | mScrollUpTimer.stop(); | 976 | mScrollUpTimer.stop(); |
977 | mScrollDownTimer.stop(); | 977 | mScrollDownTimer.stop(); |
978 | setCursor( arrowCursor ); | 978 | setCursor( arrowCursor ); |
979 | mActionItem = 0; | 979 | mActionItem = 0; |
980 | mActionType = NOP; | 980 | mActionType = NOP; |
981 | mItemMoved = 0; | 981 | mItemMoved = 0; |
982 | 982 | ||
983 | } | 983 | } |
984 | 984 | ||
985 | void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos) | 985 | void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos) |
986 | { | 986 | { |
987 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; | 987 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; |
988 | // QPoint point = viewport()->mapToGlobal(viewportPos); | 988 | // QPoint point = viewport()->mapToGlobal(viewportPos); |
989 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; | 989 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; |
990 | // point = clipper()->mapFromGlobal(point); | 990 | // point = clipper()->mapFromGlobal(point); |
991 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; | 991 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; |
992 | 992 | ||
993 | int x,y; | 993 | int x,y; |
994 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 994 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
995 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; | 995 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; |
996 | int gx,gy; | 996 | int gx,gy; |
997 | contentsToGrid(x,y,gx,gy); | 997 | contentsToGrid(x,y,gx,gy); |
998 | 998 | ||
999 | // Change cursor to resize cursor if appropriate | 999 | // Change cursor to resize cursor if appropriate |
1000 | if (mAllDayMode) { | 1000 | if (mAllDayMode) { |
1001 | int gridDistanceX = (x - gx * mGridSpacingX); | 1001 | int gridDistanceX = (x - gx * mGridSpacingX); |
1002 | if (gridDistanceX < mResizeBorderWidth && | 1002 | if (gridDistanceX < mResizeBorderWidth && |
1003 | moveItem->cellX() == gx) { | 1003 | moveItem->cellX() == gx) { |
1004 | setCursor(sizeHorCursor); | 1004 | setCursor(sizeHorCursor); |
1005 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && | 1005 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && |
1006 | moveItem->cellXWidth() == gx) { | 1006 | moveItem->cellXWidth() == gx) { |
1007 | setCursor(sizeHorCursor); | 1007 | setCursor(sizeHorCursor); |
1008 | } else { | 1008 | } else { |
1009 | setCursor(arrowCursor); | 1009 | setCursor(arrowCursor); |
1010 | } | 1010 | } |
1011 | } else { | 1011 | } else { |
1012 | int gridDistanceY = (y - gy * mGridSpacingY); | 1012 | int gridDistanceY = (y - gy * mGridSpacingY); |
1013 | if (gridDistanceY < mResizeBorderWidth && | 1013 | if (gridDistanceY < mResizeBorderWidth && |
1014 | moveItem->cellYTop() == gy && | 1014 | moveItem->cellYTop() == gy && |
1015 | !moveItem->firstMultiItem()) { | 1015 | !moveItem->firstMultiItem()) { |
1016 | setCursor(sizeVerCursor); | 1016 | setCursor(sizeVerCursor); |
1017 | } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth && | 1017 | } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth && |
1018 | moveItem->cellYBottom() == gy && | 1018 | moveItem->cellYBottom() == gy && |
1019 | !moveItem->lastMultiItem()) { | 1019 | !moveItem->lastMultiItem()) { |
1020 | setCursor(sizeVerCursor); | 1020 | setCursor(sizeVerCursor); |
1021 | } else { | 1021 | } else { |
1022 | setCursor(arrowCursor); | 1022 | setCursor(arrowCursor); |
1023 | } | 1023 | } |
1024 | } | 1024 | } |
1025 | } | 1025 | } |
1026 | 1026 | ||
1027 | 1027 | ||
1028 | /* | 1028 | /* |
1029 | Place item in cell and take care that multiple items using the same cell do | 1029 | Place item in cell and take care that multiple items using the same cell do |
1030 | not overlap. This method is not yet optimal. It doesn´t use the maximum space | 1030 | not overlap. This method is not yet optimal. It doesn´t use the maximum space |
1031 | it can get in all cases. | 1031 | it can get in all cases. |
1032 | At the moment the method has a bug: When an item is placed only the sub cell | 1032 | At the moment the method has a bug: When an item is placed only the sub cell |
1033 | widths of the items are changed, which are within the Y region the item to | 1033 | widths of the items are changed, which are within the Y region the item to |
1034 | place spans. When the sub cell width change of one of this items affects a | 1034 | place spans. When the sub cell width change of one of this items affects a |
1035 | cell, where other items are, which do not overlap in Y with the item to place, | 1035 | cell, where other items are, which do not overlap in Y with the item to place, |
1036 | the display gets corrupted, although the corruption looks quite nice. | 1036 | the display gets corrupted, although the corruption looks quite nice. |
1037 | */ | 1037 | */ |
1038 | void KOAgenda::placeSubCells(KOAgendaItem *placeItem) | 1038 | void KOAgenda::placeSubCells(KOAgendaItem *placeItem) |
1039 | { | 1039 | { |
1040 | 1040 | ||
1041 | QPtrList<KOAgendaItem> conflictItems; | 1041 | QPtrList<KOAgendaItem> conflictItems; |
1042 | int maxSubCells = 0; | 1042 | int maxSubCells = 0; |
1043 | QIntDict<KOAgendaItem> subCellDict(5); | 1043 | QIntDict<KOAgendaItem> subCellDict(5); |
1044 | 1044 | ||
1045 | KOAgendaItem *item; | 1045 | KOAgendaItem *item; |
1046 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1046 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1047 | if (item != placeItem) { | 1047 | if (item != placeItem) { |
1048 | if (placeItem->cellX() <= item->cellXWidth() && | 1048 | if (placeItem->cellX() <= item->cellXWidth() && |
1049 | placeItem->cellXWidth() >= item->cellX()) { | 1049 | placeItem->cellXWidth() >= item->cellX()) { |
1050 | if ((placeItem->cellYTop() <= item->cellYBottom()) && | 1050 | if ((placeItem->cellYTop() <= item->cellYBottom()) && |
1051 | (placeItem->cellYBottom() >= item->cellYTop())) { | 1051 | (placeItem->cellYBottom() >= item->cellYTop())) { |
1052 | conflictItems.append(item); | 1052 | conflictItems.append(item); |
1053 | if (item->subCells() > maxSubCells) | 1053 | if (item->subCells() > maxSubCells) |
1054 | maxSubCells = item->subCells(); | 1054 | maxSubCells = item->subCells(); |
1055 | subCellDict.insert(item->subCell(),item); | 1055 | subCellDict.insert(item->subCell(),item); |
1056 | } | 1056 | } |
1057 | } | 1057 | } |
1058 | } | 1058 | } |
1059 | } | 1059 | } |
1060 | 1060 | ||
1061 | if (conflictItems.count() > 0) { | 1061 | if (conflictItems.count() > 0) { |
1062 | // Look for unused sub cell and insert item | 1062 | // Look for unused sub cell and insert item |
1063 | int i; | 1063 | int i; |
1064 | for(i=0;i<maxSubCells;++i) { | 1064 | for(i=0;i<maxSubCells;++i) { |
1065 | if (!subCellDict.find(i)) { | 1065 | if (!subCellDict.find(i)) { |
1066 | placeItem->setSubCell(i); | 1066 | placeItem->setSubCell(i); |
1067 | break; | 1067 | break; |
1068 | } | 1068 | } |
1069 | } | 1069 | } |
1070 | if (i == maxSubCells) { | 1070 | if (i == maxSubCells) { |
1071 | placeItem->setSubCell(maxSubCells); | 1071 | placeItem->setSubCell(maxSubCells); |
1072 | maxSubCells++; // add new item to number of sub cells | 1072 | maxSubCells++; // add new item to number of sub cells |
1073 | } | 1073 | } |
1074 | 1074 | ||
1075 | // Prepare for sub cell geometry adjustment | 1075 | // Prepare for sub cell geometry adjustment |
1076 | int newSubCellWidth; | 1076 | int newSubCellWidth; |
1077 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells; | 1077 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells; |
1078 | else newSubCellWidth = mGridSpacingX / maxSubCells; | 1078 | else newSubCellWidth = mGridSpacingX / maxSubCells; |
1079 | conflictItems.append(placeItem); | 1079 | conflictItems.append(placeItem); |
1080 | 1080 | ||
1081 | 1081 | ||
1082 | // Adjust sub cell geometry of all items | 1082 | // Adjust sub cell geometry of all direct conflict items |
1083 | for ( item=conflictItems.first(); item != 0; | 1083 | for ( item=conflictItems.first(); item != 0; |
1084 | item=conflictItems.next() ) { | 1084 | item=conflictItems.next() ) { |
1085 | item->setSubCells(maxSubCells); | 1085 | item->setSubCells(maxSubCells); |
1086 | if (mAllDayMode) { | 1086 | if (mAllDayMode) { |
1087 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); | 1087 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); |
1088 | } else { | 1088 | } else { |
1089 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); | 1089 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); |
1090 | } | 1090 | } |
1091 | int x,y; | 1091 | int x,y; |
1092 | gridToContents(item->cellX(),item->cellYTop(),x,y); | 1092 | gridToContents(item->cellX(),item->cellYTop(),x,y); |
1093 | if (mAllDayMode) { | 1093 | if (mAllDayMode) { |
1094 | y += item->subCell() * newSubCellWidth; | 1094 | y += item->subCell() * newSubCellWidth; |
1095 | } else { | 1095 | } else { |
1096 | x += item->subCell() * newSubCellWidth; | 1096 | x += item->subCell() * newSubCellWidth; |
1097 | } | 1097 | } |
1098 | moveChild(item,x,y); | 1098 | moveChild(item,x,y); |
1099 | // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y); | 1099 | // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y); |
1100 | //item->updateItem(); | 1100 | //item->updateItem(); |
1101 | } | 1101 | } |
1102 | 1102 | // Adjust sub cell geometry of all conflict items of all conflict items | |
1103 | for ( item=conflictItems.first(); item != 0; | ||
1104 | item=conflictItems.next() ) { | ||
1105 | if ( placeItem != item ) { | ||
1106 | KOAgendaItem *item2; | ||
1107 | QPtrList<KOAgendaItem> conflictItems2 = item->conflictItems(); | ||
1108 | for ( item2=conflictItems2.first(); item2 != 0; | ||
1109 | item2=conflictItems2.next() ) { | ||
1110 | if ( item2->subCells() != maxSubCells) { | ||
1111 | item2->setSubCells(maxSubCells); | ||
1112 | if (mAllDayMode) { | ||
1113 | item2->resize(item2->cellWidth() * mGridSpacingX, newSubCellWidth); | ||
1114 | } else { | ||
1115 | item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY); | ||
1116 | } | ||
1117 | int x,y; | ||
1118 | gridToContents(item2->cellX(),item2->cellYTop(),x,y); | ||
1119 | if (mAllDayMode) { | ||
1120 | y += item2->subCell() * newSubCellWidth; | ||
1121 | } else { | ||
1122 | x += item2->subCell() * newSubCellWidth; | ||
1123 | } | ||
1124 | moveChild(item2,x,y); | ||
1125 | //qDebug("setttttt %d %s",maxSubCells, item2->text().latin1() ); | ||
1126 | } | ||
1127 | } | ||
1128 | } | ||
1129 | } | ||
1103 | } else { | 1130 | } else { |
1104 | placeItem->setSubCell(0); | 1131 | placeItem->setSubCell(0); |
1105 | placeItem->setSubCells(1); | 1132 | placeItem->setSubCells(1); |
1106 | if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY); | 1133 | if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY); |
1107 | else placeItem->resize(mGridSpacingX,placeItem->height()); | 1134 | else placeItem->resize(mGridSpacingX,placeItem->height()); |
1108 | int x,y; | 1135 | int x,y; |
1109 | gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y); | 1136 | gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y); |
1110 | moveChild(placeItem,x,y); | 1137 | moveChild(placeItem,x,y); |
1111 | } | 1138 | } |
1112 | placeItem->setConflictItems(conflictItems); | 1139 | placeItem->setConflictItems(conflictItems); |
1113 | // for ( item=conflictItems.first(); item != 0; | 1140 | // for ( item=conflictItems.first(); item != 0; |
1114 | // item=conflictItems.next() ) { | 1141 | // item=conflictItems.next() ) { |
1115 | // //item->updateItem(); | 1142 | // //item->updateItem(); |
1116 | // //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); | 1143 | // //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); |
1117 | // } | 1144 | // } |
1118 | // placeItem->updateItem(); | 1145 | // placeItem->updateItem(); |
1119 | } | 1146 | } |
1120 | 1147 | ||
1121 | void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) | 1148 | void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) |
1122 | { | 1149 | { |
1123 | if ( globalFlagBlockAgenda ) | 1150 | if ( globalFlagBlockAgenda ) |
1124 | return; | 1151 | return; |
1125 | //qDebug("KOAgenda::drawContents "); | 1152 | //qDebug("KOAgenda::drawContents "); |
1126 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) | 1153 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) |
1127 | ;//drawContentsToPainter(); | 1154 | ;//drawContentsToPainter(); |
1128 | 1155 | ||
1129 | QPaintDevice* pd = p->device(); | 1156 | QPaintDevice* pd = p->device(); |
1130 | p->end(); | 1157 | p->end(); |
1131 | int vx, vy; | 1158 | int vx, vy; |
1132 | int selectionX = KOGlobals::self()->reverseLayout() ? | 1159 | int selectionX = KOGlobals::self()->reverseLayout() ? |
1133 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : | 1160 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : |
1134 | mSelectionCellX * mGridSpacingX; | 1161 | mSelectionCellX * mGridSpacingX; |
1135 | contentsToViewport ( cx, cy, vx,vy); | 1162 | contentsToViewport ( cx, cy, vx,vy); |
1136 | // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ; | 1163 | // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ; |
1137 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) | 1164 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) |
1138 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); | 1165 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); |
1139 | 1166 | ||
1140 | if ( mSelectionHeight > 0 ) { | 1167 | if ( mSelectionHeight > 0 ) { |
1141 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); | 1168 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); |
1142 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1169 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1143 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { | 1170 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { |
1144 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); | 1171 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); |
1145 | bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); | 1172 | bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); |
1146 | } | 1173 | } |
1147 | } | 1174 | } |
1148 | //qDebug("btbl "); | 1175 | //qDebug("btbl "); |
1149 | p->begin( pd ); | 1176 | p->begin( pd ); |
1150 | //qDebug("end "); | 1177 | //qDebug("end "); |
1151 | } | 1178 | } |
1152 | 1179 | ||
1153 | void KOAgenda::finishUpdate() | 1180 | void KOAgenda::finishUpdate() |
1154 | { | 1181 | { |
1155 | 1182 | ||
1156 | KOAgendaItem *item; | 1183 | KOAgendaItem *item; |
1157 | globalFlagBlockAgendaItemPaint = 1; | 1184 | globalFlagBlockAgendaItemPaint = 1; |
1158 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1185 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1159 | if ( !item->isVisible() ) | 1186 | if ( !item->isVisible() ) |
1160 | item->show(); | 1187 | item->show(); |
1161 | 1188 | ||
1162 | } | 1189 | } |
1163 | globalFlagBlockAgendaItemUpdate = 0; | 1190 | globalFlagBlockAgendaItemUpdate = 0; |
1164 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1191 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1165 | item->repaintMe( ); | 1192 | item->repaintMe( ); |
1166 | } | 1193 | } |
1167 | globalFlagBlockAgendaItemUpdate = 1; | 1194 | globalFlagBlockAgendaItemUpdate = 1; |
1168 | qApp->processEvents(); | 1195 | qApp->processEvents(); |
1169 | globalFlagBlockAgendaItemPaint = 0; | 1196 | globalFlagBlockAgendaItemPaint = 0; |
1170 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1197 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1171 | item->repaint( false ); | 1198 | item->repaint( false ); |
1172 | } | 1199 | } |
1173 | 1200 | ||
1174 | } | 1201 | } |
1175 | 1202 | ||
1176 | /* | 1203 | /* |
1177 | Draw grid in the background of the agenda. | 1204 | Draw grid in the background of the agenda. |
1178 | */ | 1205 | */ |
1179 | void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch) | 1206 | void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch) |
1180 | { | 1207 | { |
1181 | 1208 | ||
1182 | 1209 | ||
1183 | if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask ) | 1210 | if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask ) |
1184 | return; | 1211 | return; |
1185 | if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 ) | 1212 | if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 ) |
1186 | return; | 1213 | return; |
1187 | int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight(); | 1214 | int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight(); |
1188 | if ( ch < 1 ) | 1215 | if ( ch < 1 ) |
1189 | ch = 1; | 1216 | ch = 1; |
1190 | if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) { | 1217 | if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) { |
1191 | mPaintPixmap.resize( contentsWidth()+42, ch ); | 1218 | mPaintPixmap.resize( contentsWidth()+42, ch ); |
1192 | } | 1219 | } |
1193 | mCurPixWid = contentsWidth(); | 1220 | mCurPixWid = contentsWidth(); |
1194 | mCurPixHei = ch; | 1221 | mCurPixHei = ch; |
1195 | if ( mHighlightPixmap.width() < mGridSpacingX-1 || mHighlightPixmap.height() < ch ) { | 1222 | if ( mHighlightPixmap.width() < mGridSpacingX-1 || mHighlightPixmap.height() < ch ) { |
1196 | mHighlightPixmap.resize( mGridSpacingX-1, ch ); | 1223 | mHighlightPixmap.resize( mGridSpacingX-1, ch ); |
1197 | mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor ); | 1224 | mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor ); |
1198 | } | 1225 | } |
1199 | mPixPainter.begin( &mPaintPixmap) ; | 1226 | mPixPainter.begin( &mPaintPixmap) ; |
1200 | //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() ); | 1227 | //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() ); |
1201 | QPainter * p ; | 1228 | QPainter * p ; |
1202 | if (paint == 0) { | 1229 | if (paint == 0) { |
1203 | mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor); | 1230 | mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor); |
1204 | p = &mPixPainter; | 1231 | p = &mPixPainter; |
1205 | } | 1232 | } |
1206 | else | 1233 | else |
1207 | p = paint ; | 1234 | p = paint ; |
1208 | // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch); | 1235 | // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch); |
1209 | 1236 | ||
1210 | //--cx;++cw; | 1237 | //--cx;++cw; |
1211 | int lGridSpacingY = mGridSpacingY*2; | 1238 | int lGridSpacingY = mGridSpacingY*2; |
1212 | int selDay; | 1239 | int selDay; |
1213 | if ( !backgroundOnly ) | 1240 | if ( !backgroundOnly ) |
1214 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) | 1241 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) |
1215 | { | 1242 | { |
1216 | if ( mSelectedDates[selDay] == QDateTime::currentDateTime ().date() && KOPrefs::instance()->mHighlightCurrentDay) { | 1243 | if ( mSelectedDates[selDay] == QDateTime::currentDateTime ().date() && KOPrefs::instance()->mHighlightCurrentDay) { |
1217 | int x1 = cx; | 1244 | int x1 = cx; |
1218 | int y1 = 0; | 1245 | int y1 = 0; |
1219 | if (y1 < cy) y1 = cy; | 1246 | if (y1 < cy) y1 = cy; |
1220 | int x2 = cx+cw-1; | 1247 | int x2 = cx+cw-1; |
1221 | int y2 = contentsHeight(); | 1248 | int y2 = contentsHeight(); |
1222 | if (y2 > cy+ch-1) y2=cy+ch-1; | 1249 | if (y2 > cy+ch-1) y2=cy+ch-1; |
1223 | if (x2 >= x1 && y2 >= y1) { | 1250 | if (x2 >= x1 && y2 >= y1) { |
1224 | int gxStart = selDay; | 1251 | int gxStart = selDay; |
1225 | int gxEnd = gxStart ; | 1252 | int gxEnd = gxStart ; |
1226 | int xStart = KOGlobals::self()->reverseLayout() ? | 1253 | int xStart = KOGlobals::self()->reverseLayout() ? |
1227 | (mColumns - 1 - gxStart)*mGridSpacingX : | 1254 | (mColumns - 1 - gxStart)*mGridSpacingX : |
1228 | gxStart*mGridSpacingX; | 1255 | gxStart*mGridSpacingX; |
1229 | if (xStart < x1) xStart = x1; | 1256 | if (xStart < x1) xStart = x1; |
1230 | int xEnd = KOGlobals::self()->reverseLayout() ? | 1257 | int xEnd = KOGlobals::self()->reverseLayout() ? |
1231 | (mColumns - gxStart)*mGridSpacingX-1 : | 1258 | (mColumns - gxStart)*mGridSpacingX-1 : |
1232 | (gxStart+1)*mGridSpacingX-1; | 1259 | (gxStart+1)*mGridSpacingX-1; |
1233 | if (xEnd > x2) xEnd = x2; | 1260 | if (xEnd > x2) xEnd = x2; |
1234 | if ( KOPrefs::instance()->mUseHighlightLightColor ) | 1261 | if ( KOPrefs::instance()->mUseHighlightLightColor ) |
1235 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1262 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1236 | KOPrefs::instance()->mAgendaBgColor.light()); | 1263 | KOPrefs::instance()->mAgendaBgColor.light()); |
1237 | else | 1264 | else |
1238 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1265 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1239 | KOPrefs::instance()->mAgendaBgColor.dark()); | 1266 | KOPrefs::instance()->mAgendaBgColor.dark()); |
1240 | 1267 | ||
1241 | } | 1268 | } |
1242 | } | 1269 | } |
1243 | } | 1270 | } |
1244 | // Highlight working hours | 1271 | // Highlight working hours |
1245 | 1272 | ||
1246 | if ( !backgroundOnly ) | 1273 | if ( !backgroundOnly ) |
1247 | if (mWorkingHoursEnable) { | 1274 | if (mWorkingHoursEnable) { |
1248 | int x1 = cx; | 1275 | int x1 = cx; |
1249 | int y1 = mWorkingHoursYTop; | 1276 | int y1 = mWorkingHoursYTop; |
1250 | if (y1 < cy) y1 = cy; | 1277 | if (y1 < cy) y1 = cy; |
1251 | int x2 = cx+cw-1; | 1278 | int x2 = cx+cw-1; |
1252 | // int x2 = mGridSpacingX * 5 - 1; | 1279 | // int x2 = mGridSpacingX * 5 - 1; |
1253 | // if (x2 > cx+cw-1) x2 = cx + cw - 1; | 1280 | // if (x2 > cx+cw-1) x2 = cx + cw - 1; |
1254 | int y2 = mWorkingHoursYBottom; | 1281 | int y2 = mWorkingHoursYBottom; |
1255 | if (y2 > cy+ch-1) y2=cy+ch-1; | 1282 | if (y2 > cy+ch-1) y2=cy+ch-1; |
1256 | 1283 | ||
1257 | if (x2 >= x1 && y2 >= y1) { | 1284 | if (x2 >= x1 && y2 >= y1) { |
1258 | // qDebug("x1 %d mGridSpacingX %d ", x1, mGridSpacingX ); | 1285 | // qDebug("x1 %d mGridSpacingX %d ", x1, mGridSpacingX ); |
1259 | int gxStart = x1/mGridSpacingX; | 1286 | int gxStart = x1/mGridSpacingX; |
1260 | int gxEnd = x2/mGridSpacingX; | 1287 | int gxEnd = x2/mGridSpacingX; |
1261 | while(gxStart <= gxEnd) { | 1288 | while(gxStart <= gxEnd) { |
1262 | if (gxStart < int(mHolidayMask->count()) && | 1289 | if (gxStart < int(mHolidayMask->count()) && |
1263 | !mHolidayMask->at(gxStart)) { | 1290 | !mHolidayMask->at(gxStart)) { |
1264 | int xStart = KOGlobals::self()->reverseLayout() ? | 1291 | int xStart = KOGlobals::self()->reverseLayout() ? |
1265 | (mColumns - 1 - gxStart)*mGridSpacingX : | 1292 | (mColumns - 1 - gxStart)*mGridSpacingX : |
1266 | gxStart*mGridSpacingX; | 1293 | gxStart*mGridSpacingX; |
1267 | if (xStart < x1) xStart = x1; | 1294 | if (xStart < x1) xStart = x1; |
1268 | int xEnd = KOGlobals::self()->reverseLayout() ? | 1295 | int xEnd = KOGlobals::self()->reverseLayout() ? |
1269 | (mColumns - gxStart)*mGridSpacingX-1 : | 1296 | (mColumns - gxStart)*mGridSpacingX-1 : |
1270 | (gxStart+1)*mGridSpacingX-1; | 1297 | (gxStart+1)*mGridSpacingX-1; |
1271 | if (xEnd > x2) xEnd = x2; | 1298 | if (xEnd > x2) xEnd = x2; |
1272 | if ( mSelectedDates[gxStart] == QDateTime::currentDateTime ().date()&& KOPrefs::instance()->mHighlightCurrentDay ) { | 1299 | if ( mSelectedDates[gxStart] == QDateTime::currentDateTime ().date()&& KOPrefs::instance()->mHighlightCurrentDay ) { |
1273 | if ( KOPrefs::instance()->mUseHighlightLightColor ) | 1300 | if ( KOPrefs::instance()->mUseHighlightLightColor ) |
1274 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1301 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1275 | KOPrefs::instance()->mWorkingHoursColor.light()); | 1302 | KOPrefs::instance()->mWorkingHoursColor.light()); |
1276 | else | 1303 | else |
1277 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1304 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1278 | KOPrefs::instance()->mWorkingHoursColor.dark()); | 1305 | KOPrefs::instance()->mWorkingHoursColor.dark()); |
1279 | } else { | 1306 | } else { |
1280 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1307 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1281 | KOPrefs::instance()->mWorkingHoursColor); | 1308 | KOPrefs::instance()->mWorkingHoursColor); |
1282 | } | 1309 | } |
1283 | } | 1310 | } |
1284 | ++gxStart; | 1311 | ++gxStart; |
1285 | } | 1312 | } |
1286 | } | 1313 | } |
1287 | } | 1314 | } |
1288 | /* | 1315 | /* |
1289 | int selectionX = KOGlobals::self()->reverseLayout() ? | 1316 | int selectionX = KOGlobals::self()->reverseLayout() ? |
1290 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : | 1317 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : |
1291 | mSelectionCellX * mGridSpacingX; | 1318 | mSelectionCellX * mGridSpacingX; |
1292 | 1319 | ||
1293 | // Draw selection | 1320 | // Draw selection |
1294 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1321 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp index d0a7b07..38bd93a 100644 --- a/korganizer/koagendaitem.cpp +++ b/korganizer/koagendaitem.cpp | |||
@@ -1,329 +1,330 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <qlabel.h> | 20 | #include <qlabel.h> |
21 | #include <qlayout.h> | 21 | #include <qlayout.h> |
22 | #include <qhbox.h> | 22 | #include <qhbox.h> |
23 | #include <qvbox.h> | 23 | #include <qvbox.h> |
24 | #include <qtooltip.h> | 24 | #include <qtooltip.h> |
25 | #include <qwhatsthis.h> | 25 | #include <qwhatsthis.h> |
26 | #include <qdragobject.h> | 26 | #include <qdragobject.h> |
27 | #include <qdrawutil.h> | 27 | #include <qdrawutil.h> |
28 | #include <qpainter.h> | 28 | #include <qpainter.h> |
29 | 29 | ||
30 | #include <kiconloader.h> | 30 | #include <kiconloader.h> |
31 | #include <kdebug.h> | 31 | #include <kdebug.h> |
32 | #include <kglobal.h> | 32 | #include <kglobal.h> |
33 | #include <klocale.h> | 33 | #include <klocale.h> |
34 | #ifndef DESKTOP_VERSION | 34 | #ifndef DESKTOP_VERSION |
35 | #include <qpe/qpeapplication.h> | 35 | #include <qpe/qpeapplication.h> |
36 | #define AGENDA_ICON_SIZE 5 | 36 | #define AGENDA_ICON_SIZE 5 |
37 | #else | 37 | #else |
38 | #define AGENDA_ICON_SIZE 7 | 38 | #define AGENDA_ICON_SIZE 7 |
39 | #endif | 39 | #endif |
40 | #include <libkcal/icaldrag.h> | 40 | #include <libkcal/icaldrag.h> |
41 | #include <libkcal/vcaldrag.h> | 41 | #include <libkcal/vcaldrag.h> |
42 | #include <libkcal/kincidenceformatter.h> | 42 | #include <libkcal/kincidenceformatter.h> |
43 | extern int globalFlagBlockAgenda; | 43 | extern int globalFlagBlockAgenda; |
44 | extern int globalFlagBlockAgendaItemPaint; | 44 | extern int globalFlagBlockAgendaItemPaint; |
45 | extern int globalFlagBlockAgendaItemUpdate; | 45 | extern int globalFlagBlockAgendaItemUpdate; |
46 | 46 | ||
47 | #include "koprefs.h" | 47 | #include "koprefs.h" |
48 | 48 | ||
49 | #include "koagendaitem.h" | 49 | #include "koagendaitem.h" |
50 | //#include "koagendaitem.moc" | 50 | //#include "koagendaitem.moc" |
51 | 51 | ||
52 | 52 | ||
53 | //-------------------------------------------------------------------------- | 53 | //-------------------------------------------------------------------------- |
54 | 54 | ||
55 | QToolTipGroup *KOAgendaItem::mToolTipGroup = 0; | 55 | QToolTipGroup *KOAgendaItem::mToolTipGroup = 0; |
56 | 56 | ||
57 | //-------------------------------------------------------------------------- | 57 | //-------------------------------------------------------------------------- |
58 | 58 | ||
59 | class KOAgendaItemWhatsThis :public QWhatsThis | 59 | class KOAgendaItemWhatsThis :public QWhatsThis |
60 | { | 60 | { |
61 | public: | 61 | public: |
62 | KOAgendaItemWhatsThis( KOAgendaItem* view ) : QWhatsThis( view ),_view (view) { }; | 62 | KOAgendaItemWhatsThis( KOAgendaItem* view ) : QWhatsThis( view ),_view (view) { }; |
63 | 63 | ||
64 | protected: | 64 | protected: |
65 | virtual QString text( const QPoint& ) | 65 | virtual QString text( const QPoint& ) |
66 | { | 66 | { |
67 | return _view->getWhatsThisText() ; | 67 | return _view->getWhatsThisText() ; |
68 | } | 68 | } |
69 | private: | 69 | private: |
70 | KOAgendaItem * _view; | 70 | KOAgendaItem * _view; |
71 | }; | 71 | }; |
72 | 72 | ||
73 | KOAgendaItem::KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent,bool allday, | 73 | KOAgendaItem::KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent,bool allday, |
74 | const char *name,WFlags) : | 74 | const char *name,WFlags) : |
75 | QWidget(parent, name), mIncidence(incidence), mDate(qd) | 75 | QWidget(parent, name), mIncidence(incidence), mDate(qd) |
76 | { | 76 | { |
77 | #ifndef DESKTOP_VERSION | 77 | #ifndef DESKTOP_VERSION |
78 | QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); | 78 | QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); |
79 | #endif | 79 | #endif |
80 | new KOAgendaItemWhatsThis(this); | 80 | new KOAgendaItemWhatsThis(this); |
81 | int wflags = getWFlags() |WRepaintNoErase;// WResizeNoErase | 81 | int wflags = getWFlags() |WRepaintNoErase;// WResizeNoErase |
82 | setWFlags ( wflags); | 82 | setWFlags ( wflags); |
83 | mAllDay = allday; | 83 | mAllDay = allday; |
84 | init ( incidence, qd ); | 84 | init ( incidence, qd ); |
85 | setMouseTracking(true); | 85 | setMouseTracking(true); |
86 | //setAcceptDrops(true); | 86 | //setAcceptDrops(true); |
87 | xPaintCoord = -1; | 87 | xPaintCoord = -1; |
88 | yPaintCoord = -1; | 88 | yPaintCoord = -1; |
89 | } | 89 | } |
90 | QString KOAgendaItem::getWhatsThisText() | 90 | QString KOAgendaItem::getWhatsThisText() |
91 | { | 91 | { |
92 | if ( mIncidence ) | 92 | if ( mIncidence ) |
93 | return KIncidenceFormatter::instance()->getFormattedText( mIncidence, | 93 | return KIncidenceFormatter::instance()->getFormattedText( mIncidence, |
94 | KOPrefs::instance()->mWTshowDetails, | 94 | KOPrefs::instance()->mWTshowDetails, |
95 | KOPrefs::instance()->mWTshowCreated, | 95 | KOPrefs::instance()->mWTshowCreated, |
96 | KOPrefs::instance()->mWTshowChanged); | 96 | KOPrefs::instance()->mWTshowChanged); |
97 | return "KOAgendaItem::getWhatsThisText()::internal error"; | 97 | return "KOAgendaItem::getWhatsThisText()::internal error"; |
98 | } | 98 | } |
99 | void KOAgendaItem::init ( Incidence *incidence, QDate qd ) | 99 | void KOAgendaItem::init ( Incidence *incidence, QDate qd ) |
100 | { | 100 | { |
101 | mIncidence = incidence; | 101 | mIncidence = incidence; |
102 | mDate = qd; | 102 | mDate = qd; |
103 | mFirstMultiItem = 0; | 103 | mFirstMultiItem = 0; |
104 | mNextMultiItem = 0; | 104 | mNextMultiItem = 0; |
105 | mLastMultiItem = 0; | 105 | mLastMultiItem = 0; |
106 | computeText(); | 106 | computeText(); |
107 | 107 | ||
108 | if ( (incidence->type() == "Todo") && | 108 | if ( (incidence->type() == "Todo") && |
109 | ( !((static_cast<Todo*>(incidence))->isCompleted()) && | 109 | ( !((static_cast<Todo*>(incidence))->isCompleted()) && |
110 | ((static_cast<Todo*>(incidence))->dtDue().date() <= QDate::currentDate()) ) ) { | 110 | ((static_cast<Todo*>(incidence))->dtDue().date() <= QDate::currentDate()) ) ) { |
111 | if ( (static_cast<Todo*>(incidence))->dtDue() < QDateTime::currentDateTime().date()) | 111 | if ( (static_cast<Todo*>(incidence))->dtDue() < QDateTime::currentDateTime().date()) |
112 | mBackgroundColor = KOPrefs::instance()->mTodoOverdueColor ; | 112 | mBackgroundColor = KOPrefs::instance()->mTodoOverdueColor ; |
113 | else | 113 | else |
114 | mBackgroundColor = KOPrefs::instance()->mTodoDueTodayColor; | 114 | mBackgroundColor = KOPrefs::instance()->mTodoDueTodayColor; |
115 | } | 115 | } |
116 | else { | 116 | else { |
117 | QStringList categories = mIncidence->categories(); | 117 | QStringList categories = mIncidence->categories(); |
118 | QString cat = categories.first(); | 118 | QString cat = categories.first(); |
119 | if (cat.isEmpty()) { | 119 | if (cat.isEmpty()) { |
120 | if ( (incidence->type() == "Todo") &&((static_cast<Todo*>(incidence))->isCompleted()) ) | 120 | if ( (incidence->type() == "Todo") &&((static_cast<Todo*>(incidence))->isCompleted()) ) |
121 | mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; | 121 | mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; |
122 | else | 122 | else |
123 | mBackgroundColor =KOPrefs::instance()->mEventColor; | 123 | mBackgroundColor =KOPrefs::instance()->mEventColor; |
124 | } else { | 124 | } else { |
125 | mBackgroundColor = *KOPrefs::instance()->categoryColor(cat); | 125 | mBackgroundColor = *KOPrefs::instance()->categoryColor(cat); |
126 | if ( (incidence->type() == "Todo") &&((static_cast<Todo*>(incidence))->isCompleted()) ) { | 126 | if ( (incidence->type() == "Todo") &&((static_cast<Todo*>(incidence))->isCompleted()) ) { |
127 | if ( mBackgroundColor == KOPrefs::instance()->mEventColor ) | 127 | if ( mBackgroundColor == KOPrefs::instance()->mEventColor ) |
128 | mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; | 128 | mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; |
129 | } | 129 | } |
130 | } | 130 | } |
131 | 131 | ||
132 | } | 132 | } |
133 | mColorGroup = QColorGroup( mBackgroundColor.light(), | 133 | mColorGroup = QColorGroup( mBackgroundColor.light(), |
134 | mBackgroundColor.dark(),mBackgroundColor.light(), | 134 | mBackgroundColor.dark(),mBackgroundColor.light(), |
135 | mBackgroundColor.dark(),mBackgroundColor, black, mBackgroundColor) ; | 135 | mBackgroundColor.dark(),mBackgroundColor, black, mBackgroundColor) ; |
136 | setBackgroundColor( mBackgroundColor ); | 136 | setBackgroundColor( mBackgroundColor ); |
137 | 137 | ||
138 | mConflictItems.clear(); | ||
138 | setCellXY(0,0,1); | 139 | setCellXY(0,0,1); |
139 | setCellXWidth(0); | 140 | setCellXWidth(0); |
140 | setSubCell(0); | 141 | setSubCell(0); |
141 | setSubCells(1); | 142 | setSubCells(1); |
142 | setMultiItem(0,0,0); | 143 | setMultiItem(0,0,0); |
143 | startMove(); | 144 | startMove(); |
144 | mSelected = true; | 145 | mSelected = true; |
145 | select(false); | 146 | select(false); |
146 | QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont); | 147 | QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont); |
147 | mFontPixelSize = fontinf.height();; | 148 | mFontPixelSize = fontinf.height();; |
148 | hide(); | 149 | hide(); |
149 | xPaintCoord = -1; | 150 | xPaintCoord = -1; |
150 | yPaintCoord = -1; | 151 | yPaintCoord = -1; |
151 | } | 152 | } |
152 | 153 | ||
153 | 154 | ||
154 | KOAgendaItem::~KOAgendaItem() | 155 | KOAgendaItem::~KOAgendaItem() |
155 | { | 156 | { |
156 | // qDebug("deleteKOAgendaItem::~KOAgendaItem( "); | 157 | // qDebug("deleteKOAgendaItem::~KOAgendaItem( "); |
157 | 158 | ||
158 | } | 159 | } |
159 | 160 | ||
160 | void KOAgendaItem::recreateIncidence() | 161 | void KOAgendaItem::recreateIncidence() |
161 | { | 162 | { |
162 | #if 0 | 163 | #if 0 |
163 | Incidence* newInc = mIncidence->clone(); | 164 | Incidence* newInc = mIncidence->clone(); |
164 | newInc->recreate(); | 165 | newInc->recreate(); |
165 | if ( mIncidence->doesRecur() ) { | 166 | if ( mIncidence->doesRecur() ) { |
166 | mIncidence->addExDate( mDate ); | 167 | mIncidence->addExDate( mDate ); |
167 | newInc->recurrence()->unsetRecurs(); | 168 | newInc->recurrence()->unsetRecurs(); |
168 | int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd()); | 169 | int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd()); |
169 | QTime tim = mIncidence->dtStart().time(); | 170 | QTime tim = mIncidence->dtStart().time(); |
170 | newInc->setDtStart( QDateTime(mDate, tim) ); | 171 | newInc->setDtStart( QDateTime(mDate, tim) ); |
171 | ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); | 172 | ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); |
172 | } | 173 | } |
173 | #endif | 174 | #endif |
174 | mIncidence = mIncidence->recreateCloneException( mDate ); | 175 | mIncidence = mIncidence->recreateCloneException( mDate ); |
175 | } | 176 | } |
176 | bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout) | 177 | bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout) |
177 | { | 178 | { |
178 | int size = AGENDA_ICON_SIZE; | 179 | int size = AGENDA_ICON_SIZE; |
179 | 180 | ||
180 | int yOff = 0; | 181 | int yOff = 0; |
181 | int xOff = 0; | 182 | int xOff = 0; |
182 | int x = pos().x() +3; | 183 | int x = pos().x() +3; |
183 | int y; | 184 | int y; |
184 | if ( mAllDay ) | 185 | if ( mAllDay ) |
185 | y = pos().y()+3; | 186 | y = pos().y()+3; |
186 | else | 187 | else |
187 | y = mCellYTop * ( height() / cellHeight() ) +3; | 188 | y = mCellYTop * ( height() / cellHeight() ) +3; |
188 | if (mIncidence->cancelled()) { | 189 | if (mIncidence->cancelled()) { |
189 | int xpos = xOff*( 1 +AGENDA_ICON_SIZE )+x; | 190 | int xpos = xOff*( 1 +AGENDA_ICON_SIZE )+x; |
190 | int ypos = yOff*( 1 +AGENDA_ICON_SIZE)+y; | 191 | int ypos = yOff*( 1 +AGENDA_ICON_SIZE)+y; |
191 | p->drawLine( xpos, ypos, xpos+AGENDA_ICON_SIZE-1, ypos+AGENDA_ICON_SIZE-1 ); | 192 | p->drawLine( xpos, ypos, xpos+AGENDA_ICON_SIZE-1, ypos+AGENDA_ICON_SIZE-1 ); |
192 | p->drawLine( xpos, ypos+AGENDA_ICON_SIZE-1, xpos+AGENDA_ICON_SIZE-1, ypos ); | 193 | p->drawLine( xpos, ypos+AGENDA_ICON_SIZE-1, xpos+AGENDA_ICON_SIZE-1, ypos ); |
193 | if ( horLayout ) | 194 | if ( horLayout ) |
194 | ++xOff; | 195 | ++xOff; |
195 | else | 196 | else |
196 | ++yOff; | 197 | ++yOff; |
197 | } | 198 | } |
198 | if (mIncidence->isAlarmEnabled()) { | 199 | if (mIncidence->isAlarmEnabled()) { |
199 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, red ); | 200 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, red ); |
200 | if ( horLayout ) | 201 | if ( horLayout ) |
201 | ++xOff; | 202 | ++xOff; |
202 | else | 203 | else |
203 | ++yOff; | 204 | ++yOff; |
204 | } | 205 | } |
205 | if (mIncidence->recurrence()->doesRecur()) { | 206 | if (mIncidence->recurrence()->doesRecur()) { |
206 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, blue ); | 207 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, blue ); |
207 | if ( horLayout ) | 208 | if ( horLayout ) |
208 | ++xOff; | 209 | ++xOff; |
209 | else | 210 | else |
210 | ++yOff; | 211 | ++yOff; |
211 | } | 212 | } |
212 | if (mIncidence->description().length() > 0) { | 213 | if (mIncidence->description().length() > 0) { |
213 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkGreen ); | 214 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkGreen ); |
214 | if ( horLayout ) | 215 | if ( horLayout ) |
215 | ++xOff; | 216 | ++xOff; |
216 | else | 217 | else |
217 | ++yOff; | 218 | ++yOff; |
218 | } | 219 | } |
219 | if (mIncidence->isReadOnly()) { | 220 | if (mIncidence->isReadOnly()) { |
220 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, white ); | 221 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, white ); |
221 | if ( horLayout ) | 222 | if ( horLayout ) |
222 | ++xOff; | 223 | ++xOff; |
223 | else | 224 | else |
224 | ++yOff; | 225 | ++yOff; |
225 | } | 226 | } |
226 | 227 | ||
227 | if (mIncidence->attendeeCount()>0) { | 228 | if (mIncidence->attendeeCount()>0) { |
228 | 229 | ||
229 | if (mIncidence->organizer() == KOPrefs::instance()->email()) { | 230 | if (mIncidence->organizer() == KOPrefs::instance()->email()) { |
230 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, black ); | 231 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, black ); |
231 | if ( horLayout ) | 232 | if ( horLayout ) |
232 | ++xOff; | 233 | ++xOff; |
233 | else | 234 | else |
234 | ++yOff; | 235 | ++yOff; |
235 | } else { | 236 | } else { |
236 | Attendee *me = mIncidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 237 | Attendee *me = mIncidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
237 | if (me!=0) { | 238 | if (me!=0) { |
238 | 239 | ||
239 | 240 | ||
240 | } else { | 241 | } else { |
241 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, yellow ); | 242 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, yellow ); |
242 | if ( horLayout ) | 243 | if ( horLayout ) |
243 | ++xOff; | 244 | ++xOff; |
244 | else | 245 | else |
245 | ++yOff; | 246 | ++yOff; |
246 | 247 | ||
247 | } | 248 | } |
248 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkYellow ); | 249 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkYellow ); |
249 | if ( horLayout ) | 250 | if ( horLayout ) |
250 | ++xOff; | 251 | ++xOff; |
251 | else | 252 | else |
252 | ++yOff; | 253 | ++yOff; |
253 | 254 | ||
254 | } | 255 | } |
255 | 256 | ||
256 | } | 257 | } |
257 | return ( yOff || xOff ); | 258 | return ( yOff || xOff ); |
258 | } | 259 | } |
259 | 260 | ||
260 | 261 | ||
261 | void KOAgendaItem::select(bool selected) | 262 | void KOAgendaItem::select(bool selected) |
262 | { | 263 | { |
263 | //qDebug("select %d %d",firstMultiItem(), nextMultiItem() ); | 264 | //qDebug("select %d %d",firstMultiItem(), nextMultiItem() ); |
264 | if (mSelected == selected) return; | 265 | if (mSelected == selected) return; |
265 | mSelected = selected; | 266 | mSelected = selected; |
266 | if ( ! isVisible() ) | 267 | if ( ! isVisible() ) |
267 | return; | 268 | return; |
268 | if ( firstMultiItem() ) | 269 | if ( firstMultiItem() ) |
269 | firstMultiItem()->select( selected ); | 270 | firstMultiItem()->select( selected ); |
270 | if ( !firstMultiItem() && nextMultiItem() ) { | 271 | if ( !firstMultiItem() && nextMultiItem() ) { |
271 | KOAgendaItem * placeItem = nextMultiItem(); | 272 | KOAgendaItem * placeItem = nextMultiItem(); |
272 | while ( placeItem ) { | 273 | while ( placeItem ) { |
273 | placeItem->select( selected ); | 274 | placeItem->select( selected ); |
274 | placeItem = placeItem->nextMultiItem(); | 275 | placeItem = placeItem->nextMultiItem(); |
275 | } | 276 | } |
276 | } | 277 | } |
277 | globalFlagBlockAgendaItemUpdate = 0; | 278 | globalFlagBlockAgendaItemUpdate = 0; |
278 | paintMe( selected ); | 279 | paintMe( selected ); |
279 | globalFlagBlockAgendaItemUpdate = 1; | 280 | globalFlagBlockAgendaItemUpdate = 1; |
280 | repaint( false ); | 281 | repaint( false ); |
281 | } | 282 | } |
282 | 283 | ||
283 | 284 | ||
284 | /* | 285 | /* |
285 | The eventFilter has to filter the mouse events of the agenda item childs. The | 286 | The eventFilter has to filter the mouse events of the agenda item childs. The |
286 | events are fed into the event handling method of KOAgendaItem. This allows the | 287 | events are fed into the event handling method of KOAgendaItem. This allows the |
287 | KOAgenda to handle the KOAgendaItems by using an eventFilter. | 288 | KOAgenda to handle the KOAgendaItems by using an eventFilter. |
288 | */ | 289 | */ |
289 | bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e ) | 290 | bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e ) |
290 | { | 291 | { |
291 | if (e->type() == QEvent::MouseButtonPress || | 292 | if (e->type() == QEvent::MouseButtonPress || |
292 | e->type() == QEvent::MouseButtonDblClick || | 293 | e->type() == QEvent::MouseButtonDblClick || |
293 | e->type() == QEvent::MouseButtonRelease || | 294 | e->type() == QEvent::MouseButtonRelease || |
294 | e->type() == QEvent::MouseMove) { | 295 | e->type() == QEvent::MouseMove) { |
295 | QMouseEvent *me = (QMouseEvent *)e; | 296 | QMouseEvent *me = (QMouseEvent *)e; |
296 | QPoint itemPos = this->mapFromGlobal(((QWidget *)object)-> | 297 | QPoint itemPos = this->mapFromGlobal(((QWidget *)object)-> |
297 | mapToGlobal(me->pos())); | 298 | mapToGlobal(me->pos())); |
298 | QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state()); | 299 | QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state()); |
299 | return event(&returnEvent); | 300 | return event(&returnEvent); |
300 | } else { | 301 | } else { |
301 | return false; | 302 | return false; |
302 | } | 303 | } |
303 | } | 304 | } |
304 | void KOAgendaItem::repaintMe( ) | 305 | void KOAgendaItem::repaintMe( ) |
305 | { | 306 | { |
306 | paintMe ( mSelected ); | 307 | paintMe ( mSelected ); |
307 | } | 308 | } |
308 | void KOAgendaItem::paintMe( bool selected, QPainter* paint ) | 309 | void KOAgendaItem::paintMe( bool selected, QPainter* paint ) |
309 | { | 310 | { |
310 | if ( globalFlagBlockAgendaItemUpdate && ! selected) | 311 | if ( globalFlagBlockAgendaItemUpdate && ! selected) |
311 | return; | 312 | return; |
312 | QPainter pa; | 313 | QPainter pa; |
313 | 314 | ||
314 | if ( mSelected ) { | 315 | if ( mSelected ) { |
315 | pa.begin( paintPixSel() ); | 316 | pa.begin( paintPixSel() ); |
316 | } else { | 317 | } else { |
317 | if ( mAllDay ) | 318 | if ( mAllDay ) |
318 | pa.begin( paintPixAllday() ); | 319 | pa.begin( paintPixAllday() ); |
319 | else | 320 | else |
320 | pa.begin( paintPix() ); | 321 | pa.begin( paintPix() ); |
321 | } | 322 | } |
322 | int x, yy, w, h; | 323 | int x, yy, w, h; |
323 | float nfh = 7.0; | 324 | float nfh = 7.0; |
324 | x = pos().x(); w = width(); h = height (); | 325 | x = pos().x(); w = width(); h = height (); |
325 | if ( mAllDay ) | 326 | if ( mAllDay ) |
326 | yy = y(); | 327 | yy = y(); |
327 | else | 328 | else |
328 | yy = mCellYTop * ( height() / cellHeight() ); | 329 | yy = mCellYTop * ( height() / cellHeight() ); |
329 | xPaintCoord= x; | 330 | xPaintCoord= x; |