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

kdgantt

kdganttglobal.cpp

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 #include "kdganttglobal.h"
00024 
00025 using namespace KDGantt;
00026 
00066 Span::~Span()
00067 {
00068 }
00069 
00070 DateTimeSpan::DateTimeSpan()
00071 {
00072 }
00073 
00074 DateTimeSpan::DateTimeSpan( const QDateTime& start, const QDateTime& end )
00075     : m_start( start ), m_end( end )
00076 {
00077 }
00078 
00079 DateTimeSpan::DateTimeSpan( const DateTimeSpan& other )
00080 {
00081     *this = other;
00082 }
00083 
00084 DateTimeSpan::~DateTimeSpan()
00085 {
00086 }
00087 
00088 DateTimeSpan& DateTimeSpan::operator=( const DateTimeSpan& other )
00089 {
00090     if ( this != &other ) {
00091         m_start = other.m_start;
00092         m_end = other.m_end;
00093     }
00094     return *this;
00095 }
00096 
00097 bool DateTimeSpan::isValid() const
00098 {
00099     return m_start.isValid() && m_end.isValid();
00100 }
00101 
00102 bool DateTimeSpan::equals( const DateTimeSpan& other ) const
00103 {
00104     return m_start==other.m_start && m_end==other.m_end;
00105 }
00106 
00107 #ifndef QT_NO_DEBUG_STREAM
00108 
00109 QDebug operator<<( QDebug dbg, KDGantt::ItemDataRole r)
00110 {
00111   switch(r){
00112   case KDGantt::StartTimeRole:      dbg << "KDGantt::StartTimeRole"; break;
00113   case KDGantt::EndTimeRole:        dbg << "KDGantt::EndTimeRole"; break;
00114   case KDGantt::TaskCompletionRole: dbg << "KDGantt::TaskCompletionRole"; break;
00115   case KDGantt::ItemTypeRole:       dbg << "KDGantt::ItemTypeRole"; break;
00116   case KDGantt::LegendRole:         dbg << "KDGantt::LegendRole"; break;
00117   default: dbg << static_cast<Qt::ItemDataRole>(r);
00118   }
00119   return dbg;
00120 }
00121 
00122 QDebug operator<<( QDebug dbg, const KDGantt::Span& s )
00123 {
00124     dbg << "KDGantt::Span[ start="<<s.start()<<" length="<<s.length()<<"]";
00125     return dbg;
00126 }
00127 QDebug operator<<( QDebug dbg, const KDGantt::DateTimeSpan& s )
00128 {
00129     dbg << "KDGantt::DateTimeSpan[ start="<<s.start()<<" end="<<s.end()<<"]";
00130     return dbg;
00131 }
00132 
00133 #endif /* QT_NO_DEBUG_STREAM */
00134 
00135 #ifndef KDAB_NO_UNIT_TESTS
00136 #include "unittest/test.h"
00137 
00138 namespace {
00139     std::ostream& operator<<( std::ostream& os, const Span& span )
00140     {
00141         os << "Span[ start="<<span.start()<<", length="<<span.length()<<"]";
00142         return os;
00143     }
00144     std::ostream& operator<<( std::ostream& os, const DateTimeSpan& span )
00145     {
00146         os << "DateTimeSpan[ start="<<span.start().toString().toStdString()
00147            << ", end="<<span.end().toString().toStdString() << "]";
00148         return os;
00149     }
00150 }
00151 
00152 KDAB_SCOPED_UNITTEST_SIMPLE( KDGantt, Span, "test" ) {
00153     Span s1;
00154     assertFalse( s1.isValid() );
00155     s1.setStart( 10. );
00156     s1.setLength( 2. );
00157 
00158     Span s2( s1.start(), s1.length() );
00159     assertEqual( s1, s2 );
00160 }
00161 
00162 KDAB_SCOPED_UNITTEST_SIMPLE( KDGantt, DateTimeSpan, "test" ) {
00163     DateTimeSpan s1;
00164     assertFalse( s1.isValid() );
00165     QDateTime dt = QDateTime::currentDateTime();
00166     s1.setStart( dt );
00167     assertTrue( dt.isValid() );
00168     s1.setEnd( dt.addDays( 1 ) );
00169 
00170     DateTimeSpan s2( dt, dt.addDays( 1 ) );
00171 
00172     assertEqual( s1, s2 );
00173 
00174     DateTimeSpan s3;
00175 
00176     assertNotEqual( s1, s3 );
00177 }
00178 #endif /* KDAB_NO_UNIT_TESTS */

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