summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-04-02 08:36:37 (UTC)
committer zautrix <zautrix>2005-04-02 08:36:37 (UTC)
commite7cb4c20af8b07bf923c864026481ce316c40e1d (patch) (unidiff)
treec88b2d0c01ce683e73ea9f4657f4d5c6fbe6f922 /korganizer
parent7aefe488d1fe0c34cf29460f48a9a97d632f615e (diff)
downloadkdepimpi-e7cb4c20af8b07bf923c864026481ce316c40e1d.zip
kdepimpi-e7cb4c20af8b07bf923c864026481ce316c40e1d.tar.gz
kdepimpi-e7cb4c20af8b07bf923c864026481ce316c40e1d.tar.bz2
more fixes
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagendaview.cpp86
-rw-r--r--korganizer/kodaymatrix.cpp8
2 files changed, 81 insertions, 13 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index 2b05d37..8d32152 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -17,301 +17,365 @@
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qhbox.h> 24#include <qhbox.h>
25#include <qvbox.h> 25#include <qvbox.h>
26#include <qlabel.h> 26#include <qlabel.h>
27#include <qframe.h> 27#include <qframe.h>
28#include <qlayout.h> 28#include <qlayout.h>
29#ifndef KORG_NOSPLITTER 29#ifndef KORG_NOSPLITTER
30#include <qsplitter.h> 30#include <qsplitter.h>
31#endif 31#endif
32#include <qfont.h> 32#include <qfont.h>
33#include <qfontmetrics.h> 33#include <qfontmetrics.h>
34#include <qpopupmenu.h> 34#include <qpopupmenu.h>
35#include <qtooltip.h> 35#include <qtooltip.h>
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 cx = contentsX() + frameWidth()*2;
114 // return; 114 cw = contentsWidth() ;
115 // bug: the parameters cx, cy, cw, ch are the areas that need to be 115 // end of workaround
116 // redrawn, not the area of the widget. unfortunately, this 116
117 // code assumes the latter... 117 int cell = ((int)(cy/mCellHeight));
118 118 int y = cell * mCellHeight;
119 // now, for a workaround... 119 QFontMetrics fm = fontMetrics();
120 // these two assignments fix the weird redraw bug 120 QString hour;
121 QString suffix = "am";
122 int timeHeight = fm.ascent();
123 QFont nFont = p->font();
124
125 if (!KGlobal::locale()->use12Clock()) {
126 if ( QApplication::desktop()->width() <= 320 )
127 suffix = "00";
128 else
129 suffix = "00";
130 }
131
132 if ( timeHeight > mCellHeight ) {
133 timeHeight = mCellHeight-1;
134 int pointS = nFont.pointSize();
135 while ( pointS > 4 ) {
136 nFont.setPointSize( pointS );
137 fm = QFontMetrics( nFont );
138 if ( fm.ascent() < mCellHeight )
139 break;
140 -- pointS;
141 }
142 fm = QFontMetrics( nFont );
143 timeHeight = fm.ascent();
144 }
145 //timeHeight -= (timeHeight/4-2);
146 QFont sFont = nFont;
147 sFont.setPointSize( sFont.pointSize()/2 );
148 QFontMetrics fmS( sFont );
149 int sHei = fmS.ascent() ;
150 //sHei -= (sHei/4-2);
151 int startW = this->width() - frameWidth()-2;
152 int tw2 = fmS.width(suffix);
153 timeHeight = (timeHeight-1) /2 -1;
154 while (y < cy + ch+mCellHeight) {
155 p->drawLine(startW-tw2+1 ,y,cw,y);
156 hour.setNum(cell);
157 // handle 24h and am/pm time formats
158 if (KGlobal::locale()->use12Clock()) {
159 if (cell > 11) suffix = "pm";
160 else
161 suffix = "am";
162 if (cell == 0) hour.setNum(12);
163 if (cell > 12) hour.setNum(cell - 12);
164 }
165
166 // center and draw the time label
167 int timeWidth = fm.width(hour);
168 int offset = startW - timeWidth - tw2 ;
169 p->setFont( nFont );
170 p->drawText( offset, y+ timeHeight, hour);
171 p->setFont( sFont );
172 offset = startW - tw2+1;
173 p->drawText( offset, y -1, suffix);
174
175 // increment indices
176 y += mCellHeight;
177 cell++;
178 }
179
180
181
182
183#if 0
121 mRedrawNeeded = true; 184 mRedrawNeeded = true;
122 if ( mRedrawNeeded ) { 185 if ( mRedrawNeeded ) {
123 cx = contentsX() + frameWidth()*2; 186 cx = contentsX() + frameWidth()*2;
124 cw = contentsWidth() ; 187 cw = contentsWidth() ;
125 // end of workaround 188 // end of workaround
126 189
127 int cell = ((int)(cy/mCellHeight)); 190 int cell = ((int)(cy/mCellHeight));
128 int y = cell * mCellHeight; 191 int y = cell * mCellHeight;
129 QFontMetrics fm = fontMetrics(); 192 QFontMetrics fm = fontMetrics();
130 QString hour; 193 QString hour;
131 QString suffix; 194 QString suffix;
132 int timeHeight = fm.ascent(); 195 int timeHeight = fm.ascent();
133 QFont nFont = p->font(); 196 QFont nFont = p->font();
134 197
135 if (!KGlobal::locale()->use12Clock()) { 198 if (!KGlobal::locale()->use12Clock()) {
136 if ( QApplication::desktop()->width() <= 320 ) 199 if ( QApplication::desktop()->width() <= 320 )
137 suffix = ""; 200 suffix = "";
138 else 201 else
139 suffix = "00"; 202 suffix = "00";
140 } 203 }
141 204
142 if ( timeHeight > mCellHeight ) { 205 if ( timeHeight > mCellHeight ) {
143 timeHeight = mCellHeight-1; 206 timeHeight = mCellHeight-1;
144 int pointS = nFont.pointSize(); 207 int pointS = nFont.pointSize();
145 while ( pointS > 4 ) { 208 while ( pointS > 4 ) {
146 nFont.setPointSize( pointS ); 209 nFont.setPointSize( pointS );
147 fm = QFontMetrics( nFont ); 210 fm = QFontMetrics( nFont );
148 if ( fm.ascent() < mCellHeight ) 211 if ( fm.ascent() < mCellHeight )
149 break; 212 break;
150 -- pointS; 213 -- pointS;
151 } 214 }
152 fm = QFontMetrics( nFont ); 215 fm = QFontMetrics( nFont );
153 timeHeight = fm.ascent(); 216 timeHeight = fm.ascent();
154 } 217 }
155 //timeHeight -= (timeHeight/4-2); 218 //timeHeight -= (timeHeight/4-2);
156 QFont sFont = nFont; 219 QFont sFont = nFont;
157 sFont.setPointSize( sFont.pointSize()/2 ); 220 sFont.setPointSize( sFont.pointSize()/2 );
158 QFontMetrics fmS( sFont ); 221 QFontMetrics fmS( sFont );
159 int sHei = fmS.ascent() ; 222 int sHei = fmS.ascent() ;
160 //sHei -= (sHei/4-2); 223 //sHei -= (sHei/4-2);
161 int startW = this->width() - frameWidth()-2; 224 int startW = this->width() - frameWidth()-2;
162 int tw2 = fmS.width(suffix); 225 int tw2 = fmS.width(suffix);
163 while (y < cy + ch) { 226 while (y < cy + ch) {
164 p->drawLine(cx,y,cw,y); 227 p->drawLine(cx,y,cw,y);
165 hour.setNum(cell); 228 hour.setNum(cell);
166 // handle 24h and am/pm time formats 229 // handle 24h and am/pm time formats
167 if (KGlobal::locale()->use12Clock()) { 230 if (KGlobal::locale()->use12Clock()) {
168 if (cell > 11) suffix = "pm"; 231 if (cell > 11) suffix = "pm";
169 else 232 else
170 suffix = "am"; 233 suffix = "am";
171 if (cell == 0) hour.setNum(12); 234 if (cell == 0) hour.setNum(12);
172 if (cell > 12) hour.setNum(cell - 12); 235 if (cell > 12) hour.setNum(cell - 12);
173 tw2 = fmS.width(suffix); 236 tw2 = fmS.width(suffix);
174 } 237 }
175 238
176 // center and draw the time label 239 // center and draw the time label
177 int timeWidth = fm.width(hour); 240 int timeWidth = fm.width(hour);
178 int offset = startW - timeWidth - tw2 ; 241 int offset = startW - timeWidth - tw2 ;
179 p->setFont( nFont ); 242 p->setFont( nFont );
180 p->drawText( offset, y+ timeHeight, hour); 243 p->drawText( offset, y+ timeHeight, hour);
181 p->setFont( sFont ); 244 p->setFont( sFont );
182 offset = startW - tw2+1; 245 offset = startW - tw2+1;
183 p->drawText( offset, y+ sHei, suffix); 246 p->drawText( offset, y+ sHei, suffix);
184 247
185 // increment indices 248 // increment indices
186 y += mCellHeight; 249 y += mCellHeight;
187 cell++; 250 cell++;
188 } 251 }
189 } else { 252 } else {
190 //qDebug("NO redraw "); 253 //qDebug("NO redraw ");
191 } 254 }
192 // double buffer not yet implemented 255 // double buffer not yet implemented
193 //bitBlt (this, 0, 0, &myPix, 0 ,0,width(), height() ,CopyROP); 256 //bitBlt (this, 0, 0, &myPix, 0 ,0,width(), height() ,CopyROP);
194 //mRedrawNeeded = false; 257 //mRedrawNeeded = false;
258#endif
195} 259}
196 260
197/** 261/**
198 Calculates the minimum width. 262 Calculates the minimum width.
199*/ 263*/
200int TimeLabels::minimumWidth() const 264int TimeLabels::minimumWidth() const
201{ 265{
202 return mMiniWidth; 266 return mMiniWidth;
203} 267}
204 268
205/** updates widget's internal state */ 269/** updates widget's internal state */
206void TimeLabels::updateConfig() 270void TimeLabels::updateConfig()
207{ 271{
208 mRedrawNeeded = true; 272 mRedrawNeeded = true;
209 // set the font 273 // set the font
210 // config->setGroup("Fonts"); 274 // config->setGroup("Fonts");
211 // QFont font = config->readFontEntry("TimeBar Font"); 275 // QFont font = config->readFontEntry("TimeBar Font");
212 setFont(KOPrefs::instance()->mTimeBarFont); 276 setFont(KOPrefs::instance()->mTimeBarFont);
213 QString test = "20"; 277 QString test = "20";
214 if (KGlobal::locale()->use12Clock()) 278 if (KGlobal::locale()->use12Clock())
215 test = "12"; 279 test = "12";
216 mMiniWidth = fontMetrics().width(test); 280 mMiniWidth = fontMetrics().width(test);
217 if (KGlobal::locale()->use12Clock()) 281 if (KGlobal::locale()->use12Clock())
218 test = "pm"; 282 test = "pm";
219 else { 283 else {
220 if ( QApplication::desktop()->width() <= 320 ) 284 if ( QApplication::desktop()->width() <= 320 )
221 test = ""; 285 test = "00";
222 else 286 else
223 test = "00"; 287 test = "00";
224 } 288 }
225 QFont sFont = font(); 289 QFont sFont = font();
226 sFont.setPointSize( sFont.pointSize()/2 ); 290 sFont.setPointSize( sFont.pointSize()/2 );
227 QFontMetrics fmS( sFont ); 291 QFontMetrics fmS( sFont );
228 mMiniWidth += fmS.width( test ) + frameWidth()*2 +4 ; 292 mMiniWidth += fmS.width( test ) + frameWidth()*2 +4 ;
229 // update geometry restrictions based on new settings 293 // update geometry restrictions based on new settings
230 setFixedWidth( mMiniWidth ); 294 setFixedWidth( mMiniWidth );
231 295
232 // update HourSize 296 // update HourSize
233 mCellHeight = KOPrefs::instance()->mHourSize*4; 297 mCellHeight = KOPrefs::instance()->mHourSize*4;
234 resizeContents(50,mRows * mCellHeight); 298 resizeContents(50,mRows * mCellHeight);
235} 299}
236 300
237/** update time label positions */ 301/** update time label positions */
238void TimeLabels::positionChanged() 302void TimeLabels::positionChanged()
239{ 303{
240 int adjustment = mAgenda->contentsY(); 304 int adjustment = mAgenda->contentsY();
241 setContentsPos(0, adjustment); 305 setContentsPos(0, adjustment);
242} 306}
243 307
244/** */ 308/** */
245void TimeLabels::setAgenda(KOAgenda* agenda) 309void TimeLabels::setAgenda(KOAgenda* agenda)
246{ 310{
247 mAgenda = agenda; 311 mAgenda = agenda;
248} 312}
249 313
250void TimeLabels::contentsMousePressEvent ( QMouseEvent * e) 314void TimeLabels::contentsMousePressEvent ( QMouseEvent * e)
251{ 315{
252 mMouseDownY = e->pos().y(); 316 mMouseDownY = e->pos().y();
253 mOrgCap = topLevelWidget()->caption(); 317 mOrgCap = topLevelWidget()->caption();
254} 318}
255 319
256void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e ) 320void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e )
257{ 321{
258 int diff = mMouseDownY - e->pos().y(); 322 int diff = mMouseDownY - e->pos().y();
259 if ( diff < 10 && diff > -10 ) 323 if ( diff < 10 && diff > -10 )
260 return; 324 return;
261 int tSize = KOPrefs::instance()->mHourSize + (diff/10) ; 325 int tSize = KOPrefs::instance()->mHourSize + (diff/10) ;
262 if ( tSize < 4 ) 326 if ( tSize < 4 )
263 tSize = 4; 327 tSize = 4;
264 if ( tSize > 22 ) 328 if ( tSize > 22 )
265 tSize = 22; 329 tSize = 22;
266 tSize = (tSize-2)/2; 330 tSize = (tSize-2)/2;
267 topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize)); 331 topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize));
268 332
269} 333}
270void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e ) 334void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e )
271{ 335{
272 topLevelWidget()->setCaption( mOrgCap ); 336 topLevelWidget()->setCaption( mOrgCap );
273 int diff = mMouseDownY - e->pos().y(); 337 int diff = mMouseDownY - e->pos().y();
274 if ( diff < 10 && diff > -10 ) 338 if ( diff < 10 && diff > -10 )
275 return; 339 return;
276 int tSize = KOPrefs::instance()->mHourSize + (diff/10); 340 int tSize = KOPrefs::instance()->mHourSize + (diff/10);
277 if ( tSize < 4 ) 341 if ( tSize < 4 )
278 tSize = 4; 342 tSize = 4;
279 if ( tSize > 22 ) 343 if ( tSize > 22 )
280 tSize = 22; 344 tSize = 22;
281 tSize = (tSize/2)*2; 345 tSize = (tSize/2)*2;
282 if ( tSize == KOPrefs::instance()->mHourSize ) 346 if ( tSize == KOPrefs::instance()->mHourSize )
283 return; 347 return;
284 KOPrefs::instance()->mHourSize = tSize; 348 KOPrefs::instance()->mHourSize = tSize;
285 emit scaleChanged(); 349 emit scaleChanged();
286} 350}
287 351
288/** This is called in response to repaint() */ 352/** This is called in response to repaint() */
289void TimeLabels::paintEvent(QPaintEvent*) 353void TimeLabels::paintEvent(QPaintEvent*)
290{ 354{
291 355
292 // kdDebug() << "paintevent..." << endl; 356 // kdDebug() << "paintevent..." << endl;
293 // this is another hack! 357 // this is another hack!
294 // QPainter painter(this); 358 // QPainter painter(this);
295 //QString c 359 //QString c
296 repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight()); 360 repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight());
297} 361}
298 362
299//////////////////////////////////////////////////////////////////////////// 363////////////////////////////////////////////////////////////////////////////
300 364
301EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name) 365EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name)
302 : QFrame(parent,name) 366 : QFrame(parent,name)
303{ 367{
304 mColumns = 1; 368 mColumns = 1;
305 mTopBox = 0; 369 mTopBox = 0;
306 mLocation = loc; 370 mLocation = loc;
307 mTopLayout = 0; 371 mTopLayout = 0;
308 mPaintWidget = 0; 372 mPaintWidget = 0;
309 mXOffset = 0; 373 mXOffset = 0;
310 if (mLocation == Top) mPixmap = SmallIcon("1uparrow"); 374 if (mLocation == Top) mPixmap = SmallIcon("1uparrow");
311 else mPixmap = SmallIcon("1downarrow"); 375 else mPixmap = SmallIcon("1downarrow");
312 mEnabled.resize(mColumns); 376 mEnabled.resize(mColumns);
313 mEnabled.fill( false ); 377 mEnabled.fill( false );
314 setMinimumHeight(mPixmap.height()); 378 setMinimumHeight(mPixmap.height());
315} 379}
316 380
317EventIndicator::~EventIndicator() 381EventIndicator::~EventIndicator()
@@ -581,253 +645,257 @@ KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) :
581 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 645 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
582 646
583 647
584} 648}
585 649
586void KOAgendaView::toggleAllDay() 650void KOAgendaView::toggleAllDay()
587{ 651{
588 if ( mSplitterAgenda->firstHandle() ) 652 if ( mSplitterAgenda->firstHandle() )
589 mSplitterAgenda->firstHandle()->toggle(); 653 mSplitterAgenda->firstHandle()->toggle();
590} 654}
591void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) 655void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld )
592{ 656{
593 calendar()->addIncidence( inc ); 657 calendar()->addIncidence( inc );
594 658
595 if ( incOld ) { 659 if ( incOld ) {
596 if ( incOld->type() == "Todo" ) 660 if ( incOld->type() == "Todo" )
597 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); 661 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED );
598 else 662 else
599 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); 663 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED);
600 } 664 }
601 665
602} 666}
603 667
604KOAgendaView::~KOAgendaView() 668KOAgendaView::~KOAgendaView()
605{ 669{
606 delete mAgendaPopup; 670 delete mAgendaPopup;
607 delete mAllDayAgendaPopup; 671 delete mAllDayAgendaPopup;
608 delete KOAgendaItem::paintPix(); 672 delete KOAgendaItem::paintPix();
609 delete KOAgendaItem::paintPixSel(); 673 delete KOAgendaItem::paintPixSel();
610} 674}
611void KOAgendaView::resizeEvent( QResizeEvent* e ) 675void KOAgendaView::resizeEvent( QResizeEvent* e )
612{ 676{
613 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); 677 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width());
614 bool uc = false; 678 bool uc = false;
615 int ow = e->oldSize().width(); 679 int ow = e->oldSize().width();
616 int oh = e->oldSize().height(); 680 int oh = e->oldSize().height();
617 int w = e->size().width(); 681 int w = e->size().width();
618 int h = e->size().height(); 682 int h = e->size().height();
619 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { 683 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) {
620 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) 684 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda )
621 uc = true; 685 uc = true;
622 //qDebug("view changed %d %d %d %d ", ow, oh , w , h); 686 //qDebug("view changed %d %d %d %d ", ow, oh , w , h);
623 } 687 }
624 mUpcomingWidth = e->size().width() ; 688 mUpcomingWidth = e->size().width() ;
625 if ( mBlockUpdating || uc ) { 689 if ( mBlockUpdating || uc ) {
626 mBlockUpdating = false; 690 mBlockUpdating = false;
627 //mAgenda->setMinimumSize(800 , 600 ); 691 //mAgenda->setMinimumSize(800 , 600 );
628 //qDebug("mAgenda->resize+++++++++++++++ "); 692 //qDebug("mAgenda->resize+++++++++++++++ ");
629 updateConfig(); 693 updateConfig();
630 //qDebug("KOAgendaView::Updating now possible "); 694 //qDebug("KOAgendaView::Updating now possible ");
631 } else 695 } else
632 createDayLabels(); 696 createDayLabels();
633 //qDebug("resizeEvent end "); 697 //qDebug("resizeEvent end ");
634 698
635} 699}
636void KOAgendaView::slotDaylabelClicked( int num ) 700void KOAgendaView::slotDaylabelClicked( int num )
637{ 701{
638 702
639 QDate firstDate = mSelectedDates.first(); 703 QDate firstDate = mSelectedDates.first();
640 if ( num == -1 ) 704 if ( num == -1 )
641 emit showDateView( 6, firstDate ); 705 emit showDateView( 6, firstDate );
642 else if (num >= 0 ) { 706 else if (num >= 0 ) {
643 if ( mSelectedDates.count() == 1) 707 if ( mSelectedDates.count() == 1)
644 emit showDateView( 9, firstDate.addDays( num ) ); 708 emit showDateView( 9, firstDate.addDays( num ) );
645 else 709 else
646 emit showDateView( 3, firstDate.addDays( num ) ); 710 emit showDateView( 3, firstDate.addDays( num ) );
647 } 711 }
648 else 712 else
649 showDateView( 10, firstDate.addDays(1) ); 713 showDateView( 10, firstDate.addDays(1) );
650} 714}
651 715
652KOAgendaButton* KOAgendaView::getNewDaylabel() 716KOAgendaButton* KOAgendaView::getNewDaylabel()
653{ 717{
654 718
655 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); 719 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels);
656 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); 720 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) );
657 mDayLabelsList.append( dayLabel ); 721 mDayLabelsList.append( dayLabel );
658 mLayoutDayLabels->addWidget(dayLabel); 722 mLayoutDayLabels->addWidget(dayLabel);
659 return dayLabel ; 723 return dayLabel ;
660} 724}
661 725
662void KOAgendaView::createDayLabels() 726void KOAgendaView::createDayLabels()
663{ 727{
664 728
665 if ( mBlockUpdating || globalFlagBlockLabel == 1) { 729 if ( mBlockUpdating || globalFlagBlockLabel == 1) {
666 // qDebug(" KOAgendaView::createDayLabels() blocked "); 730 // qDebug(" KOAgendaView::createDayLabels() blocked ");
667 return; 731 return;
668 732
669 } 733 }
670 int newHight; 734 int newHight;
671 735
672 // ### Before deleting and recreating we could check if mSelectedDates changed... 736 // ### Before deleting and recreating we could check if mSelectedDates changed...
673 // It would remove some flickering and gain speed (since this is called by 737 // It would remove some flickering and gain speed (since this is called by
674 // each updateView() call) 738 // each updateView() call)
675 739
676 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2; 740 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2;
741 if ( QApplication::desktop()->width() <= 320 )
742 maxWid -= 10;
677 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); 743 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth );
678 if ( maxWid < 0 ) 744 if ( maxWid < 0 )
679 maxWid = 20; 745 maxWid = 20;
680 746
681 QFont dlf = KOPrefs::instance()->mTimeLabelsFont; 747 QFont dlf = KOPrefs::instance()->mTimeLabelsFont;
682 QFontMetrics fm ( dlf ); 748 QFontMetrics fm ( dlf );
683 int selCount = mSelectedDates.count(); 749 int selCount = mSelectedDates.count();
684 QString dayTest = "Mon 20"; 750 QString dayTest = "Mon 20";
685 //QString dayTest = "Mon 20"; 751 //QString dayTest = "Mon 20";
686 int wid = fm.width( dayTest ); 752 int wid = fm.width( dayTest );
687 //maxWid -= ( selCount * 3 ); //working for QLabels 753 //maxWid -= ( selCount * 3 ); //working for QLabels
688 maxWid -= ( selCount * 3 ); //working for QPushButton 754 maxWid -= ( selCount * 3 ); //working for QPushButton
689 if ( maxWid < 0 ) 755 if ( maxWid < 0 )
690 maxWid = 20; 756 maxWid = 20;
691 int needWid = wid * selCount; 757 int needWid = wid * selCount;
692 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); 758 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid );
693 //if ( needWid > maxWid ) 759 //if ( needWid > maxWid )
694 // qDebug("DAYLABELS TOOOOOOO BIG "); 760 // qDebug("DAYLABELS TOOOOOOO BIG ");
695 while ( needWid > maxWid ) { 761 while ( needWid > maxWid ) {
696 dayTest = dayTest.left( dayTest.length() - 1 ); 762 dayTest = dayTest.left( dayTest.length() - 1 );
697 wid = fm.width( dayTest ); 763 wid = fm.width( dayTest );
698 needWid = wid * selCount; 764 needWid = wid * selCount;
699 } 765 }
700 int maxLen = dayTest.length(); 766 int maxLen = dayTest.length();
701 int fontPoint = dlf.pointSize(); 767 int fontPoint = dlf.pointSize();
702 if ( maxLen < 2 ) { 768 if ( maxLen < 2 ) {
703 int fontPoint = dlf.pointSize(); 769 int fontPoint = dlf.pointSize();
704 while ( fontPoint > 4 ) { 770 while ( fontPoint > 4 ) {
705 --fontPoint; 771 --fontPoint;
706 dlf.setPointSize( fontPoint ); 772 dlf.setPointSize( fontPoint );
707 QFontMetrics f( dlf ); 773 QFontMetrics f( dlf );
708 wid = f.width( "30" ); 774 wid = f.width( "30" );
709 needWid = wid * selCount; 775 needWid = wid * selCount;
710 if ( needWid < maxWid ) 776 if ( needWid < maxWid )
711 break; 777 break;
712 } 778 }
713 maxLen = 2; 779 maxLen = 2;
714 } 780 }
715 //qDebug("Max len %d ", dayTest.length() ); 781 //qDebug("Max len %d ", dayTest.length() );
716 782
717 QFontMetrics tempF( dlf ); 783 QFontMetrics tempF( dlf );
718 newHight = tempF.height(); 784 newHight = tempF.height();
719 mDayLabels->setFont( dlf ); 785 mDayLabels->setFont( dlf );
720 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; 786 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);;
721 // mLayoutDayLabels->addSpacing(mTimeLabels->width()); 787 // mLayoutDayLabels->addSpacing(mTimeLabels->width());
722 //mLayoutDayLabels->addSpacing( 2 ); 788 //mLayoutDayLabels->addSpacing( 2 );
723 // QFont lFont = dlf; 789 // QFont lFont = dlf;
724 bool appendLabels = false; 790 bool appendLabels = false;
725 KOAgendaButton *dayLabel; 791 KOAgendaButton *dayLabel;
726 dayLabel = mDayLabelsList.first(); 792 dayLabel = mDayLabelsList.first();
727 if ( !dayLabel ) { 793 if ( !dayLabel ) {
728 appendLabels = true; 794 appendLabels = true;
729 dayLabel = getNewDaylabel(); 795 dayLabel = getNewDaylabel();
730 } 796 }
731 dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() ); 797 dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() );
732 dayLabel->setFont( dlf ); 798 dayLabel->setFont( dlf );
733 dayLabel->setNum( -1 ); 799 dayLabel->setNum( -1 );
734 //dayLabel->setAlignment(QLabel::AlignHCenter); 800 //dayLabel->setAlignment(QLabel::AlignHCenter);
801#if 0
735 if ( QApplication::desktop()->width() <= 320 ) 802 if ( QApplication::desktop()->width() <= 320 )
736 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ).left(2) ); 803 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ).left(2) );
737 else 804 else
805#endif
738 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); 806 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) );
739 dayLabel->show(); 807 dayLabel->show();
740 DateList::ConstIterator dit; 808 DateList::ConstIterator dit;
741 bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); 809 bool oneday = (mSelectedDates.first() == mSelectedDates.last() );
742 int counter = -1; 810 int counter = -1;
743 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { 811 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
744 ++counter; 812 ++counter;
745 QDate date = *dit; 813 QDate date = *dit;
746 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); 814 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels);
747 if ( ! appendLabels ) { 815 if ( ! appendLabels ) {
748 dayLabel = mDayLabelsList.next(); 816 dayLabel = mDayLabelsList.next();
749 if ( !dayLabel ) 817 if ( !dayLabel )
750 appendLabels = true; 818 appendLabels = true;
751 } 819 }
752 if ( appendLabels ) { 820 if ( appendLabels ) {
753 dayLabel = getNewDaylabel(); 821 dayLabel = getNewDaylabel();
754 } 822 }
755 dayLabel->setMinimumWidth( 1 ); 823 dayLabel->setMinimumWidth( 1 );
756 dayLabel->setMaximumWidth( 10240 ); 824 dayLabel->setMaximumWidth( 10240 );
757 dayLabel->setFont( dlf ); 825 dayLabel->setFont( dlf );
758 dayLabel->show(); 826 dayLabel->show();
759 dayLabel->setAutoRepeat( false ); 827 dayLabel->setAutoRepeat( false );
760 dayLabel->setNum( counter ); 828 dayLabel->setNum( counter );
761 QString str; 829 QString str;
762 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); 830 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date);
763 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); 831 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true );
764 switch ( maxLen ) { 832 switch ( maxLen ) {
765 case 2: 833 case 2:
766 str = QString::number( date.day() ); 834 str = QString::number( date.day() );
767 break; 835 break;
768 836
769 case 3: 837 case 3:
770 str = dayName.left( 1 ) +QString::number( date.day()); 838 str = dayName.left( 1 ) +QString::number( date.day());
771 839
772 break; 840 break;
773 case 4: 841 case 4:
774 str = dayName.left( 1 ) + " " +QString::number( date.day()); 842 str = dayName.left( 1 ) + " " +QString::number( date.day());
775 843
776 break; 844 break;
777 case 5: 845 case 5:
778 str = dayName.left( 2 ) + " " +QString::number( date.day()); 846 str = dayName.left( 2 ) + " " +QString::number( date.day());
779 847
780 break; 848 break;
781 case 6: 849 case 6:
782 str = dayName.left( 3 ) + " " +QString::number( date.day()); 850 str = dayName.left( 3 ) + " " +QString::number( date.day());
783 break; 851 break;
784 852
785 default: 853 default:
786 break; 854 break;
787 } 855 }
788 if ( oneday ) { 856 if ( oneday ) {
789 QString addString; 857 QString addString;
790 if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) 858 if ( mSelectedDates.first() == QDateTime::currentDateTime().date() )
791 addString = i18n("Today"); 859 addString = i18n("Today");
792 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) 860 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) )
793 addString = i18n("Tomorrow"); 861 addString = i18n("Tomorrow");
794 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) 862 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) )
795 addString = i18n("Yesterday"); 863 addString = i18n("Yesterday");
796 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) 864 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) )
797 addString = i18n("Day before yesterday"); 865 addString = i18n("Day before yesterday");
798 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) 866 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) )
799 addString = i18n("Day after tomorrow"); 867 addString = i18n("Day after tomorrow");
800 if ( !addString.isEmpty() ) { 868 if ( !addString.isEmpty() ) {
801 str = addString+", " + str; 869 str = addString+", " + str;
802 } else { 870 } else {
803 str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer); 871 str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer);
804 } 872 }
805 } 873 }
806 dayLabel->setText(str); 874 dayLabel->setText(str);
807 //dayLabel->setAlignment(QLabel::AlignHCenter); 875 //dayLabel->setAlignment(QLabel::AlignHCenter);
808 if (date == QDate::currentDate()) { 876 if (date == QDate::currentDate()) {
809 QFont bFont = dlf; 877 QFont bFont = dlf;
810 bFont.setBold( true ); 878 bFont.setBold( true );
811 dayLabel->setFont(bFont); 879 dayLabel->setFont(bFont);
812 } 880 }
813 //dayLayout->addWidget(dayLabel); 881 //dayLayout->addWidget(dayLabel);
814 882
815#ifndef KORG_NOPLUGINS 883#ifndef KORG_NOPLUGINS
816 CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); 884 CalendarDecoration::List cds = KOCore::self()->calendarDecorations();
817 CalendarDecoration *it; 885 CalendarDecoration *it;
818 for(it = cds.first(); it; it = cds.next()) { 886 for(it = cds.first(); it; it = cds.next()) {
819 QString text = it->shortText( date ); 887 QString text = it->shortText( date );
820 if ( !text.isEmpty() ) { 888 if ( !text.isEmpty() ) {
821 QLabel *label = new QLabel(text,mDayLabels); 889 QLabel *label = new QLabel(text,mDayLabels);
822 label->setAlignment(AlignCenter); 890 label->setAlignment(AlignCenter);
823 dayLayout->addWidget(label); 891 dayLayout->addWidget(label);
824 } 892 }
825 } 893 }
826 894
827 for(it = cds.first(); it; it = cds.next()) { 895 for(it = cds.first(); it; it = cds.next()) {
828 QWidget *wid = it->smallWidget(mDayLabels,date); 896 QWidget *wid = it->smallWidget(mDayLabels,date);
829 if ( wid ) { 897 if ( wid ) {
830 // wid->setHeight(20); 898 // wid->setHeight(20);
831 dayLayout->addWidget(wid); 899 dayLayout->addWidget(wid);
832 } 900 }
833 } 901 }
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp
index b8a0f09..8affe50 100644
--- a/korganizer/kodaymatrix.cpp
+++ b/korganizer/kodaymatrix.cpp
@@ -674,208 +674,208 @@ void KODayMatrix::dropEvent(QDropEvent *e)
674// P A I N T E V E N T H A N D L I N G 674// P A I N T E V E N T H A N D L I N G
675// ---------------------------------------------------------------------------- 675// ----------------------------------------------------------------------------
676 676
677void KODayMatrix::paintEvent(QPaintEvent * pevent) 677void KODayMatrix::paintEvent(QPaintEvent * pevent)
678{ 678{
679 679
680 if ( width() <= 0 || height() <= 0 ) 680 if ( width() <= 0 || height() <= 0 )
681 return; 681 return;
682 if ( mPendingUpdateBeforeRepaint ) { 682 if ( mPendingUpdateBeforeRepaint ) {
683 updateViewTimed(); 683 updateViewTimed();
684 mPendingUpdateBeforeRepaint = false; 684 mPendingUpdateBeforeRepaint = false;
685 } 685 }
686 if ( myPix.width() != width() || myPix.height()!=height() ) { 686 if ( myPix.width() != width() || myPix.height()!=height() ) {
687 myPix.resize(size() ); 687 myPix.resize(size() );
688 mRedrawNeeded = true; 688 mRedrawNeeded = true;
689 } 689 }
690 690
691 if ( mRedrawNeeded ) { 691 if ( mRedrawNeeded ) {
692 //qDebug("REDRAW "); 692 //qDebug("REDRAW ");
693 QPainter p(&myPix); 693 QPainter p(&myPix);
694 p.setFont(font()); 694 p.setFont(font());
695 695
696 696
697 int dheight = daysize.height(); 697 int dheight = daysize.height();
698 int dwidth = daysize.width(); 698 int dwidth = daysize.width();
699 int row,col; 699 int row,col;
700 int selw, selh; 700 int selw, selh;
701 int xyOff = frameWidth(); 701 int xyOff = frameWidth();
702 int colModulo = (width()-2) % 7; 702 int colModulo = (width()-2) % 7;
703 int rowModulo = (height()-2) % 6; 703 int rowModulo = (height()-2) % 6;
704 //qDebug("col %d row %d ",colModulo,rowModulo ); 704 //qDebug("col %d row %d ",colModulo,rowModulo );
705 705
706 bool isRTL = KOGlobals::self()->reverseLayout(); 706 bool isRTL = KOGlobals::self()->reverseLayout();
707 707
708 // draw background and topleft frame 708 // draw background and topleft frame
709 p.fillRect(0,0,width(),height(), mDefaultBackColor); 709 p.fillRect(0,0,width(),height(), mDefaultBackColor);
710 p.setPen(mDefaultTextColor); 710 p.setPen(mDefaultTextColor);
711 p.drawRect(0, 0, width(), height()); 711 p.drawRect(0, 0, width(), height());
712 int mSelStartT = mSelStart; 712 int mSelStartT = mSelStart;
713 int mSelEndT = mSelEnd; 713 int mSelEndT = mSelEnd;
714 if ( mSelEndT >= NUMDAYS ) 714 if ( mSelEndT >= NUMDAYS )
715 mSelEndT = NUMDAYS-1; 715 mSelEndT = NUMDAYS-1;
716 // draw selected days with highlighted background color 716 // draw selected days with highlighted background color
717 if (mSelStart != NOSELECTION) { 717 if (mSelStart != NOSELECTION) {
718 bool skip = false; 718 bool skip = false;
719 if ( ! mouseDown ) { 719 if ( ! mouseDown ) {
720 int mo = days[20].month(); 720 int mo = days[20].month();
721 //qDebug("-- %d %d ", mSelStartT, mSelEndT); 721 //qDebug("-- %d %d ", mSelStartT, mSelEndT);
722 //qDebug("%d %d %d - d %d", mo, days[mSelStartT].month() , days[mSelEndT].month(), days[mSelEndT].day() ); 722 //qDebug("%d %d %d - d %d", mo, days[mSelStartT].month() , days[mSelEndT].month(), days[mSelEndT].day() );
723 int startMo = days[mSelStartT].month(); 723 int startMo = days[mSelStartT].month();
724 int endMo = days[mSelEndT].month(); 724 int endMo = days[mSelEndT].month();
725 if ( startMo == 12 && mo == 1 && endMo <= 2 ) 725 if ( startMo == 12 && mo == 1 && endMo <= 2 )
726 startMo = 1; 726 startMo = 1;
727 if ( endMo == 1 && mo == 12 ) 727 if ( endMo == 1 && mo == 12 )
728 endMo = 12; 728 endMo = 12;
729 if ( mo == 12 && startMo == 1 ) 729 if ( mo == 12 && startMo == 1 )
730 startMo = 13; 730 startMo = 13;
731 if ( (startMo > mo || endMo < mo) ) { 731 if ( (startMo > mo || endMo < mo) ) {
732 skip = true; 732 skip = true;
733 } else { 733 } else {
734 if ( days[mSelStartT].month() != mo ) { 734 if ( days[mSelStartT].month() != mo ) {
735 int add = days[mSelStartT].daysInMonth ()-days[mSelStartT].day(); 735 int add = days[mSelStartT].daysInMonth ()-days[mSelStartT].day();
736 mSelStartT += add +1; 736 mSelStartT += add +1;
737 } 737 }
738 if ( days[mSelEndT].month() != mo ) { 738 if ( days[mSelEndT].month() != mo ) {
739 int sub = days[mSelEndT].day(); 739 int sub = days[mSelEndT].day();
740 mSelEndT -= sub ; 740 mSelEndT -= sub ;
741 } 741 }
742 } 742 }
743 } 743 }
744 //qDebug("SKIP %d ", skip); 744 //qDebug("SKIP %d ", skip);
745 if ( ! skip ) { 745 if ( ! skip ) {
746 row = mSelStartT/7; 746 row = mSelStartT/7;
747 col = mSelStartT -row*7; 747 col = mSelStartT -row*7;
748 QColor selcol = KOPrefs::instance()->mHighlightColor; 748 QColor selcol = KOPrefs::instance()->mHighlightColor;
749 int addCol = 0; 749 int addCol = 0;
750 int addRow = 0; 750 int addRow = 0;
751 int addRow2 = 0; 751 int addRow2 = 0;
752 int addCol2 = 0; 752 int addCol2 = 0;
753 if (row == mSelEndT/7) { 753 if (row == mSelEndT/7) {
754 if ( rowModulo ) { 754 if ( rowModulo ) {
755 if ( row >= 6 - rowModulo ) 755 if ( row >= 6 - rowModulo )
756 addRow = row - 5 + rowModulo; 756 addRow = row - 5 + rowModulo;
757 } 757 }
758 if ( colModulo ) { 758 if ( colModulo ) {
759 int colt1 = mSelEndT%7; 759 int colt1 = mSelEndT%7;
760 //qDebug("colt1 %d ", colt1 ); 760 //qDebug("colt1 %d ", colt1 );
761 if ( colt1 >= 7 - colModulo ) 761 if ( colt1 >= 7 - colModulo )
762 addCol = colt1 - 7 + colModulo+1; 762 addCol = colt1 - 7 + colModulo+1;
763 int colt = mSelStartT%7; 763 int colt = mSelStartT%7;
764 if ( colt >= 7 - colModulo ) 764 if ( colt >= 7 - colModulo )
765 addCol2 = colt - 7 + colModulo; 765 addCol2 = colt - 7 + colModulo;
766 addCol -= addCol2; 766 addCol -= addCol2;
767 //qDebug("COL %d %d %d %d ",col , colt1 ,addCol ,addCol2 ); 767 //qDebug("COL %d %d %d %d ",col , colt1 ,addCol ,addCol2 );
768 } 768 }
769 // Single row selection 769 // Single row selection
770 if ( row == 0) 770 //if ( row == 0)
771 addRow = 1; 771 // addRow = 1;
772 p.fillRect(isRTL ? (7 - (mSelEndT-mSelStartT+1) - col)*dwidth : col*dwidth+1+addCol2, 772 p.fillRect(isRTL ? (7 - (mSelEndT-mSelStartT+1) - col)*dwidth : col*dwidth+1+addCol2,
773 row*dheight+addRow, (mSelEndT-mSelStartT+1)*dwidth+addCol, dheight+1, selcol); 773 row*dheight+addRow, (mSelEndT-mSelStartT+1)*dwidth+addCol, dheight+1, selcol);
774 } else { 774 } else {
775 // draw first row to the right 775 // draw first row to the right
776 if ( colModulo ) { 776 if ( colModulo ) {
777 if ( col >= 7 - colModulo ) 777 if ( col >= 7 - colModulo )
778 addCol2 = col - 7 + colModulo; 778 addCol2 = col - 7 + colModulo;
779 } 779 }
780 if ( rowModulo ) { 780 if ( rowModulo ) {
781 if ( row >= 6 - rowModulo ) 781 if ( row >= 6 - rowModulo )
782 addRow = row - 5 + rowModulo; 782 addRow = row - 5 + rowModulo;
783 } 783 }
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 //qDebug("%d %d %d ",selh, row, addRow ); 796 //qDebug("%d %d %d ",selh, row, addRow );
797 int addrow2 = addRow-selh+1; 797 int addrow2 = addRow-selh+1;
798 if ( addrow2 < 0 ) 798 if ( addrow2 < 0 )
799 addrow2 = 0; 799 addrow2 = 0;
800 if (selh > 1) { 800 if (selh > 1) {
801 p.fillRect(1, (row+1)*dheight+addrow2, 7*dwidth+colModulo, (selh-1)*dheight+addRow,selcol); 801 p.fillRect(1, (row+1)*dheight+addrow2, 7*dwidth+colModulo, (selh-1)*dheight+addRow,selcol);
802 } 802 }
803 // draw last block from left to mSelEndT 803 // draw last block from left to mSelEndT
804 selw = mSelEndT-7*(mSelEndT/7)+1; 804 selw = mSelEndT-7*(mSelEndT/7)+1;
805 //qDebug("esl %d ",selw ); 805 //qDebug("esl %d ",selw );
806 int add = 0; 806 int add = 0;
807 if ( colModulo ) { 807 if ( colModulo ) {
808 add = 7 - colModulo; 808 add = 7 - colModulo;
809 if ( selw > add ) 809 if ( selw > add )
810 add = selw - add; 810 add = selw - add;
811 else 811 else
812 add = 0; 812 add = 0;
813 } 813 }
814 //qDebug("add %d ", add); 814 //qDebug("add %d ", add);
815 p.fillRect(isRTL ? (7-selw)*dwidth : 1, (row+selh)*dheight+addRow, 815 p.fillRect(isRTL ? (7-selw)*dwidth : 1, (row+selh)*dheight+addRow,
816 selw*dwidth+add, dheight+1, selcol); 816 selw*dwidth+add, dheight+1, selcol);
817 } 817 }
818 } 818 }
819 } 819 }
820 820
821 // iterate over all days in the matrix and draw the day label in appropriate colors 821 // iterate over all days in the matrix and draw the day label in appropriate colors
822 QColor actcol = mDefaultTextColorShaded; 822 QColor actcol = mDefaultTextColorShaded;
823 p.setPen(actcol); 823 p.setPen(actcol);
824 QPen tmppen; 824 QPen tmppen;
825 for(int i = 0; i < NUMDAYS; i++) { 825 for(int i = 0; i < NUMDAYS; i++) {
826 row = i/7; 826 row = i/7;
827 col = isRTL ? 6-(i-row*7) : i-row*7; 827 col = isRTL ? 6-(i-row*7) : i-row*7;
828 828
829 // if it is the first day of a month switch color from normal to shaded and vice versa 829 // if it is the first day of a month switch color from normal to shaded and vice versa
830 if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) { 830 if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) {
831 if (actcol == mDefaultTextColorShaded) { 831 if (actcol == mDefaultTextColorShaded) {
832 actcol = mDefaultTextColor; 832 actcol = mDefaultTextColor;
833 } else { 833 } else {
834 actcol = mDefaultTextColorShaded; 834 actcol = mDefaultTextColorShaded;
835 } 835 }
836 p.setPen(actcol); 836 p.setPen(actcol);
837 } 837 }
838 if (actcol == mDefaultTextColorShaded) { 838 if (actcol == mDefaultTextColorShaded) {
839 if ( ! mouseDown ) { 839 if ( ! mouseDown ) {
840 continue; 840 continue;
841 } 841 }
842 } 842 }
843 //Reset pen color after selected days block 843 //Reset pen color after selected days block
844 if (i == mSelEndT+1) { 844 if (i == mSelEndT+1) {
845 p.setPen(actcol); 845 p.setPen(actcol);
846 } 846 }
847 847
848 // if today then draw rectangle around day 848 // if today then draw rectangle around day
849 if (today == i) { 849 if (today == i) {
850 tmppen = p.pen(); 850 tmppen = p.pen();
851 QPen mTodayPen(p.pen()); 851 QPen mTodayPen(p.pen());
852 if ( daysize.width() < 20 ) 852 if ( daysize.width() < 20 )
853 mTodayPen.setWidth(1); 853 mTodayPen.setWidth(1);
854 else 854 else
855 mTodayPen.setWidth(mTodayMarginWidth); 855 mTodayPen.setWidth(mTodayMarginWidth);
856 //draw red rectangle for holidays 856 //draw red rectangle for holidays
857 if (!mHolidays[i].isNull()) { 857 if (!mHolidays[i].isNull()) {
858 if (actcol == mDefaultTextColor) { 858 if (actcol == mDefaultTextColor) {
859 mTodayPen.setColor(KOPrefs::instance()->mHolidayColor); 859 mTodayPen.setColor(KOPrefs::instance()->mHolidayColor);
860 } else { 860 } else {
861 mTodayPen.setColor(mHolidayColorShaded); 861 mTodayPen.setColor(mHolidayColorShaded);
862 } 862 }
863 } 863 }
864 //draw gray rectangle for today if in selection 864 //draw gray rectangle for today if in selection
865 if (i >= mSelStartT && i <= mSelEndT) { 865 if (i >= mSelStartT && i <= mSelEndT) {
866 QColor grey("grey"); 866 QColor grey("grey");
867 mTodayPen.setColor(grey); 867 mTodayPen.setColor(grey);
868 } 868 }
869 p.setPen(mTodayPen); 869 p.setPen(mTodayPen);
870 870
871 871
872 int addCol = 0; 872 int addCol = 0;
873 int addRow = 0; 873 int addRow = 0;
874 if (rowModulo) { 874 if (rowModulo) {
875 if ( row >= 6 - rowModulo ) 875 if ( row >= 6 - rowModulo )
876 addRow = row - 5 + rowModulo; 876 addRow = row - 5 + rowModulo;
877 } 877 }
878 if ( colModulo ) { 878 if ( colModulo ) {
879 if ( col >= 7 - colModulo ) 879 if ( col >= 7 - colModulo )
880 addCol = col - 6 + colModulo-1; 880 addCol = col - 6 + colModulo-1;
881 } 881 }