• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

kdgantt2

  • sources
  • kde-4.12
  • kdepim
  • kdgantt2
kdganttglobal.h
Go to the documentation of this file.
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.
10  **
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.
14  **
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.
17  **
18  ** See http://www.kdab.net/kdgantt for
19  ** information about KD Gantt Commercial License Agreements.
20  **
21  ** Contact info@kdab.net if any conditions of this
22  ** licensing are not clear to you.
23  **
24  **********************************************************************/
25 #ifndef KDGANTTGLOBAL_H
26 #define KDGANTTGLOBAL_H
27 
28 #include <Qt>
29 #include <QDateTime>
30 #include <QDebug>
31 #include <QMetaType>
32 
33 #include "kdgantt_export.h"
34 
35 template <typename T>
36 inline T & __kdab__dereference_for_methodcall( T & o ) {
37  return o;
38 }
39 
40 template <typename T>
41 inline T & __kdab__dereference_for_methodcall( T * o ) {
42  return *o;
43 }
44 
45 #define KDAB_SET_OBJECT_NAME( x ) __kdab__dereference_for_methodcall( x ).setObjectName( QLatin1String( #x ) )
46 
47 #if defined(_MSC_VER) && _MSC_VER <= 1300
48 #define KDGANTT_DECLARE_PRIVATE_DERIVED( X ) \
49 public: \
50  class Private; \
51  friend class Private; \
52 protected: \
53  inline Private * d_func(); \
54  inline const Private * d_func() const; \
55  explicit inline X( Private * ); \
56 private: \
57  void init();
58 #else
59 #define KDGANTT_DECLARE_PRIVATE_DERIVED( X ) \
60 protected: \
61  class Private; \
62  friend class Private; \
63  inline Private * d_func(); \
64  inline const Private * d_func() const; \
65  explicit inline X( Private * ); \
66 private: \
67  void init();
68 #endif
69 
70 #if defined(_MSC_VER) && _MSC_VER <= 1300
71 #define KDGANTT_DECLARE_PRIVATE_DERIVED_PARENT( X, ParentType ) \
72 public: \
73  class Private; \
74  friend class Private; \
75 protected: \
76  inline Private * d_func(); \
77  inline const Private * d_func() const; \
78  explicit inline X( Private *, ParentType ); \
79 private: \
80  void init();
81 #else
82 #define KDGANTT_DECLARE_PRIVATE_DERIVED_PARENT( X, ParentType ) \
83 protected: \
84  class Private; \
85  friend class Private; \
86  inline Private * d_func(); \
87  inline const Private * d_func() const; \
88  explicit inline X( Private *, ParentType ); \
89 private: \
90  void init();
91 #endif
92 
93 #define KDGANTT_DECLARE_PRIVATE_DERIVED_QWIDGET( X ) \
94  KDGANTT_DECLARE_PRIVATE_DERIVED_PARENT( X, QWidget* )
95 
96 #define KDGANTT_DECLARE_PRIVATE_BASE_VALUE( X ) \
97 public: \
98  inline void swap( X & other ) { qSwap( _d, other._d ); } \
99 protected: \
100  class Private; \
101  friend class Private; \
102  Private * d_func() { return _d; } \
103  const Private * d_func() const { return _d; } \
104 private: \
105  void init(); \
106  Private * _d;
107 
108 #if defined(_MSC_VER) && _MSC_VER <= 1300
109 #define KDGANTT_DECLARE_PRIVATE_BASE_POLYMORPHIC( X ) \
110 public: \
111  class Private; \
112  friend class Private; \
113 protected: \
114  Private * d_func() { return _d; } \
115  const Private * d_func() const { return _d; } \
116  explicit inline X( Private * ); \
117 private: \
118  void init(); \
119  Private * _d;
120 #else
121 #define KDGANTT_DECLARE_PRIVATE_BASE_POLYMORPHIC( X ) \
122 protected: \
123  class Private; \
124  friend class Private; \
125  Private * d_func() { return _d; } \
126  const Private * d_func() const { return _d; } \
127  explicit inline X( Private * ); \
128 private: \
129  void init(); \
130  Private * _d;
131 #endif
132 
133 #if defined(_MSC_VER) && _MSC_VER <= 1300
134 #define KDGANTT_DECLARE_PRIVATE_BASE_POLYMORPHIC_QWIDGET( X ) \
135 public: \
136  class Private; \
137  friend class Private; \
138 protected: \
139  Private * d_func() { return _d; } \
140  const Private * d_func() const { return _d; } \
141  explicit inline X( Private *, QWidget* ); \
142 private: \
143  void init(); \
144  Private * _d;
145 #else
146 #define KDGANTT_DECLARE_PRIVATE_BASE_POLYMORPHIC_QWIDGET( X ) \
147 protected: \
148  class Private; \
149  friend class Private; \
150  Private * d_func() { return _d; } \
151  const Private * d_func() const { return _d; } \
152  explicit inline X( Private *, QWidget* ); \
153 private: \
154  void init(); \
155  Private * _d;
156 #endif
157 
158 
159 
160 // enable this for testing if KD Gantt works without STL support in Qt:
161 //
162 // #define QT_NO_STL
163 
164 
165 #include <QtAlgorithms> // qSwap
166 #ifndef QT_NO_STL
167 #include <algorithm>
168 #define KDGANTT_DECLARE_SWAP_SPECIALISATION( X ) \
169  template <> inline void qSwap<X>( X & lhs, X & rhs ) \
170  { lhs.swap( rhs ); } \
171  namespace std { \
172  template <> inline void swap<X>( X & lhs, X & rhs ) \
173  { lhs.swap( rhs ); } \
174  }
175 #else
176 #define KDGANTT_DECLARE_SWAP_SPECIALISATION( X ) \
177  template <> inline void qSwap<X>( X & lhs, X & rhs ) \
178  { lhs.swap( rhs ); }
179 #endif
180 
181 #define KDGANTT_DECLARE_SWAP_SPECIALISATION_DERIVED( X ) \
182  KDGANTT_DECLARE_SWAP_SPECIALISATION( X )
183 
184 #define KDGANTT_DECLARE_SWAP_BASE( X ) \
185 protected: \
186  void doSwap( X& other ) \
187  { qSwap( _d, other._d); }
188 
189 #define KDGANTT_DECLARE_SWAP_DERIVED( X ) \
190  void swap( X& other ) { doSwap( other ); }
191 
192 #if defined(Q_OS_WIN) && defined(QT_DLL)
193 #if _MSC_VER >= 1300
194 // workaround http://support.microsoft.com/default.aspx?scid=kb;en-us;309801
195 #include <QPointF>
196 #include <QVector>
197 template class Q_DECL_IMPORT QVector<QPointF>;
198 #endif
199 #endif
200 
201 namespace KDGantt {
202  enum ItemDataRole {
203  KDGanttRoleBase = Qt::UserRole + 1174,
204  StartTimeRole = KDGanttRoleBase + 1,
205  EndTimeRole = KDGanttRoleBase + 2,
206  TaskCompletionRole = KDGanttRoleBase + 3,
207  ItemTypeRole = KDGanttRoleBase + 4,
208  LegendRole = KDGanttRoleBase + 5,
209  TextPositionRole = KDGanttRoleBase + 6
210  };
211  enum ItemType {
212  TypeNone = 0,
213  TypeEvent = 1,
214  TypeTask = 2,
215  TypeSummary = 3,
216  TypeMulti = 4,
217  TypeUser = 1000
218  };
219 
220  class Span {
221  qreal m_start;
222  qreal m_length;
223  public:
224  inline Span() : m_start( -1 ), m_length( 0 ) {}
225  inline Span( qreal start, qreal length ) : m_start( start ), m_length( length ) {}
226  inline Span( const Span& other ) : m_start(other.m_start), m_length(other.m_length) {}
227  ~Span();
228 
229  inline Span& operator=( const Span& other ) { m_start=other.m_start; m_length=other.m_length; return *this; }
230 
231  inline void setStart( qreal start ) { m_start=start; }
232  inline qreal start() const { return m_start; }
233  inline void setEnd( qreal end ) { m_length = m_start-end; }
234  inline qreal end() const { return m_start+m_length; }
235 
236  inline void setLength( qreal length ) { m_length=length; }
237  inline qreal length() const { return m_length; }
238 
239  inline bool isValid() const { return m_start >= 0.;}
240 
241  inline bool equals( const Span& other ) const {
242  return m_start == other.m_start && m_length == other.m_length;
243  }
244  inline Span expandedTo( const Span& other) const {
245  const qreal new_start = qMin(start(),other.start());
246  return Span( new_start, (end()<other.end())?other.end()-new_start:end()-new_start);
247  }
248  };
249 
250  inline bool operator==( const Span& s1, const Span& s2) { return s1.equals( s2 ); }
251  inline bool operator!=( const Span& s1, const Span& s2) { return !s1.equals( s2 ); }
252 
253 
254  class DateTimeSpan {
255  QDateTime m_start;
256  QDateTime m_end;
257  public:
258  DateTimeSpan();
259  DateTimeSpan( const QDateTime& start, const QDateTime& end );
260  DateTimeSpan( const DateTimeSpan& other );
261  ~DateTimeSpan();
262 
263  DateTimeSpan& operator=( const DateTimeSpan& other );
264 
265  inline void setStart( const QDateTime& start ) { m_start=start; }
266  inline QDateTime start() const { return m_start; }
267 
268  inline void setEnd( const QDateTime& end ) { m_end=end; }
269  inline QDateTime end() const { return m_end; }
270 
271  bool isValid() const;
272 
273  bool equals( const DateTimeSpan& other ) const;
274  };
275 
276  inline bool operator==( const DateTimeSpan& s1, const DateTimeSpan& s2) { return s1.equals( s2 ); }
277  inline bool operator!=( const DateTimeSpan& s1, const DateTimeSpan& s2) { return !s1.equals( s2 ); }
278 }
279 
280 Q_DECLARE_METATYPE(KDGantt::ItemType)
281 Q_DECLARE_TYPEINFO(KDGantt::Span, Q_MOVABLE_TYPE);
282 Q_DECLARE_TYPEINFO(KDGantt::DateTimeSpan, Q_MOVABLE_TYPE);
283 
284 #ifndef QT_NO_DEBUG_STREAM
285 
286 
287 QDebug KDGANTT_EXPORT operator<<( QDebug dbg, KDGantt::ItemDataRole r);
288 QDebug KDGANTT_EXPORT operator<<( QDebug dbg, KDGantt::ItemType t);
289 QDebug KDGANTT_EXPORT operator<<( QDebug dbg, const KDGantt::Span& s );
290 QDebug KDGANTT_EXPORT operator<<( QDebug dbg, const KDGantt::DateTimeSpan& s );
291 
292 #endif /* QT_NO_DEBUG_STREAM */
293 
294 #endif /* KDGANTTGLOBAL_H */
KDGantt::Span::start
qreal start() const
Definition: kdganttglobal.h:232
KDGantt::TypeUser
Definition: kdganttglobal.h:217
KDGantt::TypeSummary
Definition: kdganttglobal.h:215
kdgantt_export.h
KDGantt::operator!=
bool operator!=(const DateTimeSpan &s1, const DateTimeSpan &s2)
Definition: kdganttglobal.h:277
KDGantt::TypeEvent
Definition: kdganttglobal.h:213
KDGantt::ItemType
ItemType
Definition: kdganttglobal.h:211
KDGANTT_EXPORT
#define KDGANTT_EXPORT
Definition: kdgantt_export.h:40
KDGantt::StartTimeRole
Definition: kdganttglobal.h:204
KDGantt::Span::Span
Span(const Span &other)
Definition: kdganttglobal.h:226
KDGantt::DateTimeSpan::setEnd
void setEnd(const QDateTime &end)
Definition: kdganttglobal.h:268
KDGantt::Span::Span
Span()
Definition: kdganttglobal.h:224
__kdab__dereference_for_methodcall
T & __kdab__dereference_for_methodcall(T &o)
Definition: kdganttglobal.h:36
KDGantt::TypeTask
Definition: kdganttglobal.h:214
KDGantt::Span::setLength
void setLength(qreal length)
Definition: kdganttglobal.h:236
operator<<
QDebug KDGANTT_EXPORT operator<<(QDebug dbg, KDGantt::ItemDataRole r)
Definition: kdganttglobal.cpp:127
KDGantt::Span::end
qreal end() const
Definition: kdganttglobal.h:234
KDGantt::Span
A class representing a start point and a length.
Definition: kdganttglobal.h:220
KDGantt::ItemTypeRole
Definition: kdganttglobal.h:207
KDGantt::DateTimeSpan::equals
bool equals(const DateTimeSpan &other) const
Definition: kdganttglobal.cpp:120
KDGantt::Span::isValid
bool isValid() const
Definition: kdganttglobal.h:239
KDGantt::ItemDataRole
ItemDataRole
Definition: kdganttglobal.h:202
KDGantt::LegendRole
Definition: kdganttglobal.h:208
KDGantt::EndTimeRole
Definition: kdganttglobal.h:205
KDGantt::DateTimeSpan::end
QDateTime end() const
Definition: kdganttglobal.h:269
KDGantt::Span::expandedTo
Span expandedTo(const Span &other) const
Definition: kdganttglobal.h:244
KDGantt::Span::operator=
Span & operator=(const Span &other)
Definition: kdganttglobal.h:229
Q_DECLARE_TYPEINFO
Q_DECLARE_TYPEINFO(KDGantt::Span, Q_MOVABLE_TYPE)
KDGantt::Span::equals
bool equals(const Span &other) const
Definition: kdganttglobal.h:241
KDGantt::TextPositionRole
Definition: kdganttglobal.h:209
KDGantt::TaskCompletionRole
Definition: kdganttglobal.h:206
KDGantt::TypeMulti
Definition: kdganttglobal.h:216
KDGantt::DateTimeSpan::setStart
void setStart(const QDateTime &start)
Definition: kdganttglobal.h:265
KDGantt::TypeNone
Definition: kdganttglobal.h:212
KDGantt::DateTimeSpan::start
QDateTime start() const
Definition: kdganttglobal.h:266
KDGantt::KDGanttRoleBase
Definition: kdganttglobal.h:203
KDGantt::Span::length
qreal length() const
Definition: kdganttglobal.h:237
KDGantt::Span::setStart
void setStart(qreal start)
Definition: kdganttglobal.h:231
KDGantt::operator==
bool operator==(const DateTimeSpan &s1, const DateTimeSpan &s2)
Definition: kdganttglobal.h:276
KDGantt::Span::Span
Span(qreal start, qreal length)
Definition: kdganttglobal.h:225
KDGantt::DateTimeSpan
Definition: kdganttglobal.h:254
KDGantt::Span::setEnd
void setEnd(qreal end)
Definition: kdganttglobal.h:233
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:55:05 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kdgantt2

Skip menu "kdgantt2"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal