Commit ef0d3725 authored by Johannes Simon's avatar Johannes Simon

Allow chart to have multiple data tables.

A TableSource is introduced which is used to manage all tables as name/model pairs. The CellRegion is changed
to store a Table* pointer ("handed out" by TableSource) instead ot just the sheet name.

The ChartProxyModel is adapted to accommodate these changes. ChartProxyModel::slotRows/Columns/Inserted/Removes()
are obsolete, remove them. Another commit will change the ChartTableEditor to take care of handling removals
and insertions in the internal data table, as this is to be handled as a special case.

Various test cases have been written to cover these changes and are in this commit or will be committet later.

See http://svn.reviewboard.kde.org/r/5373/

svn path=/trunk/koffice/; revision=1176523
parent 3e8eb4c8
......@@ -20,28 +20,48 @@
#define KOCHART_INTERFACE
#include <QtCore/QtPlugin>
#include <QtPlugin>
#include <Qt>
#define ChartShapeId "ChartShape"
class QAbstractItemModel;
class QRect;
class QString;
namespace KoChart
{
/**
* Interface for ChartShape to embed it into a spreadsheet.
*/
class ChartInterface
{
public:
virtual ~ChartInterface() {}
virtual void setModel(QAbstractItemModel* model, bool takeOwnershipOfModel = false) = 0;
virtual void setModel(QAbstractItemModel* model, const QVector<QRect> &selection) = 0;
virtual void setFirstRowIsLabel(bool isLabel) = 0;
virtual void setFirstColumnIsLabel(bool isLabel) = 0;
virtual void setDataDirection(Qt::Orientation orientation) = 0;
/**
* Sets the SheetAccessModel to be used by this chart. Use this method if
* you want to embed the ChartShape into a spreadsheet.
*
* See kspread/SheetAccessModel.h for details.
*/
virtual void setSheetAccessModel(QAbstractItemModel* model) = 0;
/**
* Re-initializes the chart with data from an arbitrary region.
*
* @param region Name of region to use, e.g. "Table1.A1:B3"
* @param firstRowIsLabel Whether to interpret the first row as labels
* @param firstColumnIsLabel Whether to interpret the first column as labels
* @param dataDirection orientation of a data set. Qt::Horizontal means a row is
* to be interpreted as one data set, columns with Qt::Vertical.
*/
virtual void reset(const QString& region,
bool firstRowIsLabel,
bool firstColumnIsLabel,
Qt::Orientation dataDirection) = 0;
};
} // namespace KoChart
......@@ -49,3 +69,4 @@ public:
Q_DECLARE_INTERFACE(KoChart::ChartInterface, "org.koffice.KoChart.ChartInterface:1.0")
#endif // KOCHART_INTERFACE
......@@ -63,6 +63,7 @@
#include <KDChartThreeDPieAttributes>
#include <KDChartThreeDLineAttributes>
#include <KDChartDataValueAttributes>
#include <KDChartBackgroundAttributes>
// KChart
#include "PlotArea.h"
......@@ -73,7 +74,7 @@
#include "ChartProxyModel.h"
#include "TextLabelDummy.h"
#include "Layout.h"
#include <KDChartBackgroundAttributes>
#include "OdfLoadingHelper.h"
using namespace KChart;
......@@ -176,7 +177,7 @@ public:
ChartType plotAreaChartType;
ChartSubtype plotAreaChartSubType;
QString categoryDataRegionString;
CellRegion categoryDataRegion;
// If KDChart::LineDiagram::centerDataPoints() property is set to true,
// the data points drawn in a line (i.e., also an area) diagram start at
......@@ -1149,7 +1150,7 @@ bool Axis::attachDataSet( DataSet *dataSet, bool silent )
d->dataSets.append( dataSet );
if ( dimension() == XAxisDimension ) {
dataSet->setCategoryDataRegionString( d->categoryDataRegionString );
dataSet->setCategoryDataRegion( d->categoryDataRegion );
}
else if ( dimension() == YAxisDimension ) {
dataSet->setAttachedAxis( this );
......@@ -1186,7 +1187,7 @@ bool Axis::detachDataSet( DataSet *dataSet, bool silent )
d->dataSets.removeAll( dataSet );
if ( dimension() == XAxisDimension ) {
dataSet->setCategoryDataRegionString( "" );
dataSet->setCategoryDataRegion( CellRegion() );
}
else if ( dimension() == YAxisDimension ) {
ChartType chartType = dataSet->chartType();
......@@ -1443,17 +1444,17 @@ Qt::Orientation Axis::orientation()
return Qt::Vertical;
}
QString Axis::categoryDataRegionString() const
CellRegion Axis::categoryDataRegion() const
{
return d->categoryDataRegionString;
return d->categoryDataRegion;
}
void Axis::setCategoryDataRegionString( const QString &region )
void Axis::setCategoryDataRegion( const CellRegion &region )
{
d->categoryDataRegionString = region;
d->categoryDataRegion = region;
foreach( DataSet *dataSet, d->dataSets )
dataSet->setCategoryDataRegionString( region );
dataSet->setCategoryDataRegion( region );
}
bool Axis::loadOdf( const KoXmlElement &axisElement, KoShapeLoadingContext &context )
......@@ -1461,6 +1462,8 @@ bool Axis::loadOdf( const KoXmlElement &axisElement, KoShapeLoadingContext &cont
KoStyleStack &styleStack = context.odfLoadingContext().styleStack();
styleStack.save();
OdfLoadingHelper *helper = (OdfLoadingHelper*)context.sharedData( OdfLoadingHelperId );
d->title->setVisible( false );
QPen gridPen(Qt::NoPen);
......@@ -1553,7 +1556,7 @@ bool Axis::loadOdf( const KoXmlElement &axisElement, KoShapeLoadingContext &cont
}
else if ( n.localName() == "categories" ) {
if ( n.hasAttributeNS( KoXmlNS::table, "cell-range-address" ) )
setCategoryDataRegionString( n.attributeNS( KoXmlNS::table, "cell-range-address" ) );
setCategoryDataRegion( CellRegion( helper->tableSource, n.attributeNS( KoXmlNS::table, "cell-range-address" ) ) );
}
}
......
......@@ -76,9 +76,18 @@ public:
Qt::Orientation orientation();
QFont font() const;
bool isVisible() const;
QString categoryDataRegionString() const;
void setCategoryDataRegionString( const QString &region );
CellRegion categoryDataRegion() const;
/**
* Sets the cell region to use for categories in this axis.
*
* FIXME: This only applies to an x axis. Also, there's always exactly
* one region for categories in an entire chart (TODO: verify).
* Right now there's four (!) classes holding this region: Axis, DataSet,
* PlotArea and ChartProxyModel. Only one should hold this property.
*/
void setCategoryDataRegion( const CellRegion &region );
void setPosition( AxisPosition position );
void setTitleText( const QString &text );
......
add_subdirectory( kdchart )
add_subdirectory( tests )
include_directories( ${CMAKE_SOURCE_DIR}/plugins/chartshape
${CMAKE_SOURCE_DIR}/plugins/chartshape/kdchart/include
......@@ -19,6 +20,7 @@ SET (chartshape_LIB_SRCS
Legend.cpp
TextLabelDummy.cpp
PlotArea.cpp
TableSource.cpp
ChartProxyModel.cpp
KDChartModel.cpp
Surface.cpp
......
......@@ -36,6 +36,9 @@
// KDE
#include <kdebug.h>
// KChart
#include "TableSource.h"
using std::pow;
using namespace KChart;
......@@ -66,14 +69,15 @@ public:
// changes were made to this region.
bool origStringValid;
// Name of the sheet this region lies in
QString sheetName;
/// Table this region is in (name/model pair provided by TableSource)
Table *table;
};
CellRegion::Private::Private()
{
origStringValid = false;
table = 0;
}
CellRegion::Private::~Private()
......@@ -97,7 +101,7 @@ CellRegion::CellRegion( const CellRegion &region )
*this = region;
}
CellRegion::CellRegion( const QString& region )
CellRegion::CellRegion( TableSource *source, const QString& region )
: d( new Private() )
{
// A dollar sign before a part of the address means that this part
......@@ -121,9 +125,10 @@ CellRegion::CellRegion( const QString& region )
// here. We do not support more than one table in a cell region.
// Also we do not support regions spanned over different sheets. For us
// everything is either on no sheet or on the same sheet.
d->sheetName = regEx.cap( 1 );
if ( d->sheetName.endsWith( "." ) )
d->sheetName = d->sheetName.left( d->sheetName.length() - 1 );
QString sheetName = regEx.cap( 1 );
if ( sheetName.endsWith( "." ) )
sheetName = sheetName.left( sheetName.length() - 1 );
d->table = source->get( sheetName );
QPoint topLeft( rangeStringToInt( regEx.cap(2) ), regEx.cap(3).toInt() );
if ( isPoint ) {
......@@ -138,28 +143,32 @@ CellRegion::CellRegion( const QString& region )
d->origStringValid = true;
}
CellRegion::CellRegion( const QPoint &point )
CellRegion::CellRegion( Table *table, const QPoint &point )
: d( new Private() )
{
d->table = table;
add( point );
}
CellRegion::CellRegion( const QRect &rect )
CellRegion::CellRegion( Table *table, const QRect &rect )
: d( new Private() )
{
d->table = table;
add( rect );
}
CellRegion::CellRegion( const QPoint &point, const QSize &size )
CellRegion::CellRegion( Table *table, const QVector<QRect> &rects )
: d( new Private() )
{
add( QRect( point, size ) );
d->table = table;
foreach( QRect rect, rects )
add( rect );
}
CellRegion::CellRegion( const QVector<QRect> &rects )
CellRegion::CellRegion( Table *table )
: d( new Private() )
{
add( rects );
d->table = table;
}
CellRegion::~CellRegion()
......@@ -174,7 +183,7 @@ CellRegion& CellRegion::operator = ( const CellRegion& region )
d->boundingRect = region.d->boundingRect;
d->origString = region.d->origString;
d->origStringValid = region.d->origStringValid;
d->sheetName = region.d->sheetName;
d->table = region.d->table;
return *this;
}
......@@ -185,6 +194,10 @@ bool CellRegion::operator == ( const CellRegion &other ) const
}
Table *CellRegion::table() const
{
return d->table;
}
QVector<QRect> CellRegion::rects() const
{
......@@ -198,7 +211,7 @@ int CellRegion::rectCount() const
QString CellRegion::sheetName() const
{
return d->sheetName;
return d->table->name();
}
bool CellRegion::isValid() const
......@@ -210,8 +223,6 @@ QString CellRegion::Private::pointToString( const QPoint &point ) const
{
QString result;
if(!sheetName.isEmpty())
result.append( '$' + sheetName + '.' );
result.append( '$' + columnName( point.x() ) );
result.append( '$' + QString::number( point.y() ) );
......@@ -230,6 +241,8 @@ QString CellRegion::toString() const
for ( int i = 0; i < d->rects.count(); ++i ) {
const QRect range = d->rects[i];
// Top-left corner
if ( table() )
result.append( '$' + table()->name() + '.' );
result.append( d->pointToString( range.topLeft() ) );
// If it is not a point, append rect's bottom-right corner
......@@ -330,6 +343,8 @@ void CellRegion::add( const QRect &rect )
{
d->origStringValid = false;
// These checks are obsolete, a CellRegion can be used otherwise as well
#if 0
if ( !rect.isValid() ) {
qWarning() << "CellRegion::add() Attempt to add invalid rectangle";
qWarning() << "CellRegion::add():" << rect;
......@@ -341,6 +356,7 @@ void CellRegion::add( const QRect &rect )
qWarning() << "CellRegion::add():" << rect;
return;
}
#endif
d->rects.append( rect );
d->boundingRect |= rect;
......@@ -490,11 +506,6 @@ static QString rangeIntToString( int i )
return tmp;
}
#endif
// static
QVector<QRect> CellRegion::stringToRegion( const QString &string )
{
return CellRegion( string ).rects();
}
int CellRegion::rangeCharToInt( char c )
{
......@@ -542,9 +553,3 @@ static QString columnName( uint column )
return str;
}
// static
QString CellRegion::regionToString( const QVector<QRect> &region )
{
return CellRegion( region ).toString();
}
......@@ -68,20 +68,25 @@ namespace KChart {
* region can vary, as well as their sizes.
*/
// Definition in TableSource.h
class Table;
class CHARTSHAPELIB_EXPORT CellRegion
{
public:
CellRegion();
CellRegion( const CellRegion& region );
CellRegion( const QString& region );
CellRegion( const QPoint &point );
CellRegion( const QRect &rect );
CellRegion( const QPoint &point, const QSize &size );
CellRegion( const QVector<QRect> &rects );
CellRegion( TableSource *source, const QString& region );
CellRegion( Table *table, const QPoint &point );
CellRegion( Table *table, const QRect &rect );
CellRegion( Table *table, const QVector<QRect> &rects );
CellRegion( Table *table );
~CellRegion();
CellRegion& operator = ( const CellRegion& region );
bool operator == ( const CellRegion &other ) const;
Table *table() const;
QVector<QRect> rects() const;
......@@ -116,9 +121,6 @@ public:
QPoint pointAtIndex( int index ) const;
int indexAtPoint( const QPoint &point ) const;
static QString regionToString( const QVector<QRect> &region );
static QVector<QRect> stringToRegion( const QString &string );
static int rangeCharToInt( char c );
static int rangeStringToInt( const QString &string );
static QString rangeIntToString( int i );
......
......@@ -63,6 +63,7 @@
#include "commands/ChartTypeCommand.h"
#include "CellRegionStringValidator.h"
#include "ChartTableModel.h"
#include "TableSource.h"
using namespace KChart;
......@@ -140,6 +141,8 @@ public:
// Table Editor (a.k.a. the data editor)
TableEditorDialog *tableEditorDialog;
// Source containing all tables the chart uses (name/model pairs)
TableSource *tableSource;
// Legend
QButtonGroup *positionButtonGroup;
......@@ -426,9 +429,11 @@ void ChartConfigWidget::open( KoShape* shape )
}
}
KoChart::ChartModel *spreadSheetModel = qobject_cast<KoChart::ChartModel*>( d->shape->model() );
ChartTableModel *tableModel = qobject_cast<ChartTableModel*>( d->shape->model() );
d->isExternalDataSource = ( spreadSheetModel != 0 && tableModel == 0 );
// NOTE: There's no single source table anymore, a KSpread workbook allows multiple to be used with a chart.
// KoChart::ChartModel *spreadSheetModel = qobject_cast<KoChart::ChartModel*>( d->shape->internalModel() );
// NOTE: This is obsolete, ChartShape::isEmbedded() is now used instead.
// ChartTableModel *tableModel = qobject_cast<ChartTableModel*>( d->shape->model() );
// d->isExternalDataSource = ( spreadSheetModel != 0 && tableModel == 0 );
// Update the axis titles
//d->ui.xAxisTitle->setText( ((KDChart::AbstractCartesianDiagram*)d->shape->chart()->coordinatePlane()->diagram())->axes()[0]->titleText() );
......@@ -438,12 +443,16 @@ void ChartConfigWidget::open( KoShape* shape )
//d->ui.legendTitle->setText( d->shape->legend()->title() );
// Fill the data table
if ( d->isExternalDataSource ) {
if ( d->shape->isEmbedded() ) {
// FIXME: CellRegion itself together with a TableSource should now be used
// to validate the correctness of a table range address.
#if 0
d->cellRegionStringValidator = new CellRegionStringValidator( spreadSheetModel );
d->cellRegionDialog.labelDataRegion->setValidator( d->cellRegionStringValidator );
d->cellRegionDialog.xDataRegion->setValidator( d->cellRegionStringValidator );
d->cellRegionDialog.yDataRegion->setValidator( d->cellRegionStringValidator );
d->cellRegionDialog.categoryDataRegion->setValidator( d->cellRegionStringValidator );
#endif
// If the data source is external, the editData button opens a
// dialog to edit the data ranges instead of the data itself.
......@@ -1045,6 +1054,7 @@ void ChartConfigWidget::slotShowTableEditor( bool show )
if ( !d->tableEditorDialog ) {
d->tableEditorDialog = new TableEditorDialog;
d->tableEditorDialog->setProxyModel( d->shape->proxyModel() );
d->tableEditorDialog->setModel( d->shape->internalModel() );
}
if ( show ) {
......@@ -1268,7 +1278,8 @@ void ChartConfigWidget::ui_dataSetXDataRegionChanged()
if ( d->selectedDataSet_CellRegionDialog < 0 )
return;
const QString region = d->cellRegionDialog.xDataRegion->text();
const QString regionString = d->cellRegionDialog.xDataRegion->text();
const CellRegion region( d->tableSource, regionString );
DataSet *dataSet = d->dataSets[ d->selectedDataSet_CellRegionDialog ];
......@@ -1281,7 +1292,8 @@ void ChartConfigWidget::ui_dataSetYDataRegionChanged()
if ( d->selectedDataSet_CellRegionDialog < 0 )
return;
const QString region = d->cellRegionDialog.yDataRegion->text();
const QString regionString = d->cellRegionDialog.yDataRegion->text();
const CellRegion region( d->tableSource, regionString );
DataSet *dataSet = d->dataSets[ d->selectedDataSet_CellRegionDialog ];
......@@ -1313,7 +1325,8 @@ void ChartConfigWidget::ui_dataSetCategoryDataRegionChanged()
if ( d->selectedDataSet_CellRegionDialog < 0 )
return;
const QString region = d->cellRegionDialog.categoryDataRegion->text();
const QString regionString = d->cellRegionDialog.categoryDataRegion->text();
const CellRegion region( d->tableSource, regionString );
DataSet *dataSet = d->dataSets[ d->selectedDataSet_CellRegionDialog ];
......@@ -1326,7 +1339,8 @@ void ChartConfigWidget::ui_dataSetLabelDataRegionChanged()
if ( d->selectedDataSet_CellRegionDialog < 0 )
return;
const QString region = d->cellRegionDialog.labelDataRegion->text();
const QString regionString = d->cellRegionDialog.labelDataRegion->text();
const CellRegion region( d->tableSource, regionString );
DataSet *dataSet = d->dataSets[ d->selectedDataSet_CellRegionDialog ];
......@@ -1342,16 +1356,16 @@ void ChartConfigWidget::ui_dataSetSelectionChanged_CellRegionDialog( int index )
DataSet *dataSet = d->dataSets[ index ];
const int dimensions = dataSet->dimension();
d->cellRegionDialog.labelDataRegion->setText( dataSet->labelDataRegionString() );
d->cellRegionDialog.labelDataRegion->setText( dataSet->labelDataRegion().toString() );
if ( dimensions > 1 )
{
d->cellRegionDialog.xDataRegion->setEnabled( true );
d->cellRegionDialog.xDataRegion->setText( dataSet->xDataRegionString() );
d->cellRegionDialog.xDataRegion->setText( dataSet->xDataRegion().toString() );
}
else
d->cellRegionDialog.xDataRegion->setEnabled( false );
d->cellRegionDialog.yDataRegion->setText( dataSet->yDataRegionString() );
d->cellRegionDialog.categoryDataRegion->setText( dataSet->categoryDataRegionString() );
d->cellRegionDialog.yDataRegion->setText( dataSet->yDataRegion().toString() );
d->cellRegionDialog.categoryDataRegion->setText( dataSet->categoryDataRegion().toString() );
d->selectedDataSet_CellRegionDialog = index;
}
......
......@@ -124,11 +124,11 @@ signals:
void showVerticalLinesChanged( bool b );
void showHorizontalLinesChanged( bool b );
void dataSetXDataRegionChanged( DataSet *dataSet, const QString &region );
void dataSetYDataRegionChanged( DataSet *dataSet, const QString &region );
void dataSetCustomDataRegionChanged( DataSet *dataSet, const QString &region );
void dataSetCategoryDataRegionChanged( DataSet *dataSet, const QString &region );
void dataSetLabelDataRegionChanged( DataSet *dataSet, const QString &region );
void dataSetXDataRegionChanged( DataSet *dataSet, const CellRegion &region );
void dataSetYDataRegionChanged( DataSet *dataSet, const CellRegion &region );
void dataSetCustomDataRegionChanged( DataSet *dataSet, const CellRegion &region );
void dataSetCategoryDataRegionChanged( DataSet *dataSet, const CellRegion &region );
void dataSetLabelDataRegionChanged( DataSet *dataSet, const CellRegion &region );
void datasetColorChanged( DataSet *dataSet, const QColor& color );
void datasetShowValuesChanged( DataSet *dataSet, bool b );
......
This diff is collapsed.
......@@ -22,6 +22,9 @@
#define KCHART_PROXYMODEL_H
#define INTERNAL_TABLE_NAME "ChartTable"
// KChart
#include "ChartShape.h"
#include "CellRegion.h"
......@@ -34,7 +37,7 @@ namespace KoChart
// Qt
#include <QAbstractProxyModel>
#include <QAbstractTableModel>
namespace KChart {
......@@ -42,24 +45,38 @@ namespace KChart {
/**
* @brief The ChartProxyModel is a factory for the DataSet's and decorates the ChartTableModel.
*/
class CHARTSHAPELIB_EXPORT ChartProxyModel : public QAbstractProxyModel
class CHARTSHAPELIB_EXPORT ChartProxyModel : public QAbstractTableModel
{
Q_OBJECT
public:
ChartProxyModel();
ChartProxyModel( TableSource *source );
~ChartProxyModel();
public slots:
virtual void setSourceModel( QAbstractItemModel *sourceModel );
virtual void setSourceModel( QAbstractItemModel *sourceModel,
const QVector<QRect> &selection );
/**
* Used for data retrieval of all relevant dimensions: x, y, z, etc.
*
* This enum may be extended at a later point to store and retrieve
* attributes.
*/
enum DataRole {
XDataRole = Qt::UserRole,
YDataRole,
CustomDataRole,
LabelDataRole,
CategoryDataRole,
};
void setSelection( const QVector<QRect> &selection );
void setAutomaticDataSetCreation( bool enable );
bool automaticDataSetCreation() const;
/**
* Re-initializes the model with data from an arbitrary region.
*
* All data will be taken from the data source passed in the constructor.
* The ProxyModel will not react on insertions or removals in one of
* these models.
*/
void reset( const CellRegion &region );
public slots:
QList<DataSet*> createDataSetsFromRegion( QList<DataSet*> dataSetsToRecycle );
/**
......@@ -68,23 +85,21 @@ public slots:
bool loadOdf( const KoXmlElement &element, KoShapeLoadingContext &context );
void saveOdf( KoShapeSavingContext &context ) const;
virtual QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const;
virtual QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;
virtual QVariant data( const QModelIndex &index, int role ) const;
virtual QVariant headerData( int section, Qt::Orientation orientation, int role ) const;
virtual void dataChanged( const QModelIndex& topLeft, const QModelIndex& bottomRight );
virtual QMap<int, QVariant> itemData( const QModelIndex &index ) const;
virtual QModelIndex index( int row, int column, const QModelIndex &parent = QModelIndex() ) const;
virtual QModelIndex parent( const QModelIndex &index ) const;
virtual QModelIndex mapFromSource( const QModelIndex &sourceIndex ) const;
virtual QModelIndex mapToSource( const QModelIndex &proxyIndex ) const;
Qt::Orientation mapFromSource( Qt::Orientation orientation ) const;
Qt::Orientation mapToSource( Qt::Orientation orientation ) const;
/**
* Returns the number of data sets in this model.
*/
virtual int rowCount( const QModelIndex &parent = QModelIndex() ) const;
/**
* Returns maximum the number of data points the data sets have.
*/
virtual int columnCount( const QModelIndex &parent = QModelIndex() ) const;
// The following methods are specific to the chart
......@@ -92,18 +107,13 @@ public slots:
void setFirstColumnIsLabel( bool b );
void setDataDirection( Qt::Orientation orientation );
void setDataDimensions( int dimensions );
void slotRowsInserted( const QModelIndex &parent, int start, int end );
void slotRowsRemoved( const QModelIndex &parent, int start, int end );
void slotColumnsInserted( const QModelIndex &parent, int start, int end );
void slotColumnsRemoved( const QModelIndex &parent, int start, int end );
bool firstRowIsLabel() const;
bool firstColumnIsLabel() const;
Qt::Orientation dataDirection();
QString categoryDataRegion() const;
void setCategoryDataRegion(const QString& region);
CellRegion categoryDataRegion() const;
void setCategoryDataRegion( const CellRegion &region );
QList<DataSet*> dataSets() const;
......@@ -114,12 +124,23 @@ public slots:
*/
void rebuildDataMap();
/**
* Called by the TableSource whenever a table is added to it.
*
* TODO: It might improve performance if tables are only added when
* they are really in use. That is not necessarily the case if they
* are in the TableSource.
*/
void addTable( Table *table );
/**
* Called by the TableSource whenever a table is removed from it.
*/
void removeTable( Table *table );
signals:
void dataChanged();
protected slots:
void slotModelReset();
private:
#if QT_VERSION < 0x040600
//! @todo Remove once we drop support for Qt < 4.6
......
......@@ -103,6 +103,8 @@
#include "ChartDocument.h"
#include "ChartTableModel.h"
#include "Layout.h"
#include "TableSource.h"
#include "OdfLoadingHelper.h"
// Define the protocol used here for embedded documents' URL
......@@ -255,8 +257,11 @@ public:
PlotArea *plotArea;
// Data
QAbstractItemModel *internalModel; // The actual data
ChartProxyModel *proxyModel; // What's presented to KDChart
ChartProxyModel *proxyModel; /// What's presented to KDChart
QAbstractItemModel *internalModel;
TableSource tableSource;
bool embedded; /// @see isEmbedded()
ChartDocument *document;
......@@ -268,6 +273,7 @@ public:
ChartShape::Private::Private( ChartShape *shape )
: resourceManager(0)
, internalModel( 0 )
{
// Register the owner.
this->shape = shape;
......@@ -280,9 +286,11 @@ ChartShape::Private::Private( ChartShape *shape )
plotArea = 0;
// Data
internalModel = 0;
proxyModel = 0;
// If not explicitly set otherwise, this chart is not embedded.
embedded = false;
document = 0;
}
......@@ -366,7 +374,7 @@ ChartShape::ChartShape(KoResourceManager *resourceManager)
setShapeId( ChartShapeId );