summaryrefslogtreecommitdiffabout
path: root/korganizer/koagenda.cpp
authorzautrix <zautrix>2005-08-17 13:06:53 (UTC)
committer zautrix <zautrix>2005-08-17 13:06:53 (UTC)
commit4b66565ed2db51bc636b7b4c12f19f036d9b80f3 (patch) (unidiff)
tree402372be9f52835e15757a51c18cfc46d47c8953 /korganizer/koagenda.cpp
parent31393a99cd2b190e62a7a09a7739a14af83936d1 (diff)
downloadkdepimpi-4b66565ed2db51bc636b7b4c12f19f036d9b80f3.zip
kdepimpi-4b66565ed2db51bc636b7b4c12f19f036d9b80f3.tar.gz
kdepimpi-4b66565ed2db51bc636b7b4c12f19f036d9b80f3.tar.bz2
allday agenda item fix
Diffstat (limited to 'korganizer/koagenda.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagenda.cpp42
1 files changed, 24 insertions, 18 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp
index 88f5d99..796d633 100644
--- a/korganizer/koagenda.cpp
+++ b/korganizer/koagenda.cpp
@@ -948,59 +948,60 @@ void KOAgenda::performItemAction(QPoint viewportPos)
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 ) {
@@ -1208,76 +1209,79 @@ void KOAgenda::placeSubCells(KOAgendaItem *placeItem)
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{
@@ -1386,40 +1390,41 @@ void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch)
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;
@@ -1827,25 +1832,25 @@ KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int
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
@@ -1933,28 +1938,29 @@ void KOAgenda::computeSizes()
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 );