diff options
author | Marek Rosa <marek.rosa@digia.com> | 2012-09-07 16:27:10 +0300 |
---|---|---|
committer | Marek Rosa <marek.rosa@digia.com> | 2012-09-07 16:27:10 +0300 |
commit | 14e68f99d8d529f68216b3c0cab82f9d813ac2f3 (patch) | |
tree | 098829b7f852914313d7976554275fa54b44185c | |
parent | 205e74ad98a10b24edc9ef220da28dbd282d1240 (diff) |
Ok. Now chartviewer demo actually removed
23 files changed, 0 insertions, 1897 deletions
diff --git a/demos/chartviewer/charts.h b/demos/chartviewer/charts.h deleted file mode 100644 index 3ab83c67..00000000 --- a/demos/chartviewer/charts.h +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Commercial Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#ifndef CHARTS_H -#define CHARTS_H -#include "model.h" -#include <QList> -#include <QString> -#include <qchartglobal.h> - -QTCOMMERCIALCHART_BEGIN_NAMESPACE -class QChart; -QTCOMMERCIALCHART_END_NAMESPACE - -QTCOMMERCIALCHART_USE_NAMESPACE - -class Chart -{ -public: - virtual ~Chart(){}; - virtual QChart* createChart(const DataTable& table) = 0; - virtual QString name() = 0; - virtual QString category() = 0; - virtual QString subCategory() = 0; - -}; - -namespace Charts -{ - -typedef QList<Chart*> ChartList; - -inline ChartList& chartList() -{ - static ChartList list; - return list; -} - -inline bool findChart(Chart* chart) -{ - ChartList& list = chartList(); - if (list.contains(chart)) { - return true; - } - foreach (Chart* item, list) { - if (item->name() == chart->name() && item->category() == chart->category() && item->subCategory() == chart->subCategory()) { - return true; - } - } - return false; -} - -inline void addChart(Chart* chart) -{ - ChartList& list = chartList(); - if (!findChart(chart)) { - list.append(chart); - } -} -} - -template <class T> -class ChartWrapper -{ -public: - QSharedPointer<T> chart; - ChartWrapper() : chart(new T) - { - Charts::addChart(chart.data()); - } -}; - -#define DECLARE_CHART(chartName) static ChartWrapper<chartName> chartName; - -#endif diff --git a/demos/chartviewer/charts/barseries/horizontalbarchart.cpp b/demos/chartviewer/charts/barseries/horizontalbarchart.cpp deleted file mode 100644 index 5ebe9971..00000000 --- a/demos/chartviewer/charts/barseries/horizontalbarchart.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Commercial Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "charts.h" -#include "qchart.h" -#include "qhorizontalbarseries.h" -#include "qbarset.h" - -class HorizontalBarChart: public Chart -{ -public: - QString name() { return QObject::tr("HorizontalBarChart"); } - QString category() { return QObject::tr("BarSeries"); } - QString subCategory() { return QObject::tr("Horizontal"); } - - QChart* createChart(const DataTable& table) - { - - QChart* chart = new QChart(); - - chart->setTitle("Horizontal bar chart"); - - QHorizontalBarSeries* series = new QHorizontalBarSeries(chart); - for (int i(0); i < table.count(); i++) { - QBarSet *set = new QBarSet("Bar set " + QString::number(i)); - foreach (Data data, table[i]) - *set << data.first.y(); - series->append(set); - } - chart->addSeries(series); - chart->createDefaultAxes(); - return chart; - } - -}; - -DECLARE_CHART(HorizontalBarChart) - diff --git a/demos/chartviewer/charts/barseries/horizontalpercentbarchart.cpp b/demos/chartviewer/charts/barseries/horizontalpercentbarchart.cpp deleted file mode 100644 index ce1223a5..00000000 --- a/demos/chartviewer/charts/barseries/horizontalpercentbarchart.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Commercial Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "charts.h" -#include "qchart.h" -#include "qhorizontalpercentbarseries.h" -#include "qbarset.h" - -class HorizontalPercentBarChart: public Chart -{ -public: - QString name() { return QObject::tr("HorizontalPercentBarChart"); } - QString category() { return QObject::tr("BarSeries"); } - QString subCategory() { return QObject::tr("Horizontal"); } - - QChart* createChart(const DataTable& table) - { - - QChart* chart = new QChart(); - - chart->setTitle("Horizontal percent chart"); - - QHorizontalPercentBarSeries* series = new QHorizontalPercentBarSeries(chart); - for (int i(0); i < table.count(); i++) { - QBarSet *set = new QBarSet("Bar set " + QString::number(i)); - foreach (Data data, table[i]) - *set << data.first.y(); - series->append(set); - } - chart->addSeries(series); - chart->createDefaultAxes(); - return chart; - } - -}; - -DECLARE_CHART(HorizontalPercentBarChart) - diff --git a/demos/chartviewer/charts/barseries/horizontalstackedbarchart.cpp b/demos/chartviewer/charts/barseries/horizontalstackedbarchart.cpp deleted file mode 100644 index e8ba4e3c..00000000 --- a/demos/chartviewer/charts/barseries/horizontalstackedbarchart.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Commercial Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "charts.h" -#include "qchart.h" -#include "qhorizontalstackedbarseries.h" -#include "qbarset.h" - -class HorizontalStackedBarChart: public Chart -{ -public: - QString name() { return QObject::tr("HorizontalStackedBarChart"); } - QString category() { return QObject::tr("BarSeries"); } - QString subCategory() { return QObject::tr("Horizontal"); } - - QChart* createChart(const DataTable& table) - { - - QChart* chart = new QChart(); - - chart->setTitle("Horizontal stacked chart"); - - QHorizontalStackedBarSeries* series = new QHorizontalStackedBarSeries(chart); - for (int i(0); i < table.count(); i++) { - QBarSet *set = new QBarSet("Bar set " + QString::number(i)); - foreach (Data data, table[i]) - *set << data.first.y(); - series->append(set); - } - chart->addSeries(series); - chart->createDefaultAxes(); - return chart; - } - -}; - -DECLARE_CHART(HorizontalStackedBarChart) - diff --git a/demos/chartviewer/charts/barseries/verticalbarchart.cpp b/demos/chartviewer/charts/barseries/verticalbarchart.cpp deleted file mode 100644 index a480b3d4..00000000 --- a/demos/chartviewer/charts/barseries/verticalbarchart.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Commercial Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "charts.h" -#include "qchart.h" -#include "qbarseries.h" -#include "qbarset.h" - -class VerticalBarChart: public Chart -{ -public: - QString name() { return QObject::tr("VerticalBarChart"); } - QString category() { return QObject::tr("BarSeries"); } - QString subCategory() { return QObject::tr("Vertical"); } - - QChart* createChart(const DataTable& table) - { - - QChart* chart = new QChart(); - - chart->setTitle("Vertical bar chart"); - - QBarSeries* series = new QBarSeries(chart); - for (int i(0); i < table.count(); i++) { - QBarSet *set = new QBarSet("Bar set " + QString::number(i)); - foreach (Data data, table[i]) - *set << data.first.y(); - series->append(set); - } - chart->addSeries(series); - chart->createDefaultAxes(); - return chart; - } - -}; - -DECLARE_CHART(VerticalBarChart) - diff --git a/demos/chartviewer/charts/barseries/verticalpercentbarchart.cpp b/demos/chartviewer/charts/barseries/verticalpercentbarchart.cpp deleted file mode 100644 index 5adeb388..00000000 --- a/demos/chartviewer/charts/barseries/verticalpercentbarchart.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Commercial Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "charts.h" -#include "qchart.h" -#include "qpercentbarseries.h" -#include "qbarset.h" - -class VerticalPercentBarChart: public Chart -{ -public: - QString name() { return QObject::tr("VerticalPercentBarChart"); } - QString category() { return QObject::tr("BarSeries"); } - QString subCategory() { return QObject::tr("Vertical"); } - - QChart* createChart(const DataTable& table) - { - - QChart* chart = new QChart(); - - chart->setTitle("Stacked bar chart"); - - QPercentBarSeries* series = new QPercentBarSeries(chart); - for (int i(0); i < table.count(); i++) { - QBarSet *set = new QBarSet("Bar set " + QString::number(i)); - foreach (Data data, table[i]) - *set << data.first.y(); - series->append(set); - } - chart->addSeries(series); - chart->createDefaultAxes(); - return chart; - } - -}; - -DECLARE_CHART(VerticalPercentBarChart) - diff --git a/demos/chartviewer/charts/barseries/verticalstackedbarchart.cpp b/demos/chartviewer/charts/barseries/verticalstackedbarchart.cpp deleted file mode 100644 index c9c1a606..00000000 --- a/demos/chartviewer/charts/barseries/verticalstackedbarchart.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Commercial Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "charts.h" -#include "qchart.h" -#include "qstackedbarseries.h" -#include "qbarset.h" - -class VerticalStackedBarChart: public Chart -{ -public: - QString name() { return QObject::tr("VerticalStackedBarChart"); } - QString category() { return QObject::tr("BarSeries"); } - QString subCategory() { return QObject::tr("Vertical"); } - - QChart* createChart(const DataTable& table) - { - - QChart* chart = new QChart(); - - chart->setTitle("Stacked bar chart"); - - QStackedBarSeries* series = new QStackedBarSeries(chart); - for (int i(0); i < table.count(); i++) { - QBarSet *set = new QBarSet("Bar set " + QString::number(i)); - foreach (Data data, table[i]) - *set << data.first.y(); - series->append(set); - } - chart->addSeries(series); - chart->createDefaultAxes(); - return chart; - } - -}; - -DECLARE_CHART(VerticalStackedBarChart) - diff --git a/demos/chartviewer/charts/charts.pri b/demos/chartviewer/charts/charts.pri deleted file mode 100644 index 43eba969..00000000 --- a/demos/chartviewer/charts/charts.pri +++ /dev/null @@ -1,17 +0,0 @@ -INCLUDEPATH += $$PWD -DEPENDPATH += $$PWD -SOURCES += \ - font/font.cpp \ - xyseries/linechart.cpp \ - xyseries/scatterchart.cpp \ - xyseries/splinechart.cpp \ - xyseries/areachart.cpp \ - xyseries/categorylinechart.cpp \ - barseries/verticalstackedbarchart.cpp \ - barseries/horizontalstackedbarchart.cpp \ - barseries/verticalbarchart.cpp \ - barseries/horizontalbarchart.cpp \ - barseries/horizontalpercentbarchart.cpp \ - barseries/verticalpercentbarchart.cpp \ - pieseries/piechart.cpp \ - pieseries/donutchart.cpp diff --git a/demos/chartviewer/charts/font/font.cpp b/demos/chartviewer/charts/font/font.cpp deleted file mode 100644 index 1ec9d493..00000000 --- a/demos/chartviewer/charts/font/font.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Commercial Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "charts.h" -#include "qchart.h" -#include "qlineseries.h" - -class FontChart: public Chart -{ -public: - FontChart(int fontSize):m_fontSize(fontSize){}; - QString name() { return QObject::tr("Font") + " " + QString::number(m_fontSize); } - QString category() { return QObject::tr("Font"); } - QString subCategory() { return QString::null; } - - QChart* createChart(const DataTable& table) { - - QChart* chart = new QChart(); - chart->setTitle("Font size " + QString::number(m_fontSize)); - - QString name("Series "); - int nameIndex = 0; - foreach (DataList list, table) { - QLineSeries *series = new QLineSeries(chart); - foreach (Data data, list) - series->append(data.first); - series->setName(name + QString::number(nameIndex)); - nameIndex++; - chart->addSeries(series); - } - - chart->createDefaultAxes(); - QFont font; - font.setPixelSize(m_fontSize); - chart->setTitleFont(font); - chart->axisX()->setLabelsFont(font); - chart->axisY()->setLabelsFont(font); - - return chart; - } - -private: - int m_fontSize; - -}; - -class FontChart6:public FontChart{ -public: - FontChart6():FontChart(6){}; -}; - -class FontChart8:public FontChart{ -public: - FontChart8():FontChart(8){}; -}; - -class FontChart10:public FontChart{ -public: - FontChart10():FontChart(10){}; -}; - -class FontChart14:public FontChart{ -public: - FontChart14():FontChart(14){}; -}; - - -class FontChart18:public FontChart{ -public: - FontChart18():FontChart(18){}; -}; - -class FontChart20:public FontChart{ -public: - FontChart20():FontChart(20){}; -}; - -class FontChart24:public FontChart{ -public: - FontChart24():FontChart(24){}; -}; - -class FontChart28:public FontChart{ -public: - FontChart28():FontChart(28){}; -}; - -class FontChart32:public FontChart{ -public: - FontChart32():FontChart(32){}; -}; - -DECLARE_CHART(FontChart6); -DECLARE_CHART(FontChart8); -DECLARE_CHART(FontChart10); -DECLARE_CHART(FontChart14); -DECLARE_CHART(FontChart18); -DECLARE_CHART(FontChart20); -DECLARE_CHART(FontChart24); -DECLARE_CHART(FontChart28); -DECLARE_CHART(FontChart32); diff --git a/demos/chartviewer/charts/pieseries/donutchart.cpp b/demos/chartviewer/charts/pieseries/donutchart.cpp deleted file mode 100644 index 8402b2f3..00000000 --- a/demos/chartviewer/charts/pieseries/donutchart.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Commercial Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "charts.h" -#include "qchart.h" -#include "qpieseries.h" - -class DonutChart: public Chart -{ -public: - QString name() { return QObject::tr("DonutChart"); } - QString category() { return QObject::tr("PieSeries"); } - QString subCategory() { return QString::null; } - - QChart* createChart(const DataTable& table) - { - QChart* chart = new QChart(); - chart->setTitle("Donut chart"); - - for (int i = 0, j = table.count(); i < table.count(); i++,j--) { - QPieSeries *series = new QPieSeries(chart); - foreach (Data data, table[i]) { - QPieSlice *slice = series->append(data.second, data.first.y()); - if (data == table[i].first()) { - slice->setLabelVisible(); - } - } - series->setPieSize( j / (qreal) table.count()); - if(j>1) series->setHoleSize( (j-1)/ (qreal) table.count()+0.1); - series->setHorizontalPosition(0.5); - series->setVerticalPosition(0.5); - chart->addSeries(series); - } - return chart; - } - -}; - -DECLARE_CHART(DonutChart) - diff --git a/demos/chartviewer/charts/pieseries/piechart.cpp b/demos/chartviewer/charts/pieseries/piechart.cpp deleted file mode 100644 index 9fc2d5f6..00000000 --- a/demos/chartviewer/charts/pieseries/piechart.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Commercial Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "charts.h" -#include "qchart.h" -#include "qpieseries.h" - -class PieChart: public Chart -{ -public: - QString name() { return QObject::tr("PieChart"); } - QString category() { return QObject::tr("PieSeries"); } - QString subCategory() { return QString::null; } - - QChart* createChart(const DataTable& table) - { - QChart* chart = new QChart(); - chart->setTitle("Pie chart"); - - qreal pieSize = 1.0 / table.count(); - for (int i = 0; i < table.count(); i++) { - QPieSeries *series = new QPieSeries(chart); - foreach (Data data, table[i]) { - QPieSlice *slice = series->append(data.second, data.first.y()); - if (data == table[i].first()) { - slice->setLabelVisible(); - slice->setExploded(); - } - } - qreal hPos = (pieSize / 2) + (i / (qreal) table.count()); - series->setPieSize(pieSize); - series->setHorizontalPosition(hPos); - series->setVerticalPosition(0.5); - chart->addSeries(series); - } - return chart; - } - -}; - -DECLARE_CHART(PieChart) - diff --git a/demos/chartviewer/charts/xyseries/areachart.cpp b/demos/chartviewer/charts/xyseries/areachart.cpp deleted file mode 100644 index 9bb4191e..00000000 --- a/demos/chartviewer/charts/xyseries/areachart.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Commercial Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "charts.h" -#include "qchart.h" -#include "qareaseries.h" -#include "qlineseries.h" - -class AreaChart: public Chart -{ -public: - QString name() { return QObject::tr("AreaChart"); } - QString category() { return QObject::tr("XYSeries"); } - QString subCategory() { return QString::null; } - - QChart* createChart(const DataTable& table) - { - - QChart *chart = new QChart(); - chart->setTitle("Area chart"); - - // The lower series initialized to zero values - QLineSeries *lowerSeries = 0; - QString name("Series "); - int nameIndex = 0; - for (int i(0); i < table.count(); i++) { - QLineSeries *upperSeries = new QLineSeries(chart); - for (int j(0); j < table[i].count(); j++) { - Data data = table[i].at(j); - if (lowerSeries) { - const QList<QPointF>& points = lowerSeries->points(); - upperSeries->append(QPointF(j, points[i].y() + data.first.y())); - } - else - upperSeries->append(QPointF(j, data.first.y())); - } - QAreaSeries *area = new QAreaSeries(upperSeries, lowerSeries); - area->setName(name + QString::number(nameIndex)); - nameIndex++; - chart->addSeries(area); - chart->createDefaultAxes(); - lowerSeries = upperSeries; - } - - return chart; - - } - -}; - -DECLARE_CHART(AreaChart) - diff --git a/demos/chartviewer/charts/xyseries/categorylinechart.cpp b/demos/chartviewer/charts/xyseries/categorylinechart.cpp deleted file mode 100644 index 1abe55a2..00000000 --- a/demos/chartviewer/charts/xyseries/categorylinechart.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Commercial Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "charts.h" -#include "qchart.h" -#include "qlineseries.h" -#include <QCategoryAxis> - -class CategoryLineChart: public Chart -{ -public: - QString name() { return QObject::tr("CategoryLineChart"); } - QString category() { return QObject::tr("XYSeries"); } - QString subCategory() { return QString::null; } - - QChart* createChart(const DataTable& table) { - - QChart* chart = new QChart(); - chart->setTitle("Category Line chart"); - - QString name("Series "); - int nameIndex = 0; - foreach (DataList list, table) { - QLineSeries *series = new QLineSeries(chart); - foreach (Data data, list) - series->append(data.first); - series->setName(name + QString::number(nameIndex)); - nameIndex++; - chart->addSeries(series); - } - -// chart->createDefaultAxes(); - QCategoryAxis *axisX = new QCategoryAxis; - axisX->append("low", 5); - axisX->append("avg.", 12); - axisX->append("high", 19); - axisX->setRange(0, 20); - chart->setAxisX(axisX, chart->series().at(0)); - - QCategoryAxis *axisY = new QCategoryAxis; - axisY->append("cheap", 5); - axisY->append("fair", 12); - axisY->append("pricy", 20); - axisY->setRange(0, 20); - chart->setAxisY(axisY, chart->series().at(0)); - - return chart; - } - -}; - -DECLARE_CHART(CategoryLineChart) - diff --git a/demos/chartviewer/charts/xyseries/linechart.cpp b/demos/chartviewer/charts/xyseries/linechart.cpp deleted file mode 100644 index 07d43117..00000000 --- a/demos/chartviewer/charts/xyseries/linechart.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Commercial Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "charts.h" -#include "qchart.h" -#include "qlineseries.h" - -class LineChart: public Chart -{ -public: - QString name() { return QObject::tr("LineChart"); } - QString category() { return QObject::tr("XYSeries"); } - QString subCategory() { return QString::null; } - - QChart* createChart(const DataTable& table) { - - QChart* chart = new QChart(); - chart->setTitle("Line chart"); - - QString name("Series "); - int nameIndex = 0; - foreach (DataList list, table) { - QLineSeries *series = new QLineSeries(chart); - foreach (Data data, list) - series->append(data.first); - series->setName(name + QString::number(nameIndex)); - nameIndex++; - chart->addSeries(series); - } - - chart->createDefaultAxes(); - - return chart; - } - -}; - -DECLARE_CHART(LineChart) - diff --git a/demos/chartviewer/charts/xyseries/scatterchart.cpp b/demos/chartviewer/charts/xyseries/scatterchart.cpp deleted file mode 100644 index a8219624..00000000 --- a/demos/chartviewer/charts/xyseries/scatterchart.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Commercial Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "charts.h" -#include "qchart.h" -#include "qscatterseries.h" - -class ScatterChart: public Chart -{ -public: - QString name() { return QObject::tr("ScatterChart"); } - QString category() { return QObject::tr("XYSeries"); } - QString subCategory() { return QString::null; } - - QChart* createChart(const DataTable& table) - { - - QChart* chart = new QChart(); - chart->setTitle("Scatter chart"); - QString name("Series "); - int nameIndex = 0; - foreach (DataList list, table) { - QScatterSeries *series = new QScatterSeries(chart); - foreach (Data data, list) - series->append(data.first); - series->setName(name + QString::number(nameIndex)); - nameIndex++; - chart->addSeries(series); - } - chart->createDefaultAxes(); - - return chart; - } - -}; - -DECLARE_CHART(ScatterChart) diff --git a/demos/chartviewer/charts/xyseries/splinechart.cpp b/demos/chartviewer/charts/xyseries/splinechart.cpp deleted file mode 100644 index 454c1c6a..00000000 --- a/demos/chartviewer/charts/xyseries/splinechart.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Commercial Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "charts.h" -#include "qchart.h" -#include "qsplineseries.h" - -class SplineChart: public Chart -{ -public: - QString name() { return QObject::tr("SplineChart"); } - QString category() { return QObject::tr("XYSeries"); } - QString subCategory() { return QString::null; } - - QChart* createChart(const DataTable& table) - { - - QChart* chart = new QChart(); - - chart->setTitle("Spline chart"); - QString name("Series "); - int nameIndex = 0; - foreach (DataList list, table) { - QSplineSeries *series = new QSplineSeries(chart); - foreach (Data data, list) - series->append(data.first); - series->setName(name + QString::number(nameIndex)); - nameIndex++; - chart->addSeries(series); - } - chart->createDefaultAxes(); - return chart; - } - -}; - -DECLARE_CHART(SplineChart) - diff --git a/demos/chartviewer/chartviewer.pro b/demos/chartviewer/chartviewer.pro deleted file mode 100644 index 3509ecb3..00000000 --- a/demos/chartviewer/chartviewer.pro +++ /dev/null @@ -1,8 +0,0 @@ -!include( ../demos.pri ):error( "Couldn't find the demos.pri file!" ) -include(charts/charts.pri) -TARGET = chartviewer -QT += opengl -INCLUDEPATH += . -SOURCES += main.cpp window.cpp view.cpp -HEADERS += window.h view.h charts.h model.h - diff --git a/demos/chartviewer/main.cpp b/demos/chartviewer/main.cpp deleted file mode 100644 index d52bc43a..00000000 --- a/demos/chartviewer/main.cpp +++ /dev/null @@ -1,32 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Commercial Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "window.h" -#include <QApplication> -#include <QMainWindow> - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - Window window; - window.show(); - return a.exec(); -} - diff --git a/demos/chartviewer/model.h b/demos/chartviewer/model.h deleted file mode 100644 index 3fb77004..00000000 --- a/demos/chartviewer/model.h +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Commercial Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef MODEL_H -#define MODEL_H - -#include <QList> -#include <QPair> -#include <QPointF> -#include <QTime> -#include <stdlib.h> - -typedef QPair<QPointF, QString> Data; -typedef QList<Data> DataList; -typedef QList<DataList> DataTable; - - -class Model -{ -private: - Model(){} - -public: - static DataTable generateRandomData(int listCount, int valueMax, int valueCount) - { - DataTable dataTable; - - // set seed for random stuff - qsrand(QTime(0, 0, 0).secsTo(QTime::currentTime())); - - // generate random data - for (int i(0); i < listCount; i++) { - DataList dataList; - qreal yValue(0); - for (int j(0); j < valueCount; j++) { - yValue = yValue + (qreal) (qrand() % valueMax) / (qreal) valueCount; - QPointF value( - (j + (qreal) qrand() / (qreal) RAND_MAX) - * ((qreal) valueMax / (qreal) valueCount), yValue); - QString label = "Slice " + QString::number(i) + ":" + QString::number(j); - dataList << Data(value, label); - } - dataTable << dataList; - } - - return dataTable; - } - -}; - -#endif diff --git a/demos/chartviewer/view.cpp b/demos/chartviewer/view.cpp deleted file mode 100644 index 2c119a8c..00000000 --- a/demos/chartviewer/view.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** - ** - ** Copyright (C) 2012 Digia Plc - ** All rights reserved. - ** For any questions to Digia, please use contact form at http://qt.digia.com - ** - ** This file is part of the Qt Commercial Charts Add-on. - ** - ** $QT_BEGIN_LICENSE$ - ** Licensees holding valid Qt Commercial licenses may use this file in - ** accordance with the Qt Commercial License Agreement provided with the - ** Software or, alternatively, in accordance with the terms contained in - ** a written agreement between you and Digia. - ** - ** If you have questions regarding the use of this file, please use - ** contact form at http://qt.digia.com - ** $QT_END_LICENSE$ - ** - ****************************************************************************/ - -#include "view.h" -#include <QGraphicsWidget> -#include <QResizeEvent> -#include <QDebug> - -View::View(QGraphicsScene *scene, QGraphicsWidget *form , QWidget *parent):QGraphicsView(scene,parent), - m_form(form) -{ - setDragMode(QGraphicsView::NoDrag); - setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); -} - -void View::resizeEvent(QResizeEvent *event) -{ - if (scene()) - scene()->setSceneRect(QRect(QPoint(0, 0), event->size())); - if (m_form) - m_form->resize(QSizeF(event->size())); - QGraphicsView::resizeEvent(event); -} - -void View::mouseMoveEvent(QMouseEvent *event) -{ - //BugFix somehow view always eats the mouse move event; - QGraphicsView::mouseMoveEvent(event); - event->setAccepted(false); -} - -void View::mouseReleaseEvent(QMouseEvent *event) -{ - - QGraphicsView::mouseReleaseEvent(event); - //BugFix somehow view always eats the mouse release event; - event->setAccepted(false); -} diff --git a/demos/chartviewer/view.h b/demos/chartviewer/view.h deleted file mode 100644 index 7bc11eaa..00000000 --- a/demos/chartviewer/view.h +++ /dev/null @@ -1,42 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Commercial Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef VIEW_H -#define VIEW_H -#include <QGraphicsView> - -class QGraphicsScene; -class QResizeEvent; - -class View: public QGraphicsView -{ -public: - View(QGraphicsScene *scene, QGraphicsWidget *form , QWidget *parent = 0); - -protected: - void resizeEvent(QResizeEvent *event); - void mouseMoveEvent(QMouseEvent *event); - void mouseReleaseEvent(QMouseEvent *event); - -private: - QGraphicsWidget *m_form; -}; - -#endif diff --git a/demos/chartviewer/window.cpp b/demos/chartviewer/window.cpp deleted file mode 100644 index dcd496b9..00000000 --- a/demos/chartviewer/window.cpp +++ /dev/null @@ -1,589 +0,0 @@ -/**************************************************************************** - ** - ** Copyright (C) 2012 Digia Plc - ** All rights reserved. - ** For any questions to Digia, please use contact form at http://qt.digia.com - ** - ** This file is part of the Qt Commercial Charts Add-on. - ** - ** $QT_BEGIN_LICENSE$ - ** Licensees holding valid Qt Commercial licenses may use this file in - ** accordance with the Qt Commercial License Agreement provided with the - ** Software or, alternatively, in accordance with the terms contained in - ** a written agreement between you and Digia. - ** - ** If you have questions regarding the use of this file, please use - ** contact form at http://qt.digia.com - ** $QT_END_LICENSE$ - ** - ****************************************************************************/ - -#include "window.h" -#include "view.h" -#include "charts.h" -#include <QChartView> -#include <QAreaSeries> -#include <QLegend> -#include <QGridLayout> -#include <QFormLayout> -#include <QComboBox> -#include <QSpinBox> -#include <QCheckBox> -#include <QGroupBox> -#include <QLabel> -#include <QGraphicsScene> -#include <QGraphicsGridLayout> -#include <QGraphicsLinearLayout> -#include <QGraphicsProxyWidget> -#include <QGLWidget> -#include <QApplication> -#include <QDebug> -#include <QMenu> - -Window::Window(QWidget* parent) : - QMainWindow(parent), - m_listCount(3), - m_valueMax(10), - m_valueCount(7), - m_scene(new QGraphicsScene(this)), - m_view(0), - m_dataTable(Model::generateRandomData(m_listCount, m_valueMax, m_valueCount)), - m_form(0), - m_themeComboBox(0), - m_antialiasCheckBox(0), - m_animatedComboBox(0), - m_legendComboBox(0), - m_templateComboBox(0), - m_openGLCheckBox(0), - m_zoomCheckBox(0), - m_scrollCheckBox(0), - m_rubberBand(new QGraphicsRectItem()), - m_baseLayout(new QGraphicsGridLayout()), - m_menu(createMenu()), - m_state(NoState), - m_currentState(NoState), - m_template(0) -{ - createProxyWidgets(); - // create layout - QGraphicsLinearLayout *settingsLayout = new QGraphicsLinearLayout(); - settingsLayout->setOrientation(Qt::Vertical); - settingsLayout->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum); - settingsLayout->addItem(m_widgetHash["openGLCheckBox"]); - settingsLayout->addItem(m_widgetHash["antialiasCheckBox"]); - settingsLayout->addItem(m_widgetHash["themeLabel"]); - settingsLayout->addItem(m_widgetHash["themeComboBox"]); - settingsLayout->addItem(m_widgetHash["animationsLabel"]); - settingsLayout->addItem(m_widgetHash["animatedComboBox"]); - settingsLayout->addItem(m_widgetHash["legendLabel"]); - settingsLayout->addItem(m_widgetHash["legendComboBox"]); - settingsLayout->addItem(m_widgetHash["templateLabel"]); - settingsLayout->addItem(m_widgetHash["templateComboBox"]); - settingsLayout->addItem(m_widgetHash["scrollCheckBox"]); - settingsLayout->addItem(m_widgetHash["zoomCheckBox"]); - settingsLayout->addStretch(); - m_baseLayout->addItem(settingsLayout, 0, 3, 2, 1); - - //create charts - Charts::ChartList list = Charts::chartList(); - - for (int i = 0; i < 9; ++i) { - QChart* chart = 0; - if(i<list.size()){ - chart = list.at(i)->createChart(m_dataTable); - }else{ - chart = new QChart(); - chart->setTitle(tr("Empty")); - } - - m_baseLayout->addItem(chart, i / 3, i % 3); - m_chartHash[chart] = i; - } - - m_form = new QGraphicsWidget(); - m_form->setLayout(m_baseLayout); - m_scene->addItem(m_form); - m_scene->addItem(m_rubberBand); - m_rubberBand->setVisible(false); - - m_view = new View(m_scene, m_form); - m_view->setMinimumSize(m_form->minimumSize().toSize()); - - // Set defaults - m_antialiasCheckBox->setChecked(true); - updateUI(); - setCentralWidget(m_view); - - connectSignals(); -} - -Window::~Window() -{ -} - -void Window::connectSignals() -{ - QObject::connect(m_form, SIGNAL(geometryChanged()),this ,SLOT(handleGeometryChanged())); - QObject::connect(m_themeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateUI())); - QObject::connect(m_antialiasCheckBox, SIGNAL(toggled(bool)), this, SLOT(updateUI())); - QObject::connect(m_openGLCheckBox, SIGNAL(toggled(bool)), this, SLOT(updateUI())); - QObject::connect(m_zoomCheckBox, SIGNAL(toggled(bool)), this, SLOT(updateUI())); - QObject::connect(m_scrollCheckBox, SIGNAL(toggled(bool)), this, SLOT(updateUI())); - QObject::connect(m_animatedComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateUI())); - QObject::connect(m_legendComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateUI())); - QObject::connect(m_templateComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateUI())); -} - -void Window::createProxyWidgets() -{ - m_themeComboBox = createThemeBox(); - m_antialiasCheckBox = new QCheckBox(tr("Anti-aliasing")); - m_animatedComboBox = createAnimationBox(); - m_legendComboBox = createLegendBox(); - m_openGLCheckBox = new QCheckBox(tr("OpenGL")); - m_zoomCheckBox = new QCheckBox(tr("Zoom")); - m_scrollCheckBox = new QCheckBox(tr("Scroll")); - m_templateComboBox= createTempleteBox(); - m_widgetHash["themeComboBox"] = m_scene->addWidget(m_themeComboBox); - m_widgetHash["antialiasCheckBox"] = m_scene->addWidget(m_antialiasCheckBox); - m_widgetHash["animatedComboBox"] = m_scene->addWidget(m_animatedComboBox); - m_widgetHash["legendComboBox"] = m_scene->addWidget(m_legendComboBox); - m_widgetHash["openGLCheckBox"] = m_scene->addWidget(m_openGLCheckBox); - m_widgetHash["themeLabel"] = m_scene->addWidget(new QLabel("Theme")); - m_widgetHash["animationsLabel"] = m_scene->addWidget(new QLabel("Animations")); - m_widgetHash["legendLabel"] = m_scene->addWidget(new QLabel("Legend")); - m_widgetHash["templateLabel"] = m_scene->addWidget(new QLabel("Chart template")); - m_widgetHash["templateComboBox"] = m_scene->addWidget(m_templateComboBox); - m_widgetHash["zoomCheckBox"] = m_scene->addWidget(m_zoomCheckBox); - m_widgetHash["scrollCheckBox"] = m_scene->addWidget(m_scrollCheckBox); - -} - -QComboBox* Window::createThemeBox() -{ - QComboBox* themeComboBox = new ComboBox(this); - themeComboBox->addItem("Light", QChart::ChartThemeLight); - themeComboBox->addItem("Blue Cerulean", QChart::ChartThemeBlueCerulean); - themeComboBox->addItem("Dark", QChart::ChartThemeDark); - themeComboBox->addItem("Brown Sand", QChart::ChartThemeBrownSand); - themeComboBox->addItem("Blue NCS", QChart::ChartThemeBlueNcs); - themeComboBox->addItem("High Contrast", QChart::ChartThemeHighContrast); - themeComboBox->addItem("Blue Icy", QChart::ChartThemeBlueIcy); - return themeComboBox; -} - -QComboBox* Window::createAnimationBox() -{ - QComboBox* animationComboBox = new ComboBox(this); - animationComboBox->addItem("No Animations", QChart::NoAnimation); - animationComboBox->addItem("GridAxis Animations", QChart::GridAxisAnimations); - animationComboBox->addItem("Series Animations", QChart::SeriesAnimations); - animationComboBox->addItem("All Animations", QChart::AllAnimations); - return animationComboBox; -} - -QComboBox* Window::createLegendBox() -{ - QComboBox* legendComboBox = new ComboBox(this); - legendComboBox->addItem("No Legend ", 0); - legendComboBox->addItem("Legend Top", Qt::AlignTop); - legendComboBox->addItem("Legend Bottom", Qt::AlignBottom); - legendComboBox->addItem("Legend Left", Qt::AlignLeft); - legendComboBox->addItem("Legend Right", Qt::AlignRight); - return legendComboBox; -} - -QComboBox* Window::createTempleteBox() -{ - QComboBox* templateComboBox = new ComboBox(this); - templateComboBox->addItem("No Template", 0); - - Charts::ChartList list = Charts::chartList(); - QMultiMap<QString, Chart*> categoryMap; - - foreach(Chart* chart, list) { - categoryMap.insertMulti(chart->category(), chart); - } - foreach(const QString& category, categoryMap.uniqueKeys()) { - templateComboBox->addItem(category, category); - } - return templateComboBox; -} - - -void Window::updateUI() -{ - checkTemplate(); - checkOpenGL(); - checkTheme(); - checkAnimationOptions(); - checkLegend(); - checkState(); -} - -void Window::checkLegend() -{ - Qt::Alignment alignment(m_legendComboBox->itemData(m_legendComboBox->currentIndex()).toInt()); - - if (!alignment) { - foreach (QChart *chart, m_chartHash.keys()) { - chart->legend()->hide(); - } - } - else { - foreach (QChart *chart, m_chartHash.keys()) { - chart->legend()->setAlignment(alignment); - chart->legend()->show(); - } - } -} - -void Window::checkOpenGL() -{ - bool opengl = m_openGLCheckBox->isChecked(); - bool isOpengl = qobject_cast<QGLWidget*>(m_view->viewport()); - if ((isOpengl && !opengl) || (!isOpengl && opengl)) { - m_view->deleteLater(); - m_view = new View(m_scene, m_form); - m_view->setViewport(!opengl ? new QWidget() : new QGLWidget()); - setCentralWidget(m_view); - } - - bool antialias = m_antialiasCheckBox->isChecked(); - - if (opengl) - m_view->setRenderHint(QPainter::HighQualityAntialiasing, antialias); - else - m_view->setRenderHint(QPainter::Antialiasing, antialias); -} - -void Window::checkAnimationOptions() -{ - QChart::AnimationOptions options( - m_animatedComboBox->itemData(m_animatedComboBox->currentIndex()).toInt()); - if (!m_chartHash.isEmpty() && m_chartHash.keys().at(0)->animationOptions() != options) { - foreach (QChart *chart, m_chartHash.keys()) - chart->setAnimationOptions(options); - } -} - -void Window::checkState() -{ - bool scroll = m_scrollCheckBox->isChecked(); - - if (m_state != ScrollState && scroll) { - m_state = ScrollState; - m_zoomCheckBox->setChecked(false); - } - else if (!scroll && m_state == ScrollState) { - m_state = NoState; - } - - bool zoom = m_zoomCheckBox->isChecked(); - - if (m_state != ZoomState && zoom) { - m_state = ZoomState; - m_scrollCheckBox->setChecked(false); - } - else if (!zoom && m_state == ZoomState) { - m_state = NoState; - } -} - -void Window::checkTemplate() -{ - - int index = m_templateComboBox->currentIndex(); - if (m_template == index || index == 0) - return; - - m_template = index; - - QString category = m_templateComboBox->itemData(index).toString(); - Charts::ChartList list = Charts::chartList(); - - QList<QChart*> qchartList = m_chartHash.keys(); - - foreach(QChart* qchart,qchartList){ - for(int i = 0 ; i < m_baseLayout->count();++i) - { - if(m_baseLayout->itemAt(i)==qchart){ - m_baseLayout->removeAt(i); - break; - } - } - } - - m_chartHash.clear(); - qDeleteAll(qchartList); - - QChart* qchart(0); - - int j=0; - for (int i = 0; i < list.size(); ++i) { - Chart* chart = list.at(i); - if (chart->category() == category && j < 9) { - qchart = list.at(i)->createChart(m_dataTable); - m_baseLayout->addItem(qchart, j / 3, j % 3); - m_chartHash[qchart] = j; - j++; - } - } - for (; j < 9; ++j) { - qchart = new QChart(); - qchart->setTitle(tr("Empty")); - m_baseLayout->addItem(qchart, j / 3, j % 3); - m_chartHash[qchart] = j; - } - m_baseLayout->activate(); -} - -void Window::checkTheme() -{ - QChart::ChartTheme theme = (QChart::ChartTheme) m_themeComboBox->itemData( - m_themeComboBox->currentIndex()).toInt(); - - foreach (QChart *chart, m_chartHash.keys()) - chart->setTheme(theme); - - QPalette pal = window()->palette(); - if (theme == QChart::ChartThemeLight) { - pal.setColor(QPalette::Window, QRgb(0xf0f0f0)); - pal.setColor(QPalette::WindowText, QRgb(0x404044)); - } - else if (theme == QChart::ChartThemeDark) { - pal.setColor(QPalette::Window, QRgb(0x121218)); - pal.setColor(QPalette::WindowText, QRgb(0xd6d6d6)); - } - else if (theme == QChart::ChartThemeBlueCerulean) { - pal.setColor(QPalette::Window, QRgb(0x40434a)); - pal.setColor(QPalette::WindowText, QRgb(0xd6d6d6)); - } - else if (theme == QChart::ChartThemeBrownSand) { - pal.setColor(QPalette::Window, QRgb(0x9e8965)); - pal.setColor(QPalette::WindowText, QRgb(0x404044)); - } - else if (theme == QChart::ChartThemeBlueNcs) { - pal.setColor(QPalette::Window, QRgb(0x018bba)); - pal.setColor(QPalette::WindowText, QRgb(0x404044)); - } - else if (theme == QChart::ChartThemeHighContrast) { - pal.setColor(QPalette::Window, QRgb(0xffab03)); - pal.setColor(QPalette::WindowText, QRgb(0x181818)); - } - else if (theme == QChart::ChartThemeBlueIcy) { - pal.setColor(QPalette::Window, QRgb(0xcee7f0)); - pal.setColor(QPalette::WindowText, QRgb(0x404044)); - } - else { - pal.setColor(QPalette::Window, QRgb(0xf0f0f0)); - pal.setColor(QPalette::WindowText, QRgb(0x404044)); - } - foreach(QGraphicsProxyWidget* widget , m_widgetHash) { - widget->setPalette(pal); - } - m_view->setBackgroundBrush(pal.color((QPalette::Window))); - m_rubberBand->setPen(pal.color((QPalette::WindowText))); -} - -void Window::mousePressEvent(QMouseEvent *event) -{ - if (event->button() == Qt::LeftButton) { - - m_origin = event->pos(); - m_currentState = NoState; - - foreach (QChart *chart, m_chartHash.keys()) { - - QRectF geometryRect = chart->geometry(); - QRectF plotArea = chart->plotArea(); - plotArea.translate(geometryRect.topLeft()); - if (plotArea.contains(m_origin)) { - m_currentState = m_state; - - if (m_currentState == NoState && m_templateComboBox->currentIndex()==0) { - handleMenu(chart); - } - break; - } - } - - if (m_currentState == ZoomState) { - m_rubberBand->setRect(QRectF(m_origin, QSize())); - m_rubberBand->setVisible(true); - } - - event->accept(); - } - - if (event->button() == Qt::RightButton) { - m_origin = event->pos(); - m_currentState = m_state; - } -} - -void Window::mouseMoveEvent(QMouseEvent *event) -{ - if ( m_currentState != NoState) { - - foreach (QChart *chart, m_chartHash.keys()) { - - QRectF geometryRect = chart->geometry(); - QRectF plotArea = chart->plotArea(); - plotArea.translate(geometryRect.topLeft()); - - if (plotArea.contains(m_origin)) { - if (m_currentState == ScrollState) { - QPointF delta = m_origin - event->pos(); - chart->scroll(delta.x(), -delta.y()); - } - if (m_currentState == ZoomState && plotArea.contains(event->pos())) { - m_rubberBand->setRect(QRectF(m_origin, event->pos()).normalized()); - } - break; - } - } - if(m_currentState == ScrollState) m_origin = event->pos(); - event->accept(); - } -} - -void Window::mouseReleaseEvent(QMouseEvent *event) -{ - if (event->button() == Qt::LeftButton) { - if (m_currentState == ZoomState) { - m_rubberBand->setVisible(false); - - foreach (QChart *chart, m_chartHash.keys()) { - - QRectF geometryRect = chart->geometry(); - QRectF plotArea = chart->plotArea(); - plotArea.translate(geometryRect.topLeft()); - - if (plotArea.contains(m_origin)) { - QRectF rect = m_rubberBand->rect(); - rect.translate(-geometryRect.topLeft()); - chart->zoomIn(rect); - break; - } - } - } - - m_currentState = NoState; - event->accept(); - } - - if (event->button() == Qt::RightButton) { - - if (m_currentState == ZoomState) { - foreach (QChart *chart, m_chartHash.keys()) { - - QRectF geometryRect = chart->geometry(); - QRectF plotArea = chart->plotArea(); - plotArea.translate(geometryRect.topLeft()); - - if (plotArea.contains(m_origin)) { - chart->zoomOut(); - break; - } - } - } - } -} - -void Window::comboBoxFocused(QComboBox *combobox) -{ - foreach(QGraphicsProxyWidget* widget , m_widgetHash) { - if(widget->widget()==combobox) - widget->setZValue(2.0); - else - widget->setZValue(0.0); - } -} - -void Window::handleMenu(QChart* qchart) -{ - QAction *chosen = m_menu->exec(QCursor::pos()); - - if (chosen) { - Chart* chart = (Chart *) chosen->data().value<void *>(); - int index = m_chartHash[qchart]; - //not in 4.7.2 m_baseLayout->removeItem(qchart); - for(int i = 0 ; i < m_baseLayout->count();++i) - { - if(m_baseLayout->itemAt(i)==qchart){ - m_baseLayout->removeAt(i); - break; - } - } - - m_chartHash.remove(qchart); - QChart* newChart = chart->createChart(m_dataTable); - m_baseLayout->addItem(newChart, index / 3, index % 3); - m_chartHash[newChart] = index; - delete qchart; - updateUI(); - } - -} - -QMenu* Window::createMenu() -{ - Charts::ChartList list = Charts::chartList(); - QMultiMap<QString, Chart*> categoryMap; - - QMenu* result = new QMenu(this); - - foreach(Chart* chart, list) { - categoryMap.insertMulti(chart->category(), chart); - } - - foreach(const QString& category, categoryMap.uniqueKeys()) { - QMenu* menu(0); - QMultiMap<QString, Chart*> subCategoryMap; - if (category.isEmpty()) { - menu = result; - } - else { - menu = new QMenu(category, this); - result->addMenu(menu); - } - - foreach(Chart* chart , categoryMap.values(category)) { - subCategoryMap.insert(chart->subCategory(), chart); - } - - foreach(const QString& subCategory, subCategoryMap.uniqueKeys()) { - QMenu* subMenu(0); - if (subCategory.isEmpty()) { - subMenu = menu; - } - else { - subMenu = new QMenu(subCategory, this); - menu->addMenu(subMenu); - } - - foreach(Chart* chart , subCategoryMap.values(subCategory)) { - - createMenuAction(subMenu, QIcon(), chart->name(), - qVariantFromValue((void *) chart)); - } - } - } - - return result; -} - -QAction* Window::createMenuAction(QMenu *menu, const QIcon &icon, const QString &text, - const QVariant &data) -{ - QAction *action = menu->addAction(icon, text); - action->setCheckable(false); - action->setData(data); - return action; -} - -void Window::handleGeometryChanged() -{ - m_view->scene()->setSceneRect(0, 0, this->width(), this->height()); -} diff --git a/demos/chartviewer/window.h b/demos/chartviewer/window.h deleted file mode 100644 index 83817d04..00000000 --- a/demos/chartviewer/window.h +++ /dev/null @@ -1,124 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Commercial Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef WINDOW_H -#define WINDOW_H -#include "model.h" -#include <QMainWindow> -#include <QChartGlobal> -#include <QHash> -#include <QComboBox> - -class QCheckBox; -class QGraphicsRectItem; -class QGraphicsScene; -class QGraphicsWidget; -class View; -class QGraphicsGridLayout; -class Chart; - -QTCOMMERCIALCHART_BEGIN_NAMESPACE -class QChart; -QTCOMMERCIALCHART_END_NAMESPACE - -QTCOMMERCIALCHART_USE_NAMESPACE - - -class Window: public QMainWindow -{ - Q_OBJECT - enum State{ NoState = 0, ZoomState, ScrollState}; -public: - explicit Window(QWidget *parent = 0); - ~Window(); - -private Q_SLOTS: - void updateUI(); - void handleGeometryChanged(); -private: - QComboBox* createThemeBox(); - QComboBox* createAnimationBox(); - QComboBox* createLegendBox(); - QComboBox* createTempleteBox(); - void connectSignals(); - void createProxyWidgets(); - void comboBoxFocused(QComboBox *combox); - inline void checkAnimationOptions(); - inline void checkLegend(); - inline void checkOpenGL(); - inline void checkTheme(); - inline void checkState(); - inline void checkTemplate(); - QMenu* createMenu(); - void handleMenu(QChart * chart); - QAction* createMenuAction(QMenu *menu, const QIcon &icon, const QString &text, const QVariant &data); - -protected: - void mousePressEvent(QMouseEvent *event); - void mouseMoveEvent(QMouseEvent *event); - void mouseReleaseEvent(QMouseEvent *event); - -private: - int m_listCount; - int m_valueMax; - int m_valueCount; - QGraphicsScene* m_scene; - View* m_view; - QHash<QString, QGraphicsProxyWidget*> m_widgetHash; - QHash<QChart*, int> m_chartHash; - DataTable m_dataTable; - - QGraphicsWidget *m_form; - QComboBox *m_themeComboBox; - QCheckBox *m_antialiasCheckBox; - QComboBox *m_animatedComboBox; - QComboBox *m_legendComboBox; - QComboBox *m_templateComboBox; - QCheckBox *m_openGLCheckBox; - QCheckBox *m_zoomCheckBox; - QCheckBox *m_scrollCheckBox; - QPoint m_origin; - QGraphicsRectItem* m_rubberBand; - QGraphicsGridLayout* m_baseLayout; - QMenu* m_menu; - State m_state; - State m_currentState; - int m_template; - - friend class ComboBox; -}; - -class ComboBox: public QComboBox -{ -public: - ComboBox(Window* window,QWidget *parent = 0):QComboBox(parent),m_window(window) - {} - -protected: - void focusInEvent(QFocusEvent *e) - { - QComboBox::focusInEvent(e); - m_window->comboBoxFocused(this); - } -private: - Window* m_window; -}; - -#endif |