File indexing completed on 2024-05-12 04:20:29

0001 /*
0002  * SPDX-FileCopyrightText: 2001-2015 Klaralvdalens Datakonsult AB. All rights reserved.
0003  *
0004  * This file is part of the KD Chart library.
0005  *
0006  * SPDX-License-Identifier: GPL-2.0-or-later
0007  */
0008 
0009 #ifndef KCHARTABSTRACTDIAGRAM_H
0010 #define KCHARTABSTRACTDIAGRAM_H
0011 
0012 #include <QList>
0013 #include <QRectF>
0014 #include <QAbstractItemView>
0015 
0016 #include "KChartGlobal.h"
0017 #include "KChartMarkerAttributes.h"
0018 #include "KChartAttributesModel.h"
0019 
0020 namespace KChart {
0021 
0022     class AbstractCoordinatePlane;
0023     class AttributesModel;
0024     class DataValueAttributes;
0025     class PaintContext;
0026 
0027     /**
0028      * @brief AbstractDiagram defines the interface for diagram classes
0029      *
0030      * AbstractDiagram is the base class for diagram classes ("chart types").
0031      *
0032      * It defines the interface, that needs to be implemented for the diagram,
0033      * to function within the KChart framework. It extends Interview's
0034      * QAbstractItemView.
0035      */
0036     class KCHART_EXPORT AbstractDiagram : public QAbstractItemView
0037     {
0038         Q_OBJECT
0039         Q_DISABLE_COPY( AbstractDiagram )
0040         KCHART_DECLARE_PRIVATE_BASE_POLYMORPHIC( AbstractDiagram )
0041 
0042     friend class AbstractCoordinatePlane;
0043     friend class CartesianCoordinatePlane;
0044     friend class PolarCoordinatePlane;
0045 
0046     protected:
0047         explicit inline AbstractDiagram(
0048             Private *p, QWidget* parent, AbstractCoordinatePlane* plane );
0049         explicit AbstractDiagram (
0050             QWidget* parent = nullptr, AbstractCoordinatePlane* plane = nullptr );
0051     public:
0052         ~AbstractDiagram() override;
0053 
0054 
0055         /**
0056          * Returns true if both diagrams have the same settings.
0057          */
0058         bool compare( const AbstractDiagram* other ) const;
0059 
0060 
0061         /**
0062          * @brief Return the bottom left and top right data point, that the
0063          * diagram will display (unless the grid adjusts these values).
0064          *
0065          * This method returns a cached result of calculations done by
0066          * calculateDataBoundaries.
0067          * Classes derived from AbstractDiagram must implement the
0068          * calculateDataBoundaries function, to specify their own
0069          * way of calculating the data boundaries.
0070          * If derived classes want to force recalculation of the
0071          * data boundaries, they can call setDataBoundariesDirty()
0072          *
0073          * Returned value is in diagram coordinates.
0074          */
0075         const QPair<QPointF, QPointF> dataBoundaries() const;
0076 
0077         // protected: // FIXME: why should that be private? (Mirko)
0078         /**
0079          * Draw the diagram contents to the rectangle and painter, that are
0080          * passed in as part of the paint context.
0081          *
0082          * @param paintContext All information needed for painting.
0083          */
0084         virtual void paint ( PaintContext* paintContext ) = 0;
0085 
0086         /**
0087          * Called by the widget's sizeEvent. Adjust all internal structures,
0088          * that are calculated, dependending on the size of the widget.
0089          *
0090          * @param area
0091          */
0092         virtual void resize ( const QSizeF& area );
0093 
0094         /** Associate a model with the diagram. */
0095         void setModel ( QAbstractItemModel * model ) override;
0096 
0097         /** Associate a seleection model with the diagrom. */
0098         void setSelectionModel( QItemSelectionModel* selectionModel ) override;
0099 
0100         /**
0101          * Associate an AttributesModel with this diagram. Note that
0102          * the diagram does _not_ take ownership of the AttributesModel.
0103          * This should thus only be used with AttributesModels that
0104          * have been explicitly created by the user, and are owned
0105          * by her. Setting an AttributesModel that is internal to
0106          * another diagram is an error.
0107          *
0108          * Correct:
0109          *
0110          * \code
0111          * AttributesModel *am = new AttributesModel( model, 0 );
0112          * diagram1->setAttributesModel( am );
0113          * diagram2->setAttributesModel( am );
0114          *
0115          * \endcode
0116          *
0117          * Wrong:
0118          *
0119          * \code
0120          *
0121          * diagram1->setAttributesModel( diagram2->attributesModel() );
0122          *
0123          * \endcode
0124          *
0125          * @param model The AttributesModel to use for this diagram.
0126          * @see AttributesModel, usesExternalAttributesModel
0127          */
0128         virtual void setAttributesModel( AttributesModel* model );
0129 
0130         /**
0131          * Returns whether the diagram is using its own built-in attributes model
0132          * or an attributes model that was set via setAttributesModel.
0133          *
0134          * @see setAttributesModel
0135          */
0136         virtual bool usesExternalAttributesModel() const;
0137 
0138         /**
0139          * Returns the AttributesModel, that is used by this diagram.
0140          * By default each diagram owns its own AttributesModel, which
0141          * should never be deleted. Only if a user-supplied AttributesModel
0142          * has been set does the pointer returned here not belong to the
0143          * diagram.
0144          *
0145          * @return The AttributesModel associated with the diagram.
0146          * @see setAttributesModel
0147          */
0148         virtual AttributesModel* attributesModel() const;
0149 
0150        /** Set the root index in the model, where the diagram starts
0151         * referencing data for display. */
0152         void setRootIndex ( const QModelIndex& idx ) override;
0153 
0154         /** \reimpl */
0155         QRect visualRect(const QModelIndex &index) const override;
0156         /** \reimpl */
0157         void scrollTo(const QModelIndex &index, ScrollHint hint = EnsureVisible) override;
0158         /** \reimpl */
0159         QModelIndex indexAt(const QPoint &point) const override;
0160         /** \reimpl */
0161         QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers) override;
0162         /** \reimpl */
0163         int horizontalOffset() const override;
0164         /** \reimpl */
0165         int verticalOffset() const override;
0166         /** \reimpl */
0167         bool isIndexHidden(const QModelIndex &index) const override;
0168         /** \reimpl */
0169         void setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command) override;
0170         /** \reimpl */
0171         QRegion visualRegionForSelection(const QItemSelection &selection) const override;
0172         virtual QRegion visualRegion(const QModelIndex &index) const;
0173         /** \reimpl */
0174         void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles = QVector<int>()) override;
0175         /** \reimpl */
0176         void doItemsLayout() override;
0177 
0178         /**
0179          * The coordinate plane associated with the diagram. This determines
0180          * how coordinates in value space are mapped into pixel space. By default
0181          * this is a CartesianCoordinatePlane.
0182          * @return The coordinate plane associated with the diagram.
0183          */
0184         AbstractCoordinatePlane* coordinatePlane() const;
0185 
0186         /**
0187          * Set the coordinate plane associated with the diagram. This determines
0188          * how coordinates in value space are mapped into pixel space. The chart
0189          * takes ownership.
0190          */
0191         virtual void setCoordinatePlane( AbstractCoordinatePlane* plane );
0192 
0193 
0194         /**
0195          * Hide (or unhide, resp.) a data cell.
0196          *
0197          * \note Hidden data are still taken into account by the coordinate plane,
0198          * so neither the grid nor your axes' ranges will change, when you hide data.
0199          * For totally removing data from KChart's view you can use another approach:
0200          * e.g. you could define a proxy model on top of your data model, and register
0201          * the proxy model calling setModel() instead of registering your real data model.
0202          *
0203          * @param index The datapoint to set the hidden status for. With a dataset dimension
0204          * of two, this is the index of the key of each key/value pair.
0205          * @param hidden The hidden status to set.
0206          */
0207         void setHidden( const QModelIndex & index, bool hidden );
0208 
0209         /**
0210          * Hide (or unhide, resp.) a dataset.
0211          *
0212          * \note Hidden data are still taken into account by the coordinate plane,
0213          * so neither the grid nor your axes' ranges will change, when you hide data.
0214          * For totally removing data from KChart's view you can use another approach:
0215          * e.g. you could define a proxy model on top of your data model, and register
0216          * the proxy model calling setModel() instead of registering your real data model.
0217          *
0218          * @param dataset The dataset to set the hidden status for.
0219          * @param hidden The hidden status to set.
0220          */
0221         void setHidden( int dataset, bool hidden );
0222 
0223         /**
0224          * Hide (or unhide, resp.) all datapoints in the model.
0225          *
0226          * \note Hidden data are still taken into account by the coordinate plane,
0227          * so neither the grid nor your axes' ranges will change, when you hide data.
0228          * For totally removing data from KChart's view you can use another approach:
0229          * e.g. you could define a proxy model on top of your data model, and register
0230          * the proxy model calling setModel() instead of registering your real data model.
0231          *
0232          * @param hidden The hidden status to set.
0233          */
0234         void setHidden( bool hidden );
0235 
0236         /**
0237          * Retrieve the hidden status specified globally. This will fall
0238          * back automatically to the default settings ( = not hidden), if there
0239          * are no specific settings.
0240          * @return The global hidden status.
0241          */
0242         bool isHidden() const;
0243 
0244         /**
0245          * Retrieve the hidden status for the given dataset. This will fall
0246          * back automatically to what was set at diagram level, if there
0247          * are no dataset specific settings.
0248          * @param dataset The dataset to retrieve the hidden status for.
0249          * @return The hidden status for the given dataset.
0250          */
0251         bool isHidden( int dataset ) const;
0252 
0253         /**
0254          * Retrieve the hidden status for the given index. This will fall
0255          * back automatically to what was set at dataset or diagram level, if there
0256          * are no datapoint specific settings.
0257          * @param index The datapoint to retrieve the hidden status for.
0258          * @return The hidden status for the given index.
0259          */
0260         bool isHidden( const QModelIndex & index ) const;
0261 
0262 
0263         /**
0264          * Set the DataValueAttributes for the given index.
0265          * @param index The datapoint to set the attributes for. With a dataset dimension
0266          * of two, this is the index of the key of each key/value pair.
0267          * @param a The attributes to set.
0268          */
0269         void setDataValueAttributes( const QModelIndex & index,
0270                                      const DataValueAttributes & a );
0271 
0272         /**
0273          * Set the DataValueAttributes for the given dataset.
0274          * @param dataset The dataset to set the attributes for.
0275          * @param a The attributes to set.
0276          */
0277         void setDataValueAttributes( int dataset, const DataValueAttributes & a );
0278 
0279         /**
0280          * Set the DataValueAttributes for all datapoints in the model.
0281          * @param a The attributes to set.
0282          */
0283         void setDataValueAttributes( const DataValueAttributes & a );
0284 
0285         /**
0286          * Retrieve the DataValueAttributes specified globally. This will fall
0287          * back automatically to the default settings, if there
0288          * are no specific settings.
0289          * @return The global DataValueAttributes.
0290          */
0291         DataValueAttributes dataValueAttributes() const;
0292 
0293         /**
0294          * Retrieve the DataValueAttributes for the given dataset. This will fall
0295          * back automatically to what was set at model level, if there
0296          * are no dataset specific settings.
0297          * @param dataset The dataset to retrieve the attributes for.
0298          * @return The DataValueAttributes for the given dataset.
0299          */
0300         DataValueAttributes dataValueAttributes( int dataset ) const;
0301 
0302         /**
0303          * Retrieve the DataValueAttributes for the given index. This will fall
0304          * back automatically to what was set at dataset or model level, if there
0305          * are no datapoint specific settings.
0306          * @param index The datapoint to retrieve the attributes for. With a dataset dimension
0307          * of two, this is the index of the key of each key/value pair.
0308          * @return The DataValueAttributes for the given index.
0309          */
0310         DataValueAttributes dataValueAttributes( const QModelIndex & index ) const;
0311 
0312         /**
0313          * Set the pen to be used, for painting the datapoint at the given index.
0314          * @param index The datapoint's index in the model. With a dataset dimension
0315          * of two, this is the index of the key of each key/value pair.
0316          * @param pen The pen to use.
0317          */
0318         void setPen( const QModelIndex& index, const QPen& pen );
0319 
0320         /**
0321          * Set the pen to be used, for painting the given dataset.
0322          * @param dataset The dataset to set the pen for.
0323          * @param pen The pen to use.
0324          */
0325         void setPen( int dataset, const QPen& pen );
0326 
0327         /**
0328          * Set the pen to be used, for painting all datasets in the model.
0329          * @param pen The pen to use.
0330          */
0331         void setPen( const QPen& pen );
0332 
0333         /**
0334          * Retrieve the pen to be used for painting datapoints globally. This will fall
0335          * back automatically to the default settings, if there
0336          * are no specific settings.
0337          * @return The pen to use for painting.
0338          */
0339         QPen pen() const;
0340         /**
0341          * Retrieve the pen to be used for the given dataset. This will fall
0342          * back automatically to what was set at model level, if there
0343          * are no dataset specific settings.
0344          * @param dataset The dataset to retrieve the pen for.
0345          * @return The pen to use for painting.
0346          */
0347         QPen pen( int dataset ) const;
0348         /**
0349          * Retrieve the pen to be used, for painting the datapoint at the given
0350          * index in the model.
0351          * @param index The index of the datapoint in the model. With a dataset dimension
0352          * of two, this is the index of the key of each key/value pair.
0353          * @return The pen to use for painting.
0354          */
0355         QPen pen( const QModelIndex& index ) const;
0356 
0357         /**
0358          * Set the brush to be used, for painting the datapoint at the given index.
0359          * @param index The datapoint's index in the model. With a dataset dimension
0360          * of two, this is the index of the key of each key/value pair.
0361          * @param brush The brush to use.
0362          */
0363         void setBrush( const QModelIndex& index, const QBrush& brush);
0364 
0365         /**
0366          * Set the brush to be used, for painting the given dataset.
0367          * @param dataset The dataset to set the brush for.
0368          * @param brush The brush to use.
0369          */
0370         void setBrush( int dataset, const QBrush& brush );
0371 
0372         /**
0373          * Set the brush to be used, for painting all datasets in the model.
0374          * @param brush The brush to use.
0375          */
0376         void setBrush( const QBrush& brush);
0377 
0378         /**
0379          * Retrieve the brush to be used for painting datapoints globally. This will fall
0380          * back automatically to the default settings, if there
0381          * are no specific settings.
0382          * @return The brush to use for painting.
0383          */
0384         QBrush brush() const;
0385         /**
0386          * Retrieve the brush to be used for the given dataset. This will fall
0387          * back automatically to what was set at model level, if there
0388          * are no dataset specific settings.
0389          * @param dataset The dataset to retrieve the brush for.
0390          * @return The brush to use for painting.
0391          */
0392         QBrush brush( int dataset ) const;
0393         /**
0394          * Retrieve the brush to be used, for painting the datapoint at the given
0395          * index in the model.
0396          * @param index The index of the datapoint in the model. With a dataset dimension
0397          * of two, this is the index of the key of each key/value pair.
0398          * @return The brush to use for painting.
0399          */
0400         QBrush brush( const QModelIndex& index ) const;
0401 
0402         /**
0403          * Set the unit prefix to be used on axes for one specific column.
0404          * @param prefix The prefix to be used.
0405          * @param column The column which should be set.
0406          * @param orientation The orientation of the axis to use.
0407          */
0408         void setUnitPrefix( const QString& prefix, int column, Qt::Orientation orientation );
0409         /**
0410          * Set the unit prefix to be used on axes for all columns.
0411          * @param prefix The prefix to be used.
0412          * @param orientation The orientation of the axis to use.
0413          */
0414         void setUnitPrefix( const QString& prefix, Qt::Orientation orientation );
0415 
0416         /**
0417          * Set the unit prefix to be used on axes for one specific column.
0418          * @param suffix The suffix to be used.
0419          * @param column The column which should be set.
0420          * @param orientation The orientation of the axis to use.
0421          */
0422         void setUnitSuffix( const QString& suffix, int column, Qt::Orientation orientation );
0423         /**
0424          * Set the unit prefix to be used on axes for all columns.
0425          * @param suffix The suffix to be used.
0426          * @param orientation The orientation of the axis to use.
0427          */
0428          void setUnitSuffix( const QString& suffix, Qt::Orientation orientation );
0429 
0430         /**
0431          * Retrieves the axis unit prefix for a specific column.
0432          * @param column The column whose prefix should be retrieved.
0433          * @param orientation The orientation of the axis.
0434          * @param fallback If true, the prefix for all columns is returned, when
0435          *                 none is set for the selected column.
0436          * @return The axis unit prefix.
0437          */
0438         QString unitPrefix( int column, Qt::Orientation orientation, bool fallback = false ) const;
0439         /**
0440          * Retrieves the axis unit prefix.
0441          * @param orientation The orientation of the axis.
0442          * @return The axis unit prefix.
0443          */
0444         QString unitPrefix( Qt::Orientation orientation ) const;
0445 
0446         /**
0447          * Retrieves the axis unit suffix for a specific column.
0448          * @param column The column whose prefix should be retrieved.
0449          * @param orientation The orientation of the axis.
0450          * @param fallback If true, the suffix for all columns is returned, when
0451          *                 none is set for the selected column.
0452          * @return The axis unit suffix.
0453          */
0454         QString unitSuffix( int column, Qt::Orientation orientation, bool fallback = false ) const;
0455         /**
0456          * Retrieves the axis unit suffix.
0457          * @param orientation The orientation of the axis.
0458          * @return The axis unit suffix.
0459          */
0460         QString unitSuffix( Qt::Orientation orientation ) const;
0461 
0462         /**
0463          * Set whether data value labels are allowed to overlap.
0464          * @param allow True means that overlapping labels are allowed.
0465          */
0466         void setAllowOverlappingDataValueTexts( bool allow );
0467 
0468         /**
0469          * @return Whether data value labels are allowed to overlap.
0470          */
0471         bool allowOverlappingDataValueTexts() const;
0472 
0473         /**
0474          * Set whether anti-aliasing is to be used while rendering
0475          * this diagram.
0476          * @param enabled True means that AA is enabled.
0477          */
0478         void setAntiAliasing( bool enabled );
0479 
0480         /**
0481          * @return Whether anti-aliasing is to be used for rendering
0482          * this diagram.
0483          */
0484         bool antiAliasing() const;
0485 
0486         /**
0487          * Set the palette to be used, for painting datasets to the default
0488          * palette.
0489          * @see KChart::Palette.
0490          * FIXME: fold into one usePalette (KChart::Palette&) method
0491          */
0492         void useDefaultColors();
0493 
0494         /**
0495          * Set the palette to be used, for painting datasets to the rainbow
0496          * palette.
0497          * @see KChart::Palette.
0498          */
0499         void useRainbowColors();
0500 
0501         /**
0502          * Set the palette to be used, for painting datasets to the subdued
0503          * palette.
0504          * @see KChart::Palette.
0505         */
0506         void useSubduedColors();
0507 
0508         /**
0509          * The set of item row labels currently displayed, for use in Abscissa axes, etc.
0510          * @return The set of item row labels currently displayed.
0511          */
0512         QStringList itemRowLabels() const;
0513 
0514         /**
0515          * The set of dataset labels currently displayed, for use in legends, etc.
0516          * @return The set of dataset labels currently displayed.
0517          */
0518         QStringList datasetLabels() const;
0519 
0520         /**
0521          * The set of dataset brushes currently used, for use in legends, etc.
0522          *
0523          * @note Cell-level override brushes, if set, take precedence over the
0524          * dataset values, so you might need to check these too, in order to find
0525          * the brush, that is used for a single cell.
0526          *
0527          * @return The current set of dataset brushes.
0528          */
0529         QList<QBrush> datasetBrushes() const;
0530 
0531         /**
0532          * The set of dataset pens currently used, for use in legends, etc.
0533          *
0534          * @note Cell-level override pens, if set, take precedence over the
0535          * dataset values, so you might need to check these too, in order to find
0536          * the pens, that is used for a single cell.
0537          *
0538          * @return The current set of dataset pens.
0539          */
0540         QList<QPen> datasetPens() const;
0541 
0542         /**
0543          * The set of dataset markers currently used, for use in legends, etc.
0544          *
0545          * @note Cell-level override markers, if set, take precedence over the
0546          * dataset values, so you might need to check these too, in order to find
0547          * the marker, that is shown for a single cell.
0548          *
0549          * @return The current set of dataset brushes.
0550          */
0551         QList<MarkerAttributes> datasetMarkers() const;
0552 
0553 
0554         /**
0555          * \deprecated
0556          *
0557          * \brief Deprecated method that turns the percent mode of this diagram on or off.
0558          *
0559          * This method is deprecated. Use the setType() method of a supporting diagram implementation
0560          * instead, e.g. BarDiagram::setType().
0561          *
0562          * \see percentMode
0563          */
0564         void setPercentMode( bool percent );
0565 
0566 
0567         /**
0568          * \brief Returns whether this diagram is drawn in percent mode.
0569          *
0570          * If true, all data points in the same column of a diagram will
0571          * be be drawn at the same X coordinate and stacked up so that the distance from the
0572          * last data point (or the zero line) to a data point P is always the ratio of (Y-Value of P)/
0573          * (sum of all Y-Values in same column as P) relative to the diagrams height
0574          * (or width, if abscissa and ordinate are swapped).
0575          *
0576          * Note that this property is not applicable to all diagram types.
0577          */
0578         bool percentMode() const;
0579 
0580         virtual void paintMarker( QPainter* painter,
0581                                   const MarkerAttributes& markerAttributes,
0582                                   const QBrush& brush, const QPen&,
0583                                   const QPointF& point, const QSizeF& size );
0584 
0585         /**
0586          * The dataset dimension of a diagram determines how many value dimensions
0587          * it expects each datapoint to have.
0588          * For each dimension and data series it will expect one column of values in the model.
0589          * If the dimension is 1, automatic values will be used for X.
0590          *
0591          * For example, a diagram with the default dimension of 1 will have one column
0592          * per data series (the Y values) and will use automatic values for X
0593          * (1, 2, 3, ... n).
0594          * If the dimension is 2, the diagram will use the first, (and the third,
0595          * fifth, etc) columns as X values, and the second, (and the fourth, sixth,
0596          * etc) column as Y values.
0597          * @return The dataset dimension of the diagram.
0598          */
0599         int datasetDimension() const;
0600 
0601         /**
0602          * \deprecated
0603          *
0604          * Sets the dataset dimension of the diagram. Using this method
0605          * is deprecated. Use the specific diagram types instead.
0606          */
0607         void setDatasetDimension( int dimension );
0608 
0609     protected:
0610         void setDatasetDimensionInternal( int dimension );
0611 
0612     public:
0613         void update() const;
0614 
0615         void paintMarker( QPainter* painter, const DataValueAttributes& a,
0616                           const QModelIndex& index,
0617                           const QPointF& pos );
0618         void paintMarker( QPainter* painter,
0619                           const QModelIndex& index,
0620                           const QPointF& pos );
0621         void paintDataValueText( QPainter* painter, const QModelIndex& index,
0622                                  const QPointF& pos, qreal value );
0623 
0624         // reverse mapping:
0625         /** This method is added alongside with indexAt from QAIM,
0626         since in KChart multiple indexes can be displayed at the same
0627         spot. */
0628         QModelIndexList indexesAt( const QPoint& point ) const;
0629         QModelIndexList indexesIn( const QRect& rect ) const;
0630 
0631     protected:
0632         virtual bool checkInvariants( bool justReturnTheStatus=false ) const;
0633         virtual const QPair<QPointF, QPointF> calculateDataBoundaries() const = 0;
0634 
0635     protected Q_SLOTS:
0636         void setDataBoundariesDirty() const;
0637 
0638     protected:
0639         /**
0640          * \deprecated
0641          * This method is deprecated and provided for backward-compatibility only.
0642          * Your own diagram classes should call
0643          * d->paintDataValueTextsAndMarkers() instead
0644          * which also is taking care for showing your cell-specific comments, if any,
0645          */
0646         virtual void paintDataValueTexts( QPainter* painter );
0647         /**
0648          * \deprecated
0649          * This method is deprecated and provided for backward-compatibility only.
0650          * Your own diagram classes should call
0651          * d->paintDataValueTextsAndMarkers() instead
0652          * which also is taking care for showing your cell-specific comments, if any,
0653          */
0654         virtual void paintMarkers( QPainter* painter );
0655 
0656         /*! \internal */
0657         void setAttributesModelRootIndex( const QModelIndex& );
0658 
0659         /*! returns a QModelIndex pointing into the AttributesModel that corresponds to the
0660           root index of the diagram. */
0661         QModelIndex attributesModelRootIndex() const;
0662 
0663         /**
0664          * Helper method, retrieving the data value (DisplayRole) for a given row and column
0665          * @param row The row to query.
0666          * @param column The column to query.
0667          * @return The value of the display role at the given row and column as a qreal.
0668          * @deprecated
0669          */
0670         qreal valueForCell( int row, int column ) const;
0671 
0672     Q_SIGNALS:
0673         /** Diagrams are supposed to emit this signal, when the layout of one
0674             of their element changes. Layouts can change, for example, when
0675             axes are added or removed, or when the configuration was changed
0676             in a way that the axes or the diagram itself are displayed in a
0677             different geometry.
0678             Changes in the diagrams coordinate system also result
0679             in the layoutChanged() signal being emitted.
0680         */
0681         void layoutChanged( KChart::AbstractDiagram* );
0682 
0683         /**
0684          * This signal is emitted when this diagram is being destroyed, but before all the
0685          * data, i.e. the attributes model, is invalidated.
0686          */
0687         void aboutToBeDestroyed();
0688 
0689         /** This signal is emitted when either the model or the AttributesModel is replaced. */
0690         void modelsChanged();
0691 
0692         /** This signal is emitted just before the new attributes model is connected internally.
0693             It gives you a chance to connect to its signals first or perform other setup work. */
0694         void attributesModelAboutToChange( KChart::AttributesModel* newModel, KChart::AttributesModel* oldModel );
0695 
0696         /** This signal is emitted, when the model data is changed. */
0697         void modelDataChanged();
0698 
0699         /** This signal is emitted, when the hidden status of at least one data cell was (un)set. */
0700         void dataHidden();
0701 
0702         /** Emitted upon change of a property of the Diagram. */
0703         void propertiesChanged();
0704 
0705         /** Emitted upon change of a data boundary */
0706         void boundariesChanged();
0707         /** Emitted upon change of the view coordinate system */
0708         void viewportCoordinateSystemChanged();
0709 
0710     private:
0711         QModelIndex conditionallyMapFromSource( const QModelIndex & sourceIndex ) const;
0712     };
0713 
0714     typedef QList<AbstractDiagram*> AbstractDiagramList;
0715     typedef QList<const AbstractDiagram*> ConstAbstractDiagramList;
0716 
0717     /**
0718       * @brief Internally used class just adding a special constructor used by AbstractDiagram
0719       */
0720     class PrivateAttributesModel : public AttributesModel {
0721         Q_OBJECT
0722     public:
0723         explicit PrivateAttributesModel( QAbstractItemModel* model, QObject * parent = nullptr )
0724             : AttributesModel(model,parent) {}
0725     };
0726 }
0727 
0728 #endif