[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdepim/kdgantt
From:       Dag Andersen <danders () get2net ! dk>
Date:       2010-03-31 7:07:13
Message-ID: 20100331070713.6882EAC88B () svn ! kde ! org
[Download RAW message or body]

SVN commit 1109466 by danders:

QStyle::CE_Header does not honor clipRegion()
Mainly a problem when printing since it prints outside pagerect.


 M  +56 -8     kdganttdatetimegrid.cpp  


--- trunk/KDE/kdepim/kdgantt/kdganttdatetimegrid.cpp #1109465:1109466
@@ -591,7 +591,13 @@
         opt.rect = QRectF( x-offset, headerRect.top()+headerRect.height()/2., \
dayWidth()/24., headerRect.height()/2. ).toRect();  opt.text = dt.time().toString( \
QString::fromAscii( "hh" ) );  opt.textAlignment = Qt::AlignCenter;
-        style->drawControl(QStyle::CE_Header, &opt, painter, widget);
+        // NOTE:CE_Header does not honor clipRegion(), so we do the CE_Header logic \
here +        style->drawControl( QStyle::CE_HeaderSection, &opt, painter, widget );
+        QStyleOptionHeader subopt = opt;
+        subopt.rect = style->subElementRect( QStyle::SE_HeaderLabel, &opt, widget );
+        if ( subopt.rect.isValid() ) {
+            style->drawControl( QStyle::CE_HeaderLabel, &subopt, painter, widget );
+        }
     }
 
     dt = d->chartXtoDateTime( offset+exposedRect.left() );
@@ -604,7 +610,13 @@
         opt.rect = QRectF( x2-offset, headerRect.top(), dayWidth(), \
headerRect.height()/2. ).toRect();  opt.text = QDate::longDayName( \
dt.date().dayOfWeek() );  opt.textAlignment = Qt::AlignCenter;
-        style->drawControl(QStyle::CE_Header, &opt, painter, widget);
+        // NOTE:CE_Header does not honor clipRegion(), so we do the CE_Header logic \
here +        style->drawControl( QStyle::CE_HeaderSection, &opt, painter, widget );
+        QStyleOptionHeader subopt = opt;
+        subopt.rect = style->subElementRect( QStyle::SE_HeaderLabel, &opt, widget );
+        if ( subopt.rect.isValid() ) {
+            style->drawControl( QStyle::CE_HeaderLabel, &subopt, painter, widget );
+        }
     }
 }
 
@@ -627,7 +639,13 @@
         opt.rect = QRectF( x-offset, headerRect.top()+headerRect.height()/2., \
dayWidth(), headerRect.height()/2. ).toRect();  opt.text = dt.toString( \
QString::fromAscii( "ddd" ) ).left( 1 );  opt.textAlignment = Qt::AlignCenter;
-        style->drawControl(QStyle::CE_Header, &opt, painter, widget);
+        // NOTE:CE_Header does not honor clipRegion(), so we do the CE_Header logic \
here +        style->drawControl( QStyle::CE_HeaderSection, &opt, painter, widget );
+        QStyleOptionHeader subopt = opt;
+        subopt.rect = style->subElementRect( QStyle::SE_HeaderLabel, &opt, widget );
+        if ( subopt.rect.isValid() ) {
+            style->drawControl( QStyle::CE_HeaderLabel, &subopt, painter, widget );
+        }
     }
 
     dt = d->chartXtoDateTime( offset+exposedRect.left() );
@@ -642,7 +660,13 @@
         opt.rect = QRectF( x2-offset, headerRect.top(), dayWidth()*7., \
headerRect.height()/2. ).toRect();  opt.text = QString::number( \
dt.date().weekNumber() );  opt.textAlignment = Qt::AlignCenter;
-        style->drawControl(QStyle::CE_Header, &opt, painter, widget);
+        // NOTE:CE_Header does not honor clipRegion(), so we do the CE_Header logic \
here +        style->drawControl( QStyle::CE_HeaderSection, &opt, painter, widget );
+        QStyleOptionHeader subopt = opt;
+        subopt.rect = style->subElementRect( QStyle::SE_HeaderLabel, &opt, widget );
+        if ( subopt.rect.isValid() ) {
+            style->drawControl( QStyle::CE_HeaderLabel, &subopt, painter, widget );
+        }
     }
 }
 
