diff --git a/doc/src/classes.qdoc b/doc/src/classes.qdoc index 00a4178..850dae6 100644 --- a/doc/src/classes.qdoc +++ b/doc/src/classes.qdoc @@ -55,7 +55,13 @@
  • QSplineSeries
  • QStackedBarSeries
  • QXYSeries
  • -
  • QLegend
  • +
  • QLegend
  • +
  • QHPieModelMapper
  • +
  • QVPieModelMapper
  • +
  • QHBarModelMapper
  • +
  • QVBarModelMapper
  • +
  • QHXYModelMapper
  • +
  • QVXYModelMapper
  • diff --git a/src/barchart/qbarmodelmapper.cpp b/src/barchart/qbarmodelmapper.cpp index 919b98d..eb1e387 100644 --- a/src/barchart/qbarmodelmapper.cpp +++ b/src/barchart/qbarmodelmapper.cpp @@ -2,6 +2,8 @@ #include "qbarmodelmapper_p.h" #include "qbarseries.h" #include "qbarset.h" +#include "qchart.h" +#include "qaxis.h" #include QTCOMMERCIALCHART_BEGIN_NAMESPACE @@ -145,7 +147,6 @@ void QBarModelMapper::reset() Q_D(QBarModelMapper); d->m_first = 0; d->m_count = -1; - d->m_orientation = Qt::Vertical; d->m_firstBarSetSection = -1; d->m_lastBarSetSection = -1; d->m_categoriesSection = -1; @@ -185,8 +186,12 @@ QBarSet* QBarModelMapperPrivate::barSet(QModelIndex index) return 0; if (m_orientation == Qt::Vertical && index.column() >= m_firstBarSetSection && index.column() <= m_lastBarSetSection) { - if (index.row() >= m_first && (m_count == - 1 || index.row() < m_first + m_count)) - return m_series->barSets().at(index.column() - m_firstBarSetSection); + if (index.row() >= m_first && (m_count == - 1 || index.row() < m_first + m_count)) { +// if (m_model->index(index.row(), m_valuesSection).isValid() && m_model->index(index.row(), m_labelsSection).isValid()) + return m_series->barSets().at(index.column() - m_firstBarSetSection); +// else +// return 0; + } } else if (m_orientation == Qt::Horizontal && index.row() >= m_firstBarSetSection && index.row() <= m_lastBarSetSection) { if (index.column() >= m_first && (m_count == - 1 || index.column() < m_first + m_count)) return m_series->barSets().at(index.row() - m_firstBarSetSection); @@ -334,6 +339,7 @@ void QBarModelMapperPrivate::insertData(int start, int end) point.setY(m_model->data(yModelIndex(i - m_first), Qt::DisplayRole).toDouble()); m_series->insert(i - m_first, point); } +>>>>>>> Stashed changes } // remove excess of slices (abouve m_count) @@ -403,7 +409,7 @@ void QBarModelMapperPrivate::initializeBarFromModel() m_series->append(barSet); } - if (m_categoriesSection != -1) { + if (m_series->chart() && m_categoriesSection != -1) { int posInCategories = 0; QStringList categories; QModelIndex categoriesIndex = categoriesModelIndex(posInCategories); @@ -412,8 +418,7 @@ void QBarModelMapperPrivate::initializeBarFromModel() posInCategories++; categoriesIndex = categoriesModelIndex(posInCategories); } - // TODO: set the categories to axis -// m_series->setCategories(categories); + m_series->chart()->axisX()->categories()->insert(categories); } blockSeriesSignals(false); } diff --git a/src/barchart/qbarmodelmapper.h b/src/barchart/qbarmodelmapper.h index 748abd3..c5f9c3c 100644 --- a/src/barchart/qbarmodelmapper.h +++ b/src/barchart/qbarmodelmapper.h @@ -10,6 +10,7 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE class QBarModelMapperPrivate; class QBarSeries; +class QChart; class QTCOMMERCIALCHART_EXPORT QBarModelMapper : public QObject { @@ -36,6 +37,9 @@ public: int count() const; void setCount(int count); + void reset(); + +protected: int firstBarSetSection() const; void setFirstBarSetSection(int firstBarSetSection); @@ -45,11 +49,8 @@ public: int categoriesSection() const; void setCategoriesSection(int categoriesSection); -protected: Qt::Orientation orientation() const; - void setOrientation(Qt::Orientation orientation); - - void reset(); + void setOrientation(Qt::Orientation orientation); Q_SIGNALS: void updated(); diff --git a/src/barchart/qhbarmodelmapper.cpp b/src/barchart/qhbarmodelmapper.cpp index 62172b3..05e971d 100644 --- a/src/barchart/qhbarmodelmapper.cpp +++ b/src/barchart/qhbarmodelmapper.cpp @@ -2,6 +2,14 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE +/*! + \class QHBarModelMapper + \brief part of QtCommercial chart API. + \mainclass + + Nothing here yet +*/ + QHBarModelMapper::QHBarModelMapper(QObject *parent) : QBarModelMapper(parent) { diff --git a/src/barchart/qvbarmodelmapper.cpp b/src/barchart/qvbarmodelmapper.cpp index 63d1c7c..593d2c0 100644 --- a/src/barchart/qvbarmodelmapper.cpp +++ b/src/barchart/qvbarmodelmapper.cpp @@ -2,6 +2,14 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE +/*! + \class QVBarModelMapper + \brief part of QtCommercial chart API. + \mainclass + + Nothing here yet +*/ + QVBarModelMapper::QVBarModelMapper(QObject *parent) : QBarModelMapper(parent) { diff --git a/src/piechart/qhpiemodelmapper.cpp b/src/piechart/qhpiemodelmapper.cpp index c4ae013..5ffc97e 100644 --- a/src/piechart/qhpiemodelmapper.cpp +++ b/src/piechart/qhpiemodelmapper.cpp @@ -22,6 +22,14 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE +/*! + \class QHPieModelMapper + \brief part of QtCommercial chart API. + \mainclass + + Nothing here yet +*/ + QHPieModelMapper::QHPieModelMapper(QObject *parent) : QPieModelMapper(parent) { diff --git a/src/piechart/qvpiemodelmapper.cpp b/src/piechart/qvpiemodelmapper.cpp index 537134a..0e02861 100644 --- a/src/piechart/qvpiemodelmapper.cpp +++ b/src/piechart/qvpiemodelmapper.cpp @@ -23,6 +23,14 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE +/*! + \class QVPieModelMapper + \brief part of QtCommercial chart API. + \mainclass + + Nothing here yet +*/ + QVPieModelMapper::QVPieModelMapper(QObject *parent) : QPieModelMapper(parent) { diff --git a/src/xychart/qhxymodelmapper.cpp b/src/xychart/qhxymodelmapper.cpp index ad123a4..6167959 100644 --- a/src/xychart/qhxymodelmapper.cpp +++ b/src/xychart/qhxymodelmapper.cpp @@ -2,6 +2,14 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE +/*! + \class QHXYModelMapper + \brief part of QtCommercial chart API. + \mainclass + + Nothing here yet +*/ + QHXYModelMapper::QHXYModelMapper(QObject *parent) : QXYModelMapper(parent) { diff --git a/src/xychart/qvxymodelmapper.cpp b/src/xychart/qvxymodelmapper.cpp index 78539cd..433c873 100644 --- a/src/xychart/qvxymodelmapper.cpp +++ b/src/xychart/qvxymodelmapper.cpp @@ -2,6 +2,14 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE +/*! + \class QVXYModelMapper + \brief part of QtCommercial chart API. + \mainclass + + Nothing here yet +*/ + QVXYModelMapper::QVXYModelMapper(QObject *parent) : QXYModelMapper(parent) { diff --git a/tests/tablemodelchart/tablewidget.cpp b/tests/tablemodelchart/tablewidget.cpp index 61196d3..4a415eb 100644 --- a/tests/tablemodelchart/tablewidget.cpp +++ b/tests/tablemodelchart/tablewidget.cpp @@ -136,7 +136,7 @@ TableWidget::TableWidget(QWidget *parent) connect(m_pieRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool))); connect(m_areaRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool))); connect(m_barRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool))); - m_lineRadioButton->setChecked(true); + m_barRadioButton->setChecked(true); // radio buttons layout QVBoxLayout* radioLayout = new QVBoxLayout; @@ -484,23 +484,27 @@ void TableWidget::updateChartType(bool toggle) // barSeries->setModelMappingRange(2, 5); // barSeries->setModelMapping(5, 2, 4, Qt::Vertical); + int first = 3; -// int count = 4; + int count = 6; QVBarModelMapper *mapper = new QVBarModelMapper; - mapper->setCategoriesSection(5); - mapper->setFirstBarSetSection(2); - mapper->setLastBarSetSection(4); + mapper->setCategoriesColumn(5); + mapper->setFirstBarSetColumn(2); + mapper->setLastBarSetColumn(4); mapper->setFirst(first); -// mapper->setCount(count); + mapper->setCount(count); mapper->setSeries(barSeries); mapper->setModel(m_model); // barSeries->setModelMapper(mapper); m_chart->addSeries(barSeries); + QList barsets = barSeries->barSets(); for (int i = 0; i < barsets.count(); i++) { seriesColorHex = "#" + QString::number(barsets.at(i)->brush().color().rgb(), 16).right(6).toUpper(); m_model->addMapping(seriesColorHex, QRect(2 + i, first, 1, barsets.at(i)->count())); } + + }