summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-04-01 19:05:18 (UTC)
committer zautrix <zautrix>2005-04-01 19:05:18 (UTC)
commit1022d8763a5185c74d1fb1fba9857d6e3afd9ff5 (patch) (unidiff)
tree116b7ac7aef10e27c20ce30f3bae548ebde84da0
parentedc032c21ae3788d02a632ea8066e4ac5a4feedb (diff)
downloadkdepimpi-1022d8763a5185c74d1fb1fba9857d6e3afd9ff5.zip
kdepimpi-1022d8763a5185c74d1fb1fba9857d6e3afd9ff5.tar.gz
kdepimpi-1022d8763a5185c74d1fb1fba9857d6e3afd9ff5.tar.bz2
fixes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagendaview.cpp30
-rw-r--r--korganizer/kodaymatrix.cpp4
2 files changed, 16 insertions, 18 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index 072d464..99f547a 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -36,280 +36,276 @@
36#include <qpainter.h> 36#include <qpainter.h>
37#include <qpushbutton.h> 37#include <qpushbutton.h>
38#include <qapplication.h> 38#include <qapplication.h>
39 39
40#include <kapplication.h> 40#include <kapplication.h>
41#include <KDGanttMinimizeSplitter.h> 41#include <KDGanttMinimizeSplitter.h>
42#include <kdebug.h> 42#include <kdebug.h>
43#include <kstandarddirs.h> 43#include <kstandarddirs.h>
44#include <kiconloader.h> 44#include <kiconloader.h>
45#include <klocale.h> 45#include <klocale.h>
46#include <kconfig.h> 46#include <kconfig.h>
47#include <kglobal.h> 47#include <kglobal.h>
48#include "calendarview.h" 48#include "calendarview.h"
49#include "koviewmanager.h" 49#include "koviewmanager.h"
50 50
51#include <libkcal/calendar.h> 51#include <libkcal/calendar.h>
52#include <libkcal/icaldrag.h> 52#include <libkcal/icaldrag.h>
53#include <libkcal/dndfactory.h> 53#include <libkcal/dndfactory.h>
54 54
55#include <kcalendarsystem.h> 55#include <kcalendarsystem.h>
56 56
57#include "koglobals.h" 57#include "koglobals.h"
58#ifndef KORG_NOPLUGINS 58#ifndef KORG_NOPLUGINS
59#include "kocore.h" 59#include "kocore.h"
60#endif 60#endif
61#include "koprefs.h" 61#include "koprefs.h"
62#include "koagenda.h" 62#include "koagenda.h"
63#include "koagendaitem.h" 63#include "koagendaitem.h"
64#ifndef KORG_NOPRINTER 64#ifndef KORG_NOPRINTER
65#include "calprinter.h" 65#include "calprinter.h"
66#endif 66#endif
67 67
68#include "koagendaview.h" 68#include "koagendaview.h"
69//#include "koagendaview.moc" 69//#include "koagendaview.moc"
70 70
71//extern bool globalFlagBlockPainting; 71//extern bool globalFlagBlockPainting;
72extern int globalFlagBlockAgenda; 72extern int globalFlagBlockAgenda;
73extern int globalFlagBlockStartup; 73extern int globalFlagBlockStartup;
74extern int globalFlagBlockAgendaItemPaint; 74extern int globalFlagBlockAgendaItemPaint;
75extern int globalFlagBlockAgendaItemUpdate; 75extern int globalFlagBlockAgendaItemUpdate;
76extern int globalFlagBlockLabel; 76extern int globalFlagBlockLabel;
77using namespace KOrg; 77using namespace KOrg;
78 78
79 79
80 80
81TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) : 81TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) :
82 QScrollView(parent,name,f) 82 QScrollView(parent,name,f)
83{ 83{
84 myPix.resize( 1, 1 ); 84 myPix.resize( 1, 1 );
85 mRows = rows; 85 mRows = rows;
86 86
87 mRedrawNeeded = true; 87 mRedrawNeeded = true;
88 setMinimumHeight( 20 ); 88 setMinimumHeight( 20 );
89 mCellHeight = KOPrefs::instance()->mHourSize*4; 89 mCellHeight = KOPrefs::instance()->mHourSize*4;
90 90
91 enableClipper(true); 91 enableClipper(true);
92 92
93 setHScrollBarMode(AlwaysOff); 93 setHScrollBarMode(AlwaysOff);
94 setVScrollBarMode(AlwaysOff); 94 setVScrollBarMode(AlwaysOff);
95 95
96 resizeContents(50,mRows * mCellHeight); 96 resizeContents(50,mRows * mCellHeight);
97 97
98 viewport()->setBackgroundMode( PaletteBackground ); 98 viewport()->setBackgroundMode( PaletteBackground );
99} 99}
100 100
101void TimeLabels::setCellHeight(int height) 101void TimeLabels::setCellHeight(int height)
102{ 102{
103 mCellHeight = height; 103 mCellHeight = height;
104} 104}
105 105
106/* 106/*
107 Optimization so that only the "dirty" portion of the scroll view 107 Optimization so that only the "dirty" portion of the scroll view
108 is redrawn. Unfortunately, this is not called by default paintEvent() method. 108 is redrawn. Unfortunately, this is not called by default paintEvent() method.
109*/ 109*/
110void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) 110void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch)
111{ 111{
112 112
113 // if ( globalFlagBlockAgenda ) 113 // if ( globalFlagBlockAgenda )
114 // return; 114 // return;
115 // bug: the parameters cx, cy, cw, ch are the areas that need to be 115 // bug: the parameters cx, cy, cw, ch are the areas that need to be
116 // redrawn, not the area of the widget. unfortunately, this 116 // redrawn, not the area of the widget. unfortunately, this
117 // code assumes the latter... 117 // code assumes the latter...
118 118
119 // now, for a workaround... 119 // now, for a workaround...
120 // these two assignments fix the weird redraw bug 120 // these two assignments fix the weird redraw bug
121 mRedrawNeeded = true; 121 mRedrawNeeded = true;
122 if ( mRedrawNeeded ) { 122 if ( mRedrawNeeded ) {
123 cx = contentsX() + frameWidth()*2; 123 cx = contentsX() + frameWidth()*2;
124 cw = contentsWidth() ; 124 cw = contentsWidth() ;
125 // end of workaround 125 // end of workaround
126 126
127 int cell = ((int)(cy/mCellHeight)); 127 int cell = ((int)(cy/mCellHeight));
128 int y = cell * mCellHeight; 128 int y = cell * mCellHeight;
129 QFontMetrics fm = fontMetrics(); 129 QFontMetrics fm = fontMetrics();
130 QString hour; 130 QString hour;
131 QString suffix; 131 QString suffix;
132 int tW = fm.width("24:00i"); 132 int timeHeight = fm.ascent();
133 int timeHeight = fm.height();
134 //timeHeight -= (timeHeight/4-2);
135 int borderWidth = 0;
136 QFont nFont = p->font(); 133 QFont nFont = p->font();
137 134
138 if (!KGlobal::locale()->use12Clock()) 135 if (!KGlobal::locale()->use12Clock())
139 suffix = "00"; 136 suffix = "00";
140 else 137
141 borderWidth = 0;
142 if ( timeHeight > mCellHeight ) { 138 if ( timeHeight > mCellHeight ) {
143 timeHeight = mCellHeight-1; 139 timeHeight = mCellHeight-1;
144 int pointS = nFont.pointSize(); 140 int pointS = nFont.pointSize();
145 while ( pointS > 4 ) { 141 while ( pointS > 4 ) {
146 nFont.setPointSize( pointS ); 142 nFont.setPointSize( pointS );
147 fm = QFontMetrics( nFont ); 143 fm = QFontMetrics( nFont );
148 if ( fm.height() < mCellHeight ) 144 if ( fm.ascent() < mCellHeight )
149 break; 145 break;
150 -- pointS; 146 -- pointS;
151 } 147 }
152 fm = QFontMetrics( nFont ); 148 fm = QFontMetrics( nFont );
153 borderWidth = 4; 149 timeHeight = fm.ascent();
154 timeHeight = fm.height();
155 } 150 }
156 //timeHeight -= (timeHeight/4-2); 151 //timeHeight -= (timeHeight/4-2);
157 QFont sFont = nFont; 152 QFont sFont = nFont;
158 sFont.setPointSize( sFont.pointSize()/2+2 ); 153 sFont.setPointSize( sFont.pointSize()/2 );
159 QFontMetrics fmS( sFont ); 154 QFontMetrics fmS( sFont );
160 int sHei = fmS.height(); 155 int sHei = fmS.ascent() ;
161 //sHei -= (sHei/4-2); 156 //sHei -= (sHei/4-2);
162 int startW = this->width() - frameWidth()-1; 157 int startW = this->width() - 2*frameWidth()-1;
158 int tw2 = fmS.width(suffix);
163 while (y < cy + ch) { 159 while (y < cy + ch) {
164 p->drawLine(cx,y,cx+tW,y); 160 p->drawLine(cx,y,cw,y);
165 hour.setNum(cell); 161 hour.setNum(cell);
166 162
167 // handle 24h and am/pm time formats 163 // handle 24h and am/pm time formats
168 if (KGlobal::locale()->use12Clock()) { 164 if (KGlobal::locale()->use12Clock()) {
169 if (cell > 11) suffix = "pm"; 165 if (cell > 11) suffix = "pm";
170 else 166 else
171 suffix = "am"; 167 suffix = "am";
172 if (cell == 0) hour.setNum(12); 168 if (cell == 0) hour.setNum(12);
173 if (cell > 12) hour.setNum(cell - 12); 169 if (cell > 12) hour.setNum(cell - 12);
170 tw2 = fmS.width(suffix);
174 } 171 }
175 172
176 // center and draw the time label 173 // center and draw the time label
177 int timeWidth = fm.width(hour); 174 int timeWidth = fm.width(hour);
178 int tw2 = fm.width(suffix);
179 int offset = startW - timeWidth - tw2 ; 175 int offset = startW - timeWidth - tw2 ;
180 p->setFont( nFont ); 176 p->setFont( nFont );
181 p->drawText( offset, y+ timeHeight, hour); 177 p->drawText( offset, y+ timeHeight, hour);
182 p->setFont( sFont ); 178 p->setFont( sFont );
183 offset = startW - tw2+1; 179 offset = startW - tw2+1;
184 p->drawText( offset, y+ sHei, suffix); 180 p->drawText( offset, y+ sHei, suffix);
185 181
186 // increment indices 182 // increment indices
187 y += mCellHeight; 183 y += mCellHeight;
188 cell++; 184 cell++;
189 } 185 }
190 } else { 186 } else {
191 //qDebug("NO redraw "); 187 //qDebug("NO redraw ");
192 } 188 }
193 // double buffer not yet implemented 189 // double buffer not yet implemented
194 //bitBlt (this, 0, 0, &myPix, 0 ,0,width(), height() ,CopyROP); 190 //bitBlt (this, 0, 0, &myPix, 0 ,0,width(), height() ,CopyROP);
195 //mRedrawNeeded = false; 191 //mRedrawNeeded = false;
196} 192}
197 193
198/** 194/**
199 Calculates the minimum width. 195 Calculates the minimum width.
200*/ 196*/
201int TimeLabels::minimumWidth() const 197int TimeLabels::minimumWidth() const
202{ 198{
203 return mMiniWidth; 199 return mMiniWidth;
204} 200}
205 201
206/** updates widget's internal state */ 202/** updates widget's internal state */
207void TimeLabels::updateConfig() 203void TimeLabels::updateConfig()
208{ 204{
209 mRedrawNeeded = true; 205 mRedrawNeeded = true;
210 // set the font 206 // set the font
211 // config->setGroup("Fonts"); 207 // config->setGroup("Fonts");
212 // QFont font = config->readFontEntry("TimeBar Font"); 208 // QFont font = config->readFontEntry("TimeBar Font");
213 setFont(KOPrefs::instance()->mTimeBarFont); 209 setFont(KOPrefs::instance()->mTimeBarFont);
214 QString test = "88:88"; 210 QString test = "20oo";
215 if (KGlobal::locale()->use12Clock()) 211 if (KGlobal::locale()->use12Clock())
216 test += "i"; 212 test = "12mi";
217 mMiniWidth = fontMetrics().width(test) + frameWidth()*2 +1 ; 213 mMiniWidth = fontMetrics().width(test) + frameWidth()*2 +1 ;
218 // update geometry restrictions based on new settings 214 // update geometry restrictions based on new settings
219 setFixedWidth(minimumWidth()); 215 setFixedWidth( mMiniWidth );
220 216
221 // update HourSize 217 // update HourSize
222 mCellHeight = KOPrefs::instance()->mHourSize*4; 218 mCellHeight = KOPrefs::instance()->mHourSize*4;
223 resizeContents(50,mRows * mCellHeight); 219 resizeContents(50,mRows * mCellHeight);
224} 220}
225 221
226/** update time label positions */ 222/** update time label positions */
227void TimeLabels::positionChanged() 223void TimeLabels::positionChanged()
228{ 224{
229 int adjustment = mAgenda->contentsY(); 225 int adjustment = mAgenda->contentsY();
230 setContentsPos(0, adjustment); 226 setContentsPos(0, adjustment);
231} 227}
232 228
233/** */ 229/** */
234void TimeLabels::setAgenda(KOAgenda* agenda) 230void TimeLabels::setAgenda(KOAgenda* agenda)
235{ 231{
236 mAgenda = agenda; 232 mAgenda = agenda;
237} 233}
238 234
239void TimeLabels::contentsMousePressEvent ( QMouseEvent * e) 235void TimeLabels::contentsMousePressEvent ( QMouseEvent * e)
240{ 236{
241 mMouseDownY = e->pos().y(); 237 mMouseDownY = e->pos().y();
242 mOrgCap = topLevelWidget()->caption(); 238 mOrgCap = topLevelWidget()->caption();
243} 239}
244 240
245void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e ) 241void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e )
246{ 242{
247 int diff = mMouseDownY - e->pos().y(); 243 int diff = mMouseDownY - e->pos().y();
248 if ( diff < 10 && diff > -10 ) 244 if ( diff < 10 && diff > -10 )
249 return; 245 return;
250 int tSize = KOPrefs::instance()->mHourSize + (diff/10) ; 246 int tSize = KOPrefs::instance()->mHourSize + (diff/10) ;
251 if ( tSize < 4 ) 247 if ( tSize < 4 )
252 tSize = 4; 248 tSize = 4;
253 if ( tSize > 22 ) 249 if ( tSize > 22 )
254 tSize = 22; 250 tSize = 22;
255 tSize = (tSize-2)/2; 251 tSize = (tSize-2)/2;
256 topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize)); 252 topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize));
257 253
258} 254}
259void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e ) 255void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e )
260{ 256{
261 topLevelWidget()->setCaption( mOrgCap ); 257 topLevelWidget()->setCaption( mOrgCap );
262 int diff = mMouseDownY - e->pos().y(); 258 int diff = mMouseDownY - e->pos().y();
263 if ( diff < 10 && diff > -10 ) 259 if ( diff < 10 && diff > -10 )
264 return; 260 return;
265 int tSize = KOPrefs::instance()->mHourSize + (diff/10); 261 int tSize = KOPrefs::instance()->mHourSize + (diff/10);
266 if ( tSize < 4 ) 262 if ( tSize < 4 )
267 tSize = 4; 263 tSize = 4;
268 if ( tSize > 22 ) 264 if ( tSize > 22 )
269 tSize = 22; 265 tSize = 22;
270 tSize = (tSize/2)*2; 266 tSize = (tSize/2)*2;
271 if ( tSize == KOPrefs::instance()->mHourSize ) 267 if ( tSize == KOPrefs::instance()->mHourSize )
272 return; 268 return;
273 KOPrefs::instance()->mHourSize = tSize; 269 KOPrefs::instance()->mHourSize = tSize;
274 emit scaleChanged(); 270 emit scaleChanged();
275} 271}
276 272
277/** This is called in response to repaint() */ 273/** This is called in response to repaint() */
278void TimeLabels::paintEvent(QPaintEvent*) 274void TimeLabels::paintEvent(QPaintEvent*)
279{ 275{
280 276
281 // kdDebug() << "paintevent..." << endl; 277 // kdDebug() << "paintevent..." << endl;
282 // this is another hack! 278 // this is another hack!
283 // QPainter painter(this); 279 // QPainter painter(this);
284 //QString c 280 //QString c
285 repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight()); 281 repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight());
286} 282}
287 283
288//////////////////////////////////////////////////////////////////////////// 284////////////////////////////////////////////////////////////////////////////
289 285
290EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name) 286EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name)
291 : QFrame(parent,name) 287 : QFrame(parent,name)
292{ 288{
293 mColumns = 1; 289 mColumns = 1;
294 mTopBox = 0; 290 mTopBox = 0;
295 mLocation = loc; 291 mLocation = loc;
296 mTopLayout = 0; 292 mTopLayout = 0;
297 mPaintWidget = 0; 293 mPaintWidget = 0;
298 mXOffset = 0; 294 mXOffset = 0;
299 if (mLocation == Top) mPixmap = SmallIcon("1uparrow"); 295 if (mLocation == Top) mPixmap = SmallIcon("1uparrow");
300 else mPixmap = SmallIcon("1downarrow"); 296 else mPixmap = SmallIcon("1downarrow");
301 mEnabled.resize(mColumns); 297 mEnabled.resize(mColumns);
302 mEnabled.fill( false ); 298 mEnabled.fill( false );
303 setMinimumHeight(mPixmap.height()); 299 setMinimumHeight(mPixmap.height());
304} 300}
305 301
306EventIndicator::~EventIndicator() 302EventIndicator::~EventIndicator()
307{ 303{
308} 304}
309 305
310void EventIndicator::drawContents(QPainter *p) 306void EventIndicator::drawContents(QPainter *p)
311{ 307{
312 308
313 // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl; 309 // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl;
314 KDGanttSplitterHandle* han = 0; 310 KDGanttSplitterHandle* han = 0;
315 if ( mPaintWidget ) 311 if ( mPaintWidget )
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp
index c55f7d7..5b5703f 100644
--- a/korganizer/kodaymatrix.cpp
+++ b/korganizer/kodaymatrix.cpp
@@ -784,185 +784,187 @@ void KODayMatrix::paintEvent(QPaintEvent * pevent)
784 if ( row == 0) 784 if ( row == 0)
785 addRow = 1; 785 addRow = 1;
786 int drawWid = width()-(col*dwidth+1+addCol2)-1; 786 int drawWid = width()-(col*dwidth+1+addCol2)-1;
787 p.fillRect(isRTL ? 0 : col*dwidth+1+addCol2, row*dheight+addRow, drawWid, 787 p.fillRect(isRTL ? 0 : col*dwidth+1+addCol2, row*dheight+addRow, drawWid,
788 dheight+1, selcol); 788 dheight+1, selcol);
789 // draw full block till last line 789 // draw full block till last line
790 selh = mSelEndT/7-row; 790 selh = mSelEndT/7-row;
791 addRow = 0; 791 addRow = 0;
792 if ( rowModulo ) { 792 if ( rowModulo ) {
793 if ( mSelEndT/7 >= 6 - rowModulo ) 793 if ( mSelEndT/7 >= 6 - rowModulo )
794 addRow = mSelEndT/7 - 5 + rowModulo; 794 addRow = mSelEndT/7 - 5 + rowModulo;
795 } 795 }
796 if (selh > 1) { 796 if (selh > 1) {
797 p.fillRect(1, (row+1)*dheight, 7*dwidth+colModulo, (selh-1)*dheight+addRow,selcol); 797 p.fillRect(1, (row+1)*dheight, 7*dwidth+colModulo, (selh-1)*dheight+addRow,selcol);
798 } 798 }
799 // draw last block from left to mSelEndT 799 // draw last block from left to mSelEndT
800 selw = mSelEndT-7*(mSelEndT/7)+1; 800 selw = mSelEndT-7*(mSelEndT/7)+1;
801 //qDebug("esl %d ",selw ); 801 //qDebug("esl %d ",selw );
802 int add = 0; 802 int add = 0;
803 if ( colModulo ) { 803 if ( colModulo ) {
804 add = 7 - colModulo; 804 add = 7 - colModulo;
805 if ( selw > add ) 805 if ( selw > add )
806 add = selw - add; 806 add = selw - add;
807 else 807 else
808 add = 0; 808 add = 0;
809 } 809 }
810 //qDebug("add %d ", add); 810 //qDebug("add %d ", add);
811 p.fillRect(isRTL ? (7-selw)*dwidth : 1, (row+selh)*dheight+addRow, 811 p.fillRect(isRTL ? (7-selw)*dwidth : 1, (row+selh)*dheight+addRow,
812 selw*dwidth+add, dheight+1, selcol); 812 selw*dwidth+add, dheight+1, selcol);
813 } 813 }
814 } 814 }
815 } 815 }
816 816
817 // iterate over all days in the matrix and draw the day label in appropriate colors 817 // iterate over all days in the matrix and draw the day label in appropriate colors
818 QColor actcol = mDefaultTextColorShaded; 818 QColor actcol = mDefaultTextColorShaded;
819 p.setPen(actcol); 819 p.setPen(actcol);
820 QPen tmppen; 820 QPen tmppen;
821 for(int i = 0; i < NUMDAYS; i++) { 821 for(int i = 0; i < NUMDAYS; i++) {
822 row = i/7; 822 row = i/7;
823 col = isRTL ? 6-(i-row*7) : i-row*7; 823 col = isRTL ? 6-(i-row*7) : i-row*7;
824 824
825 // if it is the first day of a month switch color from normal to shaded and vice versa 825 // if it is the first day of a month switch color from normal to shaded and vice versa
826 if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) { 826 if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) {
827 if (actcol == mDefaultTextColorShaded) { 827 if (actcol == mDefaultTextColorShaded) {
828 actcol = mDefaultTextColor; 828 actcol = mDefaultTextColor;
829 } else { 829 } else {
830 actcol = mDefaultTextColorShaded; 830 actcol = mDefaultTextColorShaded;
831 } 831 }
832 p.setPen(actcol); 832 p.setPen(actcol);
833 } 833 }
834 if (actcol == mDefaultTextColorShaded) { 834 if (actcol == mDefaultTextColorShaded) {
835 if ( ! mouseDown ) { 835 if ( ! mouseDown ) {
836 continue; 836 continue;
837 } 837 }
838 } 838 }
839 //Reset pen color after selected days block 839 //Reset pen color after selected days block
840 if (i == mSelEndT+1) { 840 if (i == mSelEndT+1) {
841 p.setPen(actcol); 841 p.setPen(actcol);
842 } 842 }
843 843
844 // if today then draw rectangle around day 844 // if today then draw rectangle around day
845 if (today == i) { 845 if (today == i) {
846 tmppen = p.pen(); 846 tmppen = p.pen();
847 QPen mTodayPen(p.pen()); 847 QPen mTodayPen(p.pen());
848 if ( daysize.width() < 20 ) 848 if ( daysize.width() < 20 )
849 mTodayPen.setWidth(1); 849 mTodayPen.setWidth(1);
850 else 850 else
851 mTodayPen.setWidth(mTodayMarginWidth); 851 mTodayPen.setWidth(mTodayMarginWidth);
852 //draw red rectangle for holidays 852 //draw red rectangle for holidays
853 if (!mHolidays[i].isNull()) { 853 if (!mHolidays[i].isNull()) {
854 if (actcol == mDefaultTextColor) { 854 if (actcol == mDefaultTextColor) {
855 mTodayPen.setColor(KOPrefs::instance()->mHolidayColor); 855 mTodayPen.setColor(KOPrefs::instance()->mHolidayColor);
856 } else { 856 } else {
857 mTodayPen.setColor(mHolidayColorShaded); 857 mTodayPen.setColor(mHolidayColorShaded);
858 } 858 }
859 } 859 }
860 //draw gray rectangle for today if in selection 860 //draw gray rectangle for today if in selection
861 if (i >= mSelStartT && i <= mSelEndT) { 861 if (i >= mSelStartT && i <= mSelEndT) {
862 QColor grey("grey"); 862 QColor grey("grey");
863 mTodayPen.setColor(grey); 863 mTodayPen.setColor(grey);
864 } 864 }
865 p.setPen(mTodayPen); 865 p.setPen(mTodayPen);
866 866
867 867
868 int addCol = 0; 868 int addCol = 0;
869 int addRow = 0; 869 int addRow = 0;
870 if (rowModulo) { 870 if (rowModulo) {
871 if ( row >= 6 - rowModulo ) 871 if ( row >= 6 - rowModulo )
872 addRow = row - 5 + rowModulo; 872 addRow = row - 5 + rowModulo;
873 } 873 }
874 if ( colModulo ) { 874 if ( colModulo ) {
875 if ( col >= 7 - colModulo ) 875 if ( col >= 7 - colModulo )
876 addCol = col - 6 + colModulo-1; 876 addCol = col - 6 + colModulo-1;
877 } 877 }
878 878
879 addCol += 1; 879 addCol += 1;
880 p.drawRect(col*dwidth+addCol, row*dheight+addRow, dwidth, dheight+1); 880 if ( row == 0 )
881 addRow = 1;
882 p.drawRect(col*dwidth+addCol, row*dheight+addRow, dwidth+1, dheight+1);
881 p.setPen(tmppen); 883 p.setPen(tmppen);
882 } 884 }
883 885
884 // if any events are on that day then draw it using a bold font 886 // if any events are on that day then draw it using a bold font
885 if ( eDays.testBit(i) ) { 887 if ( eDays.testBit(i) ) {
886 QFont myFont = font(); 888 QFont myFont = font();
887 myFont.setBold(true); 889 myFont.setBold(true);
888 p.setFont(myFont); 890 p.setFont(myFont);
889 } 891 }
890 892
891 // if it is a holiday then use the default holiday color 893 // if it is a holiday then use the default holiday color
892 if ( !mHolidays[i].isNull()) { 894 if ( !mHolidays[i].isNull()) {
893 if ( bDays.testBit(i) ) { 895 if ( bDays.testBit(i) ) {
894 if ( hDays.testBit(i) ) 896 if ( hDays.testBit(i) )
895 p.setPen(QColor(Qt::green)); 897 p.setPen(QColor(Qt::green));
896 else 898 else
897 p.setPen(QColor(Qt::green).dark()); 899 p.setPen(QColor(Qt::green).dark());
898 } else { 900 } else {
899 if (actcol == mDefaultTextColor ) { 901 if (actcol == mDefaultTextColor ) {
900 p.setPen(KOPrefs::instance()->mHolidayColor); 902 p.setPen(KOPrefs::instance()->mHolidayColor);
901 } else { 903 } else {
902 p.setPen(mHolidayColorShaded); 904 p.setPen(mHolidayColorShaded);
903 } 905 }
904 } 906 }
905 } 907 }
906 908
907 // draw selected days with special color 909 // draw selected days with special color
908 // DO NOT specially highlight holidays in selection ! 910 // DO NOT specially highlight holidays in selection !
909 if (i >= mSelStartT && i <= mSelEndT) { 911 if (i >= mSelStartT && i <= mSelEndT) {
910 ;//p.setPen(mSelectedDaysColor); 912 ;//p.setPen(mSelectedDaysColor);
911 } 913 }
912 914
913 int addCol = 0; 915 int addCol = 0;
914 int addRow = 0; 916 int addRow = 0;
915 if ( colModulo ) { 917 if ( colModulo ) {
916 if ( col >= 7 - colModulo ) 918 if ( col >= 7 - colModulo )
917 addCol = col - 7 + colModulo; 919 addCol = col - 7 + colModulo;
918 } 920 }
919 if ( rowModulo ) { 921 if ( rowModulo ) {
920 if ( row >= 6 - rowModulo ) 922 if ( row >= 6 - rowModulo )
921 addRow = row - 5 + rowModulo; 923 addRow = row - 5 + rowModulo;
922 } 924 }
923 //qDebug("add %d %d -- %d %d ", col, addCol, row, addRow); 925 //qDebug("add %d %d -- %d %d ", col, addCol, row, addRow);
924 ++addCol;//++addCol; 926 ++addCol;//++addCol;
925 if ( row == 0) 927 if ( row == 0)
926 addRow = 1; 928 addRow = 1;
927 p.drawText(col*dwidth+addCol, row*dheight+addRow, dwidth, dheight, 929 p.drawText(col*dwidth+addCol, row*dheight+addRow, dwidth, dheight,
928 Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]); 930 Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]);
929 931
930 // reset color to actual color 932 // reset color to actual color
931 if (!mHolidays[i].isNull()) { 933 if (!mHolidays[i].isNull()) {
932 p.setPen(actcol); 934 p.setPen(actcol);
933 } 935 }
934 // reset bold font to plain font 936 // reset bold font to plain font
935 if ( eDays.testBit(i)) { 937 if ( eDays.testBit(i)) {
936 QFont myFont = font(); 938 QFont myFont = font();
937 myFont.setBold(false); 939 myFont.setBold(false);
938 p.setFont(myFont); 940 p.setFont(myFont);
939 } 941 }
940 } 942 }
941 } else { 943 } else {
942 //qDebug("NO redraw "); 944 //qDebug("NO redraw ");
943 } 945 }
944 bitBlt (this, 0, 0, &myPix, 0 ,0,width(), height() ,CopyROP); 946 bitBlt (this, 0, 0, &myPix, 0 ,0,width(), height() ,CopyROP);
945 mRedrawNeeded = false; 947 mRedrawNeeded = false;
946} 948}
947 949
948// ---------------------------------------------------------------------------- 950// ----------------------------------------------------------------------------
949// R E SI Z E E V E N T H A N D L I N G 951// R E SI Z E E V E N T H A N D L I N G
950// ---------------------------------------------------------------------------- 952// ----------------------------------------------------------------------------
951 953
952void KODayMatrix::resizeEvent(QResizeEvent *) 954void KODayMatrix::resizeEvent(QResizeEvent *)
953{ 955{
954 QRect sz = frameRect(); 956 QRect sz = frameRect();
955 daysize.setHeight(sz.height()*7 / NUMDAYS); 957 daysize.setHeight(sz.height()*7 / NUMDAYS);
956 daysize.setWidth(sz.width() / 7); 958 daysize.setWidth(sz.width() / 7);
957} 959}
958 960
959QSize KODayMatrix::sizeHint() const 961QSize KODayMatrix::sizeHint() const
960{ 962{
961 963
962 QFontMetrics fm ( font() ); 964 QFontMetrics fm ( font() );
963 int wid = fm.width( "30") *7+3; 965 int wid = fm.width( "30") *7+3;
964 int hei = fm.height() * 6+3; 966 int hei = fm.height() * 6+3;
965 //qDebug("KODayMatrix::sizeHint()********************* %d %d", wid , hei); 967 //qDebug("KODayMatrix::sizeHint()********************* %d %d", wid , hei);
966 return QSize ( wid, hei ); 968 return QSize ( wid, hei );
967 969
968} 970}