1/* This file is part of the KDE project
2
3 Copyright 2008 Johannes Simon <johannes.simon@gmail.com>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License version 2 as published by the Free Software Foundation.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
18*/
19
20#ifndef KO_CHART_MODEL
21#define KO_CHART_MODEL
22
23
24#include <QHash>
25#include <QVector>
26#include <QtPlugin>
27
28
29class QAbstractItemModel;
30class QRect;
31
32
33namespace KoChart {
34
35/**
36* Item data role used to retrieve the string representing the data area
37* of a row or a column.
38*
39* Example:
40* The area string of the 3rd row would be retrieved with this line of code:
41* QString area = model->headerData( 2, Qt::Vertical, SECTION_AREA_ROLE );
42* ("$Table2.$D9:$D13", for instance)
43*/
44const int SECTION_AREA_ROLE = 32;
45
46/**
47* Item data role used to retrieve the string representing the data cell
48* of a header. The header data usually is a name for the dataset.
49*
50* Example:
51* The area string of the name of the data series that has its y-values
52* in the 5th column could be retrieved with this line of code:
53* QString cell = model->headerData( 4, Qt::Horizontal, HEADER_AREA_ROLE );
54* ("$Table1.$C8", for instance)
55*/
56const int HEADER_AREA_ROLE = 33;
57
58/**
59* The ChartModel class implements a model that can be filled and
60* passed on to KChart to provide the data used within the chart.
61*/
62class ChartModel
63{
64public:
65 virtual ~ChartModel() {}
66
67 /**
68 * \return the cell region in ranges ordered by sheet name
69 */
70 virtual QHash<QString, QVector<QRect> > cellRegion() const = 0;
71
72 /**
73 * Sets the cell region.
74 * \return \c true on success
75 */
76 virtual bool setCellRegion(const QString& regionName) = 0;
77
78 /**
79 * \return \c true if the cell region is valid
80 */
81 virtual bool isCellRegionValid(const QString& regionName) const = 0;
82};
83
84} // Namespace KoChart
85
86Q_DECLARE_INTERFACE(KoChart::ChartModel, "org.calligra.KoChart.ChartModel:1.0")
87
88#endif // KO_CHART_MODEL
89
90