summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-04-02 17:04:37 (UTC)
committer zautrix <zautrix>2005-04-02 17:04:37 (UTC)
commitf3c3a836ae97ef3e65cfbcd22156b0ba6eaae578 (patch) (unidiff)
tree726772f4d535882705cda8cab76ae5460a29beab
parent470327bf20835778a29cd2ce9414baa0cc176829 (diff)
downloadkdepimpi-f3c3a836ae97ef3e65cfbcd22156b0ba6eaae578.zip
kdepimpi-f3c3a836ae97ef3e65cfbcd22156b0ba6eaae578.tar.gz
kdepimpi-f3c3a836ae97ef3e65cfbcd22156b0ba6eaae578.tar.bz2
fixes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagendaview.cpp130
1 files changed, 26 insertions, 104 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index 95388ef..880d399 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -75,266 +75,187 @@ extern 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 cx = contentsX() + frameWidth()*2; 113 cx = contentsX() + frameWidth()*2;
114 cw = contentsWidth() ; 114 cw = contentsWidth() ;
115 // end of workaround 115 // end of workaround
116 116
117 int cell = ((int)(cy/mCellHeight)); 117 int cell = ((int)(cy/mCellHeight));
118 int y = cell * mCellHeight; 118 int y = cell * mCellHeight;
119 QFontMetrics fm = fontMetrics(); 119 QFontMetrics fm = fontMetrics();
120 QString hour; 120 QString hour;
121 QString suffix = "am"; 121 QString suffix = "am";
122 int timeHeight = fm.ascent(); 122 int timeHeight = fm.ascent();
123 QFont nFont = p->font(); 123 QFont nFont = font();
124 p->setFont( font());
124 125
125 if (!KGlobal::locale()->use12Clock()) { 126 if (!KGlobal::locale()->use12Clock()) {
126 if ( QApplication::desktop()->width() <= 320 )
127 suffix = "00"; 127 suffix = "00";
128 else 128 } else
129 suffix = "00"; 129 if (cell > 11) suffix = "pm";
130 }
131 130
132 if ( timeHeight > mCellHeight ) { 131 if ( timeHeight > mCellHeight ) {
133 timeHeight = mCellHeight-1; 132 timeHeight = mCellHeight-1;
134 int pointS = nFont.pointSize(); 133 int pointS = nFont.pointSize();
135 while ( pointS > 4 ) { 134 while ( pointS > 4 ) {
136 nFont.setPointSize( pointS ); 135 nFont.setPointSize( pointS );
137 fm = QFontMetrics( nFont ); 136 fm = QFontMetrics( nFont );
138 if ( fm.ascent() < mCellHeight ) 137 if ( fm.ascent() < mCellHeight )
139 break; 138 break;
140 -- pointS; 139 -- pointS;
141 } 140 }
142 fm = QFontMetrics( nFont ); 141 fm = QFontMetrics( nFont );
143 timeHeight = fm.ascent(); 142 timeHeight = fm.ascent();
144 } 143 }
145 //timeHeight -= (timeHeight/4-2); 144 //timeHeight -= (timeHeight/4-2);
146 QFont sFont = nFont; 145 QFont sFont = nFont;
147 sFont.setPointSize( sFont.pointSize()/2 ); 146 sFont.setPointSize( sFont.pointSize()/2 );
148 QFontMetrics fmS( sFont ); 147 QFontMetrics fmS( sFont );
149 int sHei = fmS.ascent() ; 148 int sHei = fmS.ascent() ;
150 //sHei -= (sHei/4-2); 149 //sHei -= (sHei/4-2);
151 int startW = this->width() - frameWidth()-2; 150 int startW = mMiniWidth - frameWidth()-2 ;
152 int tw2 = fmS.width(suffix); 151 int tw2 = fmS.width(suffix);
153 timeHeight = (timeHeight-1) /2 -1; 152 timeHeight = (timeHeight-1) /2 -1;
153 //testline
154 //p->drawLine(0,0,0,contentsHeight());
154 while (y < cy + ch+mCellHeight) { 155 while (y < cy + ch+mCellHeight) {
155 p->drawLine(startW-tw2+1 ,y,cw,y); 156 p->drawLine(startW-tw2 ,y,cw+2,y);
156 hour.setNum(cell); 157 hour.setNum(cell);
157 // handle 24h and am/pm time formats 158 // handle 24h and am/pm time formats
158 if (KGlobal::locale()->use12Clock()) { 159 if (KGlobal::locale()->use12Clock()) {
159 if (cell > 11) suffix = "pm"; 160 if (cell == 12) suffix = "pm";
160 else
161 suffix = "am";
162 if (cell == 0) hour.setNum(12); 161 if (cell == 0) hour.setNum(12);
163 if (cell > 12) hour.setNum(cell - 12); 162 if (cell > 12) hour.setNum(cell - 12);
164 } 163 }
165 164
166 // center and draw the time label 165 // center and draw the time label
167 int timeWidth = fm.width(hour); 166 int timeWidth = fm.width(hour);
168 int offset = startW - timeWidth - tw2 ; 167 int offset = startW - timeWidth - tw2 -1 ;
169 p->setFont( nFont ); 168 p->setFont( nFont );
170 p->drawText( offset, y+ timeHeight, hour); 169 p->drawText( offset, y+ timeHeight, hour);
171 p->setFont( sFont ); 170 p->setFont( sFont );
172 offset = startW - tw2+1; 171 offset = startW - tw2;
173 p->drawText( offset, y -1, suffix); 172 p->drawText( offset, y -1, suffix);
174 173
175 // increment indices 174 // increment indices
176 y += mCellHeight; 175 y += mCellHeight;
177 cell++; 176 cell++;
178 } 177 }
179 178
180 179
181 180
182 181
183#if 0
184 mRedrawNeeded = true;
185 if ( mRedrawNeeded ) {
186 cx = contentsX() + frameWidth()*2;
187 cw = contentsWidth() ;
188 // end of workaround
189
190 int cell = ((int)(cy/mCellHeight));
191 int y = cell * mCellHeight;
192 QFontMetrics fm = fontMetrics();
193 QString hour;
194 QString suffix;
195 int timeHeight = fm.ascent();
196 QFont nFont = p->font();
197
198 if (!KGlobal::locale()->use12Clock()) {
199 if ( QApplication::desktop()->width() <= 320 )
200 suffix = "";
201 else
202 suffix = "00";
203 }
204
205 if ( timeHeight > mCellHeight ) {
206 timeHeight = mCellHeight-1;
207 int pointS = nFont.pointSize();
208 while ( pointS > 4 ) {
209 nFont.setPointSize( pointS );
210 fm = QFontMetrics( nFont );
211 if ( fm.ascent() < mCellHeight )
212 break;
213 -- pointS;
214 }
215 fm = QFontMetrics( nFont );
216 timeHeight = fm.ascent();
217 }
218 //timeHeight -= (timeHeight/4-2);
219 QFont sFont = nFont;
220 sFont.setPointSize( sFont.pointSize()/2 );
221 QFontMetrics fmS( sFont );
222 int sHei = fmS.ascent() ;
223 //sHei -= (sHei/4-2);
224 int startW = this->width() - frameWidth()-2;
225 int tw2 = fmS.width(suffix);
226 while (y < cy + ch) {
227 p->drawLine(cx,y,cw,y);
228 hour.setNum(cell);
229 // handle 24h and am/pm time formats
230 if (KGlobal::locale()->use12Clock()) {
231 if (cell > 11) suffix = "pm";
232 else
233 suffix = "am";
234 if (cell == 0) hour.setNum(12);
235 if (cell > 12) hour.setNum(cell - 12);
236 tw2 = fmS.width(suffix);
237 }
238
239 // center and draw the time label
240 int timeWidth = fm.width(hour);
241 int offset = startW - timeWidth - tw2 ;
242 p->setFont( nFont );
243 p->drawText( offset, y+ timeHeight, hour);
244 p->setFont( sFont );
245 offset = startW - tw2+1;
246 p->drawText( offset, y+ sHei, suffix);
247
248 // increment indices
249 y += mCellHeight;
250 cell++;
251 }
252 } else {
253 //qDebug("NO redraw ");
254 }
255 // double buffer not yet implemented
256 //bitBlt (this, 0, 0, &myPix, 0 ,0,width(), height() ,CopyROP);
257 //mRedrawNeeded = false;
258#endif
259} 182}
260 183
261/** 184/**
262 Calculates the minimum width. 185 Calculates the minimum width.
263*/ 186*/
264int TimeLabels::minimumWidth() const 187int TimeLabels::minimumWidth() const
265{ 188{
266 return mMiniWidth; 189 return mMiniWidth;
267} 190}
268 191
269/** updates widget's internal state */ 192/** updates widget's internal state */
270void TimeLabels::updateConfig() 193void TimeLabels::updateConfig()
271{ 194{
272 mRedrawNeeded = true; 195 mRedrawNeeded = true;
273 // set the font 196 // set the font
274 // config->setGroup("Fonts"); 197 // config->setGroup("Fonts");
275 // QFont font = config->readFontEntry("TimeBar Font"); 198 // QFont font = config->readFontEntry("TimeBar Font");
276 setFont(KOPrefs::instance()->mTimeBarFont); 199 setFont(KOPrefs::instance()->mTimeBarFont);
277 QString test = "20"; 200 QString test = "20";
278 if (KGlobal::locale()->use12Clock()) 201 if (KGlobal::locale()->use12Clock())
279 test = "12"; 202 test = "12";
280 mMiniWidth = fontMetrics().width(test); 203 mMiniWidth = fontMetrics().width(test);
281 if (KGlobal::locale()->use12Clock()) 204 if (KGlobal::locale()->use12Clock())
282 test = "pm"; 205 test = "pm";
283 else { 206 else {
284 if ( QApplication::desktop()->width() <= 320 ) 207 test = "00";
285 test = "00";
286 else
287 test = "00";
288 } 208 }
289 QFont sFont = font(); 209 QFont sFont = font();
290 sFont.setPointSize( sFont.pointSize()/2 ); 210 sFont.setPointSize( sFont.pointSize()/2 );
291 QFontMetrics fmS( sFont ); 211 QFontMetrics fmS( sFont );
292 mMiniWidth += fmS.width( test ) + frameWidth()*2 +4 ; 212 mMiniWidth += fmS.width( test ) + frameWidth()*2+4 ;
213 qDebug("testwid %d %d", mMiniWidth ,fmS.width( test ));
293 // update geometry restrictions based on new settings 214 // update geometry restrictions based on new settings
294 setFixedWidth( mMiniWidth ); 215 setFixedWidth( mMiniWidth );
295 216
296 // update HourSize 217 // update HourSize
297 mCellHeight = KOPrefs::instance()->mHourSize*4; 218 mCellHeight = KOPrefs::instance()->mHourSize*4;
298 resizeContents(50,mRows * mCellHeight); 219 resizeContents(50,mRows * mCellHeight);
299} 220}
300 221
301/** update time label positions */ 222/** update time label positions */
302void TimeLabels::positionChanged() 223void TimeLabels::positionChanged()
303{ 224{
304 int adjustment = mAgenda->contentsY(); 225 int adjustment = mAgenda->contentsY();
305 setContentsPos(0, adjustment); 226 setContentsPos(0, adjustment);
306} 227}
307 228
308/** */ 229/** */
309void TimeLabels::setAgenda(KOAgenda* agenda) 230void TimeLabels::setAgenda(KOAgenda* agenda)
310{ 231{
311 mAgenda = agenda; 232 mAgenda = agenda;
312} 233}
313 234
314void TimeLabels::contentsMousePressEvent ( QMouseEvent * e) 235void TimeLabels::contentsMousePressEvent ( QMouseEvent * e)
315{ 236{
316 mMouseDownY = e->pos().y(); 237 mMouseDownY = e->pos().y();
317 mOrgCap = topLevelWidget()->caption(); 238 mOrgCap = topLevelWidget()->caption();
318} 239}
319 240
320void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e ) 241void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e )
321{ 242{
322 int diff = mMouseDownY - e->pos().y(); 243 int diff = mMouseDownY - e->pos().y();
323 if ( diff < 10 && diff > -10 ) 244 if ( diff < 10 && diff > -10 )
324 return; 245 return;
325 int tSize = KOPrefs::instance()->mHourSize + (diff/10) ; 246 int tSize = KOPrefs::instance()->mHourSize + (diff/10) ;
326 if ( tSize < 4 ) 247 if ( tSize < 4 )
327 tSize = 4; 248 tSize = 4;
328 if ( tSize > 22 ) 249 if ( tSize > 22 )
329 tSize = 22; 250 tSize = 22;
330 tSize = (tSize-2)/2; 251 tSize = (tSize-2)/2;
331 topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize)); 252 topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize));
332 253
333} 254}
334void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e ) 255void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e )
335{ 256{
336 topLevelWidget()->setCaption( mOrgCap ); 257 topLevelWidget()->setCaption( mOrgCap );
337 int diff = mMouseDownY - e->pos().y(); 258 int diff = mMouseDownY - e->pos().y();
338 if ( diff < 10 && diff > -10 ) 259 if ( diff < 10 && diff > -10 )
339 return; 260 return;
340 int tSize = KOPrefs::instance()->mHourSize + (diff/10); 261 int tSize = KOPrefs::instance()->mHourSize + (diff/10);
@@ -689,116 +610,120 @@ void KOAgendaView::resizeEvent( QResizeEvent* e )
689 } 610 }
690 mUpcomingWidth = e->size().width() ; 611 mUpcomingWidth = e->size().width() ;
691 if ( mBlockUpdating || uc ) { 612 if ( mBlockUpdating || uc ) {
692 mBlockUpdating = false; 613 mBlockUpdating = false;
693 //mAgenda->setMinimumSize(800 , 600 ); 614 //mAgenda->setMinimumSize(800 , 600 );
694 //qDebug("mAgenda->resize+++++++++++++++ "); 615 //qDebug("mAgenda->resize+++++++++++++++ ");
695 updateConfig(); 616 updateConfig();
696 //qDebug("KOAgendaView::Updating now possible "); 617 //qDebug("KOAgendaView::Updating now possible ");
697 } else 618 } else
698 createDayLabels(); 619 createDayLabels();
699 //qDebug("resizeEvent end "); 620 //qDebug("resizeEvent end ");
700 621
701} 622}
702void KOAgendaView::slotDaylabelClicked( int num ) 623void KOAgendaView::slotDaylabelClicked( int num )
703{ 624{
704 625
705 QDate firstDate = mSelectedDates.first(); 626 QDate firstDate = mSelectedDates.first();
706 if ( num == -1 ) 627 if ( num == -1 )
707 emit showDateView( 6, firstDate ); 628 emit showDateView( 6, firstDate );
708 else if (num >= 0 ) { 629 else if (num >= 0 ) {
709 if ( mSelectedDates.count() == 1) 630 if ( mSelectedDates.count() == 1)
710 emit showDateView( 9, firstDate.addDays( num ) ); 631 emit showDateView( 9, firstDate.addDays( num ) );
711 else 632 else
712 emit showDateView( 3, firstDate.addDays( num ) ); 633 emit showDateView( 3, firstDate.addDays( num ) );
713 } 634 }
714 else 635 else
715 showDateView( 10, firstDate.addDays(1) ); 636 showDateView( 10, firstDate.addDays(1) );
716} 637}
717 638
718KOAgendaButton* KOAgendaView::getNewDaylabel() 639KOAgendaButton* KOAgendaView::getNewDaylabel()
719{ 640{
720 641
721 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); 642 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels);
722 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); 643 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) );
723 mDayLabelsList.append( dayLabel ); 644 mDayLabelsList.append( dayLabel );
724 mLayoutDayLabels->addWidget(dayLabel); 645 mLayoutDayLabels->addWidget(dayLabel);
725 return dayLabel ; 646 return dayLabel ;
726} 647}
727 648
728void KOAgendaView::createDayLabels() 649void KOAgendaView::createDayLabels()
729{ 650{
730 651
731 if ( mBlockUpdating || globalFlagBlockLabel == 1) { 652 if ( mBlockUpdating || globalFlagBlockLabel == 1) {
732 // qDebug(" KOAgendaView::createDayLabels() blocked "); 653 // qDebug(" KOAgendaView::createDayLabels() blocked ");
733 return; 654 return;
734 655
735 } 656 }
736 int newHight; 657 int newHight;
658 if ( !mSelectedDates.count())
659 return;
737 660
738 // ### Before deleting and recreating we could check if mSelectedDates changed... 661 // ### Before deleting and recreating we could check if mSelectedDates changed...
739 // It would remove some flickering and gain speed (since this is called by 662 // It would remove some flickering and gain speed (since this is called by
740 // each updateView() call) 663 // each updateView() call)
741 664
742 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2; 665 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2;
743 if ( QApplication::desktop()->width() <= 320 )
744 maxWid -= 10;
745 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); 666 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth );
746 if ( maxWid < 0 ) 667 if ( maxWid < 20 )
747 maxWid = 20; 668 maxWid = 20;
748 669
749 QFont dlf = KOPrefs::instance()->mTimeLabelsFont; 670 QFont dlf = KOPrefs::instance()->mTimeLabelsFont;
750 QFontMetrics fm ( dlf ); 671 QFontMetrics fm ( dlf );
751 int selCount = mSelectedDates.count(); 672 int selCount = mSelectedDates.count();
673 int widModulo = maxWid - (mAgenda->gridSpacingX() * selCount)+1;
752 QString dayTest = "Mon 20"; 674 QString dayTest = "Mon 20";
753 //QString dayTest = "Mon 20"; 675 //QString dayTest = "Mon 20";
754 int wid = fm.width( dayTest ); 676 int wid = fm.width( dayTest );
755 //maxWid -= ( selCount * 3 ); //working for QLabels 677 //maxWid -= ( selCount * 3 ); //working for QLabels
756 maxWid -= ( selCount * 3 ); //working for QPushButton 678 if ( QApplication::desktop()->width() <= 320 )
679 maxWid -= ( selCount * 3 ); //working for QPushButton
680 else
681 maxWid -= ( selCount * 3 ); //working for QPushButton
757 if ( maxWid < 0 ) 682 if ( maxWid < 0 )
758 maxWid = 20; 683 maxWid = 20;
759 int needWid = wid * selCount; 684 int needWid = wid * selCount;
760 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); 685 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid );
761 //if ( needWid > maxWid ) 686 //if ( needWid > maxWid )
762 // qDebug("DAYLABELS TOOOOOOO BIG "); 687 // qDebug("DAYLABELS TOOOOOOO BIG ");
763 while ( needWid > maxWid ) { 688 while ( needWid > maxWid ) {
764 dayTest = dayTest.left( dayTest.length() - 1 ); 689 dayTest = dayTest.left( dayTest.length() - 1 );
765 wid = fm.width( dayTest ); 690 wid = fm.width( dayTest );
766 needWid = wid * selCount; 691 needWid = wid * selCount;
767 } 692 }
768 int maxLen = dayTest.length(); 693 int maxLen = dayTest.length();
769 int fontPoint = dlf.pointSize(); 694 int fontPoint = dlf.pointSize();
770 if ( maxLen < 2 ) { 695 if ( maxLen < 2 ) {
771 int fontPoint = dlf.pointSize(); 696 int fontPoint = dlf.pointSize();
772 while ( fontPoint > 4 ) { 697 while ( fontPoint > 4 ) {
773 --fontPoint; 698 --fontPoint;
774 dlf.setPointSize( fontPoint ); 699 dlf.setPointSize( fontPoint );
775 QFontMetrics f( dlf ); 700 QFontMetrics f( dlf );
776 wid = f.width( "30" ); 701 wid = f.width( "30" );
777 needWid = wid * selCount; 702 needWid = wid * selCount;
778 if ( needWid < maxWid ) 703 if ( needWid < maxWid )
779 break; 704 break;
780 } 705 }
781 maxLen = 2; 706 maxLen = 2;
782 } 707 }
783 //qDebug("Max len %d ", dayTest.length() ); 708 //qDebug("Max len %d ", dayTest.length() );
784 709
785 QFontMetrics tempF( dlf ); 710 QFontMetrics tempF( dlf );
786 newHight = tempF.height(); 711 newHight = tempF.height();
787 mDayLabels->setFont( dlf ); 712 mDayLabels->setFont( dlf );
788 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; 713 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);;
789 // mLayoutDayLabels->addSpacing(mTimeLabels->width()); 714 // mLayoutDayLabels->addSpacing(mTimeLabels->width());
790 //mLayoutDayLabels->addSpacing( 2 ); 715 //mLayoutDayLabels->addSpacing( 2 );
791 // QFont lFont = dlf; 716 // QFont lFont = dlf;
792 bool appendLabels = false; 717 bool appendLabels = false;
793 KOAgendaButton *dayLabel; 718 KOAgendaButton *dayLabel;
794 dayLabel = mDayLabelsList.first(); 719 dayLabel = mDayLabelsList.first();
795 if ( !dayLabel ) { 720 if ( !dayLabel ) {
796 appendLabels = true; 721 appendLabels = true;
797 dayLabel = getNewDaylabel(); 722 dayLabel = getNewDaylabel();
798 } 723 }
799 dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() ); 724 dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() );
800 dayLabel->setFont( dlf ); 725 dayLabel->setFont( dlf );
801 dayLabel->setNum( -1 ); 726 dayLabel->setNum( -1 );
802 //dayLabel->setAlignment(QLabel::AlignHCenter); 727 //dayLabel->setAlignment(QLabel::AlignHCenter);
803#if 0 728#if 0
804 if ( QApplication::desktop()->width() <= 320 ) 729 if ( QApplication::desktop()->width() <= 320 )
@@ -867,107 +792,104 @@ void KOAgendaView::createDayLabels()
867 addString = i18n("Day before yesterday"); 792 addString = i18n("Day before yesterday");
868 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) 793 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) )
869 addString = i18n("Day after tomorrow"); 794 addString = i18n("Day after tomorrow");
870 if ( !addString.isEmpty() ) { 795 if ( !addString.isEmpty() ) {
871 str = addString+", " + str; 796 str = addString+", " + str;
872 } else { 797 } else {
873 str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer); 798 str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer);
874 } 799 }
875 } 800 }
876 dayLabel->setText(str); 801 dayLabel->setText(str);
877 //dayLabel->setAlignment(QLabel::AlignHCenter); 802 //dayLabel->setAlignment(QLabel::AlignHCenter);
878 if (date == QDate::currentDate()) { 803 if (date == QDate::currentDate()) {
879 QFont bFont = dlf; 804 QFont bFont = dlf;
880 bFont.setBold( true ); 805 bFont.setBold( true );
881 dayLabel->setFont(bFont); 806 dayLabel->setFont(bFont);
882 } 807 }
883 //dayLayout->addWidget(dayLabel); 808 //dayLayout->addWidget(dayLabel);
884 809
885#ifndef KORG_NOPLUGINS 810#ifndef KORG_NOPLUGINS
886 CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); 811 CalendarDecoration::List cds = KOCore::self()->calendarDecorations();
887 CalendarDecoration *it; 812 CalendarDecoration *it;
888 for(it = cds.first(); it; it = cds.next()) { 813 for(it = cds.first(); it; it = cds.next()) {
889 QString text = it->shortText( date ); 814 QString text = it->shortText( date );
890 if ( !text.isEmpty() ) { 815 if ( !text.isEmpty() ) {
891 QLabel *label = new QLabel(text,mDayLabels); 816 QLabel *label = new QLabel(text,mDayLabels);
892 label->setAlignment(AlignCenter); 817 label->setAlignment(AlignCenter);
893 dayLayout->addWidget(label); 818 dayLayout->addWidget(label);
894 } 819 }
895 } 820 }
896 821
897 for(it = cds.first(); it; it = cds.next()) { 822 for(it = cds.first(); it; it = cds.next()) {
898 QWidget *wid = it->smallWidget(mDayLabels,date); 823 QWidget *wid = it->smallWidget(mDayLabels,date);
899 if ( wid ) { 824 if ( wid ) {
900 // wid->setHeight(20); 825 // wid->setHeight(20);
901 dayLayout->addWidget(wid); 826 dayLayout->addWidget(wid);
902 } 827 }
903 } 828 }
904#endif 829#endif
905 } 830 }
906 if ( ! appendLabels ) { 831 if ( ! appendLabels ) {
907 dayLabel = mDayLabelsList.next(); 832 dayLabel = mDayLabelsList.next();
908 if ( !dayLabel ) 833 if ( !dayLabel )
909 appendLabels = true; 834 appendLabels = true;
910 } 835 }
911 if ( appendLabels ) { 836 if ( appendLabels ) {
912 dayLabel = getNewDaylabel(); 837 dayLabel = getNewDaylabel();
913 } 838 }
914 //dayLabel->hide();//test only 839 //dayLabel->hide();//test only
915 int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()- (mAgenda->frameWidth()*2) ) % mSelectedDates.count() ; 840
916 if ( offset < 0 ) offset = 0; 841 dayLabel->setText(">");
917 //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 );
918 dayLabel->setText(">");//QString::number ( mSelectedDates.first().month() ) );
919 dayLabel->setFont( dlf ); 842 dayLabel->setFont( dlf );
920 dayLabel->setAutoRepeat( true ); 843 dayLabel->setAutoRepeat( true );
921 dayLabel->show(); 844 dayLabel->show();
922 dayLabel->setNum( -2 ); 845 dayLabel->setNum( -2 );
923 dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset ); 846 dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ widModulo );
924 847
925 //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2);
926 //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); 848 //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2);
927 if ( !appendLabels ) { 849 if ( !appendLabels ) {
928 dayLabel = mDayLabelsList.next(); 850 dayLabel = mDayLabelsList.next();
929 while ( dayLabel ) { 851 while ( dayLabel ) {
930 //qDebug("!dayLabel %d",dayLabel ); 852 //qDebug("!dayLabel %d",dayLabel );
931 dayLabel->hide(); 853 dayLabel->hide();
932 dayLabel = mDayLabelsList.next(); 854 dayLabel = mDayLabelsList.next();
933 } 855 }
934 } 856 }
935 857
936 mDayLabelsFrame->setFixedHeight( newHight + 4 ); 858 mDayLabelsFrame->setFixedHeight( newHight + 4 );
937} 859}
938 860
939int KOAgendaView::maxDatesHint() 861int KOAgendaView::maxDatesHint()
940{ 862{
941 // Not sure about the max number of events, so return 0 for now. 863 // Not sure about the max number of events, so return 0 for now.
942 return 0; 864 return 0;
943} 865}
944 866
945int KOAgendaView::currentDateCount() 867int KOAgendaView::currentDateCount()
946{ 868{
947 return mSelectedDates.count(); 869 return mSelectedDates.count();
948} 870}
949 871
950QPtrList<Incidence> KOAgendaView::selectedIncidences() 872QPtrList<Incidence> KOAgendaView::selectedIncidences()
951{ 873{
952 QPtrList<Incidence> selected; 874 QPtrList<Incidence> selected;
953 Incidence *incidence; 875 Incidence *incidence;
954 876
955 incidence = mAgenda->selectedIncidence(); 877 incidence = mAgenda->selectedIncidence();
956 if (incidence) selected.append(incidence); 878 if (incidence) selected.append(incidence);
957 879
958 incidence = mAllDayAgenda->selectedIncidence(); 880 incidence = mAllDayAgenda->selectedIncidence();
959 if (incidence) selected.append(incidence); 881 if (incidence) selected.append(incidence);
960 882
961 return selected; 883 return selected;
962} 884}
963 885
964DateList KOAgendaView::selectedDates() 886DateList KOAgendaView::selectedDates()
965{ 887{
966 DateList selected; 888 DateList selected;
967 QDate qd; 889 QDate qd;
968 890
969 qd = mAgenda->selectedIncidenceDate(); 891 qd = mAgenda->selectedIncidenceDate();
970 if (qd.isValid()) selected.append(qd); 892 if (qd.isValid()) selected.append(qd);
971 893
972 qd = mAllDayAgenda->selectedIncidenceDate(); 894 qd = mAllDayAgenda->selectedIncidenceDate();
973 if (qd.isValid()) selected.append(qd); 895 if (qd.isValid()) selected.append(qd);