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

kdgantt1

KDGanttViewTaskLinkGroup.cpp

Go to the documentation of this file.
00001 /* -*- Mode: C++ -*-
00002    $Id: KDGanttViewTaskLinkGroup.cpp 836291 2008-07-22 04:34:42Z pradeepto $
00003    KDGantt - a multi-platform charting engine
00004 */
00005 /****************************************************************************
00006  ** Copyright (C)  2002-2004 Klarälvdalens Datakonsult AB.  All rights reserved.
00007  **
00008  ** This file is part of the KDGantt library.
00009  **
00010  ** This file may be used under the terms of the GNU General Public
00011  ** License versions 2.0 or 3.0 as published by the Free Software
00012  ** Foundation and appearing in the files LICENSE.GPL2 and LICENSE.GPL3
00013  ** included in the packaging of this file.  Alternatively you may (at
00014  ** your option) use any later version of the GNU General Public
00015  ** License if such license has been publicly approved by
00016  ** Klarälvdalens Datakonsult AB (or its successors, if any).
00017  ** 
00018  ** This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
00019  ** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
00020  ** A PARTICULAR PURPOSE. Klarälvdalens Datakonsult AB reserves all rights
00021  ** not expressly granted herein.
00022  ** 
00023  ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00024  ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00025  **
00026  ** As a special exception, permission is given to link this program
00027  ** with any edition of Qt, and distribute the resulting executable,
00028  ** without including the source code for Qt in the source distribution.
00029  **
00030  **********************************************************************/
00031 
00032 
00033 #include "KDGanttView.h"
00034 
00035 #include "KDGanttViewTaskLinkGroup.h"
00036 #include "KDGanttXMLTools.h"
00037 
00038 QDict<KDGanttViewTaskLinkGroup> KDGanttViewTaskLinkGroup::sGroupDict;
00039 
00050 KDGanttViewTaskLinkGroup::KDGanttViewTaskLinkGroup()
00051 {
00052 
00053 }
00054 
00060 KDGanttViewTaskLinkGroup::~KDGanttViewTaskLinkGroup()
00061 {
00062     if (!myTaskLinkList.isEmpty()) {
00063         KDGanttViewItem* item = myTaskLinkList.first()->from().first();
00064         KDGanttView * gv = 0; 
00065         if ( item )
00066              gv = item->myGanttView;
00067         KDGanttViewTaskLink * tl = myTaskLinkList.first();
00068         while ( tl ) {
00069             tl->resetGroup();
00070             tl = myTaskLinkList.next();
00071         }
00072         if ( gv )
00073             gv->removeTaskLinkGroup(this);
00074     }
00075 }
00076 
00077 
00078 
00086 KDGanttViewTaskLinkGroup::KDGanttViewTaskLinkGroup( const QString& name )
00087 {
00088     sGroupDict.insert( name, this );
00089     _name = name;
00090 }
00091 
00092 
00102 void KDGanttViewTaskLinkGroup::insert (KDGanttViewTaskLink* link)
00103 {
00104     link->setGroup(this);
00105 }
00106 
00107 
00116 bool KDGanttViewTaskLinkGroup::remove (KDGanttViewTaskLink* link)
00117 {
00118     KDGanttViewTaskLinkGroup* g = link->group();
00119     if ((g == this))
00120         link->setGroup(0);
00121     return (g == this);
00122 }
00123 
00124 
00132 void KDGanttViewTaskLinkGroup::setVisible( bool show )
00133 {
00134     isvisible = show;
00135     QPtrListIterator<KDGanttViewTaskLink> it(myTaskLinkList);
00136     for ( ; it.current(); ++it ) {
00137         it.current()->setVisible(show);
00138     }
00139 }
00140 
00141 
00148 bool KDGanttViewTaskLinkGroup::visible() const
00149 {
00150     return isvisible;
00151 }
00152 
00153 
00162 void KDGanttViewTaskLinkGroup::setHighlight( bool highlight )
00163 {
00164     ishighlighted=  highlight;
00165     QPtrListIterator<KDGanttViewTaskLink> it(myTaskLinkList);
00166     for ( ; it.current(); ++it )
00167         it.current()->setHighlight(highlight );
00168 
00169 }
00170 
00171 
00181 bool KDGanttViewTaskLinkGroup::highlight() const
00182 {
00183     return ishighlighted;
00184 }
00185 
00186 
00193 void KDGanttViewTaskLinkGroup::setColor( const QColor& color )
00194 {
00195     myColor = color;
00196     QPtrListIterator<KDGanttViewTaskLink> it(myTaskLinkList);
00197     for ( ; it.current(); ++it )
00198         it.current()->setColor(color);
00199 }
00200 
00201 
00212 QColor KDGanttViewTaskLinkGroup::color() const
00213 {
00214     return myColor;
00215 }
00216 
00217 
00224 void KDGanttViewTaskLinkGroup::setHighlightColor( const QColor& color )
00225 {
00226 
00227     myColorHL = color;
00228     QPtrListIterator<KDGanttViewTaskLink> it(myTaskLinkList);
00229     for ( ; it.current(); ++it )
00230         it.current()->setHighlightColor(color);
00231 }
00232 
00233 
00244 QColor KDGanttViewTaskLinkGroup::highlightColor() const
00245 {
00246     return myColorHL;
00247 }
00248 
00249 
00257 void KDGanttViewTaskLinkGroup::insertItem (KDGanttViewTaskLink* link)
00258 {
00259     myTaskLinkList.append (link);
00260 }
00261 
00262 
00269 void KDGanttViewTaskLinkGroup::removeItem (KDGanttViewTaskLink* link)
00270 {
00271     myTaskLinkList.remove(link);
00272 }
00273 
00274 
00282 KDGanttViewTaskLinkGroup* KDGanttViewTaskLinkGroup::find( const QString& name )
00283 {
00284     return sGroupDict.find( name );
00285 }
00286 
00287 
00294 void KDGanttViewTaskLinkGroup::createNode( QDomDocument& doc,
00295                                            QDomElement& parentElement )
00296 {
00297     QDomElement taskLinkGroupElement = doc.createElement( "TaskLink" );
00298     parentElement.appendChild( taskLinkGroupElement );
00299 
00300     KDGanttXML::createBoolNode( doc, taskLinkGroupElement, "Highlight",
00301                            highlight() );
00302     KDGanttXML::createColorNode( doc, taskLinkGroupElement, "Color", color() );
00303     KDGanttXML::createColorNode( doc, taskLinkGroupElement, "HighlightColor",
00304                             highlightColor() );
00305     KDGanttXML::createBoolNode( doc, taskLinkGroupElement, "Visible",
00306                            visible() );
00307     KDGanttXML::createStringNode( doc, taskLinkGroupElement, "Name", _name );
00308 }
00309 
00310 
00318 KDGanttViewTaskLinkGroup* KDGanttViewTaskLinkGroup::createFromDomElement( QDomElement& element )
00319 {
00320     QDomNode node = element.firstChild();
00321     bool highlight = false, visible = false;
00322     QColor color, highlightColor;
00323     QString name;
00324     while( !node.isNull() ) {
00325         QDomElement element = node.toElement();
00326         if( !element.isNull() ) { // was really an element
00327             QString tagName = element.tagName();
00328             if( tagName == "Highlight" ) {
00329                 bool value;
00330                 if( KDGanttXML::readBoolNode( element, value ) )
00331                     highlight = value;
00332             } else if( tagName == "Visible" ) {
00333                 bool value;
00334                 if( KDGanttXML::readBoolNode( element, value ) )
00335                     visible = value;
00336             } else if( tagName == "Color" ) {
00337                 QColor value;
00338                 if( KDGanttXML::readColorNode( element, value ) )
00339                     color = value;
00340             } else if( tagName == "HighlightColor" ) {
00341                 QColor value;
00342                 if( KDGanttXML::readColorNode( element, value ) )
00343                     highlightColor = value;
00344             } else if( tagName == "Name" ) {
00345                 QString value;
00346                 if( KDGanttXML::readStringNode( element, value ) )
00347                     name = value;
00348             } else {
00349                 qDebug( "Unrecognized tag name: %s", qPrintable(tagName) );
00350                 Q_ASSERT( false );
00351             }
00352         }
00353         node = node.nextSibling();
00354     }
00355 
00356     KDGanttViewTaskLinkGroup* tlg;
00357     if( !name.isEmpty() )
00358         tlg = new KDGanttViewTaskLinkGroup( name );
00359     else
00360         tlg = new KDGanttViewTaskLinkGroup();
00361 
00362     tlg->setHighlight( highlight );
00363     tlg->setVisible( visible );
00364     tlg->setHighlightColor( highlightColor );
00365     tlg->setColor( color );
00366 
00367     return tlg;
00368 }

kdgantt1

Skip menu "kdgantt1"
  • Main Page
  • 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