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

kdgantt

kdganttglobal.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 used under the terms of the GNU General Public
00007  ** License versions 2.0 or 3.0 as published by the Free Software
00008  ** Foundation and appearing in the files LICENSE.GPL2 and LICENSE.GPL3
00009  ** included in the packaging of this file.  Alternatively you may (at
00010  ** your option) use any later version of the GNU General Public
00011  ** License if such license has been publicly approved by
00012  ** Klarälvdalens Datakonsult AB (or its successors, if any).
00013  ** 
00014  ** This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
00015  ** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
00016  ** A PARTICULAR PURPOSE. Klarälvdalens Datakonsult AB reserves all rights
00017  ** not expressly granted herein.
00018  ** 
00019  ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00020  ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00021  **
00022  **********************************************************************/
00023 #ifndef KDGANTTGLOBAL_H
00024 #define KDGANTTGLOBAL_H
00025 
00026 #include <Qt>
00027 #include <QDateTime>
00028 #include <QDebug>
00029 #include <QMetaType>
00030 
00031 #include "kdgantt_export.h"
00032 
00033 template <typename T>
00034 inline T & __kdab__dereference_for_methodcall( T & o ) {
00035     return o;
00036 }
00037 
00038 template <typename T>
00039 inline T & __kdab__dereference_for_methodcall( T * o ) {
00040     return *o;
00041 }
00042 
00043 #define KDAB_SET_OBJECT_NAME( x ) __kdab__dereference_for_methodcall( x ).setObjectName( QLatin1String( #x ) )
00044 
00045 #if defined(_MSC_VER) && _MSC_VER <= 1300
00046 #define KDGANTT_DECLARE_PRIVATE_DERIVED( X )      \
00047 public:                                           \
00048     class Private;                                \
00049     friend class Private;                     \
00050 protected:                                        \
00051     inline Private * d_func();                    \
00052     inline const Private * d_func() const;        \
00053     explicit inline X( Private * );               \
00054 private:                                          \
00055     void init();
00056 #else
00057 #define KDGANTT_DECLARE_PRIVATE_DERIVED( X )      \
00058 protected:                                        \
00059     class Private;                                \
00060     friend class Private;                     \
00061     inline Private * d_func();                    \
00062     inline const Private * d_func() const;        \
00063     explicit inline X( Private * );               \
00064 private:                                          \
00065     void init();
00066 #endif
00067 
00068 #if defined(_MSC_VER) && _MSC_VER <= 1300
00069 #define KDGANTT_DECLARE_PRIVATE_DERIVED_PARENT( X, ParentType )      \
00070 public:                                           \
00071     class Private;                                \
00072     friend class Private;                     \
00073 protected:                                        \
00074     inline Private * d_func();                    \
00075     inline const Private * d_func() const;        \
00076     explicit inline X( Private *, ParentType );   \
00077 private:                                          \
00078     void init();
00079 #else
00080 #define KDGANTT_DECLARE_PRIVATE_DERIVED_PARENT( X, ParentType )      \
00081 protected:                                        \
00082     class Private;                                \
00083     friend class Private;                     \
00084     inline Private * d_func();                    \
00085     inline const Private * d_func() const;        \
00086     explicit inline X( Private *, ParentType );   \
00087 private:                                          \
00088     void init();
00089 #endif
00090 
00091 #define KDGANTT_DECLARE_PRIVATE_DERIVED_QWIDGET( X )         \
00092     KDGANTT_DECLARE_PRIVATE_DERIVED_PARENT( X, QWidget* )
00093 
00094 #define KDGANTT_DECLARE_PRIVATE_BASE_VALUE( X )              \
00095 public:                                                      \
00096     inline void swap( X & other ) { qSwap( _d, other._d ); } \
00097 protected:                                                   \
00098     class Private;                                           \
00099     friend class Private;                                \
00100     Private * d_func() { return _d; }                        \
00101     const Private * d_func() const { return _d; }            \
00102 private:                                                     \
00103     void init();                                             \
00104     Private * _d;
00105 
00106 #if defined(_MSC_VER) && _MSC_VER <= 1300
00107 #define KDGANTT_DECLARE_PRIVATE_BASE_POLYMORPHIC( X ) \
00108 public:                                               \
00109     class Private;                                    \
00110     friend class Private;                         \
00111 protected:                                            \
00112     Private * d_func() { return _d; }                 \
00113     const Private * d_func() const { return _d; }     \
00114     explicit inline X( Private * );                   \
00115 private:                                              \
00116     void init();                                      \
00117     Private * _d;
00118 #else
00119 #define KDGANTT_DECLARE_PRIVATE_BASE_POLYMORPHIC( X ) \
00120 protected:                                            \
00121     class Private;                                    \
00122     friend class Private;                         \
00123     Private * d_func() { return _d; }                 \
00124     const Private * d_func() const { return _d; }     \
00125     explicit inline X( Private * );                   \
00126 private:                                              \
00127     void init();                                      \
00128     Private * _d;
00129 #endif
00130 
00131 #if defined(_MSC_VER) && _MSC_VER <= 1300
00132 #define KDGANTT_DECLARE_PRIVATE_BASE_POLYMORPHIC_QWIDGET( X ) \
00133 public:                                               \
00134     class Private;                                    \
00135     friend class Private;                         \
00136 protected:                                            \
00137     Private * d_func() { return _d; }                 \
00138     const Private * d_func() const { return _d; }     \
00139     explicit inline X( Private *, QWidget* );         \
00140 private:                                              \
00141     void init();                                      \
00142     Private * _d;
00143 #else
00144 #define KDGANTT_DECLARE_PRIVATE_BASE_POLYMORPHIC_QWIDGET( X ) \
00145 protected:                                            \
00146     class Private;                                    \
00147     friend class Private;                         \
00148     Private * d_func() { return _d; }                 \
00149     const Private * d_func() const { return _d; }     \
00150     explicit inline X( Private *, QWidget* );         \
00151 private:                                              \
00152     void init();                                      \
00153     Private * _d;
00154 #endif
00155 
00156 #include <QtAlgorithms> // qSwap
00157 #ifndef QT_NO_STL
00158 #include <algorithm>
00159 #define KDGANTT_DECLARE_SWAP_SPECIALISATION( X )            \
00160     template <> inline void qSwap<X>( X & lhs, X & rhs )    \
00161     { lhs.swap( rhs ); }                                    \
00162     namespace std {                                         \
00163         template <> inline void swap<X>( X & lhs, X & rhs ) \
00164         { lhs.swap( rhs ); }                                \
00165     }
00166 #else
00167 #define KDGANTT_DECLARE_SWAP_SPECIALISATION( X )            \
00168     template <> inline void qSwap<X>( X & lhs, X & rhs )    \
00169     { lhs.swap( rhs ); }
00170 #endif
00171 
00172 #define KDGANTT_DECLARE_SWAP_SPECIALISATION_DERIVED( X )    \
00173     KDGANTT_DECLARE_SWAP_SPECIALISATION( X )
00174 
00175 #define KDGANTT_DECLARE_SWAP_BASE( X ) \
00176 protected: \
00177     void doSwap( X& other ) \
00178     { qSwap( _d, other._d); }
00179 
00180 #define KDGANTT_DECLARE_SWAP_DERIVED( X ) \
00181     void swap( X& other ) { doSwap( other ); }
00182 
00183 #if defined(Q_OS_WIN) && defined(QT_DLL)
00184 #if _MSC_VER >= 1300
00185 // workaround http://support.microsoft.com/default.aspx?scid=kb;en-us;309801
00186 #include <QPointF>
00187 #include <QVector>
00188 template class Q_DECL_IMPORT QVector<QPointF>;
00189 #endif
00190 #endif
00191 
00192 namespace KDGantt {
00193     enum ItemDataRole {
00194         KDGanttRoleBase     = Qt::UserRole + 1174,
00195         StartTimeRole       = KDGanttRoleBase + 1,
00196         EndTimeRole         = KDGanttRoleBase + 2,
00197         TaskCompletionRole  = KDGanttRoleBase + 3,
00198         ItemTypeRole        = KDGanttRoleBase + 4,
00199         LegendRole          = KDGanttRoleBase + 5
00200     };
00201     enum ItemType {
00202         TypeNone    = 0,
00203         TypeEvent   = 1,
00204         TypeTask    = 2,
00205         TypeSummary = 3,
00206         TypeMulti   = 4,
00207         TypeUser    = 1000
00208     };
00209 
00210     class Span {
00211         qreal m_start;
00212         qreal m_length;
00213     public:
00214         inline Span() : m_start( -1 ), m_length( 0 ) {}
00215         inline Span( qreal start, qreal length ) : m_start( start ), m_length( length ) {}
00216         inline Span( const Span& other ) : m_start(other.m_start), m_length(other.m_length) {}
00217         ~Span();
00218 
00219         inline Span& operator=( const Span& other ) { m_start=other.m_start; m_length=other.m_length; return *this; }
00220 
00221         inline void setStart( qreal start ) { m_start=start; }
00222         inline qreal start() const { return m_start; }
00223         inline void setEnd( qreal end ) { m_length = m_start-end; }
00224         inline qreal end() const { return m_start+m_length; }
00225 
00226         inline void setLength( qreal length ) { m_length=length; }
00227         inline qreal length() const { return m_length; }
00228 
00229         inline bool isValid() const { return m_start >= 0.;}
00230 
00231         inline bool equals( const Span& other ) const {
00232             return m_start == other.m_start && m_length == other.m_length;
00233         }
00234     };
00235 
00236     inline bool operator==( const Span& s1, const Span& s2) { return s1.equals( s2 ); }
00237     inline bool operator!=( const Span& s1, const Span& s2) { return !s1.equals( s2 ); }
00238 
00239 
00240     class DateTimeSpan {
00241         QDateTime m_start;
00242         QDateTime m_end;
00243     public:
00244         DateTimeSpan();
00245         DateTimeSpan( const QDateTime& start, const QDateTime& end );
00246         DateTimeSpan( const DateTimeSpan& other );
00247         ~DateTimeSpan();
00248 
00249         DateTimeSpan& operator=( const DateTimeSpan& other );
00250 
00251         inline void setStart( const QDateTime& start ) { m_start=start; }
00252         inline QDateTime start() const { return m_start; }
00253 
00254         inline void setEnd( const QDateTime& end ) { m_end=end; }
00255         inline QDateTime end() const { return m_end; }
00256 
00257         bool isValid() const;
00258 
00259         bool equals( const DateTimeSpan& other ) const;
00260     };
00261 
00262     inline bool operator==( const DateTimeSpan& s1, const DateTimeSpan& s2) { return s1.equals( s2 ); }
00263     inline bool operator!=( const DateTimeSpan& s1, const DateTimeSpan& s2) { return !s1.equals( s2 ); }
00264 }
00265 
00266 Q_DECLARE_METATYPE(KDGantt::ItemType)
00267 Q_DECLARE_TYPEINFO(KDGantt::Span, Q_MOVABLE_TYPE);
00268 Q_DECLARE_TYPEINFO(KDGantt::DateTimeSpan, Q_MOVABLE_TYPE);
00269 
00270 #ifndef QT_NO_DEBUG_STREAM
00271 
00272 
00273 QDebug operator<<( QDebug dbg, KDGantt::ItemDataRole r);
00274 QDebug operator<<( QDebug dbg, const KDGantt::Span& s );
00275 QDebug operator<<( QDebug dbg, const KDGantt::DateTimeSpan& s );
00276 
00277 #endif /* QT_NO_DEBUG_STREAM */
00278 
00279 #endif /* KDGANTTGLOBAL_H */

kdgantt

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

kdepim

Skip menu "kdepim"
  • akonadi
  •   clients
  •   kabc
  •   kcal
  •   kcm
  • akregator
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt
  • kdgantt1
  • kjots
  • kleopatra
  • kmail
  • kmobiletools
  • knode
  • knotes
  • kontact
  • kontactinterfaces
  • korganizer
  •   korgac
  • kpilot
  • ktimetracker
  • libkdepim
  • libkholidays
  • libkleo
  • libkpgp
  • maildir
Generated for kdepim by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal