summaryrefslogtreecommitdiffabout
path: root/korganizer/koagenda.cpp
Unidiff
Diffstat (limited to 'korganizer/koagenda.cpp') (more/less context) (show whitespace changes)
-rw-r--r--korganizer/koagenda.cpp21
1 files changed, 11 insertions, 10 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp
index 7d9d674..88f5d99 100644
--- a/korganizer/koagenda.cpp
+++ b/korganizer/koagenda.cpp
@@ -1446,63 +1446,63 @@ void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// i
1446 if ( ch < 1 ) 1446 if ( ch < 1 )
1447 ch = 1; 1447 ch = 1;
1448 if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) { 1448 if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) {
1449 mPaintPixmap.resize( contentsWidth()+42, ch ); 1449 mPaintPixmap.resize( contentsWidth()+42, ch );
1450 } 1450 }
1451 mCurPixWid = contentsWidth(); 1451 mCurPixWid = contentsWidth();
1452 mCurPixHei = ch; 1452 mCurPixHei = ch;
1453 if ( mHighlightPixmap.width() < mGridSpacingX-1 ) { 1453 if ( mHighlightPixmap.width() < mGridSpacingX-1 ) {
1454 mHighlightPixmap.resize( mGridSpacingX-1, 5 ); 1454 mHighlightPixmap.resize( mGridSpacingX-1, 5 );
1455 mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor ); 1455 mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor );
1456 } 1456 }
1457 mPixPainter.begin( &mPaintPixmap) ; 1457 mPixPainter.begin( &mPaintPixmap) ;
1458 //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() ); 1458 //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() );
1459 QPainter * p ; 1459 QPainter * p ;
1460 if (paint == 0) { 1460 if (paint == 0) {
1461 mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor); 1461 mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor);
1462 p = &mPixPainter; 1462 p = &mPixPainter;
1463 } 1463 }
1464 else 1464 else
1465 p = paint ; 1465 p = paint ;
1466 // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch); 1466 // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch);
1467 1467
1468 //--cx;++cw; 1468 //--cx;++cw;
1469 int lGridSpacingY = mGridSpacingY*2; 1469 int lGridSpacingY = mGridSpacingY*2;
1470 int selDay; 1470 uint selDay;
1471 QDate curDate = QDate::currentDate(); 1471 QDate curDate = QDate::currentDate();
1472 if ( !backgroundOnly ) { 1472 if ( !backgroundOnly ) {
1473 for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) 1473 for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay)
1474 { 1474 {
1475 if ( mSelectedDates[selDay] == curDate && KOPrefs::instance()->mHighlightCurrentDay) { 1475 if ( mSelectedDates[selDay] == curDate && KOPrefs::instance()->mHighlightCurrentDay) {
1476 int x1 = cx; 1476 int x1 = cx;
1477 int y1 = 0; 1477 int y1 = 0;
1478 if (y1 < cy) y1 = cy; 1478 if (y1 < cy) y1 = cy;
1479 int x2 = cx+cw-1; 1479 int x2 = cx+cw-1;
1480 int y2 = contentsHeight(); 1480 int y2 = contentsHeight();
1481 if (y2 > cy+ch-1) y2=cy+ch-1; 1481 if (y2 > cy+ch-1) y2=cy+ch-1;
1482 if (x2 >= x1 && y2 >= y1) { 1482 if (x2 >= x1 && y2 >= y1) {
1483 int gxStart = selDay; 1483 int gxStart = selDay;
1484 int gxEnd = gxStart ; 1484 //int gxEnd = gxStart ;
1485 int xStart = KOGlobals::self()->reverseLayout() ? 1485 int xStart = KOGlobals::self()->reverseLayout() ?
1486 (mColumns - 1 - gxStart)*mGridSpacingX : 1486 (mColumns - 1 - gxStart)*mGridSpacingX :
1487 gxStart*mGridSpacingX; 1487 gxStart*mGridSpacingX;
1488 if (xStart < x1) xStart = x1; 1488 if (xStart < x1) xStart = x1;
1489 int xEnd = KOGlobals::self()->reverseLayout() ? 1489 int xEnd = KOGlobals::self()->reverseLayout() ?
1490 (mColumns - gxStart)*mGridSpacingX-1 : 1490 (mColumns - gxStart)*mGridSpacingX-1 :
1491 (gxStart+1)*mGridSpacingX-1; 1491 (gxStart+1)*mGridSpacingX-1;
1492 if (xEnd > x2) xEnd = x2; 1492 if (xEnd > x2) xEnd = x2;
1493 if ( KOPrefs::instance()->mUseHighlightLightColor ) 1493 if ( KOPrefs::instance()->mUseHighlightLightColor )
1494 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, 1494 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
1495 KOPrefs::instance()->mAgendaBgColor.light()); 1495 KOPrefs::instance()->mAgendaBgColor.light());
1496 else 1496 else
1497 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, 1497 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
1498 KOPrefs::instance()->mAgendaBgColor.dark()); 1498 KOPrefs::instance()->mAgendaBgColor.dark());
1499 1499
1500 } 1500 }
1501 } 1501 }
1502 } 1502 }
1503 } 1503 }
1504 // Highlight working hours 1504 // Highlight working hours
1505 1505
1506 if ( !backgroundOnly ) 1506 if ( !backgroundOnly )
1507 if (mWorkingHoursEnable) { 1507 if (mWorkingHoursEnable) {
1508 int x1 = cx; 1508 int x1 = cx;
@@ -1901,48 +1901,49 @@ void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd,
1901 // Preferred one. 1901 // Preferred one.
1902 // But it doesn´t hurt, so it stays. 1902 // But it doesn´t hurt, so it stays.
1903// if (mAllDayMode) { 1903// if (mAllDayMode) {
1904// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred); 1904// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
1905// } else { 1905// } else {
1906// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); 1906// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
1907// } 1907// }
1908//} 1908//}
1909void KOAgenda::finishResize ( ) 1909void KOAgenda::finishResize ( )
1910{ 1910{
1911 //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) "); 1911 //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) ");
1912 if ( globalFlagBlockAgenda == 0 ) { 1912 if ( globalFlagBlockAgenda == 0 ) {
1913 finishUpdate(); 1913 finishUpdate();
1914 //qDebug("finishUpdate() called "); 1914 //qDebug("finishUpdate() called ");
1915 } 1915 }
1916} 1916}
1917/* 1917/*
1918 Overridden from QScrollView to provide proper resizing of KOAgendaItems. 1918 Overridden from QScrollView to provide proper resizing of KOAgendaItems.
1919*/ 1919*/
1920void KOAgenda::resizeEvent ( QResizeEvent *ev ) 1920void KOAgenda::resizeEvent ( QResizeEvent *ev )
1921{ 1921{
1922 mSelectionHeight = 0; 1922 mSelectionHeight = 0;
1923 mResizeTimer.start( 150 , true ); 1923 mResizeTimer.start( 150 , true );
1924 computeSizes(); 1924 computeSizes();
1925 QScrollView::resizeEvent( ev );
1925 return; 1926 return;
1926 1927
1927} 1928}
1928void KOAgenda::computeSizes() 1929void KOAgenda::computeSizes()
1929{ 1930{
1930 if ( globalFlagBlockStartup ) 1931 if ( globalFlagBlockStartup )
1931 return; 1932 return;
1932 int frameOffset = frameWidth() * 2 +1; 1933 int frameOffset = frameWidth() * 2 +1;
1933 if (mAllDayMode) { 1934 if (mAllDayMode) {
1934 mGridSpacingX = (width()-frameOffset) / mColumns; 1935 mGridSpacingX = (width()-frameOffset) / mColumns;
1935 mGridSpacingY = height() - 2 * frameWidth() - 1; 1936 mGridSpacingY = height() - 2 * frameWidth() - 1;
1936 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1); 1937 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1);
1937 // mGridSpacingY = height(); 1938 // mGridSpacingY = height();
1938 // resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 1939 // resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
1939 1940
1940 KOAgendaItem *item; 1941 KOAgendaItem *item;
1941 int subCellWidth; 1942 int subCellWidth;
1942 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1943 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1943 subCellWidth = mGridSpacingY / item->subCells(); 1944 subCellWidth = mGridSpacingY / item->subCells();
1944 item->resize(mGridSpacingX * item->cellWidth(),subCellWidth); 1945 item->resize(mGridSpacingX * item->cellWidth(),subCellWidth);
1945 moveChild(item,KOGlobals::self()->reverseLayout() ? 1946 moveChild(item,KOGlobals::self()->reverseLayout() ?
1946 (mColumns - 1 - item->cellX()) * mGridSpacingX : 1947 (mColumns - 1 - item->cellX()) * mGridSpacingX :
1947 item->cellX() * mGridSpacingX, 1948 item->cellX() * mGridSpacingX,
1948 item->subCell() * subCellWidth); 1949 item->subCell() * subCellWidth);
@@ -2160,119 +2161,119 @@ void KOAgenda::contentsMousePressEvent ( QMouseEvent *event )
2160 2161
2161void KOAgenda::storePosition() 2162void KOAgenda::storePosition()
2162{ 2163{
2163 //mContentPosition 2164 //mContentPosition
2164 int max = mGridSpacingY*4*24; 2165 int max = mGridSpacingY*4*24;
2165 if ( contentsY() < 5 && max > viewport()->height()*3/2 ) 2166 if ( contentsY() < 5 && max > viewport()->height()*3/2 )
2166 mContentPosition = 0; 2167 mContentPosition = 0;
2167 else if ( contentsY() + viewport()->height() > max - 5 && max > viewport()->height()*3/2) 2168 else if ( contentsY() + viewport()->height() > max - 5 && max > viewport()->height()*3/2)
2168 mContentPosition = -1.0; 2169 mContentPosition = -1.0;
2169 else 2170 else
2170 mContentPosition = ((float) max)/ ((float)(contentsY()+ ( viewport()->height()/2))); 2171 mContentPosition = ((float) max)/ ((float)(contentsY()+ ( viewport()->height()/2)));
2171 //qDebug("mContentPosition %f %d %d %d",mContentPosition , max, contentsY() ,viewport()->height()); 2172 //qDebug("mContentPosition %f %d %d %d",mContentPosition , max, contentsY() ,viewport()->height());
2172 2173
2173} 2174}
2174void KOAgenda::restorePosition() 2175void KOAgenda::restorePosition()
2175{ 2176{
2176 int posY; 2177 int posY;
2177 int max = mGridSpacingY*4*24; 2178 int max = mGridSpacingY*4*24;
2178 if ( mContentPosition < 0 ) 2179 if ( mContentPosition < 0 )
2179 posY = max-viewport()->height(); 2180 posY = max-viewport()->height();
2180 else 2181 else
2181 if ( mContentPosition == 0 ) 2182 if ( mContentPosition == 0 )
2182 posY = 0; 2183 posY = 0;
2183 else 2184 else
2184 posY = (max/mContentPosition)-(viewport()->height()/2); 2185 posY = (int) ((max/mContentPosition)-(viewport()->height()/2));
2185 setContentsPos (0, posY ); 2186 setContentsPos (0, posY );
2186 //qDebug("posY %d hei %d", posY, max); 2187 //qDebug("posY %d hei %d", posY, max);
2187 2188
2188} 2189}
2189void KOAgenda::moveChild( QWidget *w, int x , int y ) 2190void KOAgenda::moveChild( QWidget *w, int x , int y )
2190{ 2191{
2191 ++x; 2192 ++x;
2192 QScrollView::moveChild( w, x , y ); 2193 QScrollView::moveChild( w, x , y );
2193} 2194}
2194#include <qmessagebox.h> 2195#include <qmessagebox.h>
2195#ifdef DESKTOP_VERSION 2196#ifdef DESKTOP_VERSION
2196#include <qprinter.h> 2197#include <qprinter.h>
2197#include <qpainter.h> 2198#include <qpainter.h>
2198#include <qpaintdevicemetrics.h> 2199#include <qpaintdevicemetrics.h>
2199 2200
2200#endif 2201#endif
2201void KOAgenda::printSelection() 2202void KOAgenda::printSelection()
2202{ 2203{
2203#ifdef DESKTOP_VERSION 2204#ifdef DESKTOP_VERSION
2204 if ( mStartCellY == mCurrentCellY ) { 2205 if ( mStartCellY == mCurrentCellY ) {
2205 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 2206 QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
2206 i18n("Nothing selected!\n\nThis prints the full width of the Agenda view as you see it!\n\nTo determine the vertical range of the printing, please select\na vertical range (with the left mouse button down) in one column. "), 2207 i18n("Nothing selected!\n\nThis prints the full width of the Agenda view as you see it!\n\nTo determine the vertical range of the printing, please select\na vertical range (with the left mouse button down) in one column. "),
2207 i18n("OK"), 0, 0, 2208 i18n("OK"), 0, 0,
2208 0, 1 ); 2209 0, 1 );
2209 return; 2210 return;
2210 } 2211 }
2211 2212
2212 float dx, dy; 2213 float dx, dy;
2213 int x,y,w,h; 2214 int x,y,w,h;
2214 x= 0; 2215 x= 0;
2215 w= contentsWidth()+2; 2216 w= contentsWidth()+2;
2216 // h= contentsHeight(); 2217 // h= contentsHeight();
2217 y = mGridSpacingY*mStartCellY; 2218 y = mGridSpacingY*mStartCellY;
2218 h = mGridSpacingY*(mCurrentCellY+1)-y+2; 2219 h = mGridSpacingY*(mCurrentCellY+1)-y+2;
2219 2220
2220 //return; 2221 //return;
2221 QPrinter* printer = new QPrinter(); 2222 QPrinter* printer = new QPrinter();
2222 if ( !printer->setup()) { 2223 if ( !printer->setup()) {
2223 delete printer; 2224 delete printer;
2224 return; 2225 return;
2225 } 2226 }
2226 QPainter p( printer ); 2227 QPainter p( printer );
2227 QPaintDeviceMetrics m = QPaintDeviceMetrics ( printer ); 2228 QPaintDeviceMetrics m = QPaintDeviceMetrics ( printer );
2228 QString date = i18n("Date range: ")+KGlobal::locale()->formatDate( mSelectedDates.first() )+" - "+KGlobal::locale()->formatDate( mSelectedDates.last() ); 2229 QString date = i18n("Date range: ")+KGlobal::locale()->formatDate( mSelectedDates.first() )+" - "+KGlobal::locale()->formatDate( mSelectedDates.last() );
2229 //date += " --- printing time: " + KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), true ); 2230 //date += " --- printing time: " + KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), true );
2230 int hei = p.boundingRect(0,0, 5, 5, Qt::AlignLeft, date ).height(); 2231 int hei = p.boundingRect(0,0, 5, 5, Qt::AlignLeft, date ).height();
2231 // p.drawText( 0, 0, date ); 2232 // p.drawText( 0, 0, date );
2232 int offset = m.width()/8; 2233 int offset = m.width()/8;
2233 // compute the scale 2234 // compute the scale
2234 dx = ((float) m.width()-offset) / (float)w; 2235 dx = ((float) m.width()-offset) / (float)w;
2235 dy = (float)(m.height() - ( 2 * hei )-offset ) / (float)h; 2236 dy = (float)(m.height() - ( 2 * hei )-offset ) / (float)h;
2236 float scale; 2237 float scale;
2237 // scale to fit the width or height of the paper 2238 // scale to fit the width or height of the paper
2238 if ( dx < dy ) 2239 if ( dx < dy )
2239 scale = dx; 2240 scale = dx;
2240 else 2241 else
2241 scale = dy; 2242 scale = dy;
2242 // set the scale 2243 // set the scale
2243 p.drawText( offset* scale, offset* scale*3/4, date ); 2244 p.drawText( (int) (offset* scale), (int) (offset* scale*3/4), date );
2244 2245
2245 int selDay; 2246 uint selDay;
2246 float widOffset = ((float) m.width()-offset) / ((float)(mSelectedDates.count())); 2247 float widOffset = ((float) m.width()-offset) / ((float)(mSelectedDates.count()));
2247 float startX = 1; 2248 float startX = 1;
2248 for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) 2249 for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay)
2249 { 2250 {
2250 QString text = KGlobal::locale()->formatDate( mSelectedDates[selDay],true ); 2251 QString text = KGlobal::locale()->formatDate( mSelectedDates[selDay],true );
2251 p.setClipRect(offset* scale+startX , 0, widOffset-4, offset* scale+(2*hei* scale) ); 2252 p.setClipRect((int) (offset* scale+startX) , 0, (int) (widOffset-4), (int) (offset* scale+(2*hei* scale)) );
2252 p.drawText( offset* scale+startX, (offset+hei)* scale, text ); 2253 p.drawText( (int) (offset* scale+startX), (int) ((offset+hei)* scale), text );
2253 startX += widOffset; 2254 startX += widOffset;
2254 2255
2255 } 2256 }
2256 p.translate( offset* scale,offset* scale+ (-y * scale)+(2*hei* scale)); 2257 p.translate( (int) (offset* scale),(int) (offset* scale+ (-y * scale)+(2*hei* scale)));
2257 p.scale( scale, scale ); 2258 p.scale( scale, scale );
2258 p.setClipRect( offset* scale, offset* scale+(2*hei* scale), w*scale, h*scale ); 2259 p.setClipRect( (int) (offset* scale), (int) (offset* scale+(2*hei* scale)), (int) (w*scale), (int) (h*scale) );
2259 // now printing with y offset: 2 hei 2260 // now printing with y offset: 2 hei
2260 // p.translate( 0, -y*scale); 2261 // p.translate( 0, -y*scale);
2261 2262
2262 drawContentsToPainter(&p, true ); 2263 drawContentsToPainter(&p, true );
2263 globalFlagBlockAgendaItemUpdate = false; 2264 globalFlagBlockAgendaItemUpdate = false;
2264 KOAgendaItem *item; 2265 KOAgendaItem *item;
2265 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 2266 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
2266 item->select(false); 2267 item->select(false);
2267 item->paintMe( false, &p ); 2268 item->paintMe( false, &p );
2268 } 2269 }
2269 globalFlagBlockAgendaItemUpdate = true; 2270 globalFlagBlockAgendaItemUpdate = true;
2270 p.end(); 2271 p.end();
2271 delete printer; 2272 delete printer;
2272#else 2273#else
2273 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 2274 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
2274 i18n("Not supported \non PDA!\n"), 2275 i18n("Not supported \non PDA!\n"),
2275 i18n("OK"), 0, 0, 2276 i18n("OK"), 0, 0,
2276 0, 1 ); 2277 0, 1 );
2277#endif 2278#endif
2278} 2279}