File indexing completed on 2024-05-12 13:00:15

0001 /* This file is part of the KDE project
0002 
0003    SPDX-FileCopyrightText: 2008 Johannes Simon <johannes.simon@gmail.com>
0004 
0005    SPDX-License-Identifier: LGPL-2.0-only
0006 */
0007 
0008 #ifndef KO_CHART_MODEL
0009 #define KO_CHART_MODEL
0010 
0011 
0012 #include <QHash>
0013 #include <QVector>
0014 #include <QtPlugin>
0015 
0016 
0017 class QRect;
0018 
0019 
0020 namespace KoChart {
0021 
0022 /**
0023 * Item data role used to retrieve the string representing the data area
0024 * of a row or a column.
0025 *
0026 * Example:
0027 * The area string of the 3rd row would be retrieved with this line of code:
0028 * QString area = model->headerData( 2, Qt::Vertical, SECTION_AREA_ROLE );
0029 * ("$Table2.$D9:$D13", for instance)
0030 */
0031 const int SECTION_AREA_ROLE = 32;
0032 
0033 /**
0034 * Item data role used to retrieve the string representing the data cell
0035 * of a header. The header data usually is a name for the dataset.
0036 *
0037 * Example:
0038 * The area string of the name of the data series that has its y-values
0039 * in the 5th column could be retrieved with this line of code:
0040 * QString cell = model->headerData( 4, Qt::Horizontal, HEADER_AREA_ROLE );
0041 * ("$Table1.$C8", for instance)
0042 */
0043 const int HEADER_AREA_ROLE  = 33;
0044 
0045 /**
0046 * The ChartModel class implements a model that can be filled and
0047 * passed on to KChart to provide the data used within the chart.
0048 */
0049 class ChartModel
0050 {
0051 public:
0052     virtual ~ChartModel() {}
0053 
0054     /**
0055      * \return the cell region in ranges ordered by sheet name
0056      */
0057     virtual QHash<QString, QVector<QRect> > cellRegion() const = 0;
0058 
0059     /**
0060      * Sets the cell region.
0061      * \return \c true on success
0062      */
0063     virtual bool setCellRegion(const QString& regionName) = 0;
0064 
0065     /**
0066      * \return \c true if the cell region is valid
0067      */
0068     virtual bool isCellRegionValid(const QString& regionName) const = 0;
0069 };
0070 
0071 } // Namespace KoChart
0072 
0073 Q_DECLARE_INTERFACE(KoChart::ChartModel, "org.calligra.KoChart.ChartModel:1.0")
0074 
0075 #endif // KO_CHART_MODEL
0076