KGantt

kganttdatetimetimeline.h
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#ifndef KGANTTDATETIMETIMELINE_H
10#define KGANTTDATETIMETIMELINE_H
11
12#include "kganttglobal.h"
13
14#include <QObject>
15
16class QDateTime;
17
18namespace KGantt {
19
20 /*!\class KGantt::DateTimeTimeLine
21 * \ingroup KGantt
22 *
23 * This class implements a timeline.
24 *
25 * The timeline can optionally be shown in the Background or in the Foreground.
26 * Default is Foreground.
27 *
28 * The pen can be set with setPen(), and must be activated by setting the option UseCustomPen.
29 *
30 * The datetime can be set using setDateTime().
31 *
32 * The timeline can priodically moved to the current datetime
33 * by setting the interval > 0 with setInterval().
34 * Setting a zero interval turns the periodically update off.
35 *
36 * The timeline is off by default.
37 *
38 * For example:
39 * \code
40 * // Show a red timeline in the foreground
41 * timeLine->setOptions(Foreground | UseCustomPen);
42 * timeLine->setPen(QPen(Qt:red));
43 * // Update the timeline every 5 seconds
44 * timeLine->setInterval(5000);
45 * \endcode
46 */
47 class KGANTT_EXPORT DateTimeTimeLine : public QObject
48 {
49 Q_OBJECT
50 KGANTT_DECLARE_PRIVATE_BASE_POLYMORPHIC( DateTimeTimeLine )
51 public:
52 enum Option {
53 Foreground = 1, ///< Display the timeline in the foreground.
54 Background = 2, ///< Display the timeline in the background.
55 UseCustomPen = 4, ///< Paint the timeline using the pen set with setPen().
56 MaxOptions = 0xFFFF
57 };
58 Q_DECLARE_FLAGS(Options, Option)
59
60 /**
61 * Create a timeline object.
62 *
63 * By default, no timeline is displayed.
64 */
66
67 /**
68 * @return options
69 */
70 DateTimeTimeLine::Options options() const;
71
72 /**
73 * Set options to @p options.
74 * If both Background and Foreground are set, Foreground is used.
75 */
76 void setOptions(DateTimeTimeLine::Options options);
77
78 /**
79 * @return the datetime
80 * If the datetime is not valid, the current datetime is returned.
81 */
82 QDateTime dateTime() const;
83
84 /**
85 * Set datetime to @p dt.
86 */
87 void setDateTime(const QDateTime &dt);
88
89 /**
90 * @return the update interval in milliseconds
91 */
92 int interval() const;
93
94 /**
95 * Set timer interval to @p msecs milliseconds.
96 * Setting a zero time disables the timer.
97 */
98 void setInterval(int msec);
99
100 /**
101 * @return the pen that will be used for rendering the timeline
102 * If no pen has been set with setPen(), a default pen is returned.
103 */
104 QPen pen() const;
105
106 /**
107 * Set the custom pen to @p pen.
108 */
109 void setPen(const QPen &pen);
110
111 /**
112 * @return the pen that has been set with setPen()
113 */
114 QPen customPen() const;
115
116 Q_SIGNALS:
117 void updated();
118 };
119}
120
121Q_DECLARE_OPERATORS_FOR_FLAGS(KGantt::DateTimeTimeLine::Options)
122
123#endif /* KGANTTDATETIMETIMELINE_H */
124
Contains KGantt macros.
Global namespace.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Oct 4 2024 12:04:27 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.