1/* This file is part of the KDE project
2 Copyright 2007 Stefan Nikolaus <stefan.nikolaus@kdemail.net>
3 Copyright (C) 2008 Thomas Zander <zander@kde.org>
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 as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/
20
21#ifndef CALLIGRA_SHEETS_BINDING_MODEL
22#define CALLIGRA_SHEETS_BINDING_MODEL
23
24#include "Region.h"
25
26#include <KoChartModel.h>
27
28#include <QAbstractTableModel>
29
30namespace Calligra
31{
32namespace Sheets
33{
34class Binding;
35
36/**
37 * A model for a cell range acting as data source.
38 */
39class BindingModel : public QAbstractTableModel, public KoChart::ChartModel
40{
41 Q_OBJECT
42 Q_INTERFACES(KoChart::ChartModel)
43public:
44 explicit BindingModel(Binding* binding, QObject *parent = 0);
45
46 // QAbstractTableModel interface
47 virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
48 virtual int rowCount(const QModelIndex& parent = QModelIndex()) const;
49 virtual int columnCount(const QModelIndex& parent = QModelIndex()) const;
50 virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
51
52 // KoChart::ChartModel interface
53 virtual QHash<QString, QVector<QRect> > cellRegion() const;
54 virtual bool setCellRegion(const QString& regionName);
55 virtual bool isCellRegionValid(const QString& regionName) const;
56
57 const Region& region() const;
58 void setRegion(const Region& region);
59
60 void emitDataChanged(const QRect& range);
61 void emitChanged(const Region& region);
62
63signals:
64 void changed(const Region& region);
65
66private:
67 Region m_region;
68 Binding* m_binding;
69};
70
71} // namespace Sheets
72} // namespace Calligra
73
74#endif // CALLIGRA_SHEETS_BINDING_MODEL
75