24 #include "KDChartBarDiagram_p.h"
29 #include "KDChartAbstractGrid.h"
30 #include "KDChartPainterSaver_p.h"
35 #include <KDABLibFakes>
37 #include "KDChartNormalBarDiagram_p.h"
38 #include "KDChartStackedBarDiagram_p.h"
39 #include "KDChartPercentBarDiagram_p.h"
40 #include "KDChartNormalLyingBarDiagram_p.h"
41 #include "KDChartStackedLyingBarDiagram_p.h"
42 #include "KDChartPercentLyingBarDiagram_p.h"
45 using namespace KDChart;
47 BarDiagram::Private::Private()
48 : orientation( Qt::Vertical )
53 , normalLyingDiagram( 0 )
54 , stackedLyingDiagram( 0 )
55 , percentLyingDiagram( 0 )
59 BarDiagram::Private::~Private()
62 delete stackedDiagram;
63 delete percentDiagram;
64 delete normalLyingDiagram;
65 delete stackedLyingDiagram;
66 delete percentLyingDiagram;
69 void BarDiagram::Private::setOrientationAndType( Qt::Orientation o,
BarDiagram::BarType type )
71 if ( orientation == o && implementor->type() == type ) {
78 if ( orientation == Qt::Vertical ) {
81 implementor = normalDiagram;
84 implementor = stackedDiagram;
87 implementor = percentDiagram;
90 Q_ASSERT_X(
false,
"BarDiagram::setType",
"unknown diagram subtype" );
95 implementor = normalLyingDiagram;
98 implementor = stackedLyingDiagram;
101 implementor = percentLyingDiagram;
104 Q_ASSERT_X(
false,
"BarDiagram::setType",
"unknown diagram subtype" );
108 Q_ASSERT( implementor->type() == type );
126 void BarDiagram::init()
128 d->normalDiagram =
new NormalBarDiagram(
this );
129 d->stackedDiagram =
new StackedBarDiagram(
this );
130 d->percentDiagram =
new PercentBarDiagram(
this );
131 d->normalLyingDiagram =
new NormalLyingBarDiagram(
this );
132 d->stackedLyingDiagram =
new StackedLyingBarDiagram(
this );
133 d->percentLyingDiagram =
new PercentLyingBarDiagram(
this );
134 d->implementor =
d->normalDiagram;
155 if ( other ==
this )
return true;
172 d->setOrientationAndType(
d->orientation, type );
180 return d->implementor->type();
188 d->setOrientationAndType( orientation,
d->implementor->type() );
196 return d->orientation;
223 d->attributesModel->mapFromSource( index ),
224 qVariantFromValue( ba ),
243 if ( attrs.isValid() )
253 return d->attributesModel->data(
254 d->attributesModel->mapFromSource( index ),
286 d->attributesModel->setData(
287 d->attributesModel->mapFromSource(index),
288 qVariantFromValue( threeDAttrs ),
308 if ( attrs.isValid() )
318 return d->attributesModel->data(
319 d->attributesModel->mapFromSource(index),
340 d->compressor.setResolution( static_cast<int>( this->size().width() *
coordinatePlane()->zoomFactorX() ),
341 static_cast<int>( this->size().height() *
coordinatePlane()->zoomFactorY() ) );
351 return d->implementor->calculateDataBoundaries();
356 QPainter painter ( viewport() );
367 const PainterSaver p( ctx->
painter() );
368 if ( model()->rowCount( rootIndex() ) == 0 || model()->columnCount( rootIndex() ) == 0 )
386 d->implementor->paint( ctx );
396 QAbstractItemView::resize( size.toSize() );
399 #if QT_VERSION < 0x040400 || defined(Q_COMPILER_MANGLES_RETURN_TYPE)
407 #if QT_VERSION < 0x040400 || defined(Q_COMPILER_MANGLES_RETURN_TYPE)