kdganttdatetimegrid.h

Go to the documentation of this file.
00001 /****************************************************************************
00002  ** Copyright (C) 2001-2006 Klarälvdalens Datakonsult AB.  All rights reserved.
00003  **
00004  ** This file is part of the KD Gantt library.
00005  **
00006  ** This file may be distributed and/or modified under the terms of the
00007  ** GNU General Public License version 2 as published by the Free Software
00008  ** Foundation and appearing in the file LICENSE.GPL included in the
00009  ** packaging of this file.
00010  **
00011  ** Licensees holding valid commercial KD Gantt licenses may use this file in
00012  ** accordance with the KD Gantt Commercial License Agreement provided with
00013  ** the Software.
00014  **
00015  ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00016  ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00017  **
00018  ** See http://www.kdab.net/kdgantt for
00019  **   information about KD Gantt Commercial License Agreements.
00020  **
00021  ** Contact info@kdab.net if any conditions of this
00022  ** licensing are not clear to you.
00023  **
00024  **********************************************************************/
00025 #ifndef KDGANTTDATETIMEGRID_H
00026 #define KDGANTTDATETIMEGRID_H
00027 
00028 #include "kdganttabstractgrid.h"
00029 
00030 #include <QDateTime>
00031 #include <QSet>
00032 
00033 namespace KDGantt {
00034     class KDCHART_EXPORT DateTimeScaleFormatter
00035     {
00036         KDGANTT_DECLARE_PRIVATE_BASE_POLYMORPHIC( DateTimeScaleFormatter )
00037     public:
00038         enum Range
00039         {
00040             Second,
00041             Minute,
00042             Hour,
00043             Day,
00044             Week,
00045             Month,
00046             Year
00047         };
00048         DateTimeScaleFormatter( Range range, const QString& formatString, 
00049                                 Qt::Alignment alignment = Qt::AlignCenter );
00050         DateTimeScaleFormatter( Range range, const QString& formatString, 
00051                                 const QString& templ, Qt::Alignment alignment = Qt::AlignCenter );
00052         DateTimeScaleFormatter( const DateTimeScaleFormatter& other );
00053         virtual ~DateTimeScaleFormatter();
00054 
00055         DateTimeScaleFormatter& operator=( const DateTimeScaleFormatter& other );
00056 
00057         QString format() const;
00058         Range range() const;
00059         Qt::Alignment alignment() const;
00060 
00061         virtual QDateTime nextRangeBegin( const QDateTime& datetime ) const;
00062         virtual QDateTime currentRangeBegin( const QDateTime& datetime ) const;
00063 
00064         QString format( const QDateTime& datetime ) const;
00065         virtual QString text( const QDateTime& datetime ) const;
00066     };
00067 
00068 
00069     class KDCHART_EXPORT DateTimeGrid : public AbstractGrid {
00070         Q_OBJECT
00071         KDGANTT_DECLARE_PRIVATE_DERIVED( DateTimeGrid )
00072     public:
00073         enum Scale { ScaleAuto, 
00074                      ScaleHour,
00075                      ScaleDay,
00076                      ScaleWeek,
00077                      ScaleMonth,
00078                      ScaleUserDefined
00079         };
00080         
00081         DateTimeGrid();
00082         virtual ~DateTimeGrid();
00083 
00084         QDateTime startDateTime() const;
00085         void setStartDateTime( const QDateTime& dt );
00086 
00087         qreal dayWidth() const;
00088         void setDayWidth( qreal );
00089 
00090         qreal mapFromDateTime( const QDateTime& dt) const;
00091         QDateTime mapToDateTime( qreal x ) const;
00092 
00093         void setWeekStart( Qt::DayOfWeek );
00094         Qt::DayOfWeek weekStart() const;
00095 
00096         void setFreeDays( const QSet<Qt::DayOfWeek>& fd );
00097         QSet<Qt::DayOfWeek> freeDays() const;
00098 
00099         void setScale( Scale s );
00100         Scale scale() const;
00101 
00102         void setUserDefinedLowerScale( DateTimeScaleFormatter* lower );
00103         void setUserDefinedUpperScale( DateTimeScaleFormatter* upper );
00104         DateTimeScaleFormatter* userDefinedLowerScale() const;
00105         DateTimeScaleFormatter* userDefinedUpperScale() const;
00106 
00107         bool rowSeparators() const;
00108         void setRowSeparators( bool enable );
00109 
00110         void setNoInformationBrush( const QBrush& brush );
00111         QBrush noInformationBrush() const;
00112 
00113         /*reimp*/ Span mapToChart( const QModelIndex& idx ) const;
00114         /*reimp*/ bool mapFromChart( const Span& span, const QModelIndex& idx,
00115                                      const QList<Constraint>& constraints=QList<Constraint>() ) const;
00116         /*reimp*/ void paintGrid( QPainter* painter, 
00117                                   const QRectF& sceneRect, const QRectF& exposedRect,
00118                                   AbstractRowController* rowController = 0,
00119                                   QWidget* widget=0 );
00120         /*reimp*/ void paintHeader( QPainter* painter, 
00121                                     const QRectF& headerRect, const QRectF& exposedRect,
00122                                     qreal offset, QWidget* widget=0 );
00123 
00124     protected:
00125         virtual void paintHourScaleHeader( QPainter* painter, 
00126                                            const QRectF& headerRect, const QRectF& exposedRect,
00127                                            qreal offset, QWidget* widget=0 );
00128         virtual void paintDayScaleHeader( QPainter* painter, 
00129                                           const QRectF& headerRect, const QRectF& exposedRect,
00130                                           qreal offset, QWidget* widget=0 );
00131         virtual void paintWeekScaleHeader( QPainter* painter,
00132                                            const QRectF& headerRect, const QRectF& exposedRect,
00133                                            qreal offset, QWidget* widget=0 );
00134         virtual void paintMonthScaleHeader( QPainter* painter,
00135                                             const QRectF& headerRect, const QRectF& exposedRect,
00136                                             qreal offset, QWidget* widget=0 );
00137 
00138         virtual void paintUserDefinedHeader( QPainter* painter, 
00139                                      const QRectF& headerRect, const QRectF& exposedRect, 
00140                                      qreal offset, const DateTimeScaleFormatter* formatter, 
00141                                      QWidget* widget = 0 );
00142     };
00143 }
00144 
00145 #ifndef QT_NO_DEBUG_STREAM
00146 QDebug KDCHART_EXPORT operator<<( QDebug dbg, KDGantt::DateTimeScaleFormatter::Range );
00147 #endif
00148 
00149 #endif /* KDGANTTDATETIMEGRID_H */
00150 

Generated on Thu Mar 4 23:19:13 2010 for KD Chart 2 by  doxygen 1.5.4