#include <kdganttdatetimegrid.h>
Definition at line 69 of file kdganttdatetimegrid.h.
Public Types | |
enum | Scale { ScaleAuto, ScaleHour, ScaleDay, ScaleWeek, ScaleMonth, ScaleUserDefined } |
Public Slots | |
virtual void | setModel (QAbstractItemModel *model) |
virtual void | setRootIndex (const QModelIndex &idx) |
Signals | |
void | gridChanged () |
Public Member Functions | |
DateTimeGrid () | |
qreal | dayWidth () const |
QSet< Qt::DayOfWeek > | freeDays () const |
bool | isSatisfiedConstraint (const Constraint &c) const |
bool | mapFromChart (const Span &span, const QModelIndex &idx, const QList< Constraint > &constraints=QList< Constraint >()) const |
qreal | mapFromDateTime (const QDateTime &dt) const |
Span | mapToChart (const QModelIndex &idx) const |
QDateTime | mapToDateTime (qreal x) const |
QAbstractItemModel * | model () const |
QBrush | noInformationBrush () const |
void | paintGrid (QPainter *painter, const QRectF &sceneRect, const QRectF &exposedRect, AbstractRowController *rowController=0, QWidget *widget=0) |
void | paintHeader (QPainter *painter, const QRectF &headerRect, const QRectF &exposedRect, qreal offset, QWidget *widget=0) |
QModelIndex | rootIndex () const |
bool | rowSeparators () const |
Scale | scale () const |
void | setDayWidth (qreal) |
void | setFreeDays (const QSet< Qt::DayOfWeek > &fd) |
void | setNoInformationBrush (const QBrush &brush) |
void | setRowSeparators (bool enable) |
void | setScale (Scale s) |
void | setStartDateTime (const QDateTime &dt) |
void | setUserDefinedLowerScale (DateTimeScaleFormatter *lower) |
void | setUserDefinedUpperScale (DateTimeScaleFormatter *upper) |
void | setWeekStart (Qt::DayOfWeek) |
QDateTime | startDateTime () const |
DateTimeScaleFormatter * | userDefinedLowerScale () const |
DateTimeScaleFormatter * | userDefinedUpperScale () const |
Qt::DayOfWeek | weekStart () const |
virtual | ~DateTimeGrid () |
Protected Member Functions | |
virtual void | paintDayScaleHeader (QPainter *painter, const QRectF &headerRect, const QRectF &exposedRect, qreal offset, QWidget *widget=0) |
virtual void | paintHourScaleHeader (QPainter *painter, const QRectF &headerRect, const QRectF &exposedRect, qreal offset, QWidget *widget=0) |
virtual void | paintMonthScaleHeader (QPainter *painter, const QRectF &headerRect, const QRectF &exposedRect, qreal offset, QWidget *widget=0) |
virtual void | paintUserDefinedHeader (QPainter *painter, const QRectF &headerRect, const QRectF &exposedRect, qreal offset, const DateTimeScaleFormatter *formatter, QWidget *widget=0) |
virtual void | paintWeekScaleHeader (QPainter *painter, const QRectF &headerRect, const QRectF &exposedRect, qreal offset, QWidget *widget=0) |
Definition at line 73 of file kdganttdatetimegrid.h.
00073 { ScaleAuto, 00074 ScaleHour, 00075 ScaleDay, 00076 ScaleWeek, 00077 ScaleMonth, 00078 ScaleUserDefined 00079 };
DateTimeGrid::DateTimeGrid | ( | ) |
Definition at line 287 of file kdganttdatetimegrid.cpp.
00287 : AbstractGrid( new Private ) 00288 { 00289 }
DateTimeGrid::~DateTimeGrid | ( | ) | [virtual] |
qreal DateTimeGrid::dayWidth | ( | ) | const |
Definition at line 319 of file kdganttdatetimegrid.cpp.
References d.
Referenced by KDAB_SCOPED_UNITTEST_SIMPLE(), paintDayScaleHeader(), paintGrid(), paintHourScaleHeader(), paintMonthScaleHeader(), and paintWeekScaleHeader().
00320 { 00321 return d->dayWidth; 00322 }
QSet< Qt::DayOfWeek > DateTimeGrid::freeDays | ( | ) | const |
Definition at line 443 of file kdganttdatetimegrid.cpp.
References d.
00444 { 00445 return d->freeDays; 00446 }
void KDGantt::AbstractGrid::gridChanged | ( | ) | [signal, inherited] |
bool AbstractGrid::isSatisfiedConstraint | ( | const Constraint & | c | ) | const [inherited] |
Definition at line 86 of file kdganttabstractgrid.cpp.
References KDGantt::Span::end(), KDGantt::Constraint::endIndex(), KDGantt::AbstractGrid::mapToChart(), and KDGantt::Constraint::startIndex().
Referenced by KDAB_SCOPED_UNITTEST_SIMPLE(), and mapFromChart().
00087 { 00088 // First check if the data is valid, 00089 // TODO: review if true is the right choice 00090 if ( !c.startIndex().isValid() || !c.endIndex().isValid() ) return true; 00091 00092 Span ss = mapToChart( c.startIndex() ); 00093 Span es = mapToChart( c.endIndex() ); 00094 return ( ss.end() <= es.start() ); 00095 }
bool DateTimeGrid::mapFromChart | ( | const Span & | span, | |
const QModelIndex & | idx, | |||
const QList< Constraint > & | constraints = QList<Constraint>() | |||
) | const [virtual] |
Maps the supplied Span to QDateTimes, and puts them as start time and end time for the supplied index.
span | The span used to map from. | |
idx | The index used for setting the start time and end time in the model. | |
constraints | A list of hard constraints to match against the start time and end time mapped from the span. |
Implements KDGantt::AbstractGrid.
Definition at line 538 of file kdganttdatetimegrid.cpp.
References c, d, KDGantt::Constraint::endIndex(), KDGantt::EndTimeRole, KDGantt::AbstractGrid::isSatisfiedConstraint(), KDGantt::Span::length(), KDGantt::AbstractGrid::model(), KDGantt::Span::start(), KDGantt::Constraint::startIndex(), KDGantt::StartTimeRole, KDGantt::Constraint::type(), and KDGantt::Constraint::TypeHard.
Referenced by KDAB_SCOPED_UNITTEST_SIMPLE().
00540 { 00541 assert( model() ); 00542 if ( !idx.isValid() ) return false; 00543 assert( idx.model()==model() ); 00544 00545 QDateTime st = d->chartXtoDateTime(span.start()); 00546 QDateTime et = d->chartXtoDateTime(span.start()+span.length()); 00547 //qDebug() << "DateTimeGrid::mapFromChart("<<span<<") => "<< st << et; 00548 Q_FOREACH( const Constraint& c, constraints ) { 00549 if ( c.type() != Constraint::TypeHard || !isSatisfiedConstraint( c )) continue; 00550 if ( c.startIndex() == idx ) { 00551 QDateTime tmpst = model()->data( c.endIndex(), StartTimeRole ).toDateTime(); 00552 //qDebug() << tmpst << "<" << et <<"?"; 00553 if ( tmpst<et ) return false; 00554 } else if ( c.endIndex() == idx ) { 00555 QDateTime tmpet = model()->data( c.startIndex(), EndTimeRole ).toDateTime(); 00556 //qDebug() << tmpet << ">" << st <<"?"; 00557 if ( tmpet>st ) return false; 00558 } 00559 } 00560 return model()->setData( idx, qVariantFromValue(st), StartTimeRole ) 00561 && model()->setData( idx, qVariantFromValue(et), EndTimeRole ); 00562 }
qreal DateTimeGrid::mapFromDateTime | ( | const QDateTime & | dt | ) | const |
Maps a given point in time dt to an X value in the scene.
Definition at line 326 of file kdganttdatetimegrid.cpp.
References d.
Referenced by KDAB_SCOPED_UNITTEST_SIMPLE().
00327 { 00328 return d->dateTimeToChartX( dt ); 00329 }
Span DateTimeGrid::mapToChart | ( | const QModelIndex & | idx | ) | const [virtual] |
idx | The index to get the Span for. |
Implements KDGantt::AbstractGrid.
Definition at line 479 of file kdganttdatetimegrid.cpp.
References d, KDGantt::EndTimeRole, KDGantt::AbstractGrid::model(), and KDGantt::StartTimeRole.
Referenced by KDAB_SCOPED_UNITTEST_SIMPLE().
00480 { 00481 assert( model() ); 00482 if ( !idx.isValid() ) return Span(); 00483 assert( idx.model()==model() ); 00484 const QVariant sv = model()->data( idx, StartTimeRole ); 00485 const QVariant ev = model()->data( idx, EndTimeRole ); 00486 if( qVariantCanConvert<QDateTime>(sv) && 00487 qVariantCanConvert<QDateTime>(ev) && 00488 !(sv.type() == QVariant::String && qVariantValue<QString>(sv).isEmpty()) && 00489 !(ev.type() == QVariant::String && qVariantValue<QString>(ev).isEmpty()) 00490 ) { 00491 QDateTime st = sv.toDateTime(); 00492 QDateTime et = ev.toDateTime(); 00493 if ( et.isValid() && st.isValid() ) { 00494 qreal sx = d->dateTimeToChartX( st ); 00495 qreal ex = d->dateTimeToChartX( et )-sx; 00496 //qDebug() << "DateTimeGrid::mapToChart("<<st<<et<<") => "<< Span( sx, ex ); 00497 return Span( sx, ex); 00498 } 00499 } 00500 // Special case for Events with only a start date 00501 if( qVariantCanConvert<QDateTime>(sv) && !(sv.type() == QVariant::String && qVariantValue<QString>(sv).isEmpty()) ) { 00502 QDateTime st = sv.toDateTime(); 00503 if ( st.isValid() ) { 00504 qreal sx = d->dateTimeToChartX( st ); 00505 return Span( sx, 0 ); 00506 } 00507 } 00508 return Span(); 00509 }
QDateTime DateTimeGrid::mapToDateTime | ( | qreal | x | ) | const |
Maps a given X value x in scene coordinates to a point in time.
Definition at line 333 of file kdganttdatetimegrid.cpp.
References d.
Referenced by KDAB_SCOPED_UNITTEST_SIMPLE().
00334 { 00335 return d->chartXtoDateTime( x ); 00336 }
QAbstractItemModel * AbstractGrid::model | ( | ) | const [inherited] |
Definition at line 64 of file kdganttabstractgrid.cpp.
References d.
Referenced by KDAB_SCOPED_UNITTEST_SIMPLE(), mapFromChart(), and mapToChart().
00065 { 00066 return d->model; 00067 }
QBrush DateTimeGrid::noInformationBrush | ( | ) | const |
Definition at line 471 of file kdganttdatetimegrid.cpp.
References d.
00472 { 00473 return d->noInformationBrush; 00474 }
void DateTimeGrid::paintDayScaleHeader | ( | QPainter * | painter, | |
const QRectF & | headerRect, | |||
const QRectF & | exposedRect, | |||
qreal | offset, | |||
QWidget * | widget = 0 | |||
) | [protected, virtual] |
Paints the day scale header.
Definition at line 973 of file kdganttdatetimegrid.cpp.
References d, dayWidth(), and StockDiagram::Private::Private().
Referenced by paintHeader().
00975 { 00976 class DayFormatter : public Private::DateTextFormatter { 00977 public: 00978 QString format( const QDateTime& dt ) { 00979 return dt.toString( QString::fromAscii( "ddd" ) ).left( 1 ); 00980 } 00981 QRect textRect( qreal x, qreal offset, qreal dayWidth, const QRectF& headerRect, const QDateTime& dt ) { 00982 return QRectF( QPointF( x, headerRect.top() ) + QPointF( -offset + 1.0, headerRect.height() / 2.0 ), 00983 QSizeF( dayWidth, headerRect.height() / 2.0 ) ).toAlignedRect(); 00984 } 00985 }; 00986 d->paintHeader( painter, headerRect, exposedRect, offset, widget, // General parameters 00987 Private::HeaderDay, new DayFormatter ); // Custom parameters 00988 00989 class WeekFormatter : public Private::DateTextFormatter { 00990 public: 00991 QString format( const QDateTime& dt ) { 00992 return QString::number( dt.date().weekNumber() ); 00993 } 00994 QRect textRect( qreal x, qreal offset, qreal dayWidth, const QRectF& headerRect, const QDateTime& dt ) { 00995 return QRectF( QPointF( x, headerRect.top() ) + QPointF( -offset, 0.0 ), 00996 QSizeF( dayWidth * 7, headerRect.height() / 2.0 ) ).toRect(); 00997 } 00998 }; 00999 d->paintHeader( painter, headerRect, exposedRect, offset, widget, // General parameters 01000 Private::HeaderWeek, new WeekFormatter ); // Custom parameters 01001 }
void DateTimeGrid::paintGrid | ( | QPainter * | painter, | |
const QRectF & | sceneRect, | |||
const QRectF & | exposedRect, | |||
AbstractRowController * | rowController = 0 , |
|||
QWidget * | widget = 0 | |||
) | [virtual] |
Implement this to paint the background of the view -- typically with some grid lines.
painter | -- the QPainter to paint with. | |
sceneRect | -- the total bounding rectangle of the scene. | |
exposedRect | -- the rectangle that needs to be painted. | |
rowController | -- the row controller used by the view -- may be 0. | |
widget | -- the widget used by the view -- may be 0. |
Implements KDGantt::AbstractGrid.
Definition at line 703 of file kdganttdatetimegrid.cpp.
References d, dayWidth(), KDGantt::AbstractRowController::indexAbove(), KDGantt::AbstractRowController::indexAt(), KDGantt::AbstractRowController::indexBelow(), KDGantt::ItemTypeRole, KDGantt::Span::length(), KDGantt::AbstractRowController::rowGeometry(), scale(), ScaleAuto, ScaleDay, ScaleHour, ScaleMonth, ScaleUserDefined, ScaleWeek, and KDGantt::Span::start().
00708 { 00709 // TODO: Support hours and weeks 00710 switch( scale() ) { 00711 case ScaleHour: 00712 case ScaleDay: 00713 case ScaleWeek: 00714 case ScaleMonth: 00715 d->paintVerticalLines( painter, sceneRect, exposedRect, widget, d->headerTypeForScale( scale() ) ); 00716 break; 00717 case ScaleAuto: { 00718 const qreal tabw = QApplication::fontMetrics().width( QLatin1String( "XXXXX" ) ); 00719 const qreal dayw = dayWidth(); 00720 if ( dayw > 24*60*60*tabw ) { 00721 d->paintVerticalUserDefinedLines( painter, sceneRect, exposedRect, &d->minute_lower, widget ); 00722 } else if ( dayw > 24*60*tabw ) { 00723 d->paintVerticalLines( painter, sceneRect, exposedRect, widget, Private::HeaderHour ); 00724 } else if ( dayw > 24*tabw ) { 00725 d->paintVerticalLines( painter, sceneRect, exposedRect, widget, Private::HeaderDay ); 00726 } else if ( dayw > tabw ) { 00727 d->paintVerticalUserDefinedLines( painter, sceneRect, exposedRect, &d->week_lower, widget ); 00728 } else if ( 4*dayw > tabw ) { 00729 d->paintVerticalUserDefinedLines( painter, sceneRect, exposedRect, &d->month_lower, widget ); 00730 } else { 00731 d->paintVerticalUserDefinedLines( painter, sceneRect, exposedRect, &d->year_lower, widget ); 00732 } 00733 break; 00734 } 00735 case ScaleUserDefined: 00736 d->paintVerticalUserDefinedLines( painter, sceneRect, exposedRect, d->lower, widget ); 00737 break; 00738 } 00739 if ( rowController ) { 00740 // First draw the rows 00741 QPen pen = painter->pen(); 00742 pen.setBrush( QApplication::palette().dark() ); 00743 pen.setStyle( Qt::DashLine ); 00744 painter->setPen( pen ); 00745 QModelIndex idx = rowController->indexAt( qRound( exposedRect.top() ) ); 00746 if ( rowController->indexAbove( idx ).isValid() ) idx = rowController->indexAbove( idx ); 00747 qreal y = 0; 00748 while ( y < exposedRect.bottom() && idx.isValid() ) { 00749 const Span s = rowController->rowGeometry( idx ); 00750 y = s.start()+s.length(); 00751 if ( d->rowSeparators ) { 00752 painter->drawLine( QPointF( sceneRect.left(), y ), 00753 QPointF( sceneRect.right(), y ) ); 00754 } 00755 if ( !idx.data( ItemTypeRole ).isValid() && d->noInformationBrush.style() != Qt::NoBrush ) { 00756 painter->fillRect( QRectF( exposedRect.left(), s.start(), exposedRect.width(), s.length() ), d->noInformationBrush ); 00757 } 00758 // Is alternating background better? 00759 //if ( idx.row()%2 ) painter->fillRect( QRectF( exposedRect.x(), s.start(), exposedRect.width(), s.length() ), QApplication::palette().alternateBase() ); 00760 idx = rowController->indexBelow( idx ); 00761 } 00762 } 00763 }
void DateTimeGrid::paintHeader | ( | QPainter * | painter, | |
const QRectF & | headerRect, | |||
const QRectF & | exposedRect, | |||
qreal | offset, | |||
QWidget * | widget = 0 | |||
) | [virtual] |
Implement this to paint the header part of the view.
painter | -- the QPainter to paint with. | |
headerRect | -- the total rectangle occupied by the header. | |
exposedRect | -- the rectangle that needs to be painted. | |
offset | -- the horizontal scroll offset of the view. | |
widget | -- the widget used by the view -- may be 0. |
Implements KDGantt::AbstractGrid.
Definition at line 803 of file kdganttdatetimegrid.cpp.
References d, paintDayScaleHeader(), paintHourScaleHeader(), paintMonthScaleHeader(), paintUserDefinedHeader(), paintWeekScaleHeader(), scale(), ScaleAuto, ScaleDay, ScaleHour, ScaleMonth, ScaleUserDefined, ScaleWeek, startDateTime(), and KDGantt::DateTimeScaleFormatter::text().
00805 { 00806 painter->save(); 00807 QPainterPath clipPath; 00808 clipPath.addRect( headerRect ); 00809 painter->setClipPath( clipPath, Qt::IntersectClip ); 00810 switch( scale() ) 00811 { 00812 case ScaleHour: 00813 paintHourScaleHeader( painter, headerRect, exposedRect, offset, widget ); 00814 break; 00815 case ScaleDay: 00816 paintDayScaleHeader( painter, headerRect, exposedRect, offset, widget ); 00817 break; 00818 case ScaleWeek: 00819 paintWeekScaleHeader( painter, headerRect, exposedRect, offset, widget ); 00820 break; 00821 case ScaleMonth: 00822 paintMonthScaleHeader( painter, headerRect, exposedRect, offset, widget ); 00823 break; 00824 case ScaleAuto: 00825 { 00826 DateTimeScaleFormatter *lower, *upper; 00827 d->getAutomaticFormatters( &lower, &upper ); 00828 const qreal lowerHeight = d->tabHeight( lower->text( startDateTime() ) ); 00829 const qreal upperHeight = d->tabHeight( upper->text( startDateTime() ) ); 00830 const qreal upperRatio = upperHeight/( lowerHeight+upperHeight ); 00831 00832 const QRectF upperHeaderRect( headerRect.x(), headerRect.top(), headerRect.width()-1, headerRect.height() * upperRatio ); 00833 const QRectF lowerHeaderRect( headerRect.x(), upperHeaderRect.bottom()+1, headerRect.width()-1, headerRect.height()-upperHeaderRect.height()-1 ); 00834 00835 paintUserDefinedHeader( painter, lowerHeaderRect, exposedRect, offset, lower, widget ); 00836 paintUserDefinedHeader( painter, upperHeaderRect, exposedRect, offset, upper, widget ); 00837 break; 00838 } 00839 case ScaleUserDefined: 00840 { 00841 const qreal lowerHeight = d->tabHeight( d->lower->text( startDateTime() ) ); 00842 const qreal upperHeight = d->tabHeight( d->upper->text( startDateTime() ) ); 00843 const qreal upperRatio = upperHeight/( lowerHeight+upperHeight ); 00844 00845 const QRectF upperHeaderRect( headerRect.x(), headerRect.top(), headerRect.width()-1, headerRect.height() * upperRatio ); 00846 const QRectF lowerHeaderRect( headerRect.x(), upperHeaderRect.bottom()+1, headerRect.width()-1, headerRect.height()-upperHeaderRect.height()-1 ); 00847 00848 paintUserDefinedHeader( painter, lowerHeaderRect, exposedRect, offset, d->lower, widget ); 00849 paintUserDefinedHeader( painter, upperHeaderRect, exposedRect, offset, d->upper, widget ); 00850 } 00851 break; 00852 } 00853 painter->restore(); 00854 }
void DateTimeGrid::paintHourScaleHeader | ( | QPainter * | painter, | |
const QRectF & | headerRect, | |||
const QRectF & | exposedRect, | |||
qreal | offset, | |||
QWidget * | widget = 0 | |||
) | [protected, virtual] |
Paints the hour scale header.
Definition at line 939 of file kdganttdatetimegrid.cpp.
References d, dayWidth(), and StockDiagram::Private::Private().
Referenced by paintHeader().
00942 { 00943 class HourFormatter : public Private::DateTextFormatter { 00944 public: 00945 QString format( const QDateTime& dt ) { 00946 return dt.time().toString( QString::fromAscii( "hh" ) ); 00947 } 00948 QRect textRect( qreal x, qreal offset, qreal dayWidth, const QRectF& headerRect, const QDateTime& dt ) { 00949 return QRectF( QPointF( x, headerRect.top() ) + QPointF( -offset + 1.0, headerRect.height() / 2.0 ), 00950 QSizeF( dayWidth / 24.0, headerRect.height() / 2.0 ) ).toAlignedRect(); 00951 } 00952 }; 00953 d->paintHeader( painter, headerRect, exposedRect, offset, widget, // General parameters 00954 Private::HeaderHour, new HourFormatter ); // Custom parameters 00955 00956 class DayFormatter : public Private::DateTextFormatter { 00957 public: 00958 QString format( const QDateTime& dt ) { 00959 return dt.date().toString(); 00960 } 00961 QRect textRect( qreal x, qreal offset, qreal dayWidth, const QRectF& headerRect, const QDateTime& dt ) { 00962 return QRectF( QPointF( x, headerRect.top() ) + QPointF( -offset, 0.0 ), 00963 QSizeF( dayWidth, headerRect.height() / 2.0 ) ).toRect(); 00964 } 00965 }; 00966 d->paintHeader( painter, headerRect, exposedRect, offset, widget, // General parameters 00967 Private::HeaderDay, new DayFormatter ); // Custom parameters 00968 }
void DateTimeGrid::paintMonthScaleHeader | ( | QPainter * | painter, | |
const QRectF & | headerRect, | |||
const QRectF & | exposedRect, | |||
qreal | offset, | |||
QWidget * | widget = 0 | |||
) | [protected, virtual] |
Paints the week scale header.
Definition at line 1039 of file kdganttdatetimegrid.cpp.
References d, dayWidth(), and StockDiagram::Private::Private().
Referenced by paintHeader().
01041 { 01042 class MonthFormatter : public Private::DateTextFormatter { 01043 public: 01044 QString format( const QDateTime& dt ) { 01045 return QDate::shortMonthName( dt.date().month() ); 01046 } 01047 QRect textRect( qreal x, qreal offset, qreal dayWidth, const QRectF& headerRect, const QDateTime& dt ) { 01048 return QRectF( QPointF( x, headerRect.top() ) + QPointF( -offset, headerRect.height() / 2.0 ), 01049 QSizeF( dayWidth * dt.date().daysInMonth(), headerRect.height() / 2.0 ) ).toRect(); 01050 } 01051 }; 01052 d->paintHeader( painter, headerRect, exposedRect, offset, widget, // General parameters 01053 Private::HeaderMonth, new MonthFormatter ); // Custom parameters 01054 01055 class YearFormatter : public Private::DateTextFormatter { 01056 public: 01057 QString format( const QDateTime& dt ) { 01058 return QString::number( dt.date().year() ); 01059 } 01060 QRect textRect( qreal x, qreal offset, qreal dayWidth, const QRectF& headerRect, const QDateTime& dt ) { 01061 return QRectF( QPointF( x, headerRect.top() ) + QPointF( -offset, 0.0 ), 01062 QSizeF( dayWidth * dt.date().daysInYear(), headerRect.height() / 2.0 ) ).toRect(); 01063 } 01064 }; 01065 d->paintHeader( painter, headerRect, exposedRect, offset, widget, // General parameters 01066 Private::HeaderYear, new YearFormatter ); // Custom parameters 01067 }
void DateTimeGrid::paintUserDefinedHeader | ( | QPainter * | painter, | |
const QRectF & | headerRect, | |||
const QRectF & | exposedRect, | |||
qreal | offset, | |||
const DateTimeScaleFormatter * | formatter, | |||
QWidget * | widget = 0 | |||
) | [protected, virtual] |
Definition at line 856 of file kdganttdatetimegrid.cpp.
References KDGantt::DateTimeScaleFormatter::alignment(), KDGantt::DateTimeScaleFormatter::currentRangeBegin(), d, KDGantt::DateTimeScaleFormatter::nextRangeBegin(), and KDGantt::DateTimeScaleFormatter::text().
Referenced by paintHeader().
00860 { 00861 const QStyle* const style = widget ? widget->style() : QApplication::style(); 00862 00863 QDateTime dt = formatter->currentRangeBegin( d->chartXtoDateTime( offset + exposedRect.left() ) ).toUTC(); 00864 qreal x = d->dateTimeToChartX( dt ); 00865 00866 while( x < exposedRect.right() + offset ) 00867 { 00868 const QDateTime next = formatter->nextRangeBegin( dt ); 00869 const qreal nextx = d->dateTimeToChartX( next ); 00870 00871 QStyleOptionHeader opt; 00872 if ( widget ) opt.init( widget ); 00873 opt.rect = QRectF( x - offset+1, headerRect.top(), qMax( 1., nextx-x-1 ), headerRect.height() ).toAlignedRect(); 00874 opt.textAlignment = formatter->alignment(); 00875 opt.text = formatter->text( dt ); 00876 style->drawControl( QStyle::CE_Header, &opt, painter, widget ); 00877 00878 dt = next; 00879 x = nextx; 00880 } 00881 }
void DateTimeGrid::paintWeekScaleHeader | ( | QPainter * | painter, | |
const QRectF & | headerRect, | |||
const QRectF & | exposedRect, | |||
qreal | offset, | |||
QWidget * | widget = 0 | |||
) | [protected, virtual] |
Paints the week scale header.
Definition at line 1006 of file kdganttdatetimegrid.cpp.
References d, dayWidth(), and StockDiagram::Private::Private().
Referenced by paintHeader().
01008 { 01009 class WeekFormatter : public Private::DateTextFormatter { 01010 public: 01011 QString format( const QDateTime& dt ) { 01012 return QString::number( dt.date().weekNumber() ); 01013 } 01014 QRect textRect( qreal x, qreal offset, qreal dayWidth, const QRectF& headerRect, const QDateTime& dt ) { 01015 return QRectF( QPointF( x, headerRect.top() ) + QPointF( -offset, headerRect.height() / 2.0 ), 01016 QSizeF( dayWidth * 7, headerRect.height() / 2.0 ) ).toRect(); 01017 } 01018 }; 01019 d->paintHeader( painter, headerRect, exposedRect, offset, widget, // General parameters 01020 Private::HeaderWeek, new WeekFormatter ); // Custom parameters 01021 01022 class MonthFormatter : public Private::DateTextFormatter { 01023 public: 01024 QString format( const QDateTime& dt ) { 01025 return QDate::longMonthName( dt.date().month() ); 01026 } 01027 QRect textRect( qreal x, qreal offset, qreal dayWidth, const QRectF& headerRect, const QDateTime& dt ) { 01028 return QRectF( QPointF( x, headerRect.top() ) + QPointF( -offset, 0.0 ), 01029 QSizeF( dayWidth * dt.date().daysInMonth(), headerRect.height() / 2.0 ) ).toRect(); 01030 } 01031 }; 01032 d->paintHeader( painter, headerRect, exposedRect, offset, widget, // General parameters 01033 Private::HeaderMonth, new MonthFormatter ); // Custom parameters 01034 }
QModelIndex AbstractGrid::rootIndex | ( | ) | const [inherited] |
Definition at line 78 of file kdganttabstractgrid.cpp.
References d.
00079 { 00080 return d->root; 00081 }
bool DateTimeGrid::rowSeparators | ( | ) | const |
Definition at line 449 of file kdganttdatetimegrid.cpp.
References d.
00450 { 00451 return d->rowSeparators; 00452 }
DateTimeGrid::Scale DateTimeGrid::scale | ( | ) | const |
Definition at line 366 of file kdganttdatetimegrid.cpp.
References d.
Referenced by paintGrid(), and paintHeader().
00367 { 00368 return d->scale; 00369 }
void DateTimeGrid::setDayWidth | ( | qreal | w | ) |
w | The width in pixels for each day in the grid. |
Definition at line 342 of file kdganttdatetimegrid.cpp.
References d, and KDGantt::AbstractGrid::gridChanged().
00343 { 00344 assert( w>0 ); 00345 d->dayWidth = w; 00346 emit gridChanged(); 00347 }
void DateTimeGrid::setFreeDays | ( | const QSet< Qt::DayOfWeek > & | fd | ) |
fd | A set of days to mark as free in the grid. |
Definition at line 436 of file kdganttdatetimegrid.cpp.
References d, and KDGantt::AbstractGrid::gridChanged().
00437 { 00438 d->freeDays = fd; 00439 emit gridChanged(); 00440 }
void AbstractGrid::setModel | ( | QAbstractItemModel * | model | ) | [virtual, slot, inherited] |
Sets the QAbstractItemModel used by this grid implementation. This is called by the view, you should never need to call this from client code.
Definition at line 58 of file kdganttabstractgrid.cpp.
References d.
Referenced by KDAB_SCOPED_UNITTEST_SIMPLE().
void DateTimeGrid::setNoInformationBrush | ( | const QBrush & | brush | ) |
Sets the brush used to display rows where no data is found. Default is a red pattern. If set to QBrush() rows with no information will not be marked.
Definition at line 463 of file kdganttdatetimegrid.cpp.
References d, and KDGantt::AbstractGrid::gridChanged().
00464 { 00465 d->noInformationBrush = brush; 00466 emit gridChanged(); 00467 }
void AbstractGrid::setRootIndex | ( | const QModelIndex & | idx | ) | [virtual, slot, inherited] |
Sets the root index used by this grid implementation. This is called by the view, you should never need to call this from client code.
Definition at line 72 of file kdganttabstractgrid.cpp.
References d.
00073 { 00074 d->root = idx; 00075 }
void DateTimeGrid::setRowSeparators | ( | bool | enable | ) |
enable | Whether to use row separators or not. |
Definition at line 454 of file kdganttdatetimegrid.cpp.
References d.
00455 { 00456 d->rowSeparators = enable; 00457 }
void DateTimeGrid::setScale | ( | Scale | s | ) |
s | The scale to be used to paint the grid. |
Definition at line 354 of file kdganttdatetimegrid.cpp.
References d, and KDGantt::AbstractGrid::gridChanged().
00355 { 00356 d->scale = s; 00357 emit gridChanged(); 00358 }
void DateTimeGrid::setStartDateTime | ( | const QDateTime & | dt | ) |
dt | The start date of the grid. It is used as the beginning of the horizontal scrollbar in the view. |
Definition at line 309 of file kdganttdatetimegrid.cpp.
References d, and KDGantt::AbstractGrid::gridChanged().
Referenced by KDAB_SCOPED_UNITTEST_SIMPLE().
00310 { 00311 d->startDateTime = dt; 00312 emit gridChanged(); 00313 }
void DateTimeGrid::setUserDefinedLowerScale | ( | DateTimeScaleFormatter * | lower | ) |
Sets the scale formatter for the lower part of the header to the user defined formatter to lower. The DateTimeGrid object takes ownership of the formatter, which has to be allocated with new.
You have to set the scale to ScaleUserDefined for this setting to take effect.
Definition at line 378 of file kdganttdatetimegrid.cpp.
References d, and KDGantt::AbstractGrid::gridChanged().
00379 { 00380 delete d->lower; 00381 d->lower = lower; 00382 emit gridChanged(); 00383 }
void DateTimeGrid::setUserDefinedUpperScale | ( | DateTimeScaleFormatter * | upper | ) |
Sets the scale formatter for the upper part of the header to the user defined formatter to upper. The DateTimeGrid object takes ownership of the formatter, which has to be allocated with new.
You have to set the scale to ScaleUserDefined for this setting to take effect.
Definition at line 392 of file kdganttdatetimegrid.cpp.
References d, and KDGantt::AbstractGrid::gridChanged().
00393 { 00394 delete d->upper; 00395 d->upper = upper; 00396 emit gridChanged(); 00397 }
void DateTimeGrid::setWeekStart | ( | Qt::DayOfWeek | ws | ) |
ws | The start day of the week. |
Definition at line 418 of file kdganttdatetimegrid.cpp.
References d, and KDGantt::AbstractGrid::gridChanged().
00419 { 00420 d->weekStart = ws; 00421 emit gridChanged(); 00422 }
QDateTime DateTimeGrid::startDateTime | ( | ) | const |
Definition at line 299 of file kdganttdatetimegrid.cpp.
References d.
Referenced by KDAB_SCOPED_UNITTEST_SIMPLE(), and paintHeader().
00300 { 00301 return d->startDateTime; 00302 }
DateTimeScaleFormatter * DateTimeGrid::userDefinedLowerScale | ( | ) | const |
Definition at line 401 of file kdganttdatetimegrid.cpp.
References d.
00402 { 00403 return d->lower; 00404 }
DateTimeScaleFormatter * DateTimeGrid::userDefinedUpperScale | ( | ) | const |
Definition at line 408 of file kdganttdatetimegrid.cpp.
References d.
00409 { 00410 return d->upper; 00411 }
Qt::DayOfWeek DateTimeGrid::weekStart | ( | ) | const |
Definition at line 425 of file kdganttdatetimegrid.cpp.
References d.
00426 { 00427 return d->weekStart; 00428 }