summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagenda.cpp42
-rw-r--r--korganizer/koagendaitem.cpp20
-rw-r--r--korganizer/koagendaitem.h1
3 files changed, 44 insertions, 19 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp
index 88f5d99..796d633 100644
--- a/korganizer/koagenda.cpp
+++ b/korganizer/koagenda.cpp
@@ -912,131 +912,132 @@ void KOAgenda::performItemAction(QPoint viewportPos)
912 mItemMoved = 0; 912 mItemMoved = 0;
913 return; 913 return;
914 } 914 }
915 } else { 915 } else {
916 switch ( mActionType ) { 916 switch ( mActionType ) {
917 case MOVE: 917 case MOVE:
918 setCursor( sizeAllCursor ); 918 setCursor( sizeAllCursor );
919 break; 919 break;
920 case RESIZETOP: 920 case RESIZETOP:
921 case RESIZEBOTTOM: 921 case RESIZEBOTTOM:
922 setCursor( sizeVerCursor ); 922 setCursor( sizeVerCursor );
923 break; 923 break;
924 case RESIZELEFT: 924 case RESIZELEFT:
925 case RESIZERIGHT: 925 case RESIZERIGHT:
926 setCursor( sizeHorCursor ); 926 setCursor( sizeHorCursor );
927 break; 927 break;
928 default: 928 default:
929 setCursor( arrowCursor ); 929 setCursor( arrowCursor );
930 } 930 }
931 } 931 }
932 932
933 // Scroll if item was moved to upper or lower end of agenda. 933 // Scroll if item was moved to upper or lower end of agenda.
934 if (clipperPos.y() < mScrollBorderWidth) { 934 if (clipperPos.y() < mScrollBorderWidth) {
935 mScrollUpTimer.start(mScrollDelay); 935 mScrollUpTimer.start(mScrollDelay);
936 } else if (visibleHeight() - clipperPos.y() < 936 } else if (visibleHeight() - clipperPos.y() <
937 mScrollBorderWidth) { 937 mScrollBorderWidth) {
938 mScrollDownTimer.start(mScrollDelay); 938 mScrollDownTimer.start(mScrollDelay);
939 } else { 939 } else {
940 mScrollUpTimer.stop(); 940 mScrollUpTimer.stop();
941 mScrollDownTimer.stop(); 941 mScrollDownTimer.stop();
942 } 942 }
943 943
944 // Move or resize item if necessary 944 // Move or resize item if necessary
945 if (mCurrentCellX != gx || mCurrentCellY != gy) { 945 if (mCurrentCellX != gx || mCurrentCellY != gy) {
946 mItemMoved = true; 946 mItemMoved = true;
947 mActionItem->raise(); 947 mActionItem->raise();
948 if (mActionType == MOVE) { 948 if (mActionType == MOVE) {
949 // Move all items belonging to a multi item 949 // Move all items belonging to a multi item
950 KOAgendaItem *moveItem = mActionItem->firstMultiItem(); 950 KOAgendaItem *moveItem = mActionItem->firstMultiItem();
951 bool isMultiItem = (moveItem || mActionItem->lastMultiItem()); 951 bool isMultiItem = (moveItem || mActionItem->lastMultiItem());
952 if (!moveItem) moveItem = mActionItem; 952 if (!moveItem) moveItem = mActionItem;
953 while (moveItem) { 953 while (moveItem) {
954 int dy; 954 int dy;
955 if (isMultiItem) dy = 0; 955 if (isMultiItem) dy = 0;
956 else dy = gy - mCurrentCellY; 956 else dy = gy - mCurrentCellY;
957 moveItem->moveRelative(gx - mCurrentCellX,dy); 957 moveItem->moveRelative(gx - mCurrentCellX,dy);
958 int x,y; 958 int x,y;
959 gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y); 959 gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y);
960 moveItem->resize(mGridSpacingX * moveItem->cellWidth(), 960 int diff = moveItem->resizeMe(mGridSpacingX, mGridSpacingX* moveItem->cellWidth(),
961 mGridSpacingY * moveItem->cellHeight()); 961 mGridSpacingY * moveItem->cellHeight());
962 moveItem->raise(); 962 moveItem->raise();
963 moveChild(moveItem,x,y); 963 moveChild(moveItem,x+diff,y);
964 moveItem = moveItem->nextMultiItem(); 964 moveItem = moveItem->nextMultiItem();
965 } 965 }
966 } else if (mActionType == RESIZETOP) { 966 } else if (mActionType == RESIZETOP) {
967 if (mCurrentCellY <= mActionItem->cellYBottom()) { 967 if (mCurrentCellY <= mActionItem->cellYBottom()) {
968 mActionItem->expandTop(gy - mCurrentCellY); 968 mActionItem->expandTop(gy - mCurrentCellY);
969 mActionItem->resize(mActionItem->width(), 969 mActionItem->resize(mActionItem->width(),
970 mGridSpacingY * mActionItem->cellHeight()); 970 mGridSpacingY * mActionItem->cellHeight());
971 int x,y; 971 int x,y;
972 gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y); 972 gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y);
973 //moveChild(mActionItem,childX(mActionItem),y); 973 //moveChild(mActionItem,childX(mActionItem),y);
974 QScrollView::moveChild( mActionItem,childX(mActionItem),y ); 974 QScrollView::moveChild( mActionItem,childX(mActionItem),y );
975 } 975 }
976 } else if (mActionType == RESIZEBOTTOM) { 976 } else if (mActionType == RESIZEBOTTOM) {
977 if (mCurrentCellY >= mActionItem->cellYTop()) { 977 if (mCurrentCellY >= mActionItem->cellYTop()) {
978 mActionItem->expandBottom(gy - mCurrentCellY); 978 mActionItem->expandBottom(gy - mCurrentCellY);
979 mActionItem->resize(mActionItem->width(), 979 mActionItem->resize(mActionItem->width(),
980 mGridSpacingY * mActionItem->cellHeight()); 980 mGridSpacingY * mActionItem->cellHeight());
981 } 981 }
982 } else if (mActionType == RESIZELEFT) { 982 } else if (mActionType == RESIZELEFT) {
983 if (mCurrentCellX <= mActionItem->cellXWidth()) { 983 if (mCurrentCellX <= mActionItem->cellXWidth()) {
984 mActionItem->expandLeft(gx - mCurrentCellX); 984 mActionItem->expandLeft(gx - mCurrentCellX);
985 mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), 985 int diff = mActionItem->resizeMe(mGridSpacingX ,
986 mActionItem->height()); 986 mGridSpacingX * mActionItem->cellWidth(),
987 mActionItem->height());
987 int x,y; 988 int x,y;
988 gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y); 989 gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y);
989 moveChild(mActionItem,x,childY(mActionItem)); 990 moveChild(mActionItem,x+diff,childY(mActionItem));
990 } 991 }
991 } else if (mActionType == RESIZERIGHT) { 992 } else if (mActionType == RESIZERIGHT) {
992 if (mCurrentCellX >= mActionItem->cellX()) { 993 if (mCurrentCellX >= mActionItem->cellX()) {
993 mActionItem->expandRight(gx - mCurrentCellX); 994 mActionItem->expandRight(gx - mCurrentCellX);
994 mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), 995 mActionItem->resizeMe(mGridSpacingX, mGridSpacingX * mActionItem->cellWidth(),
995 mActionItem->height()); 996 mActionItem->height());
996 } 997 }
997 } 998 }
998 mCurrentCellX = gx; 999 mCurrentCellX = gx;
999 mCurrentCellY = gy; 1000 mCurrentCellY = gy;
1000 } 1001 }
1001} 1002}
1002 1003
1003void KOAgenda::endItemAction() 1004void KOAgenda::endItemAction()
1004{ 1005{
1005 1006
1006 if ( mItemMoved ) { 1007 if ( mItemMoved ) {
1007 KOAgendaItem *placeItem = mActionItem->firstMultiItem(); 1008 KOAgendaItem *placeItem = mActionItem->firstMultiItem();
1008 if ( !placeItem ) { 1009 if ( !placeItem ) {
1009 placeItem = mActionItem; 1010 placeItem = mActionItem;
1010 } 1011 }
1011 if ( placeItem->incidence()->doesRecur() ) { 1012 if ( placeItem->incidence()->doesRecur() ) {
1012 Incidence* oldInc = placeItem->incidence(); 1013 Incidence* oldInc = placeItem->incidence();
1013 placeItem->recreateIncidence(); 1014 placeItem->recreateIncidence();
1014 emit addToCalSignal(placeItem->incidence(), oldInc ); 1015 emit addToCalSignal(placeItem->incidence(), oldInc );
1015 } 1016 }
1016 int type = mActionType; 1017 int type = mActionType;
1017 if ( mAllDayMode ) 1018 if ( mAllDayMode )
1018 type = -1; 1019 type = -1;
1019 KOAgendaItem *modifiedItem = placeItem; 1020 KOAgendaItem *modifiedItem = placeItem;
1020 //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */); 1021 //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */);
1021 QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems(); 1022 QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems();
1022 KOAgendaItem *item; 1023 KOAgendaItem *item;
1023 1024
1024 if ( placeItem->incidence()->typeID() == todoID ) { 1025 if ( placeItem->incidence()->typeID() == todoID ) {
1025 mSelectedItem = 0; 1026 mSelectedItem = 0;
1026 //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth()); 1027 //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth());
1027 modifiedItem->mLastMoveXPos = mCurrentCellX; 1028 modifiedItem->mLastMoveXPos = mCurrentCellX;
1028 emit itemModified( modifiedItem, mActionType ); 1029 emit itemModified( modifiedItem, mActionType );
1029 } 1030 }
1030 else { 1031 else {
1031 1032
1032 1033
1033 globalFlagBlockAgendaItemPaint = 1; 1034 globalFlagBlockAgendaItemPaint = 1;
1034 for ( item=oldconflictItems.first(); item != 0; 1035 for ( item=oldconflictItems.first(); item != 0;
1035 item=oldconflictItems.next() ) { 1036 item=oldconflictItems.next() ) {
1036 placeSubCells(item); 1037 placeSubCells(item);
1037 } 1038 }
1038 while ( placeItem ) { 1039 while ( placeItem ) {
1039 //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); 1040 //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1());
1040 oldconflictItems = placeItem->conflictItems(); 1041 oldconflictItems = placeItem->conflictItems();
1041 for ( item=oldconflictItems.first(); item != 0; 1042 for ( item=oldconflictItems.first(); item != 0;
1042 item=oldconflictItems.next() ) { 1043 item=oldconflictItems.next() ) {
@@ -1172,148 +1173,151 @@ void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos)
1172void KOAgenda::placeSubCells(KOAgendaItem *placeItem) 1173void KOAgenda::placeSubCells(KOAgendaItem *placeItem)
1173{ 1174{
1174 1175
1175 QPtrList<KOAgendaItem> conflictItems; 1176 QPtrList<KOAgendaItem> conflictItems;
1176 int maxSubCells = 0; 1177 int maxSubCells = 0;
1177 QIntDict<KOAgendaItem> subCellDict(7); 1178 QIntDict<KOAgendaItem> subCellDict(7);
1178 1179
1179 KOAgendaItem *item; 1180 KOAgendaItem *item;
1180 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1181 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1181 if (item != placeItem) { 1182 if (item != placeItem) {
1182 if (placeItem->cellX() <= item->cellXWidth() && 1183 if (placeItem->cellX() <= item->cellXWidth() &&
1183 placeItem->cellXWidth() >= item->cellX()) { 1184 placeItem->cellXWidth() >= item->cellX()) {
1184 if ((placeItem->cellYTop() <= item->cellYBottom()) && 1185 if ((placeItem->cellYTop() <= item->cellYBottom()) &&
1185 (placeItem->cellYBottom() >= item->cellYTop())) { 1186 (placeItem->cellYBottom() >= item->cellYTop())) {
1186 conflictItems.append(item); 1187 conflictItems.append(item);
1187 if (item->subCells() > maxSubCells) 1188 if (item->subCells() > maxSubCells)
1188 maxSubCells = item->subCells(); 1189 maxSubCells = item->subCells();
1189 subCellDict.insert(item->subCell(),item); 1190 subCellDict.insert(item->subCell(),item);
1190 } 1191 }
1191 } 1192 }
1192 } 1193 }
1193 } 1194 }
1194 1195
1195 if (conflictItems.count() > 0) { 1196 if (conflictItems.count() > 0) {
1196 // Look for unused sub cell and insert item 1197 // Look for unused sub cell and insert item
1197 int i; 1198 int i;
1198 for(i=0;i<maxSubCells;++i) { 1199 for(i=0;i<maxSubCells;++i) {
1199 if (!subCellDict.find(i)) { 1200 if (!subCellDict.find(i)) {
1200 placeItem->setSubCell(i); 1201 placeItem->setSubCell(i);
1201 break; 1202 break;
1202 } 1203 }
1203 } 1204 }
1204 if (i == maxSubCells) { 1205 if (i == maxSubCells) {
1205 placeItem->setSubCell(maxSubCells); 1206 placeItem->setSubCell(maxSubCells);
1206 maxSubCells++; // add new item to number of sub cells 1207 maxSubCells++; // add new item to number of sub cells
1207 } 1208 }
1208 1209
1209 // Prepare for sub cell geometry adjustment 1210 // Prepare for sub cell geometry adjustment
1210 int newSubCellWidth; 1211 int newSubCellWidth;
1211 if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells; 1212 if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells;
1212 else newSubCellWidth = mGridSpacingX / maxSubCells; 1213 else newSubCellWidth = mGridSpacingX / maxSubCells;
1213 conflictItems.append(placeItem); 1214 conflictItems.append(placeItem);
1214 1215
1215 1216
1216 // Adjust sub cell geometry of all direct conflict items 1217 // Adjust sub cell geometry of all direct conflict items
1217 for ( item=conflictItems.first(); item != 0; 1218 for ( item=conflictItems.first(); item != 0;
1218 item=conflictItems.next() ) { 1219 item=conflictItems.next() ) {
1219 item->setSubCells(maxSubCells); 1220 item->setSubCells(maxSubCells);
1221 int diff = 0;
1220 if (mAllDayMode) { 1222 if (mAllDayMode) {
1221 item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); 1223 diff = item->resizeMe( mGridSpacingX, item->cellWidth() * mGridSpacingX, newSubCellWidth);
1222 } else { 1224 } else {
1223 item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); 1225 item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY);
1224 } 1226 }
1225 int x,y; 1227 int x,y;
1226 gridToContents(item->cellX(),item->cellYTop(),x,y); 1228 gridToContents(item->cellX(),item->cellYTop(),x,y);
1227 if (mAllDayMode) { 1229 if (mAllDayMode) {
1228 y += item->subCell() * newSubCellWidth; 1230 y += item->subCell() * newSubCellWidth;
1229 } else { 1231 } else {
1230 x += item->subCell() * newSubCellWidth; 1232 x += item->subCell() * newSubCellWidth;
1231 } 1233 }
1232 moveChild(item,x,y); 1234 moveChild(item,x+diff,y);
1233 // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y); 1235 // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y);
1234 //item->updateItem(); 1236 //item->updateItem();
1235 } 1237 }
1236 // Adjust sub cell geometry of all conflict items of all conflict items 1238 // Adjust sub cell geometry of all conflict items of all conflict items
1237 for ( item=conflictItems.first(); item != 0; 1239 for ( item=conflictItems.first(); item != 0;
1238 item=conflictItems.next() ) { 1240 item=conflictItems.next() ) {
1239 if ( placeItem != item ) { 1241 if ( placeItem != item ) {
1240 KOAgendaItem *item2; 1242 KOAgendaItem *item2;
1241 QPtrList<KOAgendaItem> conflictItems2 = item->conflictItems(); 1243 QPtrList<KOAgendaItem> conflictItems2 = item->conflictItems();
1242 for ( item2=conflictItems2.first(); item2 != 0; 1244 for ( item2=conflictItems2.first(); item2 != 0;
1243 item2=conflictItems2.next() ) { 1245 item2=conflictItems2.next() ) {
1244 if ( item2->subCells() != maxSubCells) { 1246 if ( item2->subCells() != maxSubCells) {
1245 item2->setSubCells(maxSubCells); 1247 item2->setSubCells(maxSubCells);
1248 int diff = 0;
1246 if (mAllDayMode) { 1249 if (mAllDayMode) {
1247 item2->resize(item2->cellWidth() * mGridSpacingX, newSubCellWidth); 1250 diff = item2->resizeMe(mGridSpacingX, item2->cellWidth() * mGridSpacingX, newSubCellWidth);
1248 } else { 1251 } else {
1249 item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY); 1252 item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY);
1250 } 1253 }
1251 int x,y; 1254 int x,y;
1252 gridToContents(item2->cellX(),item2->cellYTop(),x,y); 1255 gridToContents(item2->cellX(),item2->cellYTop(),x,y);
1253 if (mAllDayMode) { 1256 if (mAllDayMode) {
1254 y += item2->subCell() * newSubCellWidth; 1257 y += item2->subCell() * newSubCellWidth;
1255 } else { 1258 } else {
1256 x += item2->subCell() * newSubCellWidth; 1259 x += item2->subCell() * newSubCellWidth;
1257 } 1260 }
1258 moveChild(item2,x,y); 1261 moveChild(item2,x+diff,y);
1259 //qDebug("setttttt %d %s",maxSubCells, item2->text().latin1() ); 1262 //qDebug("setttttt %d %s",maxSubCells, item2->text().latin1() );
1260 } 1263 }
1261 } 1264 }
1262 } 1265 }
1263 } 1266 }
1264 } else { 1267 } else {
1265 placeItem->setSubCell(0); 1268 placeItem->setSubCell(0);
1266 placeItem->setSubCells(1); 1269 placeItem->setSubCells(1);
1267 if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY); 1270 int diff = 0;
1271 if (mAllDayMode) diff = placeItem->resizeMe( mGridSpacingX, placeItem->width(),mGridSpacingY);
1268 else placeItem->resize(mGridSpacingX,placeItem->height()); 1272 else placeItem->resize(mGridSpacingX,placeItem->height());
1269 int x,y; 1273 int x,y;
1270 gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y); 1274 gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y);
1271 moveChild(placeItem,x,y); 1275 moveChild(placeItem,x+diff,y);
1272 } 1276 }
1273 placeItem->setConflictItems(conflictItems); 1277 placeItem->setConflictItems(conflictItems);
1274 // for ( item=conflictItems.first(); item != 0; 1278 // for ( item=conflictItems.first(); item != 0;
1275// item=conflictItems.next() ) { 1279// item=conflictItems.next() ) {
1276// //item->updateItem(); 1280// //item->updateItem();
1277// //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); 1281// //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() );
1278// } 1282// }
1279// placeItem->updateItem(); 1283// placeItem->updateItem();
1280} 1284}
1281 1285
1282void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) 1286void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch)
1283{ 1287{
1284 if ( globalFlagBlockAgenda ) 1288 if ( globalFlagBlockAgenda )
1285 return; 1289 return;
1286 1290
1287 if ( mInvalidPixmap ) { 1291 if ( mInvalidPixmap ) {
1288 mInvalidPixmap = false; 1292 mInvalidPixmap = false;
1289 qDebug("KO: dc Upsizing Pixmaps %s", QDateTime::currentDateTime().toString().latin1()); 1293 qDebug("KO: dc Upsizing Pixmaps %s", QDateTime::currentDateTime().toString().latin1());
1290 computeSizes(); 1294 computeSizes();
1291 emit updateViewSignal(); 1295 emit updateViewSignal();
1292 return; 1296 return;
1293 } 1297 }
1294 //qDebug("KOAgenda::drawContents %s", QDateTime::currentDateTime().toString().latin1()); 1298 //qDebug("KOAgenda::drawContents %s", QDateTime::currentDateTime().toString().latin1());
1295 if ( ! mAllDayMode ) { 1299 if ( ! mAllDayMode ) {
1296 // currently not working for 1300 // currently not working for
1297 1301
1298 //qDebug("KOAgenda::drawContents "); 1302 //qDebug("KOAgenda::drawContents ");
1299#if 0 1303#if 0
1300 if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) { 1304 if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) {
1301 qDebug("WAU "); 1305 qDebug("WAU ");
1302 drawContentsToPainter(); 1306 drawContentsToPainter();
1303 } 1307 }
1304#endif 1308#endif
1305 QPaintDevice* pd = p->device(); 1309 QPaintDevice* pd = p->device();
1306 p->end(); 1310 p->end();
1307 int vx, vy; 1311 int vx, vy;
1308 int selectionX = KOGlobals::self()->reverseLayout() ? 1312 int selectionX = KOGlobals::self()->reverseLayout() ?
1309 (mColumns - 1 - mSelectionCellX) * mGridSpacingX : 1313 (mColumns - 1 - mSelectionCellX) * mGridSpacingX :
1310 mSelectionCellX * mGridSpacingX; 1314 mSelectionCellX * mGridSpacingX;
1311 contentsToViewport ( cx, cy, vx,vy); 1315 contentsToViewport ( cx, cy, vx,vy);
1312 //qDebug(" %d %d %d %d %d", cx, cy, cw,ch,mGridSpacingX-1) ; 1316 //qDebug(" %d %d %d %d %d", cx, cy, cw,ch,mGridSpacingX-1) ;
1313 1317
1314 if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) { 1318 if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) {
1315 if ( mGridSpacingX == cw && mSelectionHeight > 0 && ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && 1319 if ( mGridSpacingX == cw && mSelectionHeight > 0 && ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) &&
1316 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) ) { 1320 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) ) {
1317 1321
1318 int vxSel, vySel; 1322 int vxSel, vySel;
1319 contentsToViewport ( selectionX, mSelectionYTop, vxSel,vySel); 1323 contentsToViewport ( selectionX, mSelectionYTop, vxSel,vySel);
@@ -1350,112 +1354,113 @@ void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch)
1350 if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) { 1354 if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) {
1351 qDebug("WAUWAU "); 1355 qDebug("WAUWAU ");
1352 drawContentsToPainter(); 1356 drawContentsToPainter();
1353 } 1357 }
1354#endif 1358#endif
1355 QPaintDevice* pd = p->device(); 1359 QPaintDevice* pd = p->device();
1356 p->end(); 1360 p->end();
1357 int vx, vy; 1361 int vx, vy;
1358 int selectionX = KOGlobals::self()->reverseLayout() ? 1362 int selectionX = KOGlobals::self()->reverseLayout() ?
1359 (mColumns - 1 - mSelectionCellX) * mGridSpacingX : 1363 (mColumns - 1 - mSelectionCellX) * mGridSpacingX :
1360 mSelectionCellX * mGridSpacingX; 1364 mSelectionCellX * mGridSpacingX;
1361 contentsToViewport ( cx, cy, vx,vy); 1365 contentsToViewport ( cx, cy, vx,vy);
1362 // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ; 1366 // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ;
1363 if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) 1367 if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) )
1364 bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); 1368 bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP);
1365 1369
1366 if ( mSelectionHeight > 0 ) { 1370 if ( mSelectionHeight > 0 ) {
1367 //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); 1371 //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight );
1368 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && 1372 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) &&
1369 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { 1373 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) {
1370 contentsToViewport ( selectionX, mSelectionYTop, vx,vy); 1374 contentsToViewport ( selectionX, mSelectionYTop, vx,vy);
1371 //bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); 1375 //bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP);
1372 int hei = mSelectionHeight; 1376 int hei = mSelectionHeight;
1373 int offset = 0; 1377 int offset = 0;
1374 while ( hei > 0 ) { 1378 while ( hei > 0 ) {
1375 int p_hei = 5; 1379 int p_hei = 5;
1376 if ( hei < 5 ) p_hei = hei; 1380 if ( hei < 5 ) p_hei = hei;
1377 hei -= 5; 1381 hei -= 5;
1378 bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP); 1382 bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP);
1379 offset += 5; 1383 offset += 5;
1380 } 1384 }
1381 } 1385 }
1382 } 1386 }
1383 p->begin( pd ); 1387 p->begin( pd );
1384 } 1388 }
1385 1389
1386} 1390}
1387 1391
1388void KOAgenda::finishUpdate() 1392void KOAgenda::finishUpdate()
1389{ 1393{
1390 1394
1391 KOAgendaItem *item; 1395 KOAgendaItem *item;
1392 globalFlagBlockAgendaItemPaint = 1; 1396 globalFlagBlockAgendaItemPaint = 1;
1393 // Adjust sub cell geometry of all conflict items of all conflict items of all conflict items ... of the conflict item with the max number of conflictitems 1397 // Adjust sub cell geometry of all conflict items of all conflict items of all conflict items ... of the conflict item with the max number of conflictitems
1394 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1398 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1395 if ( !item->checkLayout() ) { 1399 if ( !item->checkLayout() ) {
1396 //qDebug(" conflictitem found "); 1400 //qDebug(" conflictitem found ");
1397 int newSubCellWidth; 1401 int newSubCellWidth;
1402 int diff = 0;
1398 if (mAllDayMode) newSubCellWidth = mGridSpacingY / item->subCells(); 1403 if (mAllDayMode) newSubCellWidth = mGridSpacingY / item->subCells();
1399 else newSubCellWidth = mGridSpacingX / item->subCells(); 1404 else newSubCellWidth = mGridSpacingX / item->subCells();
1400 1405
1401 if (mAllDayMode) { 1406 if (mAllDayMode) {
1402 item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); 1407 diff = item->resizeMe(mGridSpacingX, item->cellWidth() * mGridSpacingX, newSubCellWidth);
1403 } else { 1408 } else {
1404 item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); 1409 item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY);
1405 } 1410 }
1406 int x,y; 1411 int x,y;
1407 gridToContents(item->cellX(),item->cellYTop(),x,y); 1412 gridToContents(item->cellX(),item->cellYTop(),x,y);
1408 if (mAllDayMode) { 1413 if (mAllDayMode) {
1409 y += item->subCell() * newSubCellWidth; 1414 y += item->subCell() * newSubCellWidth;
1410 } else { 1415 } else {
1411 x += item->subCell() * newSubCellWidth; 1416 x += item->subCell() * newSubCellWidth;
1412 } 1417 }
1413 moveChild(item,x,y); 1418 moveChild(item,x+diff,y);
1414 } 1419 }
1415 } 1420 }
1416 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1421 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1417 if ( !item->isVisible() ) 1422 if ( !item->isVisible() )
1418 item->show(); 1423 item->show();
1419 1424
1420 } 1425 }
1421 globalFlagBlockAgendaItemUpdate = 0; 1426 globalFlagBlockAgendaItemUpdate = 0;
1422 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1427 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1423 item->repaintMe( ); 1428 item->repaintMe( );
1424 } 1429 }
1425 globalFlagBlockAgendaItemUpdate = 1; 1430 globalFlagBlockAgendaItemUpdate = 1;
1426 qApp->processEvents(); 1431 qApp->processEvents();
1427 globalFlagBlockAgendaItemPaint = 0; 1432 globalFlagBlockAgendaItemPaint = 0;
1428 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1433 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1429 item->repaint( false ); 1434 item->repaint( false );
1430 } 1435 }
1431 marcus_bains(); 1436 marcus_bains();
1432} 1437}
1433 1438
1434/* 1439/*
1435 Draw grid in the background of the agenda. 1440 Draw grid in the background of the agenda.
1436*/ 1441*/
1437void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch) 1442void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch)
1438{ 1443{
1439 1444
1440 1445
1441 if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask ) 1446 if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask )
1442 return; 1447 return;
1443 if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 ) 1448 if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 )
1444 return; 1449 return;
1445 int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight(); 1450 int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight();
1446 if ( ch < 1 ) 1451 if ( ch < 1 )
1447 ch = 1; 1452 ch = 1;
1448 if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) { 1453 if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) {
1449 mPaintPixmap.resize( contentsWidth()+42, ch ); 1454 mPaintPixmap.resize( contentsWidth()+42, ch );
1450 } 1455 }
1451 mCurPixWid = contentsWidth(); 1456 mCurPixWid = contentsWidth();
1452 mCurPixHei = ch; 1457 mCurPixHei = ch;
1453 if ( mHighlightPixmap.width() < mGridSpacingX-1 ) { 1458 if ( mHighlightPixmap.width() < mGridSpacingX-1 ) {
1454 mHighlightPixmap.resize( mGridSpacingX-1, 5 ); 1459 mHighlightPixmap.resize( mGridSpacingX-1, 5 );
1455 mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor ); 1460 mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor );
1456 } 1461 }
1457 mPixPainter.begin( &mPaintPixmap) ; 1462 mPixPainter.begin( &mPaintPixmap) ;
1458 //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() ); 1463 //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() );
1459 QPainter * p ; 1464 QPainter * p ;
1460 if (paint == 0) { 1465 if (paint == 0) {
1461 mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor); 1466 mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor);
@@ -1791,97 +1796,97 @@ void KOAgenda::updateTodo( Todo * todo, int days, bool remove)
1791/* 1796/*
1792 Insert KOAgendaItem into agenda. 1797 Insert KOAgendaItem into agenda.
1793*/ 1798*/
1794KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom) 1799KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom)
1795{ 1800{
1796 if (mAllDayMode) { 1801 if (mAllDayMode) {
1797 qDebug("KOAgenda: calling insertItem in all-day mode is illegal. "); 1802 qDebug("KOAgenda: calling insertItem in all-day mode is illegal. ");
1798 return 0; 1803 return 0;
1799 } 1804 }
1800 1805
1801 KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); 1806 KOAgendaItem *agendaItem = getNewItem(event,qd,viewport());
1802 //agendaItem->setFrameStyle(WinPanel|Raised); 1807 //agendaItem->setFrameStyle(WinPanel|Raised);
1803 1808
1804 int YSize = YBottom - YTop + 1; 1809 int YSize = YBottom - YTop + 1;
1805 if (YSize < 0) { 1810 if (YSize < 0) {
1806 YSize = 1; 1811 YSize = 1;
1807 } 1812 }
1808 int iheight = mGridSpacingY * YSize; 1813 int iheight = mGridSpacingY * YSize;
1809 1814
1810 agendaItem->resize(mGridSpacingX,iheight ); 1815 agendaItem->resize(mGridSpacingX,iheight );
1811 agendaItem->setCellXY(X,YTop,YBottom); 1816 agendaItem->setCellXY(X,YTop,YBottom);
1812 agendaItem->setCellXWidth(X); 1817 agendaItem->setCellXWidth(X);
1813 1818
1814 //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY); 1819 //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY);
1815 mItems.append(agendaItem); 1820 mItems.append(agendaItem);
1816 1821
1817 placeSubCells(agendaItem); 1822 placeSubCells(agendaItem);
1818 1823
1819 //agendaItem->show(); 1824 //agendaItem->show();
1820 1825
1821 1826
1822 return agendaItem; 1827 return agendaItem;
1823} 1828}
1824 1829
1825 1830
1826/* 1831/*
1827 Insert all-day KOAgendaItem into agenda. 1832 Insert all-day KOAgendaItem into agenda.
1828*/ 1833*/
1829KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd) 1834KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd)
1830{ 1835{
1831 if (!mAllDayMode) { 1836 if (!mAllDayMode) {
1832 return 0; 1837 return 0;
1833 } 1838 }
1834 1839
1835 KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); 1840 KOAgendaItem *agendaItem = getNewItem(event,qd,viewport());
1836 1841
1837 agendaItem->setCellXY(XBegin,0,0); 1842 agendaItem->setCellXY(XBegin,0,0);
1838 agendaItem->setCellXWidth(XEnd); 1843 agendaItem->setCellXWidth(XEnd);
1839 agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY); 1844 agendaItem->resizeMe(mGridSpacingX, mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY);
1840 1845
1841 //addChild(agendaItem,XBegin*mGridSpacingX,0); 1846 //addChild(agendaItem,XBegin*mGridSpacingX,0);
1842 mItems.append(agendaItem); 1847 mItems.append(agendaItem);
1843 1848
1844 placeSubCells(agendaItem); 1849 placeSubCells(agendaItem);
1845 1850
1846 //agendaItem->show(); 1851 //agendaItem->show();
1847 1852
1848 return agendaItem; 1853 return agendaItem;
1849} 1854}
1850 1855
1851 1856
1852void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, 1857void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd,
1853 int YTop,int YBottom) 1858 int YTop,int YBottom)
1854{ 1859{
1855 if (mAllDayMode) { 1860 if (mAllDayMode) {
1856 ; 1861 ;
1857 return; 1862 return;
1858 } 1863 }
1859 1864
1860 int cellX,cellYTop,cellYBottom; 1865 int cellX,cellYTop,cellYBottom;
1861 QString newtext; 1866 QString newtext;
1862 int width = XEnd - XBegin + 1; 1867 int width = XEnd - XBegin + 1;
1863 int count = 0; 1868 int count = 0;
1864 KOAgendaItem *current = 0; 1869 KOAgendaItem *current = 0;
1865 QPtrList<KOAgendaItem> multiItems; 1870 QPtrList<KOAgendaItem> multiItems;
1866 for (cellX = XBegin;cellX <= XEnd;++cellX) { 1871 for (cellX = XBegin;cellX <= XEnd;++cellX) {
1867 if (cellX == XBegin) cellYTop = YTop; 1872 if (cellX == XBegin) cellYTop = YTop;
1868 else cellYTop = 0; 1873 else cellYTop = 0;
1869 if (cellX == XEnd) cellYBottom = YBottom; 1874 if (cellX == XEnd) cellYBottom = YBottom;
1870 else cellYBottom = rows() - 1; 1875 else cellYBottom = rows() - 1;
1871 newtext = QString("(%1/%2): ").arg(++count).arg(width); 1876 newtext = QString("(%1/%2): ").arg(++count).arg(width);
1872 newtext.append(event->summary()); 1877 newtext.append(event->summary());
1873 current = insertItem(event,qd,cellX,cellYTop,cellYBottom); 1878 current = insertItem(event,qd,cellX,cellYTop,cellYBottom);
1874 current->setText(newtext); 1879 current->setText(newtext);
1875 multiItems.append(current); 1880 multiItems.append(current);
1876 } 1881 }
1877 1882
1878 KOAgendaItem *next = 0; 1883 KOAgendaItem *next = 0;
1879 KOAgendaItem *last = multiItems.last(); 1884 KOAgendaItem *last = multiItems.last();
1880 KOAgendaItem *first = multiItems.first(); 1885 KOAgendaItem *first = multiItems.first();
1881 KOAgendaItem *setFirst,*setLast; 1886 KOAgendaItem *setFirst,*setLast;
1882 current = first; 1887 current = first;
1883 while (current) { 1888 while (current) {
1884 next = multiItems.next(); 1889 next = multiItems.next();
1885 if (current == first) setFirst = 0; 1890 if (current == first) setFirst = 0;
1886 else setFirst = first; 1891 else setFirst = first;
1887 if (current == last) setLast = 0; 1892 if (current == last) setLast = 0;
@@ -1897,100 +1902,101 @@ void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd,
1897//{ 1902//{
1898 // Thought this would make the all-day event agenda minimum size and the 1903 // Thought this would make the all-day event agenda minimum size and the
1899 // normal agenda take the remaining space. But it doesn´t work. The QSplitter 1904 // normal agenda take the remaining space. But it doesn´t work. The QSplitter
1900 // don´t seem to think that an Expanding widget needs more space than a 1905 // don´t seem to think that an Expanding widget needs more space than a
1901 // Preferred one. 1906 // Preferred one.
1902 // But it doesn´t hurt, so it stays. 1907 // But it doesn´t hurt, so it stays.
1903// if (mAllDayMode) { 1908// if (mAllDayMode) {
1904// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred); 1909// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
1905// } else { 1910// } else {
1906// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); 1911// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
1907// } 1912// }
1908//} 1913//}
1909void KOAgenda::finishResize ( ) 1914void KOAgenda::finishResize ( )
1910{ 1915{
1911 //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) "); 1916 //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) ");
1912 if ( globalFlagBlockAgenda == 0 ) { 1917 if ( globalFlagBlockAgenda == 0 ) {
1913 finishUpdate(); 1918 finishUpdate();
1914 //qDebug("finishUpdate() called "); 1919 //qDebug("finishUpdate() called ");
1915 } 1920 }
1916} 1921}
1917/* 1922/*
1918 Overridden from QScrollView to provide proper resizing of KOAgendaItems. 1923 Overridden from QScrollView to provide proper resizing of KOAgendaItems.
1919*/ 1924*/
1920void KOAgenda::resizeEvent ( QResizeEvent *ev ) 1925void KOAgenda::resizeEvent ( QResizeEvent *ev )
1921{ 1926{
1922 mSelectionHeight = 0; 1927 mSelectionHeight = 0;
1923 mResizeTimer.start( 150 , true ); 1928 mResizeTimer.start( 150 , true );
1924 computeSizes(); 1929 computeSizes();
1925 QScrollView::resizeEvent( ev ); 1930 QScrollView::resizeEvent( ev );
1926 return; 1931 return;
1927 1932
1928} 1933}
1929void KOAgenda::computeSizes() 1934void KOAgenda::computeSizes()
1930{ 1935{
1931 if ( globalFlagBlockStartup ) 1936 if ( globalFlagBlockStartup )
1932 return; 1937 return;
1933 int frameOffset = frameWidth() * 2 +1; 1938 int frameOffset = frameWidth() * 2 +1;
1934 if (mAllDayMode) { 1939 if (mAllDayMode) {
1935 mGridSpacingX = (width()-frameOffset) / mColumns; 1940 mGridSpacingX = (width()-frameOffset) / mColumns;
1936 mGridSpacingY = height() - 2 * frameWidth() - 1; 1941 mGridSpacingY = height() - 2 * frameWidth() - 1;
1937 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1); 1942 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1);
1938 // mGridSpacingY = height(); 1943 // mGridSpacingY = height();
1939 // resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 1944 // resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
1940 1945
1941 KOAgendaItem *item; 1946 KOAgendaItem *item;
1942 int subCellWidth; 1947 int subCellWidth;
1943 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1948 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1944 subCellWidth = mGridSpacingY / item->subCells(); 1949 subCellWidth = mGridSpacingY / item->subCells();
1945 item->resize(mGridSpacingX * item->cellWidth(),subCellWidth); 1950 int diff = 0;
1946 moveChild(item,KOGlobals::self()->reverseLayout() ? 1951 diff = item->resizeMe(mGridSpacingX ,mGridSpacingX * item->cellWidth(),subCellWidth);
1952 moveChild(item,(KOGlobals::self()->reverseLayout() ?
1947 (mColumns - 1 - item->cellX()) * mGridSpacingX : 1953 (mColumns - 1 - item->cellX()) * mGridSpacingX :
1948 item->cellX() * mGridSpacingX, 1954 item->cellX() * mGridSpacingX) + diff,
1949 item->subCell() * subCellWidth); 1955 item->subCell() * subCellWidth);
1950 } 1956 }
1951 KOPrefs::instance()->mAllDaySize = mGridSpacingY; 1957 KOPrefs::instance()->mAllDaySize = mGridSpacingY;
1952 } else { 1958 } else {
1953 mGridSpacingX = (width() - verticalScrollBar()->width()-frameOffset)/mColumns; 1959 mGridSpacingX = (width() - verticalScrollBar()->width()-frameOffset)/mColumns;
1954 if (height() > mGridSpacingY * mRows + 1 ) { 1960 if (height() > mGridSpacingY * mRows + 1 ) {
1955 KOPrefs::instance()->mHourSize = ((height())/mRows)+1; 1961 KOPrefs::instance()->mHourSize = ((height())/mRows)+1;
1956 mGridSpacingY = KOPrefs::instance()->mHourSize ; 1962 mGridSpacingY = KOPrefs::instance()->mHourSize ;
1957 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 1963 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
1958 emit resizedSignal(); 1964 emit resizedSignal();
1959 } else 1965 } else
1960 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 1966 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
1961 KOAgendaItem *item; 1967 KOAgendaItem *item;
1962 int subCellWidth; 1968 int subCellWidth;
1963 1969
1964 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1970 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1965 subCellWidth = mGridSpacingX / item->subCells(); 1971 subCellWidth = mGridSpacingX / item->subCells();
1966 item->resize(subCellWidth,item->height()); 1972 item->resize(subCellWidth,item->height());
1967 moveChild(item,(KOGlobals::self()->reverseLayout() ? 1973 moveChild(item,(KOGlobals::self()->reverseLayout() ?
1968 (mColumns - 1 - item->cellX()) * mGridSpacingX : 1974 (mColumns - 1 - item->cellX()) * mGridSpacingX :
1969 item->cellX() * mGridSpacingX) + 1975 item->cellX() * mGridSpacingX) +
1970 item->subCell() * subCellWidth,childY(item)); 1976 item->subCell() * subCellWidth,childY(item));
1971 } 1977 }
1972 } 1978 }
1973 int cw = contentsWidth(); 1979 int cw = contentsWidth();
1974 int ch = contentsHeight(); 1980 int ch = contentsHeight();
1975 if ( mAllDayMode ) { 1981 if ( mAllDayMode ) {
1976 QPixmap* paintPixAll = KOAgendaItem::paintPixAllday(); 1982 QPixmap* paintPixAll = KOAgendaItem::paintPixAllday();
1977 if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 ) { 1983 if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 ) {
1978 //qDebug("paintPixAll->resize "); 1984 //qDebug("paintPixAll->resize ");
1979 paintPixAll->resize( cw, ch ); 1985 paintPixAll->resize( cw, ch );
1980 } 1986 }
1981 } else { 1987 } else {
1982 QPixmap* paintPix = KOAgendaItem::paintPix(); 1988 QPixmap* paintPix = KOAgendaItem::paintPix();
1983 if ( paintPix->width() < cw || paintPix->height() < ch ) { 1989 if ( paintPix->width() < cw || paintPix->height() < ch ) {
1984 //qDebug("paintPix->resize "); 1990 //qDebug("paintPix->resize ");
1985 paintPix->resize( cw , ch ); 1991 paintPix->resize( cw , ch );
1986 } 1992 }
1987 } 1993 }
1988 1994
1989 checkScrollBoundaries(); 1995 checkScrollBoundaries();
1990 drawContentsToPainter(); 1996 drawContentsToPainter();
1991 viewport()->repaint(false); 1997 viewport()->repaint(false);
1992} 1998}
1993 1999
1994void KOAgenda::scrollUp() 2000void KOAgenda::scrollUp()
1995{ 2001{
1996 scrollBy(0,-mScrollOffset); 2002 scrollBy(0,-mScrollOffset);
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp
index 49ad9b8..7a685d8 100644
--- a/korganizer/koagendaitem.cpp
+++ b/korganizer/koagendaitem.cpp
@@ -611,97 +611,115 @@ void KOAgendaItem::computeText()
611 else if ( mIncidence->typeID() == todoID ) { 611 else if ( mIncidence->typeID() == todoID ) {
612 if (mIncidence->hasStartDate()) 612 if (mIncidence->hasStartDate())
613 tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr(); 613 tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr();
614 if (((Todo*)mIncidence)->hasDueDate()) 614 if (((Todo*)mIncidence)->hasDueDate())
615 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr(); 615 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr();
616 } 616 }
617 } else if ( mIncidence->typeID() == todoID ) { 617 } else if ( mIncidence->typeID() == todoID ) {
618 if (mIncidence->hasStartDate()) 618 if (mIncidence->hasStartDate())
619 tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr(); 619 tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr();
620 if (((Todo*)mIncidence)->hasDueDate()) 620 if (((Todo*)mIncidence)->hasDueDate())
621 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr(); 621 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr();
622 } 622 }
623 623
624 if (!mIncidence->location().isEmpty()) { 624 if (!mIncidence->location().isEmpty()) {
625 tipText += "\n"+i18n("Location: ")+mIncidence->location(); 625 tipText += "\n"+i18n("Location: ")+mIncidence->location();
626 } 626 }
627 QToolTip::add(this,tipText,toolTipGroup(),""); 627 QToolTip::add(this,tipText,toolTipGroup(),"");
628#endif 628#endif
629} 629}
630void KOAgendaItem::updateItem() 630void KOAgendaItem::updateItem()
631{ 631{
632 computeText(); 632 computeText();
633 633
634 //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y()); 634 //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y());
635 paintMe( mSelected ); 635 paintMe( mSelected );
636 repaint( false); 636 repaint( false);
637} 637}
638 638
639void KOAgendaItem::resizeEvent ( QResizeEvent *ev ) 639void KOAgendaItem::resizeEvent ( QResizeEvent *ev )
640{ 640{
641 //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1()); 641 //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1());
642 paintMe( mSelected ); 642 paintMe( mSelected );
643 repaint( false ); 643 repaint( false );
644} 644}
645 645
646/* 646/*
647 Return height of item in units of agenda cells 647 Return height of item in units of agenda cells
648*/ 648*/
649int KOAgendaItem::cellHeight() 649int KOAgendaItem::cellHeight()
650{ 650{
651 int ret = mCellYBottom - mCellYTop + 1; 651 int ret = mCellYBottom - mCellYTop + 1;
652 if ( ret <= 0 ) { 652 if ( ret <= 0 ) {
653 ret = 1; 653 ret = 1;
654 mCellYBottom = 0; 654 mCellYBottom = 0;
655 mCellYTop = 0; 655 mCellYTop = 0;
656 } 656 }
657 return ret; 657 return ret;
658} 658}
659 659// it may be that allday agenda items have a needed width > 32000
660// this code is to fix this problem
661int KOAgendaItem::resizeMe( int grid, int wid, int hei )
662{
663 int diff = 0;
664 if ( mCellX < -3 && mAllDay ) {
665 diff = (mCellX + 3) * -grid;
666 //qDebug("%s: cellX %d diff %d wid %d grid %d ", mDisplayedText.latin1(), mCellX, diff, wid, grid);
667 if ( diff >= wid ) {
668 // qDebug("KOAgendaItem::resizeMe: diff >= wid: diff %d wid %d ", diff, wid);
669 //diff = 0;
670 }
671 }
672 if ( wid == width() || diff >= wid )
673 resize( wid, hei );
674 else
675 resize( wid - diff, hei );
676 return diff;
677}
660/* 678/*
661 Return height of item in units of agenda cells 679 Return height of item in units of agenda cells
662*/ 680*/
663int KOAgendaItem::cellWidth() 681int KOAgendaItem::cellWidth()
664{ 682{
665 return mCellXWidth - mCellX + 1; 683 return mCellXWidth - mCellX + 1;
666} 684}
667 685
668void KOAgendaItem::setItemDate(QDate qd) 686void KOAgendaItem::setItemDate(QDate qd)
669{ 687{
670 mDate = qd; 688 mDate = qd;
671} 689}
672 690
673void KOAgendaItem::setCellXY(int X, int YTop, int YBottom) 691void KOAgendaItem::setCellXY(int X, int YTop, int YBottom)
674{ 692{
675 mCellX = X; 693 mCellX = X;
676 mCellYTop = YTop; 694 mCellYTop = YTop;
677 mCellYBottom = YBottom; 695 mCellYBottom = YBottom;
678} 696}
679 697
680void KOAgendaItem::setCellXWidth(int xwidth) 698void KOAgendaItem::setCellXWidth(int xwidth)
681{ 699{
682 mCellXWidth = xwidth; 700 mCellXWidth = xwidth;
683} 701}
684 702
685void KOAgendaItem::setCellX(int XLeft, int XRight) 703void KOAgendaItem::setCellX(int XLeft, int XRight)
686{ 704{
687 mCellX = XLeft; 705 mCellX = XLeft;
688 mCellXWidth = XRight; 706 mCellXWidth = XRight;
689} 707}
690 708
691void KOAgendaItem::setCellY(int YTop, int YBottom) 709void KOAgendaItem::setCellY(int YTop, int YBottom)
692{ 710{
693 mCellYTop = YTop; 711 mCellYTop = YTop;
694 mCellYBottom = YBottom; 712 mCellYBottom = YBottom;
695} 713}
696 714
697void KOAgendaItem::setSubCell(int subCell) 715void KOAgendaItem::setSubCell(int subCell)
698{ 716{
699 mSubCell = subCell; 717 mSubCell = subCell;
700} 718}
701 719
702void KOAgendaItem::setSubCells(int subCells) 720void KOAgendaItem::setSubCells(int subCells)
703{ 721{
704 mSubCells = subCells; 722 mSubCells = subCells;
705} 723}
706 724
707void KOAgendaItem::setMultiItem(KOAgendaItem *first,KOAgendaItem *next, 725void KOAgendaItem::setMultiItem(KOAgendaItem *first,KOAgendaItem *next,
diff --git a/korganizer/koagendaitem.h b/korganizer/koagendaitem.h
index 2b26e95..97acd4c 100644
--- a/korganizer/koagendaitem.h
+++ b/korganizer/koagendaitem.h
@@ -64,96 +64,97 @@ class KOAgendaItem : public QWidget
64 void setCellXWidth(int xwidth); 64 void setCellXWidth(int xwidth);
65 void setSubCell(int subCell); 65 void setSubCell(int subCell);
66 void setSubCells(int subCells); 66 void setSubCells(int subCells);
67 67
68 /** Start movement */ 68 /** Start movement */
69 void startMove(); 69 void startMove();
70 /** Reset to original values */ 70 /** Reset to original values */
71 void resetMove(); 71 void resetMove();
72 72
73 void moveRelative(int dx,int dy); 73 void moveRelative(int dx,int dy);
74 void expandTop(int dy); 74 void expandTop(int dy);
75 void expandBottom(int dy); 75 void expandBottom(int dy);
76 void expandLeft(int dx); 76 void expandLeft(int dx);
77 void expandRight(int dx); 77 void expandRight(int dx);
78 int mLastMoveXPos; 78 int mLastMoveXPos;
79 79
80 void setMultiItem(KOAgendaItem *first,KOAgendaItem *next, 80 void setMultiItem(KOAgendaItem *first,KOAgendaItem *next,
81 KOAgendaItem *last); 81 KOAgendaItem *last);
82 KOAgendaItem *firstMultiItem() { return mFirstMultiItem; } 82 KOAgendaItem *firstMultiItem() { return mFirstMultiItem; }
83 KOAgendaItem *nextMultiItem() { return mNextMultiItem; } 83 KOAgendaItem *nextMultiItem() { return mNextMultiItem; }
84 KOAgendaItem *lastMultiItem() { return mLastMultiItem; } 84 KOAgendaItem *lastMultiItem() { return mLastMultiItem; }
85 85
86 Incidence *incidence() const { return mIncidence; } 86 Incidence *incidence() const { return mIncidence; }
87 QDate itemDate() { return mDate; } 87 QDate itemDate() { return mDate; }
88 88
89 /** Update the date of this item's occurence (not in the event) */ 89 /** Update the date of this item's occurence (not in the event) */
90 void setItemDate(QDate qd); 90 void setItemDate(QDate qd);
91 91
92 void setText ( const QString & text ) { mDisplayedText = text; } 92 void setText ( const QString & text ) { mDisplayedText = text; }
93 QString text () { return mDisplayedText; } 93 QString text () { return mDisplayedText; }
94 94
95 virtual bool eventFilter ( QObject *, QEvent * ); 95 virtual bool eventFilter ( QObject *, QEvent * );
96 96
97 static QToolTipGroup *toolTipGroup(); 97 static QToolTipGroup *toolTipGroup();
98 98
99 QPtrList<KOAgendaItem> conflictItems(); 99 QPtrList<KOAgendaItem> conflictItems();
100 void setConflictItems(QPtrList<KOAgendaItem>); 100 void setConflictItems(QPtrList<KOAgendaItem>);
101 void addConflictItem(KOAgendaItem *ci); 101 void addConflictItem(KOAgendaItem *ci);
102 void paintMe( bool, QPainter* painter = 0 ); 102 void paintMe( bool, QPainter* painter = 0 );
103 void repaintMe(); 103 void repaintMe();
104 static QPixmap * paintPix(); 104 static QPixmap * paintPix();
105 static QPixmap * paintPixAllday(); 105 static QPixmap * paintPixAllday();
106 void updateItem(); 106 void updateItem();
107 void computeText(); 107 void computeText();
108 void recreateIncidence(); 108 void recreateIncidence();
109 bool checkLayout(); 109 bool checkLayout();
110 void initColor (); 110 void initColor ();
111 bool isAllDay() { return mAllDay; } 111 bool isAllDay() { return mAllDay; }
112 int resizeMe( int grid, int wid, int hei );
112 public slots: 113 public slots:
113 bool updateIcons( QPainter *, bool ); 114 bool updateIcons( QPainter *, bool );
114 void select(bool=true); 115 void select(bool=true);
115 void repaintItem(); 116 void repaintItem();
116 117
117 protected: 118 protected:
118 void dragEnterEvent(QDragEnterEvent *e); 119 void dragEnterEvent(QDragEnterEvent *e);
119 void dropEvent(QDropEvent *e); 120 void dropEvent(QDropEvent *e);
120 void paintEvent ( QPaintEvent * ); 121 void paintEvent ( QPaintEvent * );
121 void resizeEvent ( QResizeEvent *ev ); 122 void resizeEvent ( QResizeEvent *ev );
122 123
123 private: 124 private:
124 KOAgendaItemWhatsThis* mKOAgendaItemWhatsThis; 125 KOAgendaItemWhatsThis* mKOAgendaItemWhatsThis;
125 bool mAllDay; 126 bool mAllDay;
126 bool mWhiteText; 127 bool mWhiteText;
127 int mCellX; 128 int mCellX;
128 int mCellXWidth; 129 int mCellXWidth;
129 int mCellYTop,mCellYBottom; 130 int mCellYTop,mCellYBottom;
130 int mSubCell; // subcell number of this item 131 int mSubCell; // subcell number of this item
131 int mSubCells; // Total number of subcells in cell of this item 132 int mSubCells; // Total number of subcells in cell of this item
132 int xPaintCoord; 133 int xPaintCoord;
133 int yPaintCoord; 134 int yPaintCoord;
134 int wPaintCoord; 135 int wPaintCoord;
135 int hPaintCoord; 136 int hPaintCoord;
136 // Variables to remember start position 137 // Variables to remember start position
137 int mStartCellX; 138 int mStartCellX;
138 int mStartCellXWidth; 139 int mStartCellXWidth;
139 int mStartCellYTop,mStartCellYBottom; 140 int mStartCellYTop,mStartCellYBottom;
140 int mLastMovePos; 141 int mLastMovePos;
141 142
142 // Multi item pointers 143 // Multi item pointers
143 KOAgendaItem *mFirstMultiItem; 144 KOAgendaItem *mFirstMultiItem;
144 KOAgendaItem *mNextMultiItem; 145 KOAgendaItem *mNextMultiItem;
145 KOAgendaItem *mLastMultiItem; 146 KOAgendaItem *mLastMultiItem;
146 147
147 int mFontPixelSize; 148 int mFontPixelSize;
148 Incidence *mIncidence; // corresponding event or todo 149 Incidence *mIncidence; // corresponding event or todo
149 QDate mDate; //date this events occurs (for recurrence) 150 QDate mDate; //date this events occurs (for recurrence)
150 //void showIcon( QLabel*, int ); 151 //void showIcon( QLabel*, int );
151 //QLabel *mTodoIconLabel; 152 //QLabel *mTodoIconLabel;
152 //QLabel *mItemLabel; 153 //QLabel *mItemLabel;
153 //QWidget *mIconBox; 154 //QWidget *mIconBox;
154 //QLabel *mIconAlarm,*mIconRecur,*mIconReadonly; 155 //QLabel *mIconAlarm,*mIconRecur,*mIconReadonly;
155 //QLabel *mIconReply,*mIconGroup,*mIconOrganizer; 156 //QLabel *mIconReply,*mIconGroup,*mIconOrganizer;
156 //QLabel *mIconMoreInfo; 157 //QLabel *mIconMoreInfo;
157 static QToolTipGroup *mToolTipGroup; 158 static QToolTipGroup *mToolTipGroup;
158 159
159 QColor mBackgroundColor; 160 QColor mBackgroundColor;