From 5a2832f9c305479b4f77601caa696dace8e7d222 2012-04-12 10:11:08 From: Tero Ahola Date: 2012-04-12 10:11:08 Subject: [PATCH] Enabled dummy bar chart impl in QML again --- diff --git a/qmlplugin/declarativebarseries.cpp b/qmlplugin/declarativebarseries.cpp index 540d414..b68adc9 100644 --- a/qmlplugin/declarativebarseries.cpp +++ b/qmlplugin/declarativebarseries.cpp @@ -34,49 +34,39 @@ DeclarativeBarSeries::DeclarativeBarSeries(QDeclarativeItem *parent) : void DeclarativeBarSeries::componentComplete() { - if (!m_series) { - DeclarativeChart *declarativeChart = qobject_cast(parent()); +} - if (declarativeChart) { - QChart *chart = qobject_cast(declarativeChart->m_chart); - Q_ASSERT(chart); +void DeclarativeBarSeries::setBarCategories(QStringList categories) +{ + m_categories = categories; -// QStringList categories; -// categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun"; -// m_series = new QBarSeries(categories); -// m_series = new QBarSeries(m_categories); - m_series = new QBarSeries(m_categories); + if (m_series) { + delete m_series; + m_series = 0; + } - // TODO: use data from model - QBarSet *set0 = new QBarSet("Bub"); - QBarSet *set1 = new QBarSet("Bob"); - QBarSet *set2 = new QBarSet("Guybrush"); + DeclarativeChart *declarativeChart = qobject_cast(parent()); + if (declarativeChart) { + QChart *chart = qobject_cast(declarativeChart->m_chart); + Q_ASSERT(chart); - *set0 << 1 << 2 << 3 << 4 << 5 << 6; - *set1 << 5 << 1 << 2 << 4 << 1 << 7; - *set2 << 3 << 5 << 8 << 13 << 8 << 5; + m_series = new QBarSeries(m_categories); - m_series->appendBarSet(set0); - m_series->appendBarSet(set1); - m_series->appendBarSet(set2); + // TODO: use data from model + QBarSet *set0 = new QBarSet("Bub"); + QBarSet *set1 = new QBarSet("Bob"); + QBarSet *set2 = new QBarSet("Guybrush"); - chart->addSeries(m_series); - } - } -} + *set0 << 1 << 2 << 3 << 4 << 5 << 6; + *set1 << 5 << 1 << 2 << 4 << 1 << 7; + *set2 << 3 << 5 << 8 << 13 << 8 << 5; -void DeclarativeBarSeries::setBarCategories(QStringList /*categories*/) -{ -// m_categories = categories; -// if (m_series) { -// // Replace categories of the QBarSeries with the new categories -// for (int i(0); i < m_categories.count(); i++) { -// if (m_series->categories().at(i) != m_categories.at(i)) -// m_series->insertCategory(m_series->categoryCount(), m_categories.at(i)); -// } -// while (m_series->categoryCount() > m_categories.count()) -// m_series->removeCategory(m_series->categoryCount() - 1); -// } + m_series->appendBarSet(set0); + m_series->appendBarSet(set1); + m_series->appendBarSet(set2); + + chart->addSeries(m_series); + } } QStringList DeclarativeBarSeries::barCategories()