@@ -667,7 +691,13 @@
         opt.rect = QRectF( x-offset, headerRect.top()+headerRect.height()/2., \
dayWidth()*7, headerRect.height()/2. ).toRect();  opt.text = QString::number( \
dt.date().weekNumber() );  opt.textAlignment = Qt::AlignCenter;
-        style->drawControl(QStyle::CE_Header, &opt, painter, widget);
+        // NOTE:CE_Header does not honor clipRegion(), so we do the CE_Header logic \
here +        style->drawControl( QStyle::CE_HeaderSection, &opt, painter, widget );
+        QStyleOptionHeader subopt = opt;
+        subopt.rect = style->subElementRect( QStyle::SE_HeaderLabel, &opt, widget );
+        if ( subopt.rect.isValid() ) {
+            style->drawControl( QStyle::CE_HeaderLabel, &subopt, painter, widget );
+        }
     }
 
     // Paint a section for each month
@@ -682,7 +712,13 @@
         opt.rect = QRectF( x2-offset, headerRect.top(), dayWidth()*dt.date().daysTo( \
next ), headerRect.height()/2. ).toRect();  opt.text = QDate::longMonthName( \
dt.date().month() );  opt.textAlignment = Qt::AlignCenter;
-        style->drawControl(QStyle::CE_Header, &opt, painter, widget);
+        // NOTE:CE_Header does not honor clipRegion(), so we do the CE_Header logic \
here +        style->drawControl( QStyle::CE_HeaderSection, &opt, painter, widget );
+        QStyleOptionHeader subopt = opt;
+        subopt.rect = style->subElementRect( QStyle::SE_HeaderLabel, &opt, widget );
+        if ( subopt.rect.isValid() ) {
+            style->drawControl( QStyle::CE_HeaderLabel, &subopt, painter, widget );
+        }
         
         dt.setDate( next );
     }
@@ -708,7 +744,13 @@
         opt.rect = QRectF( x-offset, headerRect.top()+headerRect.height()/2., \
dayWidth()*dt.date().daysInMonth(), headerRect.height()/2. ).toRect();  opt.text = \
QDate::shortMonthName( dt.date().month() );  opt.textAlignment = Qt::AlignCenter;
-        style->drawControl(QStyle::CE_Header, &opt, painter, widget);
+        // NOTE:CE_Header does not honor clipRegion(), so we do the CE_Header logic \
here +        style->drawControl( QStyle::CE_HeaderSection, &opt, painter, widget );
+        QStyleOptionHeader subopt = opt;
+        subopt.rect = style->subElementRect( QStyle::SE_HeaderLabel, &opt, widget );
+        if ( subopt.rect.isValid() ) {
+            style->drawControl( QStyle::CE_HeaderLabel, &subopt, painter, widget );
+        }
     }
 
     // Paint a section for each year
@@ -723,7 +765,13 @@
         opt.rect = QRectF( x2-offset, headerRect.top(), dayWidth()*dt.date().daysTo( \
next ), headerRect.height()/2. ).toRect();  opt.text = QString::number( \
dt.date().year() );  opt.textAlignment = Qt::AlignCenter;
-        style->drawControl(QStyle::CE_Header, &opt, painter, widget);
+        // NOTE:CE_Header does not honor clipRegion(), so we do the CE_Header logic \
here +        style->drawControl( QStyle::CE_HeaderSection, &opt, painter, widget );
+        QStyleOptionHeader subopt = opt;
+        subopt.rect = style->subElementRect( QStyle::SE_HeaderLabel, &opt, widget );
+        if ( subopt.rect.isValid() ) {
+            style->drawControl( QStyle::CE_HeaderLabel, &subopt, painter, widget );
+        }
         
         dt.setDate( next );
     }


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic