Fix infinite refreshing, due to initial setCheckState triggering slotItemChanged
[kdepim.git] / kdgantt2 / kdganttdatetimegrid_p.h
blobba205071860d4613376a080459a69a633d0bc52b
1 /****************************************************************************
2 ** Copyright (C) 2001-2006 Klarälvdalens Datakonsult AB. All rights reserved.
3 **
4 ** This file is part of the KD Gantt library.
5 **
6 ** This file may be distributed and/or modified under the terms of the
7 ** GNU General Public License version 2 as published by the Free Software
8 ** Foundation and appearing in the file LICENSE.GPL included in the
9 ** packaging of this file.
11 ** Licensees holding valid commercial KD Gantt licenses may use this file in
12 ** accordance with the KD Gantt Commercial License Agreement provided with
13 ** the Software.
15 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
18 ** See http://www.kdab.net/kdgantt for
19 ** information about KD Gantt Commercial License Agreements.
21 ** Contact info@kdab.net if any conditions of this
22 ** licensing are not clear to you.
24 **********************************************************************/
25 #ifndef KDGANTTDATETIMEGRID_P_H
26 #define KDGANTTDATETIMEGRID_P_H
28 #include "kdganttdatetimegrid.h"
29 #include "kdganttabstractgrid_p.h"
31 #include <QDateTime>
32 #include <QBrush>
34 namespace KDGantt {
35 class DateTimeScaleFormatter::Private
37 public:
38 Private( DateTimeScaleFormatter::Range _range,
39 const QString& _format,
40 const QString& _templ,
41 Qt::Alignment _alignment )
42 : range( _range ),
43 format( _format ),
44 templ( _templ ),
45 alignment( _alignment )
49 const DateTimeScaleFormatter::Range range;
50 const QString format;
51 const QString templ;
52 const Qt::Alignment alignment;
55 class DateTimeGrid::Private : public AbstractGrid::Private {
56 public:
57 Private()
58 : startDateTime( QDateTime::currentDateTime().addDays( -3 ) ),
59 dayWidth( 100. ),
60 scale( ScaleAuto ),
61 weekStart( Qt::Monday ),
62 freeDays( QSet<Qt::DayOfWeek>() << Qt::Saturday << Qt::Sunday ),
63 rowSeparators( false ),
64 noInformationBrush( Qt::red, Qt::DiagCrossPattern ),
65 upper( new DateTimeScaleFormatter( DateTimeScaleFormatter::Week, QString::fromLatin1( "w" ) ) ),
66 lower( new DateTimeScaleFormatter( DateTimeScaleFormatter::Day, QString::fromLatin1( "ddd" ) ) ),
67 year_upper( DateTimeScaleFormatter::Year, QString::fromLatin1("yyyy" ) ),
68 year_lower( DateTimeScaleFormatter::Month, QString::fromLatin1("MMM" ) ),
69 month_upper( DateTimeScaleFormatter::Month, QString::fromLatin1("MMMM" ) ),
70 month_lower( DateTimeScaleFormatter::Week, QString::fromLatin1("w" ) ),
71 week_upper( DateTimeScaleFormatter::Week, QString::fromLatin1("w" ) ),
72 week_lower( DateTimeScaleFormatter::Day, QString::fromLatin1("ddd" ) ),
73 day_upper( DateTimeScaleFormatter::Day, QString::fromLatin1("dddd" ) ),
74 day_lower( DateTimeScaleFormatter::Hour, QString::fromLatin1("hh" ) ),
75 hour_upper( DateTimeScaleFormatter::Hour, QString::fromLatin1("hh" ) ),
76 hour_lower( DateTimeScaleFormatter::Minute, QString::fromLatin1("m" ) ),
77 minute_upper( DateTimeScaleFormatter::Minute, QString::fromLatin1("m" ) ),
78 minute_lower( DateTimeScaleFormatter::Second, QString::fromLatin1("s" ) )
81 ~Private()
83 delete lower;
84 delete upper;
87 qreal dateTimeToChartX( const QDateTime& dt ) const;
88 QDateTime chartXtoDateTime( qreal x ) const;
91 int tabHeight( const QString& txt, QWidget* widget = 0 ) const;
92 void getAutomaticFormatters( DateTimeScaleFormatter** lower, DateTimeScaleFormatter** upper);
94 void paintVerticalDayLines( QPainter* painter,
95 const QRectF& sceneRect,
96 const QRectF& exposedRect,
97 QWidget* widget );
98 void paintVerticalHourLines( QPainter* painter,
99 const QRectF& sceneRect,
100 const QRectF& exposedRect,
101 QWidget* widget );
102 void paintVerticalUserDefinedLines( QPainter* painter,
103 const QRectF& sceneRect,
104 const QRectF& exposedRect,
105 const DateTimeScaleFormatter* formatter,
106 QWidget* widget );
108 QDateTime startDateTime;
109 QDateTime endDateTime;
110 qreal dayWidth;
111 Scale scale;
112 Qt::DayOfWeek weekStart;
113 QSet<Qt::DayOfWeek> freeDays;
114 bool rowSeparators;
115 QBrush noInformationBrush;
117 DateTimeScaleFormatter* upper;
118 DateTimeScaleFormatter* lower;
120 DateTimeScaleFormatter year_upper;
121 DateTimeScaleFormatter year_lower;
122 DateTimeScaleFormatter month_upper;
123 DateTimeScaleFormatter month_lower;
124 DateTimeScaleFormatter week_upper;
125 DateTimeScaleFormatter week_lower;
126 DateTimeScaleFormatter day_upper;
127 DateTimeScaleFormatter day_lower;
128 DateTimeScaleFormatter hour_upper;
129 DateTimeScaleFormatter hour_lower;
130 DateTimeScaleFormatter minute_upper;
131 DateTimeScaleFormatter minute_lower;
134 inline DateTimeGrid::DateTimeGrid( DateTimeGrid::Private* d ) : AbstractGrid( d ) {}
136 inline DateTimeGrid::Private* DateTimeGrid::d_func() {
137 return static_cast<Private*>( AbstractGrid::d_func() );
139 inline const DateTimeGrid::Private* DateTimeGrid::d_func() const {
140 return static_cast<const Private*>( AbstractGrid::d_func() );
144 #endif /* KDGANTTDATETIMEGRID_P_H */