24 #include "KDChartLineDiagram_p.h"
29 #include "KDChartAbstractGrid.h"
30 #include "KDChartPainterSaver_p.h"
32 #include <KDABLibFakes>
34 #include "KDChartNormalLineDiagram_p.h"
35 #include "KDChartStackedLineDiagram_p.h"
36 #include "KDChartPercentLineDiagram_p.h"
41 #include <QPainterPath>
45 using namespace KDChart;
47 LineDiagram::Private::Private()
51 LineDiagram::Private::~Private() {}
63 void LineDiagram::init()
65 d->normalDiagram =
new NormalLineDiagram(
this );
66 d->stackedDiagram =
new StackedLineDiagram(
this );
67 d->percentDiagram =
new PercentLineDiagram(
this );
68 d->implementor =
d->normalDiagram;
69 d->centerDataPoints =
false;
70 d->reverseDatasetOrder =
false;
75 delete d->normalDiagram;
76 delete d->stackedDiagram;
77 delete d->percentDiagram;
93 if ( other ==
this )
return true;
111 if (
d->implementor->type() ==
type )
return;
113 Q_ASSERT_X (
false,
"setType()",
114 "This line chart type can't be used with multi-dimensional data." );
119 d->implementor =
d->normalDiagram;
122 d->implementor =
d->stackedDiagram;
125 d->implementor =
d->percentDiagram;
128 Q_ASSERT_X(
false,
"LineDiagram::setType",
"unknown diagram subtype" );
132 Q_ASSERT(
d->implementor->type() ==
type );
146 return d->implementor->type();
151 d->centerDataPoints = center;
157 return d->centerDataPoints;
162 d->reverseDatasetOrder = reverse;
167 return d->reverseDatasetOrder;
175 d->attributesModel->setModelData(
176 qVariantFromValue( la ),
205 const QModelIndex& index,
208 d->attributesModel->setData(
209 d->attributesModel->mapFromSource(index),
210 qVariantFromValue( la ),
220 d->attributesModel->resetData(
239 if ( attrs.isValid() )
248 const QModelIndex& index )
const
250 return d->attributesModel->data(
251 d->attributesModel->mapFromSource(index),
262 d->attributesModel->setModelData(
263 qVariantFromValue( la ),
284 const QModelIndex & index,
288 d->attributesModel->setData(
289 d->attributesModel->mapFromSource(index),
290 qVariantFromValue( la ),
309 if ( attrs.isValid() )
319 return d->attributesModel->data(
320 d->attributesModel->mapFromSource( index ),
340 d->attributesModel->setData(
d->attributesModel->mapFromSource(index),
341 qVariantFromValue( va ),
350 const QModelIndex & index )
const
352 return d->attributesModel->data(
353 d->attributesModel->mapFromSource( index ),
363 d->compressor.setResolution( static_cast<int>( this->size().width() *
coordinatePlane()->zoomFactorX() ),
364 static_cast<int>( this->size().height() *
coordinatePlane()->zoomFactorY() ) );
373 return d->implementor->calculateDataBoundaries();
379 QPainter painter ( viewport() );
382 ctx.
setRectangle ( QRectF ( 0, 0, width(), height() ) );
389 bool showHiddenCellsAsInvalid )
const
391 if ( !model()->hasIndex( row, column, rootIndex() ) ) {
396 if ( showHiddenCellsAsInvalid &&
isHidden( model()->index( row, column, rootIndex() ) ) )
399 value =
d->attributesModel->data(
402 return bOK ? value : 0.0;
407 bool shiftCountedXValuesByHalfSection,
408 qreal& valueX, qreal& valueY )
const
415 : ((shiftCountedXValuesByHalfSection ? 0.5 : 0.0) + row);
418 else if ( model()->hasIndex( row, column, rootIndex() ) ) {
420 QModelIndex index = model()->index( row, column, rootIndex() );
433 const PainterSaver p( ctx->
painter() );
434 if ( model()->rowCount( rootIndex() ) == 0 || model()->columnCount( rootIndex() ) == 0 )
442 d->implementor->paint( ctx );
452 QAbstractItemView::resize( size.toSize() );
455 #if QT_VERSION < 0x040400 || defined(Q_COMPILER_MANGLES_RETURN_TYPE)
463 #if QT_VERSION < 0x040400 || defined(Q_COMPILER_MANGLES_RETURN_TYPE)