File indexing completed on 2024-05-05 17:04:28

0001 /* This file is part of the KDE project
0002 
0003    Copyright 2008 Johannes Simon <johannes.simon@gmail.com>
0004 
0005    This library is free software; you can redistribute it and/or
0006    modify it under the terms of the GNU Library General Public
0007    License version 2 as published by the Free Software Foundation.
0008 
0009    This library is distributed in the hope that it will be useful,
0010    but WITHOUT ANY WARRANTY; without even the implied warranty of
0011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0012    Library General Public License for more details.
0013 
0014    You should have received a copy of the GNU Library General Public License
0015    along with this library; see the file COPYING.LIB.  If not, write to
0016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0017    Boston, MA 02110-1301, USA.
0018 */
0019 
0020 #ifndef KO_CHART_MODEL
0021 #define KO_CHART_MODEL
0022 
0023 
0024 #include <QHash>
0025 #include <QVector>
0026 #include <QtPlugin>
0027 
0028 
0029 class QRect;
0030 
0031 
0032 namespace KoChart {
0033 
0034 /**
0035 * Item data role used to retrieve the string representing the data area
0036 * of a row or a column.
0037 *
0038 * Example:
0039 * The area string of the 3rd row would be retrieved with this line of code:
0040 * QString area = model->headerData( 2, Qt::Vertical, SECTION_AREA_ROLE );
0041 * ("$Table2.$D9:$D13", for instance)
0042 */
0043 const int SECTION_AREA_ROLE = 32;
0044 
0045 /**
0046 * Item data role used to retrieve the string representing the data cell
0047 * of a header. The header data usually is a name for the dataset.
0048 *
0049 * Example:
0050 * The area string of the name of the data series that has its y-values
0051 * in the 5th column could be retrieved with this line of code:
0052 * QString cell = model->headerData( 4, Qt::Horizontal, HEADER_AREA_ROLE );
0053 * ("$Table1.$C8", for instance)
0054 */
0055 const int HEADER_AREA_ROLE  = 33;
0056 
0057 /**
0058 * The ChartModel class implements a model that can be filled and
0059 * passed on to KChart to provide the data used within the chart.
0060 */
0061 class ChartModel
0062 {
0063 public:
0064     virtual ~ChartModel() {}
0065 
0066     /**
0067      * \return the cell region in ranges ordered by sheet name
0068      */
0069     virtual QHash<QString, QVector<QRect> > cellRegion() const = 0;
0070 
0071     /**
0072      * Sets the cell region.
0073      * \return \c true on success
0074      */
0075     virtual bool setCellRegion(const QString& regionName) = 0;
0076 
0077     /**
0078      * \return \c true if the cell region is valid
0079      */
0080     virtual bool isCellRegionValid(const QString& regionName) const = 0;
0081 };
0082 
0083 } // Namespace KoChart
0084 
0085 Q_DECLARE_INTERFACE(KoChart::ChartModel, "org.calligra.KoChart.ChartModel:1.0")
0086 
0087 #endif // KO_CHART_MODEL
0088