KDChart::Widget Class Reference

#include <KDChartWidget.h>

Inheritance diagram for KDChart::Widget:

Inheritance graph
[legend]
Collaboration diagram for KDChart::Widget:

Collaboration graph
[legend]

List of all members.


Detailed Description

The KD Chart widget for usage without Model/View.

If you want to use KD Chart with Model/View, use KDChart::Chart instead.

Definition at line 64 of file KDChartWidget.h.


Public Types

enum  ChartType {
  NoType,
  Bar,
  Line,
  Plot,
  Pie,
  Ring,
  Polar
}
enum  SubType {
  Normal,
  Stacked,
  Percent,
  Rows
}
 Sub type values, matching the values defines for the respective Diagram classes. More...

Public Slots

void setGlobalLeading (int left, int top, int right, int bottom)
 Sets all global leadings (borders).
void setGlobalLeadingBottom (int leading)
 Sets the bottom leading (border).
void setGlobalLeadingLeft (int leading)
 Sets the left leading (border).
void setGlobalLeadingRight (int leading)
 Sets the right leading (border).
void setGlobalLeadingTop (int leading)
 Sets the top leading (border).
void setSubType (SubType subType)
 Sets the type of the chart without changing the main type.
void setType (ChartType chartType, SubType subType=Normal)
 Sets the type of the chart.

Public Member Functions

void addHeaderFooter (HeaderFooter *header)
 Adds the existing header / footer object header.
void addHeaderFooter (const QString &text, HeaderFooter::HeaderFooterType type, Position position)
 Adds a new header/footer with the given text to the position.
void addLegend (Legend *legend)
 Adds a new, already existing, legend.
void addLegend (Position position)
 Adds an empty legend on the given position.
QList< HeaderFooter * > allHeadersFooters ()
 Returns a list with all headers.
QList< Legend * > allLegends ()
 Returns a list with all legends.
BarDiagrambarDiagram ()
 If the current diagram is a BarDiagram, it is returnd; otherwise 0 is returned.
AbstractCoordinatePlanecoordinatePlane ()
 Returns a pointer to the current coordinate plane.
AbstractDiagramdiagram ()
 Returns a pointer to the current diagram.
HeaderFooterfirstHeaderFooter ()
 Returns the first of all headers.
int globalLeadingBottom () const
 Returns the bottom leading (border).
int globalLeadingLeft () const
 Returns the left leading (border).
int globalLeadingRight () const
 Returns the right leading (border).
int globalLeadingTop () const
 Returns the top leading (border).
Legendlegend ()
 Returns the first of all legends.
LineDiagramlineDiagram ()
 If the current diagram is a LineDiagram, it is returnd; otherwise 0 is returned.
PieDiagrampieDiagram ()
 If the current diagram is a Plotter, it is returnd; otherwise 0 is returned.
Plotterplotter ()
 If the current diagram is a LineDiagram, it is returnd; otherwise 0 is returned.
PolarDiagrampolarDiagram ()
 If the current diagram is a PolarDiagram, it is returnd; otherwise 0 is returned.
