KD Chart API Documentation 3.1
|
This implementation of AbstractGrid works with QDateTime and shows days and week numbers in the header. More...
#include <kdganttdatetimegrid.h>
Public Types | |
enum | Scale { ScaleAuto , ScaleHour , ScaleDay , ScaleWeek , ScaleMonth , ScaleUserDefined } |
This implementation of AbstractGrid works with QDateTime and shows days and week numbers in the header.
Definition at line 23 of file kdganttdatetimegrid.h.
Enumerator | |
---|---|
ScaleAuto | |
ScaleHour | |
ScaleDay | |
ScaleWeek | |
ScaleMonth | |
ScaleUserDefined |
Definition at line 28 of file kdganttdatetimegrid.h.
DateTimeGrid::DateTimeGrid | ( | ) |
Definition at line 288 of file kdganttdatetimegrid.cpp.
|
override |
Definition at line 293 of file kdganttdatetimegrid.cpp.
|
protected |
Return the rectangle that represents the date-range.
Definition at line 1237 of file kdganttdatetimegrid.cpp.
References d, QRectF::height(), QObject::qobject_cast(), and QRectF::top().
Return a date-range represented by the rectangle.
Definition at line 1247 of file kdganttdatetimegrid.cpp.
References d, QRectF::left(), and QRectF::right().
qreal DateTimeGrid::dayWidth | ( | ) | const |
The default is 100 pixels.
Definition at line 321 of file kdganttdatetimegrid.cpp.
References d.
Referenced by drawBackground(), drawForeground(), and paintGrid().
|
overrideprotectedvirtual |
Reimplemented from KDGantt::AbstractGrid.
Definition at line 1258 of file kdganttdatetimegrid.cpp.
References d, dayWidth(), drawDayBackground(), QRectF::height(), QRectF::left(), QObject::qobject_cast(), QPainter::restore(), QRectF::right(), QPainter::save(), and QRectF::top().
|
protectedvirtual |
Draw the background for a day.
Definition at line 1219 of file kdganttdatetimegrid.cpp.
References QObject::qobject_cast().
Referenced by drawBackground().
|
protectedvirtual |
Draw the foreground for a day.
Definition at line 1228 of file kdganttdatetimegrid.cpp.
References QObject::qobject_cast().
Referenced by drawForeground().
|
overrideprotectedvirtual |
Reimplemented from KDGantt::AbstractGrid.
Definition at line 1298 of file kdganttdatetimegrid.cpp.
References d, dayWidth(), drawDayForeground(), QRectF::height(), QRectF::left(), QObject::qobject_cast(), QPainter::restore(), QRectF::right(), QPainter::save(), and QRectF::top().
QSet< Qt::DayOfWeek > DateTimeGrid::freeDays | ( | ) | const |
Definition at line 454 of file kdganttdatetimegrid.cpp.
References d.
QBrush DateTimeGrid::freeDaysBrush | ( | ) | const |
Definition at line 469 of file kdganttdatetimegrid.cpp.
References d.
|
overridevirtual |
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 582 of file kdganttdatetimegrid.cpp.
References d, QAbstractItemModel::data(), KDGantt::EndTimeRole, QVariant::fromValue(), KDGantt::AbstractGrid::isSatisfiedConstraint(), KDGantt::Span::length(), KDGantt::AbstractGrid::model(), QObject::qobject_cast(), QAbstractItemModel::setData(), KDGantt::Span::start(), KDGantt::StartTimeRole, QVariant::toDateTime(), and KDGantt::Constraint::TypeHard.
Referenced by KDAB_SCOPED_UNITTEST_SIMPLE().
x | The x value get the datetime for. |
Reimplemented from KDGantt::AbstractGrid.
Definition at line 518 of file kdganttdatetimegrid.cpp.
References d.
Maps a given point in time dt to an X value in the scene.
Definition at line 328 of file kdganttdatetimegrid.cpp.
References d, and QObject::qobject_cast().
Referenced by KDAB_SCOPED_UNITTEST_SIMPLE().
|
overridevirtual |
idx | The index to get the Span for. |
Implements KDGantt::AbstractGrid.
Definition at line 526 of file kdganttdatetimegrid.cpp.
References d, QAbstractItemModel::data(), QVariant::DateTime, KDGantt::EndTimeRole, KDGantt::AbstractGrid::model(), QObject::qobject_cast(), KDGantt::StartTimeRole, and QVariant::String.
Referenced by KDAB_SCOPED_UNITTEST_SIMPLE().
value | The datetime to get the x value for. |
Reimplemented from KDGantt::AbstractGrid.
Definition at line 506 of file kdganttdatetimegrid.cpp.
References QVariant::canConvert(), d, QVariant::DateTime, QString::isEmpty(), QVariant::String, QVariant::toDateTime(), QVariant::toString(), and QVariant::type().
Maps a given X value x in scene coordinates to a point in time.
Definition at line 335 of file kdganttdatetimegrid.cpp.
References d.
Referenced by KDAB_SCOPED_UNITTEST_SIMPLE().
QBrush DateTimeGrid::noInformationBrush | ( | ) | const |
Definition at line 497 of file kdganttdatetimegrid.cpp.
References d.
|
protectedvirtual |
Paints the day scale header.
Definition at line 1062 of file kdganttdatetimegrid.cpp.
References d, QString::fromLatin1(), QString::number(), QObject::qobject_cast(), QRectF::toAlignedRect(), and QRectF::toRect().
Referenced by paintHeader().
|
overridevirtual |
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 772 of file kdganttdatetimegrid.cpp.
References d, Qt::DashLine, dayWidth(), QPainter::drawLine(), QPainter::fillRect(), QApplication::fontMetrics(), QFontMetrics::horizontalAdvance(), KDGantt::AbstractRowController::indexAbove(), KDGantt::AbstractRowController::indexAt(), KDGantt::AbstractRowController::indexBelow(), QModelIndex::isValid(), KDGantt::ItemTypeRole, QRectF::left(), Qt::NoBrush, QGuiApplication::palette(), QPainter::pen(), QObject::qobject_cast(), QRectF::right(), KDGantt::AbstractRowController::rowGeometry(), scale(), ScaleAuto, ScaleDay, ScaleHour, ScaleMonth, ScaleUserDefined, ScaleWeek, QPen::setBrush(), QPainter::setPen(), QPen::setStyle(), and KDGantt::Span::start().
|
overridevirtual |
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 876 of file kdganttdatetimegrid.cpp.
References QPainterPath::addRect(), d, Qt::IntersectClip, paintDayScaleHeader(), paintHourScaleHeader(), paintMonthScaleHeader(), paintUserDefinedHeader(), paintWeekScaleHeader(), QObject::qobject_cast(), QPainter::restore(), QPainter::save(), scale(), ScaleAuto, ScaleDay, ScaleHour, ScaleMonth, ScaleUserDefined, ScaleWeek, QPainter::setClipPath(), startDateTime(), and KDGantt::DateTimeScaleFormatter::text().
|
protectedvirtual |
Paints the hour scale header.
Definition at line 1009 of file kdganttdatetimegrid.cpp.
References d, QString::fromLatin1(), QObject::qobject_cast(), QRectF::toAlignedRect(), and QRectF::toRect().
Referenced by paintHeader().
|
protectedvirtual |
Paints the week scale header.
Definition at line 1171 of file kdganttdatetimegrid.cpp.
References d, QLocale::monthName(), QString::number(), QObject::qobject_cast(), QLocale::ShortFormat, and QRectF::toRect().
Referenced by paintHeader().
|
protectedvirtual |
Definition at line 925 of file kdganttdatetimegrid.cpp.
References QStyle::CE_Header, d, QStyle::drawControl(), QStyleOption::initFrom(), QObject::qobject_cast(), QApplication::style(), QWidget::style(), and QRectF::toAlignedRect().
Referenced by paintHeader().
|
protectedvirtual |
Paints the week scale header.
Definition at line 1120 of file kdganttdatetimegrid.cpp.
References d, QLocale::LongFormat, QLocale::monthName(), QString::number(), QObject::qobject_cast(), and QRectF::toRect().
Referenced by paintHeader().
bool DateTimeGrid::rowSeparators | ( | ) | const |
Definition at line 475 of file kdganttdatetimegrid.cpp.
References d.
DateTimeGrid::Scale DateTimeGrid::scale | ( | ) | const |
The default is ScaleAuto, which means the day scale will be used as long as the day width is less or equal to 500.
Definition at line 377 of file kdganttdatetimegrid.cpp.
References d.
Referenced by paintGrid(), and paintHeader().
w | The width in pixels for each day in the grid. |
The signal gridChanged() is emitted after the day width is changed.
Definition at line 344 of file kdganttdatetimegrid.cpp.
References d, KDGantt::AbstractGrid::gridChanged(), QObject::Q_EMIT(), and QObject::qobject_cast().
void DateTimeGrid::setFreeDays | ( | const QSet< Qt::DayOfWeek > & | fd | ) |
fd | A set of days to mark as free in the grid. |
Free days are filled with the alternate base brush of the palette used by the view. The signal gridChanged() is emitted after the free days are changed.
Definition at line 447 of file kdganttdatetimegrid.cpp.
References d, KDGantt::AbstractGrid::gridChanged(), QObject::Q_EMIT(), and QObject::qobject_cast().
Sets the brush to use to paint free days.
Definition at line 461 of file kdganttdatetimegrid.cpp.
References d.
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 489 of file kdganttdatetimegrid.cpp.
References d, KDGantt::AbstractGrid::gridChanged(), and QObject::Q_EMIT().
enable | Whether to use row separators or not. |
Definition at line 480 of file kdganttdatetimegrid.cpp.
References d, and QObject::qobject_cast().
s | The scale to be used to paint the grid. |
The signal gridChanged() is emitted after the scale has changed.
Following example demonstrates how to change the format of the header to use a date-scaling with the header-label displayed with the ISO date-notation.
Definition at line 365 of file kdganttdatetimegrid.cpp.
References d, KDGantt::AbstractGrid::gridChanged(), QObject::Q_EMIT(), and QObject::qobject_cast().
dt | The start date of the grid. It is used as the beginning of the horizontal scrollbar in the view. |
Emits gridChanged() after the start date has changed.
Definition at line 311 of file kdganttdatetimegrid.cpp.
References d, KDGantt::AbstractGrid::gridChanged(), QObject::Q_EMIT(), and QObject::qobject_cast().
Referenced by KDAB_SCOPED_UNITTEST_SIMPLE().
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 389 of file kdganttdatetimegrid.cpp.
References d, KDGantt::AbstractGrid::gridChanged(), and QObject::Q_EMIT().
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 403 of file kdganttdatetimegrid.cpp.
References d, KDGantt::AbstractGrid::gridChanged(), QObject::Q_EMIT(), and QObject::qobject_cast().
void DateTimeGrid::setWeekStart | ( | Qt::DayOfWeek | ws | ) |
ws | The start day of the week. |
A solid line is drawn on the grid to mark the beginning of a new week. Emits gridChanged() after the start day has changed.
Definition at line 429 of file kdganttdatetimegrid.cpp.
References d, KDGantt::AbstractGrid::gridChanged(), and QObject::Q_EMIT().
QDateTime DateTimeGrid::startDateTime | ( | ) | const |
The default is three days before the current date.
Definition at line 301 of file kdganttdatetimegrid.cpp.
References d.
Referenced by paintHeader().
DateTimeScaleFormatter * DateTimeGrid::userDefinedLowerScale | ( | ) | const |
Definition at line 412 of file kdganttdatetimegrid.cpp.
References d.
DateTimeScaleFormatter * DateTimeGrid::userDefinedUpperScale | ( | ) | const |
Definition at line 419 of file kdganttdatetimegrid.cpp.
References d.
Qt::DayOfWeek DateTimeGrid::weekStart | ( | ) | const |
Definition at line 436 of file kdganttdatetimegrid.cpp.
References d.