KGantt

kganttdatetimetimeline.cpp
1/*
2 * SPDX-FileCopyrightText: 2019 Dag Andersen <danders@get2net.dk>
3 *
4 * This file is part of the KGantt library.
5 *
6 * SPDX-License-Identifier: GPL-2.0-or-later
7 */
8
9#include "kganttdatetimetimeline.h"
10
11#include <QApplication>
12#include <QDateTime>
13#include <QString>
14#include <QPalette>
15#include <QPen>
16#include <QTimer>
17#include <QDebug>
18
19
20
21namespace KGantt {
22 class Q_DECL_HIDDEN DateTimeTimeLine::Private
23 {
24 public:
25 Private() : options(Foreground) {}
26
28 QDateTime dateTime;
29 QPen pen;
30 QTimer timer;
31 };
32
33}
34
35using namespace KGantt;
36
37
38
39
41 : _d( new Private())
42{
43 _d->options = {};
44 _d->pen = QPen(QApplication::palette().color(QPalette::Highlight), 0);
45 connect(&_d->timer, SIGNAL(timeout()), this, SIGNAL(updated()));
46}
47
48#define d d_func()
49
51{
52 return d->options;
53}
54
55
57{
58 d->options = options;
59 if (options & Foreground) {
60 d->options &= ~Background;
61 }
62 Q_EMIT updated();
63}
64
65
67{
68 return d->dateTime.isValid() ? d->dateTime : QDateTime::currentDateTime();
69}
70
71
73{
74 d->dateTime = dt;
75 Q_EMIT updated();
76}
77
78
80{
81 return d->timer.interval();
82}
83
84
86{
87 d->timer.stop();
88 d->timer.setInterval(msecs);
89 Q_EMIT updated();
90 if (msecs > 0) {
91 d->timer.start();
92 }
93}
94
95
97{
98 if (d->options & DateTimeTimeLine::UseCustomPen) {
99 return d->pen;
100 }
102}
103
104
106{
107 d->pen = pen;
108 Q_EMIT updated();
109}
110
111
113{
114 return d->pen;
115}
116
117
118#undef d
@ UseCustomPen
Paint the timeline using the pen set with setPen().
@ Foreground
Display the timeline in the foreground.
void setOptions(DateTimeTimeLine::Options options)
Set options to options.
void setInterval(int msec)
Set timer interval to msecs milliseconds.
void setPen(const QPen &pen)
Set the custom pen to pen.
DateTimeTimeLine()
Create a timeline object.
DateTimeTimeLine::Options options() const
void setDateTime(const QDateTime &dt)
Set datetime to dt.
Global namespace.
QDateTime currentDateTime()
QPalette palette()
Q_EMITQ_EMIT
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
T qobject_cast(QObject *object)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:14:21 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.