void replaceHeaderFooter (HeaderFooter *header, HeaderFooter *oldHeader=0)
 Replaces the old header (or footer, resp.
void replaceLegend (Legend *legend, Legend *oldLegend=0)
void resetData ()
 Resets all data.
RingDiagramringDiagram ()
 If the current diagram is a RingDiagram, it is returnd; otherwise 0 is returned.
void setDataCell (int row, int column, QPair< double, double > data)
 Sets the data for a given column using an (X, Y) QPair of doubles.
void setDataCell (int row, int column, double data)
 Sets the Y value data for a given cell.
void setDataset (int column, const QVector< QPair< double, double > > &data, const QString &title=QString())
 Sets the data in the given column using a QVector of QPairs of double for the (X, Y) values.
void setDataset (int column, const QVector< double > &data, const QString &title=QString())
 Sets the data in the given column using a QVector of double for the Y values.
SubType subType () const
 Returns the sub-type of the chart.
void takeHeaderFooter (HeaderFooter *header)
 Remove the header (or footer, resp.
void takeLegend (Legend *legend)
ChartType type () const
 Returns the type of the chart.
 Widget (QWidget *parent=0)
 Standard Qt-style Constructor.
 ~Widget ()
 Destructor.

Member Enumeration Documentation

enum KDChart::Widget::ChartType

Enumerator:
NoType 
Bar 
Line 
Plot 
Pie 
Ring 
Polar 

Definition at line 212 of file KDChartWidget.h.

00212 { NoType, Bar, Line, Plot, Pie, Ring, Polar };

enum KDChart::Widget::SubType

Sub type values, matching the values defines for the respective Diagram classes.

Enumerator:
Normal 
Stacked 
Percent 
Rows 

Definition at line 218 of file KDChartWidget.h.

00218 { Normal, Stacked, Percent, Rows };


Constructor & Destructor Documentation

Widget::Widget ( QWidget parent = 0  )  [explicit]

Standard Qt-style Constructor.

Constructor.

Creates a new widget with all data initialized empty.

Parameters:
parent the widget parent; passed on to QWidget

Definition at line 83 of file KDChartWidget.cpp.

References Line, and setType().

00083                                 :
00084     QWidget(parent), _d( new Private( this ) )
00085 {
00086     // as default we have a cartesian coordinate plane ...
00087     // ... and a line diagram
00088     setType( Line );
00089 }

Widget::~Widget (  ) 

Destructor.

Definition at line 94 of file KDChartWidget.cpp.

00095 {
00096     delete _d; _d = 0;
00097 }


Member Function Documentation

void Widget::addHeaderFooter ( HeaderFooter header  ) 

Adds the existing header / footer object header.

Adds an existing header / footer object.

See also:
replaceHeaderFooter, takeHeaderFooter

Definition at line 286 of file KDChartWidget.cpp.

References d, and KDChart::HeaderFooter::setParent().

00287 {
00288     header->setParent( &d->m_chart );
00289     d->m_chart.addHeaderFooter( header ); // we need this explicit call !
00290 }

void Widget::addHeaderFooter ( const QString &  text,
HeaderFooter::HeaderFooterType  type,
Position  position 
)

Adds a new header/footer with the given text to the position.

Definition at line 272 of file KDChartWidget.cpp.

References d, KDChart::HeaderFooter::setPosition(), KDChart::TextLayoutItem::setText(), and KDChart::HeaderFooter::setType().

00275 {
00276     HeaderFooter* newHeader = new HeaderFooter( &d->m_chart );
00277     newHeader->setType( type );
00278     newHeader->setPosition( position );
00279     newHeader->setText( text );
00280     d->m_chart.addHeaderFooter( newHeader ); // we need this explicit call !
00281 }

void Widget::addLegend ( Legend legend  ) 

Adds a new, already existing, legend.

Definition at line 332 of file KDChartWidget.cpp.

References d, diagram(), and KDChart::Legend::setDiagram().

00333 {
00334     legend->setDiagram( diagram() );
00335     legend->setParent( &d->m_chart );
00336     d->m_chart.addLegend( legend );
00337 }

void Widget::addLegend ( Position  position  ) 

Adds an empty legend on the given position.

Definition at line 322 of file KDChartWidget.cpp.

References d, diagram(), legend(), and KDChart::Legend::setPosition().

00323 {
00324     Legend* legend = new Legend( diagram(), &d->m_chart );
00325     legend->setPosition( position );
00326     d->m_chart.addLegend( legend );
00327 }

QList< KDChart::HeaderFooter * > Widget::allHeadersFooters (  ) 

Returns a list with all headers.

Definition at line 264 of file KDChartWidget.cpp.

References d.

00265 {
00266     return d->m_chart.headerFooters();
00267 }

QList< KDChart::Legend * > Widget::allLegends (  ) 

Returns a list with all legends.

Definition at line 314 of file KDChartWidget.cpp.

References d.

00315 {
00316     return d->m_chart.legends();
00317 }

BarDiagram * Widget::barDiagram (  ) 

If the current diagram is a BarDiagram, it is returnd; otherwise 0 is returned.

This function provides type-safe casting.

Definition at line 359 of file KDChartWidget.cpp.

References diagram().

00360 {
00361     return dynamic_cast<BarDiagram*>( diagram() );
00362 }

AbstractCoordinatePlane * Widget::coordinatePlane (  ) 

Returns a pointer to the current coordinate plane.

Definition at line 384 of file KDChartWidget.cpp.

References d.

Referenced by diagram(), and setType().

00385 {
00386     return d->m_chart.coordinatePlane();
00387 }

AbstractDiagram * Widget::diagram (  ) 

Returns a pointer to the current diagram.

Definition at line 351 of file KDChartWidget.cpp.

References coordinatePlane(), and KDChart::AbstractCoordinatePlane::diagram().

Referenced by addLegend(), barDiagram(), lineDiagram(), pieDiagram(), plotter(), polarDiagram(), replaceLegend(), ringDiagram(), setSubType(), subType(), and type().

00352 {
00353     if ( coordinatePlane() == 0 )
00354         qDebug() << "diagram(): coordinatePlane() was NULL";
00355 
00356     return coordinatePlane()->diagram();
00357 }

KDChart::HeaderFooter * Widget::firstHeaderFooter (  ) 

Returns the first of all headers.

Definition at line 256 of file KDChartWidget.cpp.

References d.

00257 {
00258     return d->m_chart.headerFooter();
00259 }

int Widget::globalLeadingBottom (  )  const

Returns the bottom leading (border).

Definition at line 248 of file KDChartWidget.cpp.

References d.

00249 {
00250     return d->m_chart.globalLeadingBottom();
00251 }

int Widget::globalLeadingLeft (  )  const

Returns the left leading (border).

Definition at line 200 of file KDChartWidget.cpp.

References d.

00201 {
00202     return d->m_chart.globalLeadingLeft();
00203 }

int Widget::globalLeadingRight (  )  const

Returns the right leading (border).

Definition at line 232 of file KDChartWidget.cpp.

References d.

00233 {
00234     return d->m_chart.globalLeadingRight();
00235 }

int Widget::globalLeadingTop (  )  const

Returns the top leading (border).

Definition at line 216 of file KDChartWidget.cpp.

References d.

00217 {
00218     return d->m_chart.globalLeadingTop();
00219 }

KDChart::Legend * Widget::legend (  ) 

Returns the first of all legends.

Definition at line 306 of file KDChartWidget.cpp.

References d.

Referenced by addLegend().

00307 {
00308     return d->m_chart.legend();
00309 }

LineDiagram * Widget::lineDiagram (  ) 

If the current diagram is a LineDiagram, it is returnd; otherwise 0 is returned.

This function provides type-safe casting.

Definition at line 363 of file KDChartWidget.cpp.

References diagram().

00364 {
00365     return dynamic_cast<LineDiagram*>( diagram() );
00366 }

PieDiagram * Widget::pieDiagram (  ) 

If the current diagram is a Plotter, it is returnd; otherwise 0 is returned.

This function provides type-safe casting.

Definition at line 371 of file KDChartWidget.cpp.

References diagram().

00372 {
00373     return dynamic_cast<PieDiagram*>( diagram() );
00374 }

Plotter * Widget::plotter (  ) 

If the current diagram is a LineDiagram, it is returnd; otherwise 0 is returned.

This function provides type-safe casting.

Note:
Do not use lineDiagram for multi-dimensional diagrams, but use plotter instead
See also:
plotter

Definition at line 367 of file KDChartWidget.cpp.

References diagram().

00368 {
00369     return dynamic_cast<Plotter*>( diagram() );
00370 }

PolarDiagram * Widget::polarDiagram (  ) 

If the current diagram is a PolarDiagram, it is returnd; otherwise 0 is returned.

This function provides type-safe casting.

Definition at line 379 of file KDChartWidget.cpp.

References diagram().

00380 {
00381     return dynamic_cast<PolarDiagram*>( diagram() );
00382 }

void Widget::replaceHeaderFooter ( HeaderFooter header,
HeaderFooter oldHeader = 0 
)

Replaces the old header (or footer, resp.

), or appends the new header or footer, it there is none yet.

Parameters:
header The header or footer to be used instead of the old one. This parameter must not be zero, or the method will do nothing.
oldHeader The header or footer to be removed by the new one. This header or footer will be deleted automatically. If the parameter is omitted, the very first header or footer will be replaced. In case, there was no header and no footer yet, the new header or footer will just be added.
Note:
If you want to re-use the old header or footer, call takeHeaderFooter and addHeaderFooter, instead of using replaceHeaderFooter.
See also:
addHeaderFooter, takeHeaderFooter

Definition at line 292 of file KDChartWidget.cpp.

References d, and KDChart::HeaderFooter::setParent().

00293 {
00294     header->setParent( &d->m_chart );
00295     d->m_chart.replaceHeaderFooter( header, oldHeader );
00296 }

void Widget::replaceLegend ( Legend legend,
Legend oldLegend = 0 
)

Definition at line 339 of file KDChartWidget.cpp.

References d, diagram(), and KDChart::Legend::setDiagram().

00340 {
00341     legend->setDiagram( diagram() );
00342     legend->setParent( &d->m_chart );
00343     d->m_chart.replaceLegend( legend, oldLegend );
00344 }

void Widget::resetData (  ) 

Resets all data.

Definition at line 175 of file KDChartWidget.cpp.

References d.

00176 {
00177     d->m_model.clear();
00178     d->usedDatasetWidth = 0;
00179 }

RingDiagram * Widget::ringDiagram (  ) 

If the current diagram is a RingDiagram, it is returnd; otherwise 0 is returned.

This function provides type-safe casting.

Definition at line 375 of file KDChartWidget.cpp.

References diagram().

00376 {
00377     return dynamic_cast<RingDiagram*>( diagram() );
00378 }

void Widget::setDataCell ( int  row,
int  column,
QPair< double, double >  data 
)

Sets the data for a given column using an (X, Y) QPair of doubles.

Definition at line 156 of file KDChartWidget.cpp.

References d.

00157 {
00158     if ( ! checkDatasetWidth( 2 ))
00159         return;
00160 
00161     QStandardItemModel & model = d->m_model;
00162 
00163     justifyModelSize( row + 1, (column + 1) * 2 );
00164 
00165     QModelIndex index = model.index( row, column * 2 );
00166     model.setData( index, QVariant( data.first ), Qt::DisplayRole );
00167 
00168     index = model.index( row, column * 2 + 1 );
00169     model.setData( index, QVariant( data.second ), Qt::DisplayRole );
00170 }

void Widget::setDataCell ( int  row,
int  column,
double  data 
)

Sets the Y value data for a given cell.

Definition at line 143 of file KDChartWidget.cpp.

References d.

00144 {
00145     if ( ! checkDatasetWidth( 1 ) )
00146         return;
00147 
00148     QStandardItemModel & model = d->m_model;
00149 
00150     justifyModelSize( row + 1, column + 1 );
00151 
00152     const QModelIndex index = model.index( row, column );
00153     model.setData( index, QVariant( data ), Qt::DisplayRole );
00154 }

void Widget::setDataset ( int  column,
const QVector< QPair< double, double > > &  data,
const QString &  title = QString() 
)

Sets the data in the given column using a QVector of QPairs of double for the (X, Y) values.

Definition at line 121 of file KDChartWidget.cpp.

References d.

00122 {
00123     if ( ! checkDatasetWidth( 2 ))
00124         return;
00125 
00126     QStandardItemModel & model = d->m_model;
00127 
00128     justifyModelSize( data.size(), (column + 1) * 2 );
00129 
00130     for( int i = 0; i < data.size(); ++i )
00131     {
00132         QModelIndex index = model.index( i, column * 2 );
00133         model.setData( index, QVariant( data[i].first ), Qt::DisplayRole );
00134 
00135         index = model.index( i, column * 2 + 1 );
00136         model.setData( index, QVariant( data[i].second ), Qt::DisplayRole );
00137     }
00138     if ( ! title.isEmpty() ){
00139         model.setHeaderData( column,   Qt::Horizontal, QVariant( title ) );
00140     }
00141 }

void Widget::setDataset ( int  column,
const QVector< double > &  data,
const QString &  title = QString() 
)

Sets the data in the given column using a QVector of double for the Y values.

Definition at line 103 of file KDChartWidget.cpp.

References d.

00104 {
00105     if ( ! checkDatasetWidth( 1 ) )
00106         return;
00107 
00108     QStandardItemModel & model = d->m_model;
00109 
00110     justifyModelSize( data.size(), column + 1 );
00111 
00112     for( int i = 0; i < data.size(); ++i )
00113     {
00114         const QModelIndex index = model.index( i, column );
00115         model.setData( index, QVariant( data[i] ), Qt::DisplayRole );
00116     }
00117     if ( ! title.isEmpty() )
00118         model.setHeaderData( column, Qt::Horizontal, QVariant( title ) );
00119 }

void Widget::setGlobalLeading ( int  left,
int  top,
int  right,
int  bottom 
) [slot]

Sets all global leadings (borders).

Definition at line 184 of file KDChartWidget.cpp.

References d.

00185 {
00186     d->m_chart.setGlobalLeading( left, top, right, bottom );
00187 }

void Widget::setGlobalLeadingBottom ( int  leading  )  [slot]

Sets the bottom leading (border).

Definition at line 240 of file KDChartWidget.cpp.

References d.

00241 {
00242     d->m_chart.setGlobalLeadingBottom( leading );
00243 }

void Widget::setGlobalLeadingLeft ( int  leading  )  [slot]

Sets the left leading (border).

Definition at line 192 of file KDChartWidget.cpp.

References d.

00193 {
00194     d->m_chart.setGlobalLeadingLeft( leading );
00195 }

void Widget::setGlobalLeadingRight ( int  leading  )  [slot]

Sets the right leading (border).

Definition at line 224 of file KDChartWidget.cpp.

References d.

00225 {
00226     d->m_chart.setGlobalLeadingRight( leading );
00227 }

void Widget::setGlobalLeadingTop ( int  leading  )  [slot]

Sets the top leading (border).

Definition at line 208 of file KDChartWidget.cpp.

References d.

00209 {
00210     d->m_chart.setGlobalLeadingTop( leading );
00211 }

void Widget::setSubType ( SubType  subType  )  [slot]

Sets the type of the chart without changing the main type.

Make sure to use a sub-type that matches the main type, so e.g. setting sub-type Rows makes sense for Bar charts only, and it will be ignored for all other chart types.

See also:
KDChartBarDiagram::BarType, KDChartLineDiagram::LineType

KDChartPieDiagram::PieType, KDChartRingDiagram::RingType

KDChartPolarDiagram::PolarType

Definition at line 478 of file KDChartWidget.cpp.

References diagram(), KDChart::Plotter::Normal, KDChart::LineDiagram::Normal, KDChart::BarDiagram::Normal, Normal, KDChart::Plotter::Percent, KDChart::LineDiagram::Percent, KDChart::BarDiagram::Percent, Percent, KDChart::BarDiagram::Rows, Rows, SET_SUB_TYPE, KDChart::LineDiagram::Stacked, KDChart::BarDiagram::Stacked, and Stacked.

Referenced by setType().

00479 {
00480     BarDiagram*  barDia     = qobject_cast< BarDiagram* >(   diagram() );
00481     LineDiagram* lineDia    = qobject_cast< LineDiagram* >(  diagram() );
00482     Plotter*     plotterDia = qobject_cast< Plotter* >(      diagram() );
00483 
00484 //FIXME(khz): Add the impl for these chart types - or remove them from here:
00485 //    PieDiagram*   pieDia   = qobject_cast< PieDiagram* >(   diagram() );
00486 //    PolarDiagram* polarDia = qobject_cast< PolarDiagram* >( diagram() );
00487 //    RingDiagram*  ringDia  = qobject_cast< RingDiagram* >(  diagram() );
00488 
00489 #define SET_SUB_TYPE(DIAGRAM, SUBTYPE) \
00490 { \
00491     if( DIAGRAM ) \
00492         DIAGRAM->setType( SUBTYPE ); \
00493 }
00494     switch ( subType )
00495     {
00496         case Normal:
00497            SET_SUB_TYPE( barDia,     BarDiagram::Normal );
00498            SET_SUB_TYPE( lineDia,    LineDiagram::Normal );
00499            SET_SUB_TYPE( plotterDia, Plotter::Normal );
00500            break;
00501         case Stacked:
00502            SET_SUB_TYPE( barDia,  BarDiagram::Stacked );
00503            SET_SUB_TYPE( lineDia, LineDiagram::Stacked );
00504            //SET_SUB_TYPE( plotterDia, Plotter::Stacked );
00505            break;
00506         case Percent:
00507            SET_SUB_TYPE( barDia,  BarDiagram::Percent );
00508            SET_SUB_TYPE( lineDia, LineDiagram::Percent );
00509            SET_SUB_TYPE( plotterDia, Plotter::Percent );
00510            break;
00511         case Rows:
00512            SET_SUB_TYPE( barDia, BarDiagram::Rows );
00513            break;
00514         default:
00515            Q_ASSERT_X ( false,
00516                         "Widget::setSubType", "Sub-type not supported!" );
00517            break;
00518     }
00519 //    coordinatePlane()->show();
00520 }

void Widget::setType ( ChartType  chartType,
SubType  subType = Normal 
) [slot]

Sets the type of the chart.

Definition at line 401 of file KDChartWidget.cpp.

References KDChart::AbstractCartesianDiagram::axes(), Bar, coordinatePlane(), d, KDChart::AbstractCoordinatePlane::diagram(), isCartesian(), isPolar(), Line, NoType, Pie, Plot, Polar, KDChart::AbstractCoordinatePlane::replaceDiagram(), Ring, KDChart::Legend::setDiagram(), KDChart::AbstractDiagram::setModel(), setSubType(), subType(), KDChart::AbstractCartesianDiagram::takeAxis(), and type().

Referenced by Widget().

00402 {
00403     AbstractDiagram* diag = 0;
00404     const ChartType oldType = type();
00405 
00406     if ( chartType != oldType ){
00407         if( chartType != NoType ){
00408             if ( isCartesian( chartType ) && ! isCartesian( oldType ) )
00409             {
00410                 if( coordinatePlane() == &d->m_polPlane ){
00411                     d->m_chart.takeCoordinatePlane( &d->m_polPlane );
00412                     d->m_chart.addCoordinatePlane(  &d->m_cartPlane );
00413                 }else{
00414                     d->m_chart.replaceCoordinatePlane( &d->m_cartPlane );
00415                 }
00416             }
00417             else if ( isPolar( chartType ) && ! isPolar( oldType ) )
00418             {
00419                 if( coordinatePlane() == &d->m_cartPlane ){
00420                     d->m_chart.takeCoordinatePlane( &d->m_cartPlane );
00421                     d->m_chart.addCoordinatePlane(  &d->m_polPlane );
00422                 }else{
00423                     d->m_chart.replaceCoordinatePlane( &d->m_polPlane );
00424                 }
00425             }
00426         }
00427         switch ( chartType ){
00428             case Bar:
00429                 diag = new BarDiagram( &d->m_chart, &d->m_cartPlane );
00430                 break;
00431             case Line:
00432                 diag = new LineDiagram( &d->m_chart, &d->m_cartPlane );
00433                 break;
00434             case Plot:
00435                 diag = new Plotter( &d->m_chart, &d->m_cartPlane );
00436                 break;
00437             case Pie:
00438                 diag = new PieDiagram( &d->m_chart, &d->m_polPlane );
00439                 break;
00440             case Polar:
00441                 diag = new PolarDiagram( &d->m_chart, &d->m_polPlane );
00442                 break;
00443             case Ring:
00444                 diag = new RingDiagram( &d->m_chart, &d->m_polPlane );
00445                 break;
00446             case NoType:
00447                 break;
00448         }
00449         if ( diag != NULL ){
00450             if ( isCartesian( oldType ) && isCartesian( chartType ) ){
00451                 AbstractCartesianDiagram *oldDiag =
00452                         qobject_cast<AbstractCartesianDiagram*>( coordinatePlane()->diagram() );
00453                 AbstractCartesianDiagram *newDiag =
00454                         qobject_cast<AbstractCartesianDiagram*>( diag );
00455                 Q_FOREACH( CartesianAxis* axis, oldDiag->axes() ) {
00456                     oldDiag->takeAxis( axis );
00457                     newDiag->addAxis ( axis );
00458                 }
00459             }
00460             diag->setModel( &d->m_model );
00461             coordinatePlane()->replaceDiagram( diag );
00462 
00463             LegendList legends = d->m_chart.legends();
00464             Q_FOREACH(Legend* l, legends)
00465                 l->setDiagram( diag );
00466             //checkDatasetWidth( d->usedDatasetWidth );
00467         }
00468         //coordinatePlane()->setGridNeedsRecalculate();
00469     }
00470 
00471     if ( chartType != NoType ){
00472         if ( chartType != oldType || chartSubType != subType() )
00473             setSubType( chartSubType );
00474         d->m_chart.resize( size() ); // triggering immediate update
00475     }
00476 }

Widget::SubType Widget::subType (  )  const

Returns the sub-type of the chart.

Definition at line 545 of file KDChartWidget.cpp.

References Bar, diagram(), Line, KDChart::Plotter::Normal, KDChart::LineDiagram::Normal, KDChart::BarDiagram::Normal, Normal, KDChart::Plotter::Percent, KDChart::LineDiagram::Percent, Percent, KDChart::BarDiagram::Percent, Pie, Plot, Polar, Ring, Rows, KDChart::BarDiagram::Rows, KDChart::LineDiagram::Stacked, Stacked, KDChart::BarDiagram::Stacked, TEST_SUB_TYPE, and type().

Referenced by setType().

00546 {
00547     // PENDING(christoph) save the type out-of-band:
00548     Widget::SubType retVal = Normal;
00549 
00550     AbstractDiagram * const dia = const_cast<Widget*>( this )->diagram();
00551     BarDiagram*  barDia     = qobject_cast< BarDiagram* >(   dia );
00552     LineDiagram* lineDia    = qobject_cast< LineDiagram* >(  dia );
00553     Plotter*     plotterDia = qobject_cast< Plotter* >(  dia );
00554 
00555 //FIXME(khz): Add the impl for these chart types - or remove them from here:
00556 //    PieDiagram*   pieDia   = qobject_cast< PieDiagram* >(   diagram() );
00557 //    PolarDiagram* polarDia = qobject_cast< PolarDiagram* >( diagram() );
00558 //    RingDiagram*  ringDia  = qobject_cast< RingDiagram* >(  diagram() );
00559 
00560 #define TEST_SUB_TYPE(DIAGRAM, INTERNALSUBTYPE, SUBTYPE) \
00561 { \
00562     if( DIAGRAM && DIAGRAM->type() == INTERNALSUBTYPE ) \
00563         retVal = SUBTYPE; \
00564 }
00565     const Widget::ChartType mainType = type();
00566     switch ( mainType )
00567     {
00568         case Bar:
00569            TEST_SUB_TYPE( barDia, BarDiagram::Normal,  Normal );
00570            TEST_SUB_TYPE( barDia, BarDiagram::Stacked, Stacked );
00571            TEST_SUB_TYPE( barDia, BarDiagram::Percent, Percent );
00572            TEST_SUB_TYPE( barDia, BarDiagram::Rows,    Rows );
00573            break;
00574         case Line:
00575             TEST_SUB_TYPE( lineDia, LineDiagram::Normal,  Normal );
00576             TEST_SUB_TYPE( lineDia, LineDiagram::Stacked, Stacked );
00577             TEST_SUB_TYPE( lineDia, LineDiagram::Percent, Percent );
00578             break;
00579         case Plot:
00580             TEST_SUB_TYPE( plotterDia, Plotter::Normal,  Normal );
00581             TEST_SUB_TYPE( plotterDia, Plotter::Percent, Percent );
00582             break;
00583         case Pie:
00584            // no impl. yet
00585            break;
00586         case Polar:
00587            // no impl. yet
00588            break;
00589         case Ring:
00590            // no impl. yet
00591            break;
00592         default:
00593            Q_ASSERT_X ( false,
00594                         "Widget::subType", "Chart type not supported!" );
00595            break;
00596     }
00597     return retVal;
00598 }

void Widget::takeHeaderFooter ( HeaderFooter header  ) 

Remove the header (or footer, resp.

) from the widget, without deleting it. The chart no longer owns the header or footer, so it is the caller's responsibility to delete the header or footer.

See also:
addHeaderFooter, replaceHeaderFooter

Definition at line 298 of file KDChartWidget.cpp.

References d.

00299 {
00300     d->m_chart.takeHeaderFooter( header );
00301 }

void Widget::takeLegend ( Legend legend  ) 

Definition at line 346 of file KDChartWidget.cpp.

References d.

00347 {
00348     d->m_chart.takeLegend( legend );
00349 }

Widget::ChartType Widget::type (  )  const

Returns the type of the chart.

Definition at line 525 of file KDChartWidget.cpp.

References Bar, diagram(), Line, NoType, Pie, Plot, Polar, and Ring.

Referenced by setType(), and subType().

00526 {
00527     // PENDING(christoph) save the type out-of-band:
00528     AbstractDiagram * const dia = const_cast<Widget*>( this )->diagram();
00529     if ( qobject_cast< BarDiagram* >( dia ) )
00530         return Bar;
00531     else if ( qobject_cast< LineDiagram* >( dia ) )
00532         return Line;
00533     else if ( qobject_cast< Plotter* >( dia ) )
00534         return Plot;
00535     else if( qobject_cast< PieDiagram* >( dia ) )
00536         return Pie;
00537     else if( qobject_cast< PolarDiagram* >( dia ) )
00538         return Polar;
00539     else if( qobject_cast< RingDiagram* >( dia ) )
00540         return Ring;
00541     else
00542         return NoType;
00543 }


The documentation for this class was generated from the following files:
Generated on Thu Mar 4 23:26:56 2010 for KD Chart 2 by  doxygen 1.5.4