You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
koffice/kdgantt/KDGanttView.cpp

4844 lines
165 KiB

/*
$Id: KDGanttView.cpp 536225 2006-05-01 16:46:33Z tilladam $
KDGantt - a multi-platform charting engine
*/
/****************************************************************************
** Copyright (C) 2002-2004 Klarälvdalens Datakonsult AB. All rights reserved.
**
** This file is part of the KDGantt library.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** Licensees holding valid commercial KDGantt licenses may use this file in
** accordance with the KDGantt Commercial License Agreement provided with
** the Software.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.klaralvdalens-datakonsult.se/Public/products/ for
** information about KDGantt Commercial License Agreements.
**
** Contact info@klaralvdalens-datakonsult.se if any conditions of this
** licensing are not clear to you.
**
** As a special exception, permission is given to link this program
** with any edition of TQt, and distribute the resulting executable,
** without including the source code for TQt in the source distribution.
**
**********************************************************************/
#include "KDGanttView.h"
#include "KDGanttViewSubwidgets.h"
#include "KDGanttMinimizeSplitter.h"
#include "KDGanttViewItem.h"
#include "KDGanttXMLTools.h"
#include "itemAttributeDialog.h"
#include <tqprinter.h>
#include <tqpainter.h>
#include <tqlayout.h>
#include <tqpaintdevicemetrics.h>
#include <tqfile.h>
#include <tqheader.h>
#include <tqscrollview.h>
#include <tqapplication.h>
#include <tqevent.h>
#include <tqiconview.h>
#include <tqmessagebox.h>
#include <tqfileinfo.h>
#ifndef KDGANTT_MASTER_CVS
#include "KDGanttView.moc"
#endif
#if defined KDAB_EVAL
#include "../evaldialog/evaldialog.h"
#endif
/*!
\class KDGanttView KDGanttView.h
This class represents a Gantt view with the Gantt chart, the header,
an optional listview and an optional legend.
In order to set up a Gantt view, create an object of this class, and
populate it with a number of \a KDGanttViewItem objects.
If you experience problems with the repainting of the content of the
Gantt View after scrolling, call \a setRepaintMode().
*/
/*!
Constructs an empty KDGanttView.
\param parent the widget parent
\param name the internal debugging name
*/
KDGanttView::KDGanttView( TQWidget* parent, const char* name )
: KDGanttMinimizeSplitter( Qt::Vertical, parent, name ),
myCanvasView(0),
myTimeHeaderScroll(0)
{
#if defined KDAB_EVAL
EvalDialog::checkEvalLicense( "KD Gantt" );
#endif
myCurrentItem = 0;
setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
mySplitter = new KDGanttMinimizeSplitter( this );
mySplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Left );
leftWidget = new TQVBox( mySplitter );
rightWidget = new TQVBox( mySplitter );
myLegend = new KDLegendWidget( leftWidget, this );
spacerLeft = new TQHBox( leftWidget );
myListView = new KDListView(leftWidget, this);
myListView->setVScrollBarMode (TQScrollView::AlwaysOff );
connect( myListView, TQT_SIGNAL( selectionChanged( TQListViewItem* ) ),
this, TQT_SLOT( slotSelectionChanged( TQListViewItem* ) ) );
connect( myListView, TQT_SIGNAL( mouseButtonClicked ( int, TQListViewItem * , const TQPoint &, int ) ), this, TQT_SLOT( slotmouseButtonClicked ( int , TQListViewItem * , const TQPoint &, int ) ) );
connect( myListView, TQT_SIGNAL( contextMenuRequested ( TQListViewItem * , const TQPoint &, int ) ), this, TQT_SLOT( slotcontextMenuRequested ( TQListViewItem * , const TQPoint & , int ) ) );
connect( myListView, TQT_SIGNAL(doubleClicked ( TQListViewItem * ) ), this, TQT_SLOT(slotdoubleClicked ( TQListViewItem * ) ) );
connect( myListView, TQT_SIGNAL(currentChanged( TQListViewItem * ) ), this, TQT_SLOT(slotCurrentChanged ( TQListViewItem * ) ) );
connect( myListView, TQT_SIGNAL(itemRenamed ( TQListViewItem * , int , const TQString & ) ), this, TQT_SLOT(slotItemRenamed ( TQListViewItem *, int , const TQString & ) ) );
connect( myListView, TQT_SIGNAL(mouseButtonPressed( int, TQListViewItem * , const TQPoint &, int ) ), this, TQT_SLOT(slotMouseButtonPressed ( int , TQListViewItem * , const TQPoint & , int ) ) );
//connect( myListView, TQT_SIGNAL( ), this, TQT_SLOT( ) );
myTimeTable = new KDTimeTableWidget (rightWidget,this);
spacerRight = new TQWidget( rightWidget );
myTimeHeaderContainer = new TQHBox( rightWidget );
myTimeHeaderContainer->setFrameStyle( TQFrame::NoFrame );
myTimeHeaderContainer->setMargin( 0 );
myTimeHeaderScroll = new TQScrollView ( myTimeHeaderContainer );
myTimeHeaderScroll->setHScrollBarMode( TQScrollView::AlwaysOff );
myTimeHeaderScroll->setVScrollBarMode( TQScrollView::AlwaysOff );
timeHeaderSpacerWidget = new TQWidget( myTimeHeaderContainer );
/*
myTimeHeaderScroll = new TQScrollView ( rightWidget );
myTimeHeaderScroll->setHScrollBarMode( TQScrollView::AlwaysOff );
myTimeHeaderScroll->setVScrollBarMode( TQScrollView::AlwaysOn );
*/
//myTimeHeader = new KDTimeHeaderWidget (rightWidget,this);
myTimeHeader = new KDTimeHeaderWidget (myTimeHeaderScroll->viewport(),this);
myTimeHeaderScroll->addChild( myTimeHeader );
myTimeHeaderScroll->viewport()->setBackgroundColor( myTimeHeader->backgroundColor() );
timeHeaderSpacerWidget->setBackgroundColor( myTimeHeader->backgroundColor() );
myCanvasView = new KDGanttCanvasView (this,myTimeTable,rightWidget);
myTimeHeaderScroll->setFrameStyle( TQFrame::NoFrame );
//
myCanvasView->setFrameStyle( TQFrame::NoFrame );
myCanvasView->setMargin( 0 );
//
myTimeHeaderScroll->setMargin( 0 );//myCanvasView->frameWidth() );
setFrameStyle(myListView->frameStyle());
setLineWidth( 2 );
myListView->setFrameStyle( TQFrame::NoFrame );
myListView->setMargin( 0 );
TQObject::connect(myListView, TQT_SIGNAL ( expanded ( TQListViewItem * ) ) , myTimeTable , TQT_SLOT( expandItem(TQListViewItem * ))) ;
TQObject::connect(myListView, TQT_SIGNAL (collapsed ( TQListViewItem * ) ) , myTimeTable , TQT_SLOT(collapseItem(TQListViewItem * ))) ;
timeHeaderSpacerWidget->setFixedWidth(myCanvasView->verticalScrollBar()->width() );
listViewIsVisible = true;
chartIsEditable = true;
editorIsEnabled = true;
_displaySubitemsAsGroup = false;
initDefaults();
_showHeader = false;
myTextColor = TQt::black;
myLegendItems = new TQPtrList<legendItem>;
//TQObject::connect( this, TQT_SIGNAL (itemDoubleClicked( KDGanttViewItem* ) ) , this, TQT_SLOT( editItem( KDGanttViewItem* ))) ;
myItemAttributeDialog = new itemAttributeDialog();
setRepaintMode( KDGanttView::Medium );
//setRepaintMode( KDGanttView::Always );
setShowLegendButton( true );
setHeaderVisible( false );
// now connecting the widgets
connect(myCanvasView->horizontalScrollBar(), TQT_SIGNAL ( valueChanged ( int )) ,myTimeHeaderScroll->horizontalScrollBar(), TQT_SLOT( setValue ( int))) ;
connect(myCanvasView, TQT_SIGNAL ( heightResized( int )) ,myTimeTable, TQT_SLOT( checkHeight ( int))) ;
connect(myCanvasView, TQT_SIGNAL ( widthResized( int )) ,myTimeHeader, TQT_SLOT( checkWidth ( int))) ;
TQObject::connect(myCanvasView->verticalScrollBar(), TQT_SIGNAL ( valueChanged ( int ) ) ,myListView->verticalScrollBar(), TQT_SLOT( setValue ( int ))) ;
connect(myTimeHeader, TQT_SIGNAL ( sizeChanged( int ) ) ,this, TQT_SLOT(slotHeaderSizeChanged() )) ;
connect(myTimeHeader, TQT_SIGNAL ( sizeChanged( int ) ) ,myTimeTable, TQT_SLOT(resetWidth( int ) )) ;
connect(myListView, TQT_SIGNAL ( contentsMoving ( int, int ) ) ,myCanvasView, TQT_SLOT( moveMyContent( int, int ))) ;
connect(myTimeTable, TQT_SIGNAL ( heightComputed ( int ) ) ,myCanvasView, TQT_SLOT( setMyContentsHeight( int ))) ;
// the next three are for adding new ticks at left/right
connect( myCanvasView->horizontalScrollBar(), TQT_SIGNAL (prevLine () ) ,this, TQT_SLOT(addTickLeft()));
connect( myCanvasView->horizontalScrollBar(), TQT_SIGNAL (nextLine () ) ,this, TQT_SLOT(addTickRight()));
connect( myCanvasView->horizontalScrollBar(), TQT_SIGNAL (valueChanged ( int ) ) ,this, TQT_SLOT( enableAdding( int )));
// now initing
fCenterTimeLineAfterShow = false;
fDragEnabled = false;
fDropEnabled = false;
closingBlocked = false;
myTimeHeader->computeTicks();
centerTimelineAfterShow( TQDateTime::currentDateTime () );
setDisplayEmptyTasksAsLine( false );
TQValueList<int> list;
list.append(240);
list.append(530);
mySplitter->setSizes( list );
myTimeTable->setBlockUpdating();// block updating until this->show() is called
}
KDGanttView::~KDGanttView()
{
setUpdateEnabled(false);
// delete cut item, if there is any
myCanvasView->resetCutPaste( 0 );
myTimeTable->clearTaskLinks();
}
/*!
Enables or disables updating of the content of the Gantt view.
To avoid flickering in the Gantt view while inserting large amounts
of Gantt items, you should call
bool upd = KDGanttView::getUpdateEnabled();
KDGanttView::settUpdateEnabled( false );
... insert items here ...
KDGanttView::settUpdateEnabled( upd );
With this code, you avoid unwanted side effects with other parts in
your code, where you disable (and re-enable) the update.
When calling setUpdateEnabled( true ),
all the content is recomputed, resized, and updated.
Before calling show() for the first time, updating is disabled.
When calling show(), updating is automatically enabled.
\param enable if true, the content of the Gantt view is updated after
every insertion of a new item.
\sa getUpdateEnabled()
*/
void KDGanttView::setUpdateEnabled( bool enable )
{
myTimeTable->setBlockUpdating( !enable );
if ( enable ) {
myTimeTable->updateMyContent();
myCanvasView->setMyContentsHeight( 0 );
}
}
/*!
Returns whether updating is enabled or not.
\return true, if updating is enabled
\sa setUpdateEnabled()
*/
bool KDGanttView::getUpdateEnabled() const
{
return !myTimeTable->blockUpdating();
}
/*!
Sets the maximum width of the Gantt view part widget in pixels.
The largest allowed width is 32767.
\param w the maximum width
*/
void KDGanttView::setGanttMaximumWidth( int w )
{
myTimeHeader->setMaximumWidth ( w );
}
/*!
Returns the maximum width of the Gantt view part widget in pixels.
The default maximum width is 32767 pixels.
\return the maximum width of the Gantt view part widget in pixels.
*/
int KDGanttView::ganttMaximumWidth() const
{
return myTimeHeader->maximumWidth();
}
/*!
Updates the content of the GanttView and shows it.
Automatically sets setUpdateEnabled( true ).
\sa setUpdateEnabled()
*/
void KDGanttView::show()
{
myTimeTable->setBlockUpdating( false );
if (myCanvasView->horizontalScrollBar()->value() > 0 )
myCanvasView->horizontalScrollBar()->setValue(myCanvasView->horizontalScrollBar()->value()-1 );
else
myCanvasView->horizontalScrollBar()->setValue(1 );
myTimeTable->updateMyContent();
TQWidget::show();
myCanvasView->setMyContentsHeight( 0 );
if ( fCenterTimeLineAfterShow ) {
fCenterTimeLineAfterShow = false;
centerTimeline (dtCenterTimeLineAfterShow);
}
}
/*!
Closes the widget.
The closing is rejected, if a repainting is currently being done.
\param alsoDelete if true, the widget is deleted
\return true, if the widget was closed
*/
bool KDGanttView::close ( bool alsoDelete )
{
//tqDebug("close ");
if ( closingBlocked )
return false;
return TQWidget::close ( alsoDelete );
}
/*!
Returns a useful size for the view.
Returned width:
sizeHint().width() of the list view + width of TimeTable
Returned height:
height() of TimeHeader + height() of TimeTable + height() of Legend (if shown)
*/
TQSize KDGanttView::sizeHint() const
{
bool block = myTimeTable->blockUpdating();
myTimeTable->setBlockUpdating( false );
myTimeTable->updateMyContent();
/* The below causes recursive calls to various size updating methods, which
* cause TQCanvas to hide and show items like mad, which is very slow. If
* there is a legitimate gui updating issue here somewhere, it will need
* to be solved differently.
*/
//tqApp->processEvents();
int hintHeight = myTimeHeader->height();
int legendHeight = 0;
if ( showLegendButton() )
legendHeight = myLegend->height();
int listViewHeaderHeight = 0;
if ( headerVisible() )
listViewHeaderHeight = myListView->header()->height();
if ( hintHeight < legendHeight+listViewHeaderHeight )
hintHeight = legendHeight + listViewHeaderHeight;
hintHeight += myListView->horizontalScrollBar()->height();
if ( myLegend->isShown() )
hintHeight += myLegend->legendSizeHint().height() +10;
hintHeight += myTimeTable->minimumHeight+myListView->frameWidth()*2+2;
int hintWid = myListView->sizeHint().width();
//hintWid += myTimeHeader->mySizeHint+myCanvasView->verticalScrollBar()->width();
hintWid += myCanvasView->sizeHint().width();
// add 10 for the splitter-bars
// tqDebug("sizehint %d %d ",hintWid+10, hintHeight );
myTimeTable->setBlockUpdating( block );
return TQSize( hintWid+10, hintHeight );
}
/*!
Specifies whether the legend button should be visible. By default,
it is visible.
\param show true to show the legend button, false to hide it
\sa showLegendButton()
*/
void KDGanttView::setShowLegendButton( bool show )
{
_showLegendButton = show;
if ( show )
myLegend->show();
else
myLegend->hide();
slotHeaderSizeChanged();
}
/*!
Returns whether the legend button is visible.
\return whether the legend button is visible
\sa setShowLegendButton()
*/
bool KDGanttView::showLegendButton() const
{
return _showLegendButton;
}
/*!
Specifies whether the listview header should be visible. By default,
it is not visible.
\param visible true to make the header visible, false to make it invisible
*/
void KDGanttView::setHeaderVisible( bool visible )
{
if( visible )
myListView->header()->show();
else
myListView->header()->hide();
_showHeader = visible;
slotHeaderSizeChanged();
}
/*!
Returns whether the listview header is visible.
\return whether the header is visible
*/
bool KDGanttView::headerVisible() const
{
return _showHeader;
}
/*!
Returns the corresponding date and time of the coordinate X in the
Gantt view.
\param coordX the coordinate to search for
\param global true if coordX is a global position, false otherwise
\return the date and time at coordinate X in the Gantt view.
*/
TQDateTime KDGanttView::getDateTimeForCoordX(int coordX, bool global ) const
{
// default for myTimeHeader->getDateTimeForIndex() is local
return myTimeHeader->getDateTimeForIndex(coordX, !global );
}
/*!
Implements a casted pass-through of the selectionChanged() signal.
*/
void KDGanttView::slotSelectionChanged( TQListViewItem* item )
{
KDGanttViewItem* gItem = static_cast<KDGanttViewItem*>( item );
Q_ASSERT( gItem );
emit lvSelectionChanged( gItem );
}
/*
Implements a casted pass-through of the mouseButtonClicked() signal.
Signals itemLeftClicked() , itemMidClicked() are emitted as well.
*/
void KDGanttView::slotmouseButtonClicked ( int button, TQListViewItem * item,
const TQPoint & pos, int c )
{
KDGanttViewItem* gItem = static_cast<KDGanttViewItem*>( item );
emit lvMouseButtonClicked ( button , gItem, pos, c );
if (gItem == 0 && myCurrentItem != 0 ) {
myCurrentItem = 0;
emit lvCurrentChanged( gItem );
}
if (gItem != 0 && myCurrentItem == 0 ) {
myCurrentItem = gItem;
emit lvCurrentChanged( gItem );
}
// removed - makes no sense!
//emit mouseButtonClicked ( button , gItem, pos, c );
{
switch ( button ) {
case Qt::LeftButton:
emit lvItemLeftClicked( gItem );
emit itemLeftClicked( gItem );
break;
case Qt::MidButton:
emit lvItemMidClicked( gItem );
emit itemMidClicked( gItem );
break;
}
}
}
/*
Implements a casted pass-through of the contextMenuRequested() signal.
The signal itemRightClicked() is emitted as well;
the position is the global position.
*/
void KDGanttView::slotcontextMenuRequested ( TQListViewItem * item, const TQPoint & pos, int col )
{
KDGanttViewItem* gItem = static_cast<KDGanttViewItem*>( item );
emit lvContextMenuRequested ( gItem, pos, col );
emit lvItemRightClicked( gItem );
emit itemRightClicked( gItem );
}
/*
Implements a casted pass-through of the doubleClicked() signal.
*/
void KDGanttView::slotdoubleClicked ( TQListViewItem * item )
{
{
KDGanttViewItem* gItem = static_cast<KDGanttViewItem*>( item );
emit lvItemDoubleClicked( gItem );
emit itemDoubleClicked( gItem );
}
}
/*
Implements a casted pass-through of the currentChanged() signal.
*/
void KDGanttView::slotCurrentChanged ( TQListViewItem * item )
{
KDGanttViewItem* gItem = static_cast<KDGanttViewItem*>( item );
myCurrentItem = gItem;
emit lvCurrentChanged( gItem );
}
/*
Implements a casted pass-through of the itemRenamed() signal.
*/
void KDGanttView::slotItemRenamed ( TQListViewItem * item , int col,
const TQString & text )
{
KDGanttViewItem* gItem = static_cast<KDGanttViewItem*>( item );
emit lvItemRenamed( gItem, col, text );
}
/*
Implements a casted pass-through of the mouseButtonPressed() signal.
*/
void KDGanttView::slotMouseButtonPressed ( int button, TQListViewItem * item,
const TQPoint & pos, int c )
{
KDGanttViewItem* gItem = static_cast<KDGanttViewItem*>( item );
emit lvMouseButtonPressed( button, gItem, pos, c );
}
/*!
Specifies whether the content should be repainted after scrolling or
not.
\param mode If No, there is no repainting after scrolling. This is
the fastest mode.
If Medium, there is extra repainting after releasing the
scrollbar. This provides fast scrolling with updated content
after scrolling. Recommended, when repaint problems occur.
This is the default value after startup.
If Always, there is an extra update after every move of the
scrollbar. This entails slow scrolling with updated
content at all time.
*/
void KDGanttView::setRepaintMode( RepaintMode mode )
{
TQScrollBar *cvh, *cvv;
cvh = myCanvasView->horizontalScrollBar();
cvv = myCanvasView->verticalScrollBar();
// first disconnect
cvh->disconnect( this );
cvv->disconnect( this );
switch ( mode ) {
case No:
break;
case Medium:
connect( cvv, TQT_SIGNAL (sliderReleased () ) ,this, TQT_SLOT(forceRepaint()));
connect( cvh, TQT_SIGNAL (sliderReleased () ) ,this, TQT_SLOT(forceRepaint()));
connect( cvv, TQT_SIGNAL (nextLine () ) ,this, TQT_SLOT(forceRepaint()));
connect( cvh, TQT_SIGNAL (nextLine () ) ,this, TQT_SLOT(forceRepaint()));
connect( cvv, TQT_SIGNAL (prevLine () ) ,this, TQT_SLOT(forceRepaint()));
connect( cvh, TQT_SIGNAL (prevLine () ) ,this, TQT_SLOT(forceRepaint()));
break;
case Always:
connect( cvv, TQT_SIGNAL (valueChanged ( int ) ) ,this, TQT_SLOT(forceRepaint( int )));
connect( cvh, TQT_SIGNAL (valueChanged ( int ) ) ,this, TQT_SLOT(forceRepaint( int )));
connect( cvv, TQT_SIGNAL (sliderReleased () ) ,this, TQT_SLOT(forceRepaint()));
connect( cvh, TQT_SIGNAL (sliderReleased () ) ,this, TQT_SLOT(forceRepaint()));
break;
}
}
void KDGanttView::forceRepaint( int )
{
if ( myTimeTable->blockUpdating() )
return;
// tqDebug("forceRepaint( int ) ");
myTimeTable->setAllChanged();
myTimeTable->update();
}
void KDGanttView::slotHeaderSizeChanged()
{
int legendHeight = 0;
if ( showLegendButton() )
legendHeight = 24;
int listViewHeaderHeight = 0;
if ( headerVisible() )
listViewHeaderHeight = myListView->header()->height();
int timeHeaderHeight = myTimeHeader->height()+myTimeHeaderScroll->frameWidth()*2;;
int diffY = timeHeaderHeight-legendHeight-listViewHeaderHeight;
if ( diffY < 0 ) {
spacerLeft->setFixedHeight( 0 );
spacerRight->setFixedHeight(-diffY);
} else {
spacerRight->setFixedHeight( 0 );
spacerLeft->setFixedHeight( diffY );
}
myLegend->setFixedHeight( legendHeight );
myTimeHeaderContainer->setFixedHeight( timeHeaderHeight );
}
/*!
Specifies whether the legend should be shown as a dock window or not.
\param show if true, show legend as a dock window
\sa showLegend(), legendIsDoctwindow(), legendDoctwindow()
*/void KDGanttView::setLegendIsDoctwindow( bool show )
{
bool isdock = myLegend->asDoctwindow();
if ( show != isdock ) {
myLegend->setAsDoctwindow(show);
// legend is cleared - reinit legend with list
legendItem* li;
for ( li = myLegendItems->first(); li; li = myLegendItems->next() ) {
myLegend->addLegendItem(li->shape, li->color, li->text );
}
}
}
/*!
Returns whether the legend is shown as a dock window
\return true if the legend is shown as a dock window
\sa setShowLegend(), setLegendIsDoctwindow(), legendDoctwindow()
*/bool KDGanttView::legendIsDoctwindow() const
{
return myLegend->asDoctwindow();
}
/*!
Returns the pointer to the legend dock window.
DO NOT DELETE THIS POINTER!
If the legend is not a dock window, 0 is returned
To set the legend as a dock window, call
KDGanttView::setLegendIsDoctwindow( true );
\return the pointer to the legend dock window
0 is returned, if the legend is no dock window
DO NOT DELETE THIS POINTER!
\sa setShowLegend(), setLegendIsDoctwindow(),legendIsDoctwindow()
*/
TQDockWindow* KDGanttView::legendDoctwindow() const
{
return myLegend->dockwindow();
}
/*!
Specifies whether the legend should be shown or not. Besides setting
this programmatically, the user can also show/hide the legend by
using the button provided for this purpose.
\param show force legend to be shown
\sa showLegend()
*/
void KDGanttView::setShowLegend( bool show )
{
myLegend->showMe(show);
}
/*!
Returns whether the legend is currently shown. The visibility of the
legend can be changed both by \a setShowLegend(), and interactively
by the user.
\return true if the legend is currently visible
\sa setShowLegend()
*/
bool KDGanttView::showLegend() const
{
return myLegend->isShown();
}
/*!
Specifies whether the listview of the Gantt view should be shown or
not.
\param show pass true in order to show the listview and false in
order to hide it.
\sa showListView()
*/
void KDGanttView::setShowListView( bool show )
{
if(listViewIsVisible == show) return;
listViewIsVisible = show;
if (listViewIsVisible)
myListView->parentWidget()->show();
else
myListView->parentWidget()->hide();
}
/*!
Returns whether the listview of the Gantt view is shown or not.
\return true if the listview is shown
\sa setShowListView()
*/
bool KDGanttView::showListView() const
{
return listViewIsVisible;
}
/*!
Specifies whether it should be possible to edit the appearance of a
Gantt item visually in a dialog by double-clicking the item.
\param enable pass true in order to enable the visual editor and
false in order to turn it off
\sa editorEnabled()
*/
void KDGanttView::setEditorEnabled( bool enable )
{
editorIsEnabled = enable;
}
/*!
Returns whether it is possible to edit the appearance of a Gantt
item visually in a dialog by double-clicking the item.
\return true if visual editing is enabled, false otherwise
\sa setEditorEnabled()
*/
bool KDGanttView::editorEnabled() const
{
return editorIsEnabled;
}
/*!
Specifies whether the Gantt chart is user-editable.
\param editable pass true in order to get a user-editable Gantt
chart, pass false in order to get a read-only chart
\sa editable()
*/
void KDGanttView::setEditable( bool editable )
{
chartIsEditable = editable;
}
/*!
Returns whether the Gantt chart is user-editable
\return true if the Gantt chart is user-editable
\sa setEditable()
*/
bool KDGanttView::editable() const
{
return chartIsEditable;
}
/*!
Saves the state of the Gantt view in an IO device in XML format. The saved
data can be reloaded with \a loadProject().
\param device a pointer to the IO device in which to store the Gantt
view state.
\return true if the data could be written, false if an error
occurred
\sa loadProject()
*/
bool KDGanttView::saveProject( TQIODevice* device )
{
Q_ASSERT( device );
TQDomDocument doc = saveXML();
if( device->isOpen() )
device->close();
if( device->open( IO_WriteOnly ) ) {
TQTextStream ts( device );
ts << doc.toString();
return true;
} else
return false;
}
/*!
Loads a previously saved state of the Gantt view. All current
settings and items are discarded before loading the data.
\param device a pointer to the IO device from which to load the
Gantt view state.
\return true if the file could be read, false if an error
occurred
\sa saveProject()
*/
bool KDGanttView::loadProject( TQIODevice* device )
{
Q_ASSERT( device );
if( device->isOpen() )
device->close();
if( device->open( IO_ReadOnly ) ) {
TQDomDocument doc( "GanttView" );
TQString err;
int errline, errcol;
if ( !doc.setContent( device, &err, &errline, &errcol ) ) {
tqDebug("KDGantt::Error parsing XML data at line %d. Message is:", errline );
tqDebug("%s ", err.latin1());
device->close();
return false;
}
device->close();
return loadXML( doc );
} else
return false;
}
/*!
Sends a Gantt view to a printer. The printer should already be set
up for printing (by calling TQPrinter::setup()).
If the printer is not set up, TQPrinter::setup() is called before printing
You can specify, whether the ListView, TimeLine, or Legend will be
printed. All combinations of these three widgets are allowed.
\param printer a pointer to the printer to print on. If printer is
0, the method creates a temporary printer and discards it when it is
done printing.
\param printListView if true, the list view is printed
\param printTimeLine if true, the time line is printed
\param printLegend if true, the legend is printed
\sa drawContents()
*/
void KDGanttView::print( TQPrinter* printer ,
bool printListView, bool printTimeLine,
bool printLegend )
{
bool deletePrinter = false;
if (! printer ) {
printer = new TQPrinter();
deletePrinter = true;
if ( !printer->setup()) {
delete printer;
return;
}
}
// now we have a printer to print on
TQPainter p( printer );
// get the paper metrics
TQPaintDeviceMetrics m = TQPaintDeviceMetrics ( printer );
float dx, dy;
// get the size of the desired output for scaling.
// here we want to print all: ListView, TimeLine, and Legend
// for this purpose, we call drawContents() with a 0 pointer as painter
TQSize size = drawContents( 0, printListView, printTimeLine, printLegend );
// at the top, we want to print current time/date
TQString date = "Printing Time: " + TQDateTime::currentDateTime().toString();
int hei = p.boundingRect(0,0, 5, 5, TQt::AlignLeft, date ).height();
p.drawText( 0, 0, date );
// compute the scale
dx = (float) m.width() / (float)size.width();
dy = (float)(m.height() - ( 2 * hei )) / (float)size.height();
float scale;
// scale to fit the width or height of the paper
if ( dx < dy )
scale = dx;
else
scale = dy;
// set the scale
p.scale( scale, scale );
// now printing with y offset: 2 hei
p.translate( 0, 2*hei );
drawContents( &p, printListView, printTimeLine, printLegend );
// the drawContents() has the side effect, that the painter translation is
// after drawContents() set to the bottom of the painted stuff
// for instance a
// p.drawText(0, 0, "printend");
// would be painted directly below the paintout of drawContents()
p.end();
if ( deletePrinter )
delete printer;
}
/*!
Paints a Gantt view on a TQPainter.
You can specify, whether the list view, the time line, or the legend
is painted.
All combinations of these three widgets are allowed.
Returns the size of the painted area.
Paints the list view in the top-left corner, the time line to the
right of the list view, and the legend below the list view.
If called with \a p = 0, nothing is painted and only
the size of the painted area is computed.
This is useful for determining only the painted area and setting
the scale of the painter, before calling this method with a painter.
In order to get the output fitted to your paper and your printer,
call first
TQSize size = drawContents( 0, printListView, printTimeLine, printLegend );
//then compute the scale
dx = paper.width() / size.width();
dy = paper.height() / size.height();
//then make float scale to fit the width or height of the paper
if ( dx < dy )
scale = dx;
else
scale = dy;
// then set the scale
p.scale( scale, scale );
// and now call drawContents with painter p
drawContents( &p, printListView, printTimeLine, printLegend );
For a detailed example, please see the commented source code in
KDGanttView::print(...)
\param p a pointer to the painter to paint on. If p is
0, nothing is painted and only the size of the painted area is computed
\param drawListView if true, the list view is painted
\param drawTimeLine if true, the time line is painted
\param drawLegend if true, the legend is painted
\return the size of the painted area
\sa print()
*/
TQSize KDGanttView::drawContents( TQPainter* p,
bool drawListView , bool drawTimeLine, bool drawLegend )
{
TQSize size;
int lvX, lvY, thX, thY, tlX, tlY, lwX, lwY, allX, allY;
lvX = myListView->contentsWidth();
lvY = myCanvasView->canvas()->height() + 20;
thX = myTimeHeader->width();
thY = myTimeHeader->height();
tlX = myCanvasView->canvas()->width();
tlY = lvY;
lwX = myLegend->legendSize().width();
lwY = myLegend->legendSize().height();
allX = 0;
allY = 0;
if ( drawListView ) {
allX += lvX;
allY += tlY;
}
if ( drawTimeLine ) {
allX += thX;
allY += thY;
}
if ( drawLegend ) {
allY += lwY;
if ( allX < lwX )
allX = lwX ;
}
size = TQSize( allX, allY );
int temp = 0;
if ( p ) {
if ( drawListView ) {
if ( drawTimeLine )
temp = thY;
p->translate( 0, temp );
//HACK: Only draw list headers if we draw timeline, else
// there is no room for it.
myListView->drawToPainter( p, drawTimeLine );
p->translate( lvX, -temp);
}
if ( drawTimeLine ) {
p->translate( myCanvasView->frameWidth(), 0);
myTimeHeader->repaintMe( 0, myTimeHeader->width(), p );
p->translate( -myCanvasView->frameWidth(), thY);
myCanvasView->drawToPainter( p );
if ( drawListView )
p->translate( -lvX, tlY);
else
p->translate( 0, tlY);
} else {
if ( drawListView )
p->translate( -lvX, 0 );
}
if ( drawLegend ) {
myLegend->drawToPainter( p );
p->translate( 0, lwY );
}
}
return size;
}
/*!
Zooms into the Gantt chart. Values less than 1 mean zooming in,
values greater than 1 mean zooming out. A zooming factor of exactly
1.0 means original size.
\param factor the zoom factor
\param absolute if true, factor is interpreted absolutely, if false,
factor is interpreted relatively to the current zoom factor
\sa zoomToFit()
\sa zoomToSelection()
\sa zoomFactor()
*/
void KDGanttView::setZoomFactor( double factor, bool absolute )
{
myTimeHeader->zoom(factor,absolute);
}
/*!
Returns the current zoom factor.
\return the current zoom factor
\sa zoomToFit(), zoomToSelection(), setZoomFactor()
*/
double KDGanttView::zoomFactor() const
{
return myTimeHeader->zoomFactor();
}
/*!
Zooms such that the Gantt chart is less than the available space of the widget.
\sa setZoomFactor()
\sa zoomFactor()
\sa zoomToSelection()
*/
void KDGanttView::zoomToFit()
{
myTimeHeader->zoomToFit();
}
/*!
Zooms so that at least the selected time period is visible after the zoom.
\param start the new font of the widget
\param end the new font of the widget
\sa setZoomFactor()
\sa zoomFactor()
\sa zoomToFit()
*/
void KDGanttView::zoomToSelection( const TQDateTime& start, const TQDateTime& end )
{
myTimeHeader->zoomToSelection( start, end);
}
/*!
Makes sure that the specified Gantt item is visible without
scrolling.
\sa center(), centerTimelineAfterShow()
*/
void KDGanttView::ensureVisible( KDGanttViewItem* item )
{
myListView->ensureItemVisible (item);
}
/*!
Makes sure that the specified TQDateTime is in the center of the
visible Gantt chart (if possible).
If you want to center the timeline when the KDGanttView is hidden,
calling centerTimelineAfterShow() is the better alternative.
\sa center(), centerTimelineAfterShow()
*/
void KDGanttView::centerTimeline( const TQDateTime& center )
{
myTimeHeader->centerDateTime( center );
}
/*!
Makes sure that the specified TQDateTime is in the center of the
visible Gantt chart (if possible). If the KDGanttView is currently
hidden, this method resets the center once again after the next
show() call. Use this method if you want to center the timeline when
the KDGanttView is hidden. After calling KDGanttView::show(), there
may be computations of the sizes of the widgets and subwidgets and
of the automatically computed start datetime. This method ensures
that the center of the timeline is to be properly reset after
show().
\sa center(), centerTimeline()
*/
void KDGanttView::centerTimelineAfterShow( const TQDateTime& center )
{
myTimeHeader->centerDateTime( center );
if ( ! isVisible() ) {
dtCenterTimeLineAfterShow = center;
fCenterTimeLineAfterShow = true;
}
}
/*!
Sets the timeline to the horizon start.
*/
void KDGanttView::setTimelineToStart()
{
myCanvasView->horizontalScrollBar()->setValue( 0 );
}
/*!
Sets the timeline to the horizon end.
*/
void KDGanttView::setTimelineToEnd()
{
myCanvasView->horizontalScrollBar()->setValue(myCanvasView->horizontalScrollBar()->maxValue());
}
/*!
Add \a num minor ticks of the current scale of the timeline
to the start of the timeline.
The timeline is not set automatically at the start.
Call \a setTimelineToStart() to ensure that the timeline is at the start
after calling this method.
\param num the number of minor ticks which should be added
\sa addTicksRight(),setTimelineToStart(), setTimelineToEnd()
*/
void KDGanttView::addTicksLeft( int num )
{
myTimeHeader->addTickLeft( num );
}
/*!
Add \a num minor ticks of the current scale of the timeline
to the end of the timeline.
The timeline is not set automatically at the end.
Call \a setTimelineToEnd() to ensure that the timeline is at the end
after calling this method.
\param num the number of minor ticks which should be added
\sa addTicksLeft(),setTimelineToStart(), setTimelineToEnd()
*/
void KDGanttView::addTicksRight( int num )
{
myTimeHeader->addTickRight( num );
}
/*!
Makes sure that the specified Gantt item is in the center of the
visible Gantt chart (if possible).
*/
void KDGanttView::center( KDGanttViewItem* item )
{
ensureVisible(item);
int x = myListView->contentsWidth()/2;
int y = myListView->itemPos (item );
myListView->center(x,y);
}
/*!
Specifies whether task links should be shown.
\param show true for showing task links, false for not showing them
\sa showTaskLinks(), KDGanttViewTaskLink
*/
void KDGanttView::setShowTaskLinks( bool show )
{
myTimeTable->setShowTaskLinks(show);
}
/*!
Returns whether task links should be shown.
\return true if task links are shown, false otherwise
\sa setShowTaskLinks(), KDGanttViewTaskLink
*/
bool KDGanttView::showTaskLinks() const
{
return myTimeTable->showTaskLinks();
}
/*!
Sets the font in the left list view widget and
in the right time header widget.
The settings of the fonts in the time table widget are not effected.
\param font the new font of the widget
*/
void KDGanttView::setFont(const TQFont& font)
{
myListView->setFont(font);
myListView->repaint();
myTimeHeader->setFont(font);
myLegend->setFont( font );
TQWidget::setFont( font );
setScale(scale());
}
/*!
Specifies whether the configure popup menu should be shown on
right click on the time header widget.
This menu lets the user quickly change
the zoom factor,
the scale mode (minute, hour, day, week, month, auto) ,
the time format,
the year format,
the grid format,
and printing.
The default setting is not to show the popup menu.
This functionality must be enabled explicitly by the application
developer.
You can disable each submenu of the popmenu.
\param show true in order to show the popup menu, false in order not
to. The default is true.
\param showZoom show the zoom submenu, default: true
\param showScale show the scale submenu, default: true
\param showTime show the time format submenu, default: true
\param showYear show the year format submenu, default: true
\param showGrid show the grid submenu, default: true
\param showPrint show the print submenu, default: false
*/
void KDGanttView::setShowHeaderPopupMenu( bool show,
bool showZoom,
bool showScale,
bool showTime,
bool showYear,
bool showGrid,
bool showPrint)
{
myTimeHeader->setShowPopupMenu( show,showZoom,showScale,showTime,
showYear,showGrid,showPrint );
}
/*!
Returns whether the configure popup menu should be shown on right
click on the time header widget.
\return true if the popup menu should be shown
*/
bool KDGanttView::showHeaderPopupMenu() const
{
return myTimeHeader->showPopupMenu();
}
//****************************************************
/*!
Specifies whether the add item popup menu should be shown on
right click on the time table widget.
This menu lets the user quickly add new items to the Gantt view
(as root, as child or after an item).
It also offers cutting and pasting of items.
The default setting is that the popup menu is not shown.
It must be enabled by the program.
\param show true in order to show popup menu, false in order not to
*/
void KDGanttView::setShowTimeTablePopupMenu( bool show )
{
myCanvasView->setShowPopupMenu( show );
}
/*!
Returns whether the add item popup menu should be shown on right
click on the time table widget.
\return true if the popup menu should be shown
*/
bool KDGanttView::showTimeTablePopupMenu() const
{
return myCanvasView->showPopupMenu();
}
/*!
Sets the shapes for a certain type of Gantt item. Not all items use
all three shapes (e.g., only summary items use the middle shape).
This setting overrides any shape settings made on individual items.
These settings will be taken as initial values of any newly created
item of this certain type.
See also the documentation of the KDGanttViewItem class.
\param type the type of Gantt items for which to set the shapes
\param start the shape to use for the beginning of the item
\param middle the shape to use for the middle of the item
\param end the shape to use for the end of the item
\param overwriteExisting if true, overwrites existing shape settings
in the individual items
\sa shapes()
*/
void KDGanttView::setShapes( KDGanttViewItem::Type type,
KDGanttViewItem::Shape start,
KDGanttViewItem::Shape middle,
KDGanttViewItem::Shape end,
bool overwriteExisting )
{
if ( overwriteExisting ) {
TQListViewItemIterator it(myListView);
for ( ; it.current(); ++it ) {
if ( ((KDGanttViewItem*)it.current())->type() == type)
((KDGanttViewItem*)it.current())->setShapes(start,middle, end );
}
}
int index = getIndex( type );
myDefaultShape [index*3] = start;
myDefaultShape [index*3+1] = middle;
myDefaultShape [index*3+2] = end;
undefinedShape[index] = false;
}
/*!
Queries the shapes for a particular type of Gantt item.
\param type the type of Gantt items for which to query the shapes
\param start the start shape is returned in this parameter
\param middle the middle shape is returned in this parameter
\param end the end shape is returned in this parameter
\return true if there was a general shape set for the specified
type. If the return value is false, the values of the three shape
parameters are undefined.
\sa setShapes()
*/
bool KDGanttView::shapes( KDGanttViewItem::Type type,
KDGanttViewItem::Shape& start,
KDGanttViewItem::Shape& middle,
KDGanttViewItem::Shape& end ) const
{
int index = getIndex( type );
start = myDefaultShape [index*3];
middle = myDefaultShape [index*3+1];
end = myDefaultShape [index*3+2];
return !undefinedShape[index];
}
/*!
Sets the colors for a certain type of Gantt item. Not all items use
all three colors (e.g., only summary items use the middle color).
This setting overrides any color settings made on individual items.
These settings will be taken as initial values of any newly created
item of this certain type.
See also the description of the KDGanttViewItem class.
\param type the type of Gantt items for which to set the colors
\param start the color to use for the beginning of the item
\param middle the color to use for the middle of the item
\param end the color to use for the end of the item
\param overwriteExisting if true, overwrites existing color settings
on invididual items
\sa colors(), setDefaultColors(), defaultColors()
*/
void KDGanttView::setColors( KDGanttViewItem::Type type,
const TQColor& start, const TQColor& middle,
const TQColor& end,
bool overwriteExisting )
{
if ( overwriteExisting ) {
TQListViewItemIterator it(myListView);
for ( ; it.current(); ++it ) {
if ( ((KDGanttViewItem*)it.current())->type() == type)
((KDGanttViewItem*)it.current())->setColors(start,middle, end );
}
}
int index = getIndex( type );
myColor [index*3] = start;
myColor [index*3+1] = middle;
myColor [index*3+2] = end;
undefinedColor[index] = false;
}
/*!
Queries the colors for a particular type of Gantt item.
\param type the type of Gantt items for which to query the colors
\param start the start color is returned in this parameter
\param middle the middle color is returned in this parameter
\param end the end color is returned in this parameter
\return true if there was a general color set for the specified
type. If the return value is false, the values of the three color
parameters are undefined.
\sa setColors(), setDefaultColor(), defaultColor()
*/
bool KDGanttView::colors( KDGanttViewItem::Type type,
TQColor& start, TQColor& middle, TQColor& end ) const
{
int index = getIndex( type );
start = myColor [index*3];
middle = myColor [index*3+1];
end = myColor [index*3+2];
return !undefinedColor[index];
}
/*!
Sets the highlight colors for a certain type of Gantt item. Not
all items use all three highlight colors (e.g., only summary items
use the middle highlight color).
This setting overrides any highlight color settings made on
individual items.
These settings will be taken as initial values of any newly created
item of this certain type.
See also the description of the KDGanttViewItem class.
\param type the type of Gantt items for which to set the highlight colors
\param start the highlight color to use for the beginning of the item
\param middle the highlight color to use for the middle of the item
\param end the highlight color to use for the end of the item
\param overwriteExisting if true, overwrites existing color settings
in the individual items
\sa highlightColors(), setDefaultHighlightColor(), defaultHighlightColor()
*/
void KDGanttView::setHighlightColors( KDGanttViewItem::Type type,
const TQColor& start,
const TQColor& middle,
const TQColor& end,
bool overwriteExisting )
{
if ( overwriteExisting ) {
TQListViewItemIterator it(myListView);
for ( ; it.current(); ++it ) {
if ( ((KDGanttViewItem*)it.current())->type() == type)
((KDGanttViewItem*)it.current())->setHighlightColors(start,middle, end );
}
}
int index = getIndex( type );
myColorHL [index*3] = start;
myColorHL [index*3+1] = middle;
myColorHL [index*3+2] = end;
undefinedColorHL[index] = false;
}
/*!
Queries the highlight colors for a particular type of Gantt item.
\param type the type of Gantt items for which to query the highlight
colors
\param start the start highlight color is returned in this parameter
\param middle the middle highlight color is returned in this parameter
\param end the end highlight color is returned in this parameter
\return true if there was a general highlight color set for the specified
type. If the return value is false, the values of the three highlight color
parameters are undefined.
\sa setHighlightColors(), setDefaultHighlightColor(),
defaultHighlightColor()
*/
bool KDGanttView::highlightColors( KDGanttViewItem::Type type,
TQColor& start, TQColor& middle,
TQColor& end ) const
{
int index = getIndex( type );
start = myColorHL [index*3];
middle = myColorHL [index*3+1];
end = myColorHL [index*3+2];
return !undefinedColorHL[index];
}
/*!
Sets the color used for texts in the Gantt chart.
Overrides all individual settings of the Gantt items.
\param color the text color to use
\sa textColor()
*/
void KDGanttView::setTextColor( const TQColor& color )
{
TQListViewItemIterator it(myListView);
for ( ; it.current(); ++it ) {
((KDGanttViewItem*)it.current())->setTextColor(color);
}
myTextColor = color;
}
/*!
Returns the color used for texts in the Gantt chart.
\return the color used for texts in the Gantt chart.
\sa setTextColor()
*/
TQColor KDGanttView::textColor() const
{
return myTextColor;
}
/*!
Specifies the brush in which the 'showNoInformation' line of items
should be drawn.
\param brush the brush of the 'showNoInformation' lines
\sa KDGanttViewItem::showNoInformation(),
KDGanttViewItem::setShowNoInformation(),
KDGanttView::noInformationBrush()
*/
void KDGanttView::setNoInformationBrush( const TQBrush& brush )
{
myTimeTable->setNoInformationBrush( brush );
}
/*!
Returns the brush of the 'showNoInformation' lines
\return the brush of the 'showNoInformation' lines
\sa KDGanttViewItem::showNoInformation(), KDGanttViewItem::setShowNoInformation(),
setNoInformationBrush()
*/
TQBrush KDGanttView::noInformationBrush() const
{
return myTimeTable->noInformationBrush();
}
/*!
Removes all items from the legend.
\sa addLegendItem()
*/
void KDGanttView::clearLegend( )
{
myLegend->clearLegend();
myLegendItems->setAutoDelete( true );
delete myLegendItems;
myLegendItems = new TQPtrList<legendItem>;
}
/*!
Adds an item to the legend.
\param shape the shape to display
\param shapeColor the color in which to display the shape
\param text the text to display
\sa clearLegend()
*/
void KDGanttView::addLegendItem( KDGanttViewItem::Shape shape,
const TQColor& shapeColor,
const TQString& text )
{
myLegend->addLegendItem( shape,shapeColor,text );
legendItem* item = new legendItem;
item->shape = shape;
item->color = shapeColor;
item->text = text;
myLegendItems->append( item );
}
/*!
Sets the start of the horizon of the Gantt chart. If \a start is
null, the horizon start is computed automatically.
\param start the start of the horizon
\sa horizonStart()
*/
void KDGanttView::setHorizonStart( const TQDateTime& start )
{
myTimeHeader->setHorizonStart(start);
}
/*!
Returns the start of the horizon of the Gantt chart.
\return the start of the horizon of the Gantt chart
\sa setHorizonStart()
*/
TQDateTime KDGanttView::horizonStart() const
{
return myTimeHeader->horizonStart();
}
/*!
Sets the end of the horizon of the Gantt chart. If \a end is
null, the horizon end is computed automatically.
\param end the end of the horizon
\sa setHorizonEnd()
*/
void KDGanttView::setHorizonEnd( const TQDateTime& end )
{
myTimeHeader->setHorizonEnd(end);
}
/*!
Returns the end of the horizon of the Gantt chart.
\return the end of the horizon of the Gantt chart
\sa setHorizonEnd()
*/
TQDateTime KDGanttView::horizonEnd() const
{
return myTimeHeader->horizonEnd();
}
/*!
Configures the unit of the lower scale of the header. The higher
unit is computed automatically.
\param unit the unit of the lower scale of the header.
\sa scale()
*/
void KDGanttView::setScale( Scale unit )
{
myTimeHeader->setScale( unit );
}
/*!
Returns the unit of the lower scale of the header.
\return the unit of the lower scale of the header.
\sa setScale()
*/
KDGanttView::Scale KDGanttView::scale() const
{
return myTimeHeader->scale();
}
/*!
Sets the maximum allowed time scale of the lower scale of the header.
\param unit the unit of the lower scale of the header.
\sa scale()
*/
void KDGanttView::setMaximumScale( Scale unit )
{
myTimeHeader->setMaximumScale( unit );
}
/*!
Returns the maximum allowed time scale of the lower scale of the header.
\return the unit of the lower scale of the header.
\sa setScale()
*/
KDGanttView::Scale KDGanttView::maximumScale() const
{
return myTimeHeader->maximumScale();
}
/*!
Sets the minimum allowed time scale of the lower scale of the header.
\param unit the unit of the lower scale of the header.
\sa scale()
*/
void KDGanttView::setMinimumScale( Scale unit )
{
myTimeHeader->setMinimumScale( unit );
}
/*!
Returns the minimum allowed time scale of the lower scale of the header.
\return the unit of the lower scale of the header.
\sa setScale()
*/
KDGanttView::Scale KDGanttView::minimumScale() const
{
return myTimeHeader->minimumScale();
}
/*!
Sets the absolute number of minor ticks, if scaling is set to Auto.
If the scale mode is set to Auto, then the actual scale and
the minorScaleCount is automatically computed, such that there are
count minor ticks
\param count the number of minor ticks
\sa autoScaleMinorTickCount(),setScale(),scale()
*/
void KDGanttView::setAutoScaleMinorTickCount( int count )
{
myTimeHeader->setAutoScaleMinorTickCount( count );
}
/*!
Returns the absolut number of minor ticks, if scaling is set to Auto
\return the absolut number of minor ticks
\sa setAutoScaleMinorTickCount(),setScale(),scale()
*/
int KDGanttView::autoScaleMinorTickCount() const
{
return myTimeHeader->autoScaleMinorTickCount();
}
/*!
Sets the minimum width that a column needs to have. If the size of the
Gantt chart and the scale would make it necessary to go below this
limit otherwise, the chart will automatically be made less exact.
\param width the minimum column width
\sa minimumColumnWidth()
*/
void KDGanttView::setMinimumColumnWidth( int width )
{
myTimeHeader->setMinimumColumnWidth( width );
}
/*!
Returns the minimum width a column needs to have.
\return the column minimum width
\sa setMinimumColumnWidth()
*/
int KDGanttView::minimumColumnWidth() const
{
return myTimeHeader->minimumColumnWidth();
}
/*!
Specifies the format in which to display years. If no years are
shown, this method has no effect.
\param format the year format
\sa yearFormat(), setHourFormat(), hourFormat()
*/
void KDGanttView::setYearFormat( YearFormat format )
{
myTimeHeader->setYearFormat(format );
}
/*!
Returns the format in which to display years.
\return the year format
\sa setYearFormat(), setHourFormat(), hourFormat()
*/
KDGanttView::YearFormat KDGanttView::yearFormat() const
{
return myTimeHeader->yearFormat();
}
/*!
Specifies the format in which to display hours. If no hours are
shown, this method has no effect.
\param format the hour format
\sa hourFormat(), setYearFormat(), yearFormat()
*/
void KDGanttView::setHourFormat( HourFormat format )
{
myTimeHeader->setHourFormat( format );
}
/*!
Returns the format in which to display hours.
\return the hour format
\sa setHourFormat(), setYearFormat(), yearFormat()
*/
KDGanttView::HourFormat KDGanttView::hourFormat() const
{
return myTimeHeader->hourFormat();
}
/*!
Hides/shows the grid for the major ticks of the time header in the gantt view.
\param show true in order to show ticks, false in order to hide them.
If show is true, setShowMinorTicks( false ) is performed automatically
to hide the grid of the minor ticks.
In order to show now grid, call setShowMinorTicks( false ) and
setShowMajorTicks( false ).
\sa showMajorTicks(), setShowMinorTicks(), showMinorTicks()
*/
void KDGanttView::setShowMajorTicks( bool show )
{
myTimeHeader->setShowMajorTicks(show );
}
/*!
Returns whether the grid is shown on the major scale.
\return true if ticks are shown on the major scale
\sa setShowMajorTicks(), setShowMinorTicks(), showMinorTicks()
*/
bool KDGanttView::showMajorTicks() const
{
return myTimeHeader->showMajorTicks();
}
/*!
Hides/shows the grid for the minor ticks of the time header in the gantt view.
\param show true in order to show ticks, false in order to hide them.
If show is true, setShowMajorTicks( false ) is performed automatically
to hide the grid of the major ticks.
In order to show now grid, call setShowMinorTicks( false ) and
setShowMajorTicks( false ).
\sa showMinorTicks(), setShowMajorTicks(), showMajorTicks()
*/
void KDGanttView::setShowMinorTicks( bool show)
{
myTimeHeader->setShowMinorTicks( show );
}
/*!
Returns whether ticks are shown on the minor scale.
\return true if ticks are shown on the minor scale
\sa setShowMinorTicks(), setShowMajorTicks(), showMajorTicks()
*/
bool KDGanttView::showMinorTicks() const
{
return myTimeHeader->showMinorTicks();
}
/*!
Sets the background color for the column closest to \a column.
It can be specified whether the color should be shown in all scales or
only in specific scales.
If you want to define the color only for the daily view, specify
mini and maxi as Day.
If there is no value specified for mini and maxi, the color for the column
is shown on all scales. Note that it is possible that there are two
values for a column in a scale. In this case, the shown color is unspecified.
\param column the column to set the background color for
\param color the background color
\param mini show the colour only in scales greater than this
\param maxi show the colour only in scales lesser than this
\sa columnBackgroundColor(), setWeekendBackgroundColor(),
weekendBackgroundColor()
*/
void KDGanttView::setColumnBackgroundColor( const TQDateTime& column,
const TQColor& color ,
Scale mini, Scale maxi )
{
myTimeHeader->setColumnBackgroundColor( column, color,mini,maxi );
}
/*!
Sets the background color for a time interval given by \a start and
\a end. \a start may be later than \a end. If there is already a
background interval with the same \a start and \a end values
defined, the values (i.e. const TQColor& color , Scale mini, Scale
maxi) of this background interval are changed. Change the times of
an already defined interval with \a changeBackgroundInterval().
Delete an already defined interval with \a
deleteBackgroundInterval().
It can be defined, whether the color should be shown in all scales or
only in specific scales.
If you want to define the color only for the daily view, scecify
mini and maxi as Day.
If there is no value for mini/maxi specified, the color for the columns
is shown in all scales.
\param start start datetime of the time interval
\param end end datetime of the time interval
\param color the background color
\param mini show the color only in scales greater than this
\param maxi show the color only in scales lesser than this
\sa changeBackgroundInterval(), deleteBackgroundInterval(),
columnBackgroundColor(), setWeekendBackgroundColor(),
weekendBackgroundColor()
*/
void KDGanttView::setIntervalBackgroundColor( const TQDateTime& start,
const TQDateTime& end,
const TQColor& color ,
Scale mini, Scale maxi )
{
myTimeHeader->setIntervalBackgroundColor( start, end, color,mini,maxi );
}
/*!
Changes the times of an already defined background color interval.
The new values \a startnew and \a endnew should not be datetime
values of an already defined background color interval.
If that is the case, nothing is changed and false is returned.
\param oldstart the start date and time of the interval to change
\param oldend the end date and time of the interval to change
\param newstart the new start date and time
\param newend the new end date and time
\return true, if there is a backgroundcolor interval with values
\a start and \a end found and the new values \a startnew and \a endnew
are not datetime values of an already defined background color interval.
Returns false otherwise.
\sa changeBackgroundInterval(), deleteBackgroundInterval(),
columnBackgroundColor(), setWeekendBackgroundColor(),
weekendBackgroundColor()
*/
bool KDGanttView::changeBackgroundInterval( const TQDateTime& oldstart,
const TQDateTime& oldend,
const TQDateTime& newstart,
const TQDateTime& newend )
{
return myTimeHeader->changeBackgroundInterval( oldstart, oldend,
newstart, newend );
}
/*!
Deletes an already defined background color interval.
\param start start datetime of time interval
\param end end datetime of time interval
\return true, if there is a backgroundcolor interval with values
\a start and \a end found (and hence deleted).
\sa changeBackgroundInterval(), columnBackgroundColor()
*/
bool KDGanttView::deleteBackgroundInterval( const TQDateTime& start,
const TQDateTime& end)
{
return myTimeHeader->deleteBackgroundInterval( start, end );
}
/*!
Removes all background color settings set with setColumnBackgroundColor()
and setIntervalBackgroundColor().
Does not affect the settings of setWeekendBackgroundColor().
\sa setColumnBackgroundColor(), setWeekendBackgroundColor(),
weekendBackgroundColor(), setIntervalBackgroundColor()
*/
void KDGanttView::clearBackgroundColor()
{
myTimeHeader->clearBackgroundColor();
}
/*!
Returns the background color for the column closest to \a column.
\param column the column to query the background color for
\return the background color of the specified color
\sa setColumnBackgroundColor(), setWeekendBackgroundColor(),
weekendBackgroundColor()
*/
TQColor KDGanttView::columnBackgroundColor( const TQDateTime& column ) const
{
return myTimeHeader->columnBackgroundColor( column ) ;
}
/*!
Specifies the background color for weekend days. If no individual
days are visible on the Gantt chart, this method has no visible
effect.
\param color the background color to use for weekend days.
\sa weekendBackgroundColor(), setWeekendDays(), weekendDays()
*/
void KDGanttView::setWeekendBackgroundColor( const TQColor& color )
{
myTimeHeader->setWeekendBackgroundColor( color );
}
/*!
Returns the background color for weekend days.
\return the background color for weekend days
\sa setWeekendBackgroundColor(), setWeekendDays(), weekendDays()
*/
TQColor KDGanttView::weekendBackgroundColor() const
{
return myTimeHeader->weekendBackgroundColor();
}
/*!
Specifies the background color for weekday days. If no individual
days are visible on the Gantt chart, this method has no visible
effect. The days are specified as an intervals of integer values
where 1 means Monday and 7 means Sunday.
\param color the background color to use for weekend days.
\param weekday the day of the week (Monday = 1, Sunday = 7)
\sa weekendBackgroundColor(), setWeekendDays(), weekendDays()
*/
void KDGanttView::setWeekdayBackgroundColor( const TQColor& color, int weekday )
{
myTimeHeader->setWeekdayBackgroundColor( color, weekday );
}
/*!
Returns the background color for weekday days.
\param weekday the day of the week (Monday = 1, Sunday = 7)
\return the background color for weekend days
\sa setWeekendBackgroundColor(), setWeekendDays(), weekendDays()
*/
TQColor KDGanttView::weekdayBackgroundColor(int weekday) const
{
return myTimeHeader->weekdayBackgroundColor( weekday);
}
/*!
Defines which days are considered weekends. The days are specified
as an interval of integer values where 1 means Monday and 7 means
Sunday. In order to define a weekend from Sunday to Monday, specify
(7,1).
\param start the first day of the weekend
\param end the last day of the weekend
\sa weekendDays(), setWeekendBackgroundColor(), weekendBackgroundColor()
*/
void KDGanttView::setWeekendDays( int start, int end )
{
myTimeHeader->setWeekendDays( start, end );
}
/*!
Returns which days are considered weekends.
\param start in this parameter, the first day of the weekend is returned
\param end in this parameter, the end day of the weekend is returned
\sa setWeekendDays(), setWeekendBackgroundColor(), weekendBackgroundColor()
*/
void KDGanttView::weekendDays( int& start, int& end ) const
{
myTimeHeader->weekendDays( start, end );
}
/*!
\fn void KDGanttView::itemLeftClicked( KDGanttViewItem* )
This signal is emitted when the user clicks on an item with the left
mouse button.
*/
/*!
\fn void KDGanttView::itemMidClicked( KDGanttViewItem* )
This signal is emitted when the user clicks on an item with the middle
mouse button.
*/
/*!
\fn void KDGanttView::itemRightClicked( KDGanttViewItem* )
This signal is emitted when the user clicks on an item with the right
mouse button.
*/
/*!
\fn void KDGanttView::itemDoubleClicked( KDGanttViewItem* )
This signal is emitted when the user double-clicks an item.
*/
/*!
\fn void KDGanttView::itemConfigured( KDGanttViewItem* )
This signal is emitted when the user has configured an item
visually.
*/
/*!
\fn void KDGanttView::taskLinkLeftClicked( KDGanttViewTaskLink* )
This signal is emitted when the user clicks on a task link with the
left mouse button.
*/
/*!
\fn void KDGanttView::taskLinkMidClicked( KDGanttViewTaskLink* )
This signal is emitted when the user clicks on a task link with the
middle mouse button.
*/
/*!
\fn void KDGanttView::taskLinkRightClicked( KDGanttViewTaskLink* )
This signal is emitted when the user clicks on a task link with the
right mouse button.
*/
/*!
\fn void KDGanttView::taskLinkDoubleClicked( KDGanttViewTaskLink* )
This signal is emitted when the user double-clicks a task link.
*/
/*!
\enum KDGanttView::YearFormat
This enum is used to specify the year format used in the header.
*/
/*!
\enum KDGanttView::HourFormat
This enum is used to specify the hour format used in the header.
*/
/*!
\enum KDGanttView::Scale
This enum is used to specify the units of the scales in the header.
*/
/*!
Sets the number of ticks in the major scale.
\param count the number of ticks in the major scale
\sa majorScaleCount(), setMinorScaleCount(), minorScaleCount()
*/
void KDGanttView::setMajorScaleCount( int count )
{
myTimeHeader->setMajorScaleCount(count );
}
/*!
Returns the number of ticks per unit in the major scale.
\return the number of ticks in the major scale
\sa setMajorScaleCount(), setMinorScaleCount(), minorScaleCount()
*/
int KDGanttView::majorScaleCount() const
{
return myTimeHeader->majorScaleCount();
}
/*!
Sets the number of ticks in the minor scale.
\param count the number of ticks in the minor scale
\sa minorScaleCount, setMajorScaleCount, majorScaleCount()
*/
void KDGanttView::setMinorScaleCount( int count )
{
myTimeHeader->setMinorScaleCount(count );
}
/*!
Returns the number of ticks per unit in the minor scale.
\return the number of ticks in the minor scale
\sa setMinorScaleCount(), setMajorScaleCount(), majorScaleCount()
*/
int KDGanttView::minorScaleCount() const
{
return myTimeHeader->minorScaleCount();
}
/*!
Sets the default color for a particular type of Gantt item that is
used for the item if no specific start, middle, or end colors are
set.
\param type the type of Gantt items for which to query the highlight
colors
\param color the default color to use
\param overwriteExisting if true, existing settings for individual
items are overwritten
\sa defaultColor(), setColors(), colors()
*/
void KDGanttView::setDefaultColor( KDGanttViewItem::Type type,
const TQColor& color,
bool overwriteExisting )
{
if ( overwriteExisting ) {
TQListViewItemIterator it(myListView);
for ( ; it.current(); ++it ) {
if ( ((KDGanttViewItem*)it.current())->type() == type)
((KDGanttViewItem*)it.current())->setDefaultColor(color );
}
}
int index = getIndex( type );
myDefaultColor [index] = color;
}
/*!
Returns the default color for a particular type of Gantt item that
is used for the item if no specific start, middle, or end colors are
set.
\param type the type of Gantt items for which to query the highlight
colors
\return color the default color used
\sa setDefaultColor(), setColors(), colors()
*/
TQColor KDGanttView::defaultColor( KDGanttViewItem::Type type ) const
{
int index = getIndex( type );
return myDefaultColor [index];
}
/*!
Sets the default highlighting color for a particular type of
Gantt item that is used for the item if no specific start, middle,
or end colors are set.
\param type the type of Gantt items for which to query the highlight
colors
\param color the default highlighting color to use
\param overwriteExisting if true, existing color settings in
individual items are overwritten
\sa defaultHighlightColor(), setHighlightColors(), highlightColors()
*/
void KDGanttView::setDefaultHighlightColor( KDGanttViewItem::Type type,
const TQColor& color,
bool overwriteExisting )
{
if ( overwriteExisting ) {
TQListViewItemIterator it(myListView);
for ( ; it.current(); ++it ) {
if ( ((KDGanttViewItem*)it.current())->type() == type)
((KDGanttViewItem*)it.current())->setDefaultHighlightColor(color );
}
}
int index = getIndex( type );
myDefaultColorHL [index] = color;
}
/*!
Returns the default highlighting color for a particular type of
Gantt item that is used for the item if no specific start, middle,
or end colors are set.
\param type the type of Gantt items for which to query the highlight
colors
\return color the default highlighting color used
\sa setDefaultHighlightColor(), setHighlightColors(), highlightColors()
*/
TQColor KDGanttView::defaultHighlightColor( KDGanttViewItem::Type type ) const
{
int index = getIndex( type );
return myDefaultColorHL [index];
}
/*!
Returns the first item in the Gantt view.
\return the first item in the Gantt view, 0 if there are no items
*/
KDGanttViewItem* KDGanttView::firstChild() const
{
return (KDGanttViewItem*)myListView->firstChild();
}
/*!
This method turns calendar mode on and off. In calendar mode, only
those items can be opened which have subitems which have
subitems. I.e., if an item contains multiple calendars, it can be
opened, but not a calendar item itself. If you want to use this
GanttView as a calendar view, you have to call
setDisplaySubitemsAsGroup( true ); to use the root items as calendar
items. To create new calendar entries for these root items, create
a new KDGanttViewTaskItem with this root item as a parent. If you
want an item with subitems to behave like a calendar (which is
possibly empty at startup), please call setIsCalendar( true ); for
this item.
\param mode if true, the calendar view mode is turned on
if false, the calendar view mode is turned off
\sa setDisplaySubitemsAsGroup(), displaySubitemsAsGroup(), calendarMode()
*/
void KDGanttView::setCalendarMode( bool mode )
{
myListView->setCalendarMode( mode );
}
/*!
Returns true, if the Gantt view is in calendar mode. See
setCalendarMode() for the meaning of calendar mode.
\return returns true, if the Gantt view is in calendermode
\sa setCalendarMode()
*/
bool KDGanttView::calendarMode() const
{
return myListView->calendarMode();
}
/*!
This method specifies whether hidden subitems should be displayed.
It iterates over all KDGanttViewItems in this Gantt view
and sets their displaySubitemsAsGroup() property.
All newly created items will have this setting by default.
\param show if true, the hidden subitems are displayed in all items of
this Gantt view.
\sa KDGanttViewItem::setDisplaySubitemsAsGroup(), KDGanttViewItem::displaySubitemsAsGroup()
*/
void KDGanttView::setDisplaySubitemsAsGroup( bool show )
{
TQListViewItemIterator it( myListView );
for ( ; it.current(); ++it ) {
KDGanttViewItem* currentItem = ( KDGanttViewItem* )it.current();
currentItem->setDisplaySubitemsAsGroup( show );
}
_displaySubitemsAsGroup = show;
}
/*!
Returns, whether new items are created with the
displayHiddenSubitems property.
\return true, if hidden subitems should be displayed on newly created items.
\sa setDisplaySubitemsAsGroup(),
KDGanttViewItem::setDisplaySubitemsAsGroup(),
KDGanttViewItem::displaySubitemsAsGroup()
*/
bool KDGanttView::displaySubitemsAsGroup() const
{
return _displaySubitemsAsGroup;
}
/*!
This method specifies whether tasks where the start time and the end
time are the same are displayed
as a line over the full height of the Gantt view.
\param show if true, tasks with starttime == endtime are displayed
as a line
*/
void KDGanttView::setDisplayEmptyTasksAsLine( bool show )
{
_displayEmptyTasksAsLine = show;
}
/*!
Returns, whether tasks where the start time and the end time are the
same are displayed
as a line over the full height of the Gantt view.
\return true, if empty tasks are displayed as line.
*/
bool KDGanttView::displayEmptyTasksAsLine() const
{
return _displayEmptyTasksAsLine;
}
/*!
Defines the horizontal background lines of the Gantt chart.
Call setHorBackgroundLines()
(equivalent to setHorBackgroundLines( 2, TQBrush( TQColor ( 240,240,240 )) ) )
to draw a light grey horizontal background line for every second Gantt item.
Call setHorBackgroundLines(0) in order to not show horizontal
background lines.
You may specify the number of lines and the brush of the lines.
\param count for count >= 2, every count line gets a backgroud
specified by brush
for count < 2, no background lines are drawn
\param brush the brush of the lines
*/
void KDGanttView::setHorBackgroundLines( int count, TQBrush brush )
{
myTimeTable->setHorBackgroundLines( count, brush );
}
/*!
Returns the definition of the horizontal background lines of the
Gantt chart.
\param brush the brush of the lines
\return every nth line gets a background specified by brush
if 0 is returned, no backgroud lines are drawn
*/
int KDGanttView::horBackgroundLines( TQBrush& brush )
{
return myTimeTable->horBackgroundLines( brush );
}
/*!
Returns the last item in the Gantt view
\return the last item in the Gantt view, 0 if there are no items
*/
KDGanttViewItem* KDGanttView::lastItem() const
{
return (KDGanttViewItem*)myListView->lastItem ();
}
/*!
Returns the list of task links in the Gantt view.
\return the list of task links in the Gantt view
*/
TQPtrList<KDGanttViewTaskLink> KDGanttView::taskLinks() const
{
return myTimeTable->taskLinks();
}
/*!
Returns the list of task link groups in the Gantt view.
\return the list of task link groups in the Gantt view
*/
TQPtrList<KDGanttViewTaskLinkGroup> KDGanttView::taskLinkGroups() const
{
return myTaskLinkGroupList;
}
/**
Reads the parameters of the view from an XML document.
\param doc the XML document to read from
\return true if the parameters could be read, false if a file
format error occurred
\sa saveXML
*/
bool KDGanttView::loadXML( const TQDomDocument& doc )
{
TQDomElement docRoot = doc.documentElement(); // ChartParams element
TQDomNode node = docRoot.firstChild();
while( !node.isNull() ) {
TQDomElement element = node.toElement();
if( !element.isNull() ) { // was really an element
TQString tagName = element.tagName();
if( tagName == "ShowLegend" ) {
bool value;
if( KDGanttXML::readBoolNode( element, value ) )
setShowLegend( value );
} else if( tagName == "ShowLegendButton" ) {
bool value;
if( KDGanttXML::readBoolNode( element, value ) )
setShowLegendButton( value );
} else if( tagName == "LegendIsDockWindow" ) {
bool value;
if( KDGanttXML::readBoolNode( element, value ) )
setLegendIsDoctwindow( value );
} else if( tagName == "ShowListView" ) {
bool value;
if( KDGanttXML::readBoolNode( element, value ) )
setShowListView( value );
} else if( tagName == "ShowHeader" ) {
bool value;
if( KDGanttXML::readBoolNode( element, value ) )
setHeaderVisible( value );
} else if( tagName == "ShowTaskLinks" ) {
bool value;
if( KDGanttXML::readBoolNode( element, value ) )
setShowTaskLinks( value );
} else if( tagName == "EditorEnabled" ) {
bool value;
if( KDGanttXML::readBoolNode( element, value ) )
setEditorEnabled( value );
} else if( tagName == "DisplayEmptyTasksAsLine" ) {
bool value;
if( KDGanttXML::readBoolNode( element, value ) )
setDisplayEmptyTasksAsLine( value );
} else if( tagName == "GlobalFont" ) {
TQFont font;
if( KDGanttXML::readFontNode( element, font ) )
setFont( font );
} else if( tagName == "HorizonStart" ) {
TQDateTime value;
if( KDGanttXML::readDateTimeNode( element, value ) )
setHorizonStart( value );
} else if( tagName == "HorizonEnd" ) {
TQDateTime value;
if( KDGanttXML::readDateTimeNode( element, value ) )
setHorizonEnd( value );
} else if( tagName == "Scale" ) {
TQString value;
if( KDGanttXML::readStringNode( element, value ) )
setScale( stringToScale( value ) );
} else if( tagName == "MinimumScale" ) {
TQString value;
if( KDGanttXML::readStringNode( element, value ) )
setMinimumScale( stringToScale( value ) );
} else if( tagName == "MaximumScale" ) {
TQString value;
if( KDGanttXML::readStringNode( element, value ) )
setMaximumScale( stringToScale( value ) );
} else if( tagName == "YearFormat" ) {
TQString value;
if( KDGanttXML::readStringNode( element, value ) )
setYearFormat( stringToYearFormat( value ) );
} else if( tagName == "HourFormat" ) {
TQString value;
if( KDGanttXML::readStringNode( element, value ) )
setHourFormat( stringToHourFormat( value ) );
} else if( tagName == "ShowMinorTicks" ) {
bool value;
if( KDGanttXML::readBoolNode( element, value ) )
setShowMinorTicks( value );
} else if( tagName == "ShowMajorTicks" ) {
bool value;
if( KDGanttXML::readBoolNode( element, value ) )
setShowMajorTicks( value );
} else if( tagName == "DragEnabled" ) {
bool value;
if( KDGanttXML::readBoolNode( element, value ) )
setDragEnabled( value );
} else if( tagName == "DropEnabled" ) {
bool value;
if( KDGanttXML::readBoolNode( element, value ) )
setDropEnabled( value );
} else if( tagName == "CalendarMode" ) {
bool value;
if( KDGanttXML::readBoolNode( element, value ) )
setCalendarMode( value );
} else if( tagName == "Editable" ) {
bool value;
if( KDGanttXML::readBoolNode( element, value ) )
setEditable( value );
} else if( tagName == "TextColor" ) {
TQColor value;
if( KDGanttXML::readColorNode( element, value ) )
setTextColor( value );
} else if( tagName == "MajorScaleCount" ) {
int value;
if( KDGanttXML::readIntNode( element, value ) )
setMajorScaleCount( value );
} else if( tagName == "MinorScaleCount" ) {
int value;
if( KDGanttXML::readIntNode( element, value ) )
setMinorScaleCount( value );
} else if( tagName == "AutoScaleMinorTickCount" ) {
int value;
if( KDGanttXML::readIntNode( element, value ) )
setAutoScaleMinorTickCount( value );
} else if( tagName == "MinimumColumnWidth" ) {
int value;
if( KDGanttXML::readIntNode( element, value ) )
setMinimumColumnWidth( value );
} else if( tagName == "GanttMaximumWidth" ) {
int value;
if( KDGanttXML::readIntNode( element, value ) )
setGanttMaximumWidth( value );
} else if( tagName == "NoInformationBrush" ) {
TQBrush value;
if( KDGanttXML::readBrushNode( element, value ) )
setNoInformationBrush( value );
} else if( tagName == "GanttViewBackgroundColor" ) {
TQColor value;
if( KDGanttXML::readColorNode( element, value ) )
setGvBackgroundColor( value );
} else if( tagName == "ListViewBackgroundColor" ) {
TQColor value;
if( KDGanttXML::readColorNode( element, value ) )
setLvBackgroundColor( value );
} else if( tagName == "TimeHeaderBackgroundColor" ) {
TQColor value;
if( KDGanttXML::readColorNode( element, value ) )
setTimeHeaderBackgroundColor( value );
} else if( tagName == "LegendHeaderBackgroundColor" ) {
TQColor value;
if( KDGanttXML::readColorNode( element, value ) )
setLegendHeaderBackgroundColor( value );
} else if( tagName == "WeekendBackgroundColor" ) {
TQColor value;
if( KDGanttXML::readColorNode( element, value ) )
setWeekendBackgroundColor( value );
} else if( tagName == "WeekdayBackgroundColor" ) {
TQDomNode node = element.firstChild();
int day = 0;
TQColor color;
while( !node.isNull() ) {
TQDomElement element = node.toElement();
if( !element.isNull() ) { // was really an elemente
TQString tagName = element.tagName();
if( tagName == "Day" ) {
int value;
if( KDGanttXML::readIntNode( element, value ) )
day = value;
} else if( tagName == "Color" ) {
TQColor value;
if( KDGanttXML::readColorNode( element, value ) )
color = value;
} else {
tqDebug( "Unrecognized tag name: %s", tagName.latin1() );
Q_ASSERT( false );
}
}
node = node.nextSibling();
}
if( day && color.isValid() )
setWeekdayBackgroundColor( color, day );
} else if( tagName == "WeekendDays" ) {
TQString startString = element.attribute( "Start" );
TQString endString = element.attribute( "End" );
bool startOk = false, endOk = false;
int start = startString.toInt( &startOk );
int end = startString.toInt( &endOk );
if( startOk && endOk )
setWeekendDays( start, end );
} else if( tagName == "ZoomFactor" ) {
double value;
if( KDGanttXML::readDoubleNode( element, value ) )
setZoomFactor( value, true );
} else if( tagName == "ShowHeaderPopupMenu" ) {
bool value;
if( KDGanttXML::readBoolNode( element, value ) )
setShowHeaderPopupMenu( value );
} else if( tagName == "ShowTimeTablePopupMenu" ) {
bool value;
if( KDGanttXML::readBoolNode( element, value ) )
setShowTimeTablePopupMenu( value );
} else if( tagName == "Shapes" ) {
TQDomNode node = element.firstChild();
bool undefinedShape = false;
while( !node.isNull() ) {
TQDomElement element = node.toElement();
if( !element.isNull() ) { // was really an elemente
TQString tagName = element.tagName();
if( tagName == "Event" ) {
KDGanttViewItem::Shape startShape, middleShape, endShape;
startShape = KDGanttViewItem::TriangleDown;
middleShape = KDGanttViewItem::TriangleDown;
endShape = KDGanttViewItem::TriangleDown;
TQDomNode node = element.firstChild();
while( !node.isNull() ) {
TQDomElement element = node.toElement();
if( !element.isNull() ) { // was really an elemente
TQString tagName = element.tagName();
if( tagName == "Start" ) {
TQString value;
if( KDGanttXML::readStringNode( element, value ) )
startShape = KDGanttViewItem::stringToShape( value );
if ( value == "Undefined" )
undefinedShape = true;
} else if( tagName == "Middle" ) {
TQString value;
if( KDGanttXML::readStringNode( element, value ) )
middleShape = KDGanttViewItem::stringToShape( value );
if ( value == "Undefined" )
undefinedShape = true;
} else if( tagName == "End" ) {
TQString value;
if( KDGanttXML::readStringNode( element, value ) )
endShape = KDGanttViewItem::stringToShape( value );
if ( value == "Undefined" )
undefinedShape = true;
} else {
tqDebug( "Unrecognized tag name: %s", tagName.latin1() );
Q_ASSERT( false );
}
}
node = node.nextSibling();
}
if ( ! undefinedShape )
setShapes( KDGanttViewItem::Event, startShape,
middleShape, endShape, false );
undefinedShape = false;
} else if( tagName == "Task" ) {
KDGanttViewItem::Shape startShape, middleShape, endShape;
startShape = KDGanttViewItem::TriangleDown;
middleShape = KDGanttViewItem::TriangleDown;
endShape = KDGanttViewItem::TriangleDown;
TQDomNode node = element.firstChild();
while( !node.isNull()) {
TQDomElement element = node.toElement();
if( !element.isNull() ) { // was really an elemente
TQString tagName = element.tagName();
if( tagName == "Start" ) {
TQString value;
if( KDGanttXML::readStringNode( element, value ) )
startShape = KDGanttViewItem::stringToShape( value );
if ( value == "Undefined" )
undefinedShape = true;
} else if( tagName == "Middle" ) {
TQString value;
if( KDGanttXML::readStringNode( element, value ) )
middleShape = KDGanttViewItem::stringToShape( value );
if ( value == "Undefined" )
undefinedShape = true;
} else if( tagName == "End" ) {
TQString value;
if( KDGanttXML::readStringNode( element, value ) )
endShape = KDGanttViewItem::stringToShape( value );
if ( value == "Undefined" )
undefinedShape = true;
} else {
tqDebug( "Unrecognized tag name: %s", tagName.latin1() );
Q_ASSERT( false );
}
}
node = node.nextSibling();
}
if ( ! undefinedShape )
setShapes( KDGanttViewItem::Task, startShape, middleShape, endShape, false );
undefinedShape = false;
} else if( tagName == "Summary" ) {
KDGanttViewItem::Shape startShape, middleShape, endShape;
startShape = KDGanttViewItem::TriangleDown;
middleShape = KDGanttViewItem::TriangleDown;
endShape = KDGanttViewItem::TriangleDown;
TQDomNode node = element.firstChild();
while( !node.isNull() ) {
TQDomElement element = node.toElement();
if( !element.isNull() ) { // was really an elemente
TQString tagName = element.tagName();
if( tagName == "Start" ) {
TQString value;
if( KDGanttXML::readStringNode( element, value ) )
startShape = KDGanttViewItem::stringToShape( value );
if ( value == "Undefined" )
undefinedShape = true;
} else if( tagName == "Middle" ) {
TQString value;
if( KDGanttXML::readStringNode( element, value ) )
middleShape = KDGanttViewItem::stringToShape( value );
if ( value == "Undefined" )
undefinedShape = true;
} else if( tagName == "End" ) {
TQString value;
if( KDGanttXML::readStringNode( element, value ) )
endShape = KDGanttViewItem::stringToShape( value );
if ( value == "Undefined" )
undefinedShape = true;
} else {
tqDebug( "Unrecognized tag name: %s", tagName.latin1() );
Q_ASSERT( false );
}
}
node = node.nextSibling();
}
if ( ! undefinedShape )
setShapes( KDGanttViewItem::Summary, startShape,
middleShape, endShape, false );
undefinedShape = false;
} else {
tqDebug( "Unrecognized tag name: %s", tagName.latin1() );
Q_ASSERT( false );
}
}
node = node.nextSibling();
}
} else if( tagName == "Colors" ) {
TQDomNode node = element.firstChild();
while( !node.isNull()) {
TQDomElement element = node.toElement();
if( !element.isNull() ) { // was really an elemente
TQString tagName = element.tagName();
if( tagName == "Event" ) {
TQColor startColor, middleColor, endColor;
TQDomNode node = element.firstChild();
while( !node.isNull() ) {
TQDomElement element = node.toElement();
if( !element.isNull() ) { // was really an elemente
TQString tagName = element.tagName();
if( tagName == "Start" ) {
TQColor value;
if( KDGanttXML::readColorNode( element, value ) )
startColor = value;
} else if( tagName == "Middle" ) {
TQColor value;
if( KDGanttXML::readColorNode( element, value ) )
middleColor = value;
} else if( tagName == "End" ) {
TQColor value;
if( KDGanttXML::readColorNode( element, value ) )
endColor = value;
} else {
tqDebug( "Unrecognized tag name: %s", tagName.latin1() );
Q_ASSERT( false );
}
}
node = node.nextSibling();
}
setColors( KDGanttViewItem::Event, startColor,
middleColor, endColor, false );
} else if( tagName == "Task" ) {
TQColor startColor, middleColor, endColor;
TQDomNode node = element.firstChild();
while( !node.isNull() ) {
TQDomElement element = node.toElement();
if( !element.isNull() ) { // was really an elemente
TQString tagName = element.tagName();
if( tagName == "Start" ) {
TQColor value;
if( KDGanttXML::readColorNode( element, value ) )
startColor = value;
} else if( tagName == "Middle" ) {
TQColor value;
if( KDGanttXML::readColorNode( element, value ) )
middleColor = value;
} else if( tagName == "End" ) {
TQColor value;
if( KDGanttXML::readColorNode( element, value ) )
endColor = value;
} else {
tqDebug( "Unrecognized tag name: %s", tagName.latin1() );
Q_ASSERT( false );
}
}
node = node.nextSibling();
}
setColors( KDGanttViewItem::Task, startColor,
middleColor, endColor, false );
} else if( tagName == "Summary" ) {
TQColor startColor, middleColor, endColor;
TQDomNode node = element.firstChild();
while( !node.isNull() ) {
TQDomElement element = node.toElement();
if( !element.isNull() ) { // was really an elemente
TQString tagName = element.tagName();
if( tagName == "Start" ) {
TQColor value;
if( KDGanttXML::readColorNode( element, value ) )
startColor = value;
} else if( tagName == "Middle" ) {
TQColor value;
if( KDGanttXML::readColorNode( element, value ) )
middleColor = value;
} else if( tagName == "End" ) {
TQColor value;
if( KDGanttXML::readColorNode( element, value ) )
endColor = value;
} else {
tqDebug( "Unrecognized tag name: %s", tagName.latin1() );
Q_ASSERT( false );
}
}
node = node.nextSibling();
}
setColors( KDGanttViewItem::Summary, startColor,
middleColor, endColor , false);
} else {
tqDebug( "Unrecognized tag name: %s", tagName.latin1() );
Q_ASSERT( false );
}
}
node = node.nextSibling();
}
} else if( tagName == "DefaultColors" ) {
TQDomNode node = element.firstChild();
while( !node.isNull() ) {
TQDomElement element = node.toElement();
if( !element.isNull() ) { // was really an element
TQString tagName = element.tagName();
if( tagName == "Event" ) {
TQColor value;
if( KDGanttXML::readColorNode( element, value ) )
setDefaultColor( KDGanttViewItem::Event,
value, false );
} else if( tagName == "Task" ) {
TQColor value;
if( KDGanttXML::readColorNode( element, value ) )
setDefaultColor( KDGanttViewItem