File indexing completed on 2024-05-12 16:33:30

0001 /* This file is part of the KDE project
0002 
0003    Copyright 2008 Johannes Simon <johannes.simon@gmail.com>
0004    Copyright 2009 Inge Wallin    <inge@lysator.liu.se>
0005 
0006    This library is free software; you can redistribute it and/or
0007    modify it under the terms of the GNU Library General Public
0008    License as published by the Free Software Foundation; either
0009    version 2 of the License, or (at your option) any later version.
0010 
0011    This library is distributed in the hope that it will be useful,
0012    but WITHOUT ANY WARRANTY; without even the implied warranty of
0013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0014    Library General Public License for more details.
0015 
0016    You should have received a copy of the GNU Library General Public License
0017    along with this library; see the file COPYING.LIB.  If not, write to
0018    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0019    Boston, MA 02110-1301, USA.
0020 */
0021 
0022 
0023 #ifndef KCHART_CHARTTABLEMODEL_H
0024 #define KCHART_CHARTTABLEMODEL_H
0025 
0026 
0027 // Qt
0028 #include <QVector>
0029 #include <QStandardItemModel>
0030 
0031 // Interface
0032 #include <interfaces/KoChartModel.h>
0033 
0034 // KoChart
0035 #include "ChartShape.h"
0036 
0037 
0038 class QString;
0039 
0040 // FIXME: Should it inherit QAbstractTableModel instead?
0041 
0042 namespace KoChart {
0043 
0044 /**
0045  * @brief The ChartTableModel class is used to store a data table inside a chart document.  It's main difference to a normal table model is that it can load and store to ODF.
0046  */
0047 class ChartTableModel : public QStandardItemModel, public KoChart::ChartModel
0048 {
0049     Q_OBJECT
0050     Q_INTERFACES(KoChart::ChartModel)
0051 
0052 public:
0053     explicit ChartTableModel(QObject *parent = 0);
0054     ~ChartTableModel();
0055 
0056     QVariant headerData(int section, Qt::Orientation, int role = Qt::DisplayRole) const override;
0057 
0058     // KoChart::ChartModel interface
0059     QHash<QString, QVector<QRect> > cellRegion() const override;
0060     bool setCellRegion(const QString& regionName) override;
0061     bool isCellRegionValid(const QString& regionName) const override;
0062 
0063     // Load and save the contained data in an ODF DOM tree.
0064     // FIXME: Move saving/loading logic to helper class like TableLoaderAndSaver,
0065     // this class is outdated and should be removed.
0066     bool loadOdf(const KoXmlElement &tableElement, 
0067                  KoShapeLoadingContext &context);
0068     bool saveOdf(KoXmlWriter &bodyWriter, KoGenStyles &mainStyles) const;
0069 };
0070 
0071 }
0072 
0073 #endif // KCHART_TABLEMODEL_H