summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-04-01 19:24:18 (UTC)
committer zautrix <zautrix>2005-04-01 19:24:18 (UTC)
commitb1e3bf53b1c4cc46ef0a2ded04338bc38a640161 (patch) (unidiff)
tree7f6aecc33d464e28d18e07b0663450e917ea594b
parent1022d8763a5185c74d1fb1fba9857d6e3afd9ff5 (diff)
downloadkdepimpi-b1e3bf53b1c4cc46ef0a2ded04338bc38a640161.zip
kdepimpi-b1e3bf53b1c4cc46ef0a2ded04338bc38a640161.tar.gz
kdepimpi-b1e3bf53b1c4cc46ef0a2ded04338bc38a640161.tar.bz2
fix
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagendaview.cpp16
-rw-r--r--microkde/KDGanttMinimizeSplitter.cpp7
2 files changed, 16 insertions, 7 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index 99f547a..667ff2a 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -109,153 +109,161 @@ void TimeLabels::setCellHeight(int height)
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 timeHeight = fm.ascent(); 132 int timeHeight = fm.ascent();
133 QFont nFont = p->font(); 133 QFont nFont = p->font();
134 134
135 if (!KGlobal::locale()->use12Clock()) 135 if (!KGlobal::locale()->use12Clock())
136 suffix = "00"; 136 suffix = "00";
137 137
138 if ( timeHeight > mCellHeight ) { 138 if ( timeHeight > mCellHeight ) {
139 timeHeight = mCellHeight-1; 139 timeHeight = mCellHeight-1;
140 int pointS = nFont.pointSize(); 140 int pointS = nFont.pointSize();
141 while ( pointS > 4 ) { 141 while ( pointS > 4 ) {
142 nFont.setPointSize( pointS ); 142 nFont.setPointSize( pointS );
143 fm = QFontMetrics( nFont ); 143 fm = QFontMetrics( nFont );
144 if ( fm.ascent() < mCellHeight ) 144 if ( fm.ascent() < mCellHeight )
145 break; 145 break;
146 -- pointS; 146 -- pointS;
147 } 147 }
148 fm = QFontMetrics( nFont ); 148 fm = QFontMetrics( nFont );
149 timeHeight = fm.ascent(); 149 timeHeight = fm.ascent();
150 } 150 }
151 //timeHeight -= (timeHeight/4-2); 151 //timeHeight -= (timeHeight/4-2);
152 QFont sFont = nFont; 152 QFont sFont = nFont;
153 sFont.setPointSize( sFont.pointSize()/2 ); 153 sFont.setPointSize( sFont.pointSize()/2 );
154 QFontMetrics fmS( sFont ); 154 QFontMetrics fmS( sFont );
155 int sHei = fmS.ascent() ; 155 int sHei = fmS.ascent() ;
156 //sHei -= (sHei/4-2); 156 //sHei -= (sHei/4-2);
157 int startW = this->width() - 2*frameWidth()-1; 157 int startW = this->width() - frameWidth()-2;
158 int tw2 = fmS.width(suffix); 158 int tw2 = fmS.width(suffix);
159 while (y < cy + ch) { 159 while (y < cy + ch) {
160 p->drawLine(cx,y,cw,y); 160 p->drawLine(cx,y,cw,y);
161 hour.setNum(cell); 161 hour.setNum(cell);
162 162
163 // handle 24h and am/pm time formats 163 // handle 24h and am/pm time formats
164 if (KGlobal::locale()->use12Clock()) { 164 if (KGlobal::locale()->use12Clock()) {
165 if (cell > 11) suffix = "pm"; 165 if (cell > 11) suffix = "pm";
166 else 166 else
167 suffix = "am"; 167 suffix = "am";
168 if (cell == 0) hour.setNum(12); 168 if (cell == 0) hour.setNum(12);
169 if (cell > 12) hour.setNum(cell - 12); 169 if (cell > 12) hour.setNum(cell - 12);
170 tw2 = fmS.width(suffix); 170 tw2 = fmS.width(suffix);
171 } 171 }
172 172
173 // center and draw the time label 173 // center and draw the time label
174 int timeWidth = fm.width(hour); 174 int timeWidth = fm.width(hour);
175 int offset = startW - timeWidth - tw2 ; 175 int offset = startW - timeWidth - tw2 ;
176 p->setFont( nFont ); 176 p->setFont( nFont );
177 p->drawText( offset, y+ timeHeight, hour); 177 p->drawText( offset, y+ timeHeight, hour);
178 p->setFont( sFont ); 178 p->setFont( sFont );
179 offset = startW - tw2+1; 179 offset = startW - tw2+1;
180 p->drawText( offset, y+ sHei, suffix); 180 p->drawText( offset, y+ sHei, suffix);
181 181
182 // increment indices 182 // increment indices
183 y += mCellHeight; 183 y += mCellHeight;
184 cell++; 184 cell++;
185 } 185 }
186 } else { 186 } else {
187 //qDebug("NO redraw "); 187 //qDebug("NO redraw ");
188 } 188 }
189 // double buffer not yet implemented 189 // double buffer not yet implemented
190 //bitBlt (this, 0, 0, &myPix, 0 ,0,width(), height() ,CopyROP); 190 //bitBlt (this, 0, 0, &myPix, 0 ,0,width(), height() ,CopyROP);
191 //mRedrawNeeded = false; 191 //mRedrawNeeded = false;
192} 192}
193 193
194/** 194/**
195 Calculates the minimum width. 195 Calculates the minimum width.
196*/ 196*/
197int TimeLabels::minimumWidth() const 197int TimeLabels::minimumWidth() const
198{ 198{
199 return mMiniWidth; 199 return mMiniWidth;
200} 200}
201 201
202/** updates widget's internal state */ 202/** updates widget's internal state */
203void TimeLabels::updateConfig() 203void TimeLabels::updateConfig()
204{ 204{
205 mRedrawNeeded = true; 205 mRedrawNeeded = true;
206 // set the font 206 // set the font
207 // config->setGroup("Fonts"); 207 // config->setGroup("Fonts");
208 // QFont font = config->readFontEntry("TimeBar Font"); 208 // QFont font = config->readFontEntry("TimeBar Font");
209 setFont(KOPrefs::instance()->mTimeBarFont); 209 setFont(KOPrefs::instance()->mTimeBarFont);
210 QString test = "20oo"; 210 QString test = "20";
211 if (KGlobal::locale()->use12Clock()) 211 if (KGlobal::locale()->use12Clock())
212 test = "12mi"; 212 test = "12";
213 mMiniWidth = fontMetrics().width(test) + frameWidth()*2 +1 ; 213 mMiniWidth = fontMetrics().width(test);
214 if (KGlobal::locale()->use12Clock())
215 test = "pm";
216 else
217 test = "00";
218 QFont sFont = font();
219 sFont.setPointSize( sFont.pointSize()/2 );
220 QFontMetrics fmS( sFont );
221 mMiniWidth += fmS.width( test ) + frameWidth()*2 +4 ;
214 // update geometry restrictions based on new settings 222 // update geometry restrictions based on new settings
215 setFixedWidth( mMiniWidth ); 223 setFixedWidth( mMiniWidth );
216 224
217 // update HourSize 225 // update HourSize
218 mCellHeight = KOPrefs::instance()->mHourSize*4; 226 mCellHeight = KOPrefs::instance()->mHourSize*4;
219 resizeContents(50,mRows * mCellHeight); 227 resizeContents(50,mRows * mCellHeight);
220} 228}
221 229
222/** update time label positions */ 230/** update time label positions */
223void TimeLabels::positionChanged() 231void TimeLabels::positionChanged()
224{ 232{
225 int adjustment = mAgenda->contentsY(); 233 int adjustment = mAgenda->contentsY();
226 setContentsPos(0, adjustment); 234 setContentsPos(0, adjustment);
227} 235}
228 236
229/** */ 237/** */
230void TimeLabels::setAgenda(KOAgenda* agenda) 238void TimeLabels::setAgenda(KOAgenda* agenda)
231{ 239{
232 mAgenda = agenda; 240 mAgenda = agenda;
233} 241}
234 242
235void TimeLabels::contentsMousePressEvent ( QMouseEvent * e) 243void TimeLabels::contentsMousePressEvent ( QMouseEvent * e)
236{ 244{
237 mMouseDownY = e->pos().y(); 245 mMouseDownY = e->pos().y();
238 mOrgCap = topLevelWidget()->caption(); 246 mOrgCap = topLevelWidget()->caption();
239} 247}
240 248
241void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e ) 249void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e )
242{ 250{
243 int diff = mMouseDownY - e->pos().y(); 251 int diff = mMouseDownY - e->pos().y();
244 if ( diff < 10 && diff > -10 ) 252 if ( diff < 10 && diff > -10 )
245 return; 253 return;
246 int tSize = KOPrefs::instance()->mHourSize + (diff/10) ; 254 int tSize = KOPrefs::instance()->mHourSize + (diff/10) ;
247 if ( tSize < 4 ) 255 if ( tSize < 4 )
248 tSize = 4; 256 tSize = 4;
249 if ( tSize > 22 ) 257 if ( tSize > 22 )
250 tSize = 22; 258 tSize = 22;
251 tSize = (tSize-2)/2; 259 tSize = (tSize-2)/2;
252 topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize)); 260 topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize));
253 261
254} 262}
255void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e ) 263void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e )
256{ 264{
257 topLevelWidget()->setCaption( mOrgCap ); 265 topLevelWidget()->setCaption( mOrgCap );
258 int diff = mMouseDownY - e->pos().y(); 266 int diff = mMouseDownY - e->pos().y();
259 if ( diff < 10 && diff > -10 ) 267 if ( diff < 10 && diff > -10 )
260 return; 268 return;
261 int tSize = KOPrefs::instance()->mHourSize + (diff/10); 269 int tSize = KOPrefs::instance()->mHourSize + (diff/10);
diff --git a/microkde/KDGanttMinimizeSplitter.cpp b/microkde/KDGanttMinimizeSplitter.cpp
index d675517..6cb1f31 100644
--- a/microkde/KDGanttMinimizeSplitter.cpp
+++ b/microkde/KDGanttMinimizeSplitter.cpp
@@ -633,105 +633,106 @@ void KDGanttMinimizeSplitter::childEvent( QChildEvent *c )
633 } 633 }
634 recalcId(); 634 recalcId();
635 doResize(); 635 doResize();
636 return; 636 return;
637 } 637 }
638 p = s; 638 p = s;
639 s = data->list.next(); 639 s = data->list.next();
640 } 640 }
641 } 641 }
642} 642}
643 643
644 644
645/*! 645/*!
646 Shows a rubber band at position \a p. If \a p is negative, the 646 Shows a rubber band at position \a p. If \a p is negative, the
647 rubber band is removed. 647 rubber band is removed.
648*/ 648*/
649void KDGanttMinimizeSplitter::setRubberband( int p ) 649void KDGanttMinimizeSplitter::setRubberband( int p )
650{ 650{
651#ifdef DESKTOP_VERSION 651#ifdef DESKTOP_VERSION
652 QPainter paint( this ); 652 QPainter paint( this );
653 paint.setPen( gray ); 653 paint.setPen( gray );
654 paint.setBrush( gray ); 654 paint.setBrush( gray );
655 paint.setRasterOp( XorROP ); 655 paint.setRasterOp( XorROP );
656 QRect r = contentsRect(); 656 QRect r = contentsRect();
657 const int rBord = 3; //Themable???? 657 const int rBord = 3; //Themable????
658#if QT_VERSION >= 0x030000 658#if QT_VERSION >= 0x030000
659 int sw = style().pixelMetric(QStyle::PM_SplitterWidth, this); 659 int sw = style().pixelMetric(QStyle::PM_SplitterWidth, this);
660#else 660#else
661 int sw = style().splitterWidth(); 661 int sw = style().splitterWidth();
662#endif 662#endif
663 if ( orient == Horizontal ) { 663 if ( orient == Horizontal ) {
664 if ( opaqueOldPos >= 0 ) 664 if ( opaqueOldPos >= 0 )
665 paint.drawRect( opaqueOldPos + sw/2 - rBord , r.y(), 665 paint.drawRect( opaqueOldPos + sw/2 - rBord , r.y(),
666 2*rBord, r.height() ); 666 2*rBord, r.height() );
667 if ( p >= 0 ) 667 if ( p >= 0 )
668 paint.drawRect( p + sw/2 - rBord, r.y(), 2*rBord, r.height() ); 668 paint.drawRect( p + sw/2 - rBord, r.y(), 2*rBord, r.height() );
669 } else { 669 } else {
670 if ( opaqueOldPos >= 0 ) 670 if ( opaqueOldPos >= 0 )
671 paint.drawRect( r.x(), opaqueOldPos + sw/2 - rBord, 671 paint.drawRect( r.x(), opaqueOldPos + sw/2 - rBord,
672 r.width(), 2*rBord ); 672 r.width(), 2*rBord );
673 if ( p >= 0 ) 673 if ( p >= 0 )
674 paint.drawRect( r.x(), p + sw/2 - rBord, r.width(), 2*rBord ); 674 paint.drawRect( r.x(), p + sw/2 - rBord, r.width(), 2*rBord );
675 } 675 }
676 opaqueOldPos = p; 676 opaqueOldPos = p;
677#else 677#else
678 if ( !mRubberBand ) { 678 if ( !mRubberBand ) {
679 mRubberBand = new QFrame( 0, "rubber", WStyle_NoBorder | WStyle_Customize | WStyle_StaysOnTop); 679 mRubberBand = new QFrame( 0, "rubber", WStyle_NoBorder | WStyle_Customize | WStyle_StaysOnTop);
680 mRubberBand->setFrameStyle( Box | Raised ); 680 mRubberBand->setFrameStyle( Box | Raised );
681 mRubberBand->setPalette( QPalette ( Qt::red.light(),Qt::red.dark() ) ); 681 //mRubberBand->setPalette( QPalette ( Qt::red.light(),Qt::red.dark() ) );
682 mRubberBand->setPalette( QPalette ( QColor( 178,18,188), QColor( 242,27,255 ) ));
682 } 683 }
683 QRect r = contentsRect(); 684 QRect r = contentsRect();
684 static int rBord = 0; //Themable???? 685 static int rBord = 0; //Themable????
685 if ( !rBord ) { 686 if ( !rBord ) {
686 if (QApplication::desktop()->width() <= 320 ) 687 if (QApplication::desktop()->width() <= 320 )
687 rBord = 4; 688 rBord = 3;
688 else 689 else
689 rBord = 5; 690 rBord = 4;
690 } 691 }
691 int sw = style().splitterWidth(); 692 int sw = style().splitterWidth();
692 if ( orient == Horizontal ) { 693 if ( orient == Horizontal ) {
693 if ( p >= 0 ) { 694 if ( p >= 0 ) {
694 QPoint geo = mapToGlobal (QPoint ( p + sw/2 - rBord, r.y())); 695 QPoint geo = mapToGlobal (QPoint ( p + sw/2 - rBord, r.y()));
695 mRubberBand->setGeometry( geo.x(), geo.y(), 2*rBord, r.height() ); 696 mRubberBand->setGeometry( geo.x(), geo.y(), 2*rBord, r.height() );
696 } 697 }
697 } else { 698 } else {
698 if ( p >= 0 ) { 699 if ( p >= 0 ) {
699 QPoint geo = mapToGlobal (QPoint ( r.x(), p + sw/2 - rBord)); 700 QPoint geo = mapToGlobal (QPoint ( r.x(), p + sw/2 - rBord));
700 mRubberBand->setGeometry( geo.x(), geo.y(), r.width(), 2*rBord); 701 mRubberBand->setGeometry( geo.x(), geo.y(), r.width(), 2*rBord);
701 } 702 }
702 } 703 }
703 opaqueOldPos = p; 704 opaqueOldPos = p;
704 if ( ! mRubberBand->isVisible() ) { 705 if ( ! mRubberBand->isVisible() ) {
705 mRubberBand->show(); 706 mRubberBand->show();
706 } 707 }
707#endif 708#endif
708} 709}
709 710
710 711
711/*! \reimp */ 712/*! \reimp */
712bool KDGanttMinimizeSplitter::event( QEvent *e ) 713bool KDGanttMinimizeSplitter::event( QEvent *e )
713{ 714{
714 if ( e->type() == QEvent::LayoutHint || ( e->type() == QEvent::Show && data->firstShow ) ) { 715 if ( e->type() == QEvent::LayoutHint || ( e->type() == QEvent::Show && data->firstShow ) ) {
715 recalc( isVisible() ); 716 recalc( isVisible() );
716 if ( e->type() == QEvent::Show ) 717 if ( e->type() == QEvent::Show )
717 data->firstShow = FALSE; 718 data->firstShow = FALSE;
718 } 719 }
719 return QWidget::event( e ); 720 return QWidget::event( e );
720} 721}
721 722
722 723
723/*! 724/*!
724 \obsolete 725 \obsolete
725 726
726 Draws the splitter handle in the rectangle described by \a x, \a y, 727 Draws the splitter handle in the rectangle described by \a x, \a y,
727 \a w, \a h using painter \a p. 728 \a w, \a h using painter \a p.
728 \sa QStyle::drawPrimitive() 729 \sa QStyle::drawPrimitive()
729*/ 730*/
730void KDGanttMinimizeSplitter::drawSplitter( QPainter *p, 731void KDGanttMinimizeSplitter::drawSplitter( QPainter *p,
731 QCOORD x, QCOORD y, QCOORD w, QCOORD h ) 732 QCOORD x, QCOORD y, QCOORD w, QCOORD h )
732{ 733{
733#if 0 734#if 0
734 // LR 735 // LR
735 style().drawPrimitive(QStyle::PE_Splitter, p, QRect(x, y, w, h), colorGroup(), 736 style().drawPrimitive(QStyle::PE_Splitter, p, QRect(x, y, w, h), colorGroup(),
736 (orientation() == Qt::Horizontal ? 737 (orientation() == Qt::Horizontal ?
737 QStyle::Style_Horizontal : 0)); 738 QStyle::Style_Horizontal : 0));