• 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.cpp
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 #include "kdganttglobal.h"
26 
27 using namespace KDGantt;
28 
29 /* Older Qt dont have this macro, so define it... */
30 #ifndef QT_VERSION_CHECK
31 # define QT_VERSION_CHECK(major, minor, patch) ((major<<16)|(minor<<8)|(patch))
32 #endif
33 
34 /* Version check */
35 #if QT_VERSION < QT_VERSION_CHECK(4,3,0)
36 # error "The minimum required version of Qt for KD Gantt is 4.3.0"
37 #endif
38 
84 Span::~Span()
85 {
86 }
87 
88 DateTimeSpan::DateTimeSpan()
89 {
90 }
91 
92 DateTimeSpan::DateTimeSpan( const QDateTime& start, const QDateTime& end )
93  : m_start( start ), m_end( end )
94 {
95 }
96 
97 DateTimeSpan::DateTimeSpan( const DateTimeSpan& other )
98 {
99  *this = other;
100 }
101 
102 DateTimeSpan::~DateTimeSpan()
103 {
104 }
105 
106 DateTimeSpan& DateTimeSpan::operator=( const DateTimeSpan& other )
107 {
108  if ( this != &other ) {
109  m_start = other.m_start;
110  m_end = other.m_end;
111  }
112  return *this;
113 }
114 
115 bool DateTimeSpan::isValid() const
116 {
117  return m_start.isValid() && m_end.isValid();
118 }
119 
120 bool DateTimeSpan::equals( const DateTimeSpan& other ) const
121 {
122  return m_start==other.m_start && m_end==other.m_end;
123 }
124 
125 #ifndef QT_NO_DEBUG_STREAM
126 
127 QDebug operator<<( QDebug dbg, KDGantt::ItemDataRole r)
128 {
129  switch(r){
130  case KDGantt::StartTimeRole: dbg << "KDGantt::StartTimeRole"; break;
131  case KDGantt::EndTimeRole: dbg << "KDGantt::EndTimeRole"; break;
132  case KDGantt::TaskCompletionRole: dbg << "KDGantt::TaskCompletionRole"; break;
133  case KDGantt::ItemTypeRole: dbg << "KDGantt::ItemTypeRole"; break;
134  case KDGantt::LegendRole: dbg << "KDGantt::LegendRole"; break;
135  default: dbg << static_cast<Qt::ItemDataRole>(r);
136  }
137  return dbg;
138 }
139 
140 QDebug operator<<( QDebug dbg, KDGantt::ItemType t)
141 {
142  switch( t ) {
143  case KDGantt::TypeNone: dbg << "KDGantt::TypeNone"; break;
144  case KDGantt::TypeEvent: dbg << "KDGantt::TypeEvent"; break;
145  case KDGantt::TypeTask: dbg << "KDGantt::TypeTask"; break;
146  case KDGantt::TypeSummary: dbg << "KDGantt::TypeSummary"; break;
147  case KDGantt::TypeMulti: dbg << "KDGantt::TypeMulti"; break;
148  case KDGantt::TypeUser: dbg << "KDGantt::TypeUser"; break;
149  default: dbg << static_cast<int>(t);
150  }
151  return dbg;
152 }
153 
154 QDebug operator<<( QDebug dbg, const KDGantt::Span& s )
155 {
156  dbg << "KDGantt::Span[ start="<<s.start()<<" length="<<s.length()<<"]";
157  return dbg;
158 }
159 QDebug operator<<( QDebug dbg, const KDGantt::DateTimeSpan& s )
160 {
161  dbg << "KDGantt::DateTimeSpan[ start="<<s.start()<<" end="<<s.end()<<"]";
162  return dbg;
163 }
164 
165 #endif /* QT_NO_DEBUG_STREAM */
166 
167 #ifndef KDAB_NO_UNIT_TESTS
168 #include "unittest/test.h"
169 
170 namespace {
171  std::ostream& operator<<( std::ostream& os, const Span& span )
172  {
173  os << "Span[ start="<<span.start()<<", length="<<span.length()<<"]";
174  return os;
175  }
176  std::ostream& operator<<( std::ostream& os, const DateTimeSpan& span )
177  {
178 #ifdef QT_NO_STL
179  os << "DateTimeSpan[ start="<<span.start().toString().toLatin1().constData()
180  << ", end="<<span.end().toString().toLatin1().constData() << "]";
181 #else
182  os << "DateTimeSpan[ start="<<span.start().toString().toStdString()
183  << ", end="<<span.end().toString().toStdString() << "]";
184 #endif
185  return os;
186  }
187 }
188 
189 KDAB_SCOPED_UNITTEST_SIMPLE( KDGantt, Span, "test" ) {
190  Span s1;
191  assertFalse( s1.isValid() );
192  s1.setStart( 10. );
193  s1.setLength( 2. );
194 
195  Span s2( s1.start(), s1.length() );
196  assertEqual( s1, s2 );
197 }
198 
199 KDAB_SCOPED_UNITTEST_SIMPLE( KDGantt, DateTimeSpan, "test" ) {
200  DateTimeSpan s1;
201  assertFalse( s1.isValid() );
202  QDateTime dt = QDateTime::currentDateTime();
203  s1.setStart( dt );
204  assertTrue( dt.isValid() );
205  s1.setEnd( dt.addDays( 1 ) );
206 
207  DateTimeSpan s2( dt, dt.addDays( 1 ) );
208 
209  assertEqual( s1, s2 );
210 
211  DateTimeSpan s3;
212 
213  assertNotEqual( s1, s3 );
214 }
215 #endif /* KDAB_NO_UNIT_TESTS */
operator<<
QDebug operator<<(QDebug dbg, KDGantt::ItemDataRole r)
Definition: kdganttglobal.cpp:127
KDGantt::Span::start
qreal start() const
Definition: kdganttglobal.h:232
KDGantt::TypeUser
Definition: kdganttglobal.h:217
KDGantt::TypeSummary
Definition: kdganttglobal.h:215
kdganttglobal.h
KDGantt::TypeEvent
Definition: kdganttglobal.h:213
KDGantt::ItemType
ItemType
Definition: kdganttglobal.h:211
KDGantt::StartTimeRole
Definition: kdganttglobal.h:204
KDGantt::DateTimeSpan::setEnd
void setEnd(const QDateTime &end)
Definition: kdganttglobal.h:268
KDGantt::TypeTask
Definition: kdganttglobal.h:214
KDGantt::DateTimeSpan::DateTimeSpan
DateTimeSpan()
Definition: kdganttglobal.cpp:88
KDGantt::Span::setLength
void setLength(qreal length)
Definition: kdganttglobal.h:236
KDGantt::DateTimeSpan::operator=
DateTimeSpan & operator=(const DateTimeSpan &other)
Definition: kdganttglobal.cpp:106
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::DateTimeSpan::isValid
bool isValid() const
Definition: kdganttglobal.cpp:115
KDGantt::ItemDataRole
ItemDataRole
Definition: kdganttglobal.h:202
KDGantt::LegendRole
Definition: kdganttglobal.h:208
KDAB_SCOPED_UNITTEST_SIMPLE
KDAB_SCOPED_UNITTEST_SIMPLE(KDGantt, Span,"test")
Definition: kdganttglobal.cpp:189
KDGantt::EndTimeRole
Definition: kdganttglobal.h:205
KDGantt::DateTimeSpan::end
QDateTime end() const
Definition: kdganttglobal.h:269
KDGantt::Span::~Span
~Span()
Definition: kdganttglobal.cpp:84
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::Span::length
qreal length() const
Definition: kdganttglobal.h:237
KDGantt::Span::setStart
void setStart(qreal start)
Definition: kdganttglobal.h:231
KDGantt::DateTimeSpan::~DateTimeSpan
~DateTimeSpan()
Definition: kdganttglobal.cpp:102
KDGantt::DateTimeSpan
Definition: kdganttglobal.h:254
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