From dacd8b696e6b49668c863de287adfbd99856a458 2012-09-25 10:14:53 From: Jani Honkonen Date: 2012-09-25 10:14:53 Subject: [PATCH] coding style fixes for demos --- diff --git a/demos/chartinteractions/chart.cpp b/demos/chartinteractions/chart.cpp index 051bf73..c2d8256 100644 --- a/demos/chartinteractions/chart.cpp +++ b/demos/chartinteractions/chart.cpp @@ -54,7 +54,7 @@ qreal Chart::distance(const QPointF &p1, const QPointF &p2) void Chart::setPointClicked(bool clicked) { - m_clicked = clicked; + m_clicked = clicked; } void Chart::handlePointMove(const QPoint &point) @@ -63,30 +63,30 @@ void Chart::handlePointMove(const QPoint &point) //Map the point clicked from the ChartView //to the area occupied by the chart. QPoint mappedPoint = point; - mappedPoint.setX(point.x()-this->plotArea().x()); - mappedPoint.setY(point.y()-this->plotArea().y()); + mappedPoint.setX(point.x() - this->plotArea().x()); + mappedPoint.setY(point.y() - this->plotArea().y()); //Get the x- and y axis to be able to convert the mapped //coordinate point to the charts scale. - QAbstractAxis * axisx = this->axisX(); - QValueAxis* haxis = 0; + QAbstractAxis *axisx = this->axisX(); + QValueAxis *haxis = 0; if (axisx->type() == QAbstractAxis::AxisTypeValue) - haxis = qobject_cast(axisx); + haxis = qobject_cast(axisx); - QAbstractAxis * axisy = this->axisY(); - QValueAxis* vaxis = 0; + QAbstractAxis *axisy = this->axisY(); + QValueAxis *vaxis = 0; if (axisy->type() == QAbstractAxis::AxisTypeValue) - vaxis = qobject_cast(axisy); + vaxis = qobject_cast(axisy); if (haxis && vaxis) { //Calculate the "unit" between points on the x //y axis. - double xUnit = this->plotArea().width()/haxis->max(); - double yUnit = this->plotArea().height()/vaxis->max(); + double xUnit = this->plotArea().width() / haxis->max(); + double yUnit = this->plotArea().height() / vaxis->max(); //Convert the mappedPoint to the actual chart scale. - double x = mappedPoint.x()/xUnit; - double y = vaxis->max() - mappedPoint.y()/yUnit; + double x = mappedPoint.x() / xUnit; + double y = vaxis->max() - mappedPoint.y() / yUnit; //Replace the old point with the new one. m_series->replace(m_movingPoint, QPointF(x, y)); diff --git a/demos/chartinteractions/main.cpp b/demos/chartinteractions/main.cpp index d23217f..6d69697 100644 --- a/demos/chartinteractions/main.cpp +++ b/demos/chartinteractions/main.cpp @@ -33,7 +33,7 @@ int main(int argc, char *argv[]) { QApplication a(argc, argv); - QLineSeries* series = new QLineSeries(); + QLineSeries *series = new QLineSeries(); series->append(0, 6); series->append(1, 3); @@ -43,7 +43,7 @@ int main(int argc, char *argv[]) series->append(10, 5); *series << QPointF(11, 1) << QPointF(13, 3) << QPointF(17, 6) << QPointF(18, 3) << QPointF(20, 2); - Chart* chart = new Chart(0, 0, series); + Chart *chart = new Chart(0, 0, series); chart->legend()->hide(); chart->addSeries(series); QPen p = series->pen(); @@ -62,7 +62,7 @@ int main(int argc, char *argv[]) QObject::connect(series, SIGNAL(clicked(QPointF)), chart, SLOT(clickPoint(QPointF))); - ChartView* chartView = new ChartView(chart); + ChartView *chartView = new ChartView(chart); chartView->setRenderHint(QPainter::Antialiasing); QMainWindow window; diff --git a/demos/chartthemes/main.cpp b/demos/chartthemes/main.cpp index e227232..130575f 100644 --- a/demos/chartthemes/main.cpp +++ b/demos/chartthemes/main.cpp @@ -26,7 +26,7 @@ int main(int argc, char *argv[]) { QApplication a(argc, argv); QMainWindow window; - ThemeWidget* widget = new ThemeWidget(); + ThemeWidget *widget = new ThemeWidget(); window.setCentralWidget(widget); window.resize(900, 600); window.show(); diff --git a/demos/chartthemes/themewidget.cpp b/demos/chartthemes/themewidget.cpp index 23befb7..e5a07b8 100644 --- a/demos/chartthemes/themewidget.cpp +++ b/demos/chartthemes/themewidget.cpp @@ -43,12 +43,12 @@ #include #include -ThemeWidget::ThemeWidget(QWidget* parent) : +ThemeWidget::ThemeWidget(QWidget *parent) : QWidget(parent), m_listCount(3), m_valueMax(10), m_valueCount(7), - m_dataTable(generateRandomData(m_listCount,m_valueMax,m_valueCount)), + m_dataTable(generateRandomData(m_listCount, m_valueMax, m_valueCount)), m_themeComboBox(createThemeBox()), m_antialiasCheckBox(new QCheckBox("Anti-aliasing")), m_animatedComboBox(createAnimationBox()), @@ -56,7 +56,7 @@ ThemeWidget::ThemeWidget(QWidget* parent) : { connectSignals(); // create layout - QGridLayout* baseLayout = new QGridLayout(); + QGridLayout *baseLayout = new QGridLayout(); QHBoxLayout *settingsLayout = new QHBoxLayout(); settingsLayout->addWidget(new QLabel("Theme:")); settingsLayout->addWidget(m_themeComboBox); @@ -116,7 +116,7 @@ void ThemeWidget::connectSignals() connect(m_legendComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateUI())); } -DataTable ThemeWidget::generateRandomData(int listCount,int valueMax,int valueCount) const +DataTable ThemeWidget::generateRandomData(int listCount, int valueMax, int valueCount) const { DataTable dataTable; @@ -128,7 +128,7 @@ DataTable ThemeWidget::generateRandomData(int listCount,int valueMax,int valueCo DataList dataList; qreal yValue(0); for (int j(0); j < valueCount; j++) { - yValue = yValue + (qreal) (qrand() % valueMax) / (qreal) valueCount; + yValue = yValue + (qreal)(qrand() % valueMax) / (qreal) valueCount; QPointF value((j + (qreal) rand() / (qreal) RAND_MAX) * ((qreal) m_valueMax / (qreal) valueCount), yValue); QString label = "Slice " + QString::number(i) + ":" + QString::number(j); @@ -140,10 +140,10 @@ DataTable ThemeWidget::generateRandomData(int listCount,int valueMax,int valueCo return dataTable; } -QComboBox* ThemeWidget::createThemeBox() const +QComboBox *ThemeWidget::createThemeBox() const { // settings layout - QComboBox* themeComboBox = new QComboBox(); + QComboBox *themeComboBox = new QComboBox(); themeComboBox->addItem("Light", QChart::ChartThemeLight); themeComboBox->addItem("Blue Cerulean", QChart::ChartThemeBlueCerulean); themeComboBox->addItem("Dark", QChart::ChartThemeDark); @@ -154,10 +154,10 @@ QComboBox* ThemeWidget::createThemeBox() const return themeComboBox; } -QComboBox* ThemeWidget::createAnimationBox() const +QComboBox *ThemeWidget::createAnimationBox() const { // settings layout - QComboBox* animationComboBox = new QComboBox(); + QComboBox *animationComboBox = new QComboBox(); animationComboBox->addItem("No Animations", QChart::NoAnimation); animationComboBox->addItem("GridAxis Animations", QChart::GridAxisAnimations); animationComboBox->addItem("Series Animations", QChart::SeriesAnimations); @@ -165,9 +165,9 @@ QComboBox* ThemeWidget::createAnimationBox() const return animationComboBox; } -QComboBox* ThemeWidget::createLegendBox() const +QComboBox *ThemeWidget::createLegendBox() const { - QComboBox* legendComboBox = new QComboBox(); + QComboBox *legendComboBox = new QComboBox(); legendComboBox->addItem("No Legend ", 0); legendComboBox->addItem("Legend Top", Qt::AlignTop); legendComboBox->addItem("Legend Bottom", Qt::AlignBottom); @@ -176,7 +176,7 @@ QComboBox* ThemeWidget::createLegendBox() const return legendComboBox; } -QChart* ThemeWidget::createAreaChart() const +QChart *ThemeWidget::createAreaChart() const { QChart *chart = new QChart(); // chart->axisX()->setNiceNumbersEnabled(true); @@ -191,11 +191,12 @@ QChart* ThemeWidget::createAreaChart() const QLineSeries *upperSeries = new QLineSeries(chart); for (int j(0); j < m_dataTable[i].count(); j++) { Data data = m_dataTable[i].at(j); - if (lowerSeries){ + if (lowerSeries) { const QList& points = lowerSeries->points(); upperSeries->append(QPointF(j, points[i].y() + data.first.y())); - }else + } else { upperSeries->append(QPointF(j, data.first.y())); + } } QAreaSeries *area = new QAreaSeries(upperSeries, lowerSeries); area->setName(name + QString::number(nameIndex)); @@ -208,13 +209,13 @@ QChart* ThemeWidget::createAreaChart() const return chart; } -QChart* ThemeWidget::createBarChart(int valueCount) const +QChart *ThemeWidget::createBarChart(int valueCount) const { Q_UNUSED(valueCount); - QChart* chart = new QChart(); + QChart *chart = new QChart(); chart->setTitle("Bar chart"); - QStackedBarSeries* series = new QStackedBarSeries(chart); + QStackedBarSeries *series = new QStackedBarSeries(chart); for (int i(0); i < m_dataTable.count(); i++) { QBarSet *set = new QBarSet("Bar set " + QString::number(i)); foreach (Data data, m_dataTable[i]) @@ -227,9 +228,9 @@ QChart* ThemeWidget::createBarChart(int valueCount) const return chart; } -QChart* ThemeWidget::createLineChart() const +QChart *ThemeWidget::createLineChart() const { - QChart* chart = new QChart(); + QChart *chart = new QChart(); chart->setTitle("Line chart"); QString name("Series "); @@ -247,9 +248,9 @@ QChart* ThemeWidget::createLineChart() const return chart; } -QChart* ThemeWidget::createPieChart() const +QChart *ThemeWidget::createPieChart() const { - QChart* chart = new QChart(); + QChart *chart = new QChart(); chart->setTitle("Pie chart"); qreal pieSize = 1.0 / m_dataTable.count(); @@ -272,9 +273,10 @@ QChart* ThemeWidget::createPieChart() const return chart; } -QChart* ThemeWidget::createSplineChart() const -{ // spine chart - QChart* chart = new QChart(); +QChart *ThemeWidget::createSplineChart() const +{ + // spine chart + QChart *chart = new QChart(); chart->setTitle("Spline chart"); QString name("Series "); int nameIndex = 0; @@ -290,9 +292,10 @@ QChart* ThemeWidget::createSplineChart() const return chart; } -QChart* ThemeWidget::createScatterChart() const -{ // scatter chart - QChart* chart = new QChart(); +QChart *ThemeWidget::createScatterChart() const +{ + // scatter chart + QChart *chart = new QChart(); chart->setTitle("Scatter chart"); QString name("Series "); int nameIndex = 0; @@ -358,9 +361,8 @@ void ThemeWidget::updateUI() Qt::Alignment alignment(m_legendComboBox->itemData(m_legendComboBox->currentIndex()).toInt()); if (!alignment) { - foreach (QChartView *chartView, m_charts) { + foreach (QChartView *chartView, m_charts) chartView->chart()->legend()->hide(); - } } else { foreach (QChartView *chartView, m_charts) { chartView->chart()->legend()->setAlignment(alignment); diff --git a/demos/chartthemes/themewidget.h b/demos/chartthemes/themewidget.h index d0477fc..b3d5d08 100644 --- a/demos/chartthemes/themewidget.h +++ b/demos/chartthemes/themewidget.h @@ -49,23 +49,23 @@ private Q_SLOTS: void updateUI(); private: - DataTable generateRandomData(int listCount,int valueMax,int valueCount) const; - QComboBox* createThemeBox() const; - QComboBox* createAnimationBox() const; - QComboBox* createLegendBox() const; + DataTable generateRandomData(int listCount, int valueMax, int valueCount) const; + QComboBox *createThemeBox() const; + QComboBox *createAnimationBox() const; + QComboBox *createLegendBox() const; void connectSignals(); - QChart* createAreaChart() const; - QChart* createBarChart(int valueCount) const; - QChart* createPieChart() const; - QChart* createLineChart() const; - QChart* createSplineChart() const; - QChart* createScatterChart() const; + QChart *createAreaChart() const; + QChart *createBarChart(int valueCount) const; + QChart *createPieChart() const; + QChart *createLineChart() const; + QChart *createSplineChart() const; + QChart *createScatterChart() const; private: int m_listCount; int m_valueMax; int m_valueCount; - QList m_charts; + QList m_charts; DataTable m_dataTable; QComboBox *m_themeComboBox; diff --git a/demos/chartviewer/charts.h b/demos/chartviewer/charts.h index 08dfa1c..5c95310 100644 --- a/demos/chartviewer/charts.h +++ b/demos/chartviewer/charts.h @@ -35,8 +35,8 @@ QTCOMMERCIALCHART_USE_NAMESPACE class Chart { public: - virtual ~Chart(){}; - virtual QChart* createChart(const DataTable& table) = 0; + virtual ~Chart() {}; + virtual QChart *createChart(const DataTable &table) = 0; virtual QString name() = 0; virtual QString category() = 0; virtual QString subCategory() = 0; @@ -46,46 +46,41 @@ public: namespace Charts { -typedef QList ChartList; + typedef QList ChartList; -inline ChartList& chartList() -{ - static ChartList list; - return list; -} - -inline bool findChart(Chart* chart) -{ - ChartList& list = chartList(); - if (list.contains(chart)) { - return true; + inline ChartList &chartList() + { + static ChartList list; + return list; } - foreach (Chart* item, list) { - if (item->name() == chart->name() && item->category() == chart->category() && item->subCategory() == chart->subCategory()) { + + 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; } - return false; -} -inline void addChart(Chart* chart) -{ - ChartList& list = chartList(); - if (!findChart(chart)) { - list.append(chart); + inline void addChart(Chart *chart) + { + ChartList &list = chartList(); + if (!findChart(chart)) + list.append(chart); } } -} template class ChartWrapper { public: QSharedPointer chart; - ChartWrapper() : chart(new T) - { - Charts::addChart(chart.data()); - } + ChartWrapper() : chart(new T) { Charts::addChart(chart.data()); } }; #define DECLARE_CHART(chartType) static ChartWrapper chartType; diff --git a/demos/chartviewer/charts/axis/categoryaxis.cpp b/demos/chartviewer/charts/axis/categoryaxis.cpp index 25a2028..c41bf55 100644 --- a/demos/chartviewer/charts/axis/categoryaxis.cpp +++ b/demos/chartviewer/charts/axis/categoryaxis.cpp @@ -30,39 +30,38 @@ public: QString category() { return QObject::tr("Axis"); } QString subCategory() { return QString::null; } - QChart* createChart(const DataTable& table) { + QChart *createChart(const DataTable &table) + { + QChart *chart = new QChart(); + chart->setTitle("Category X , Category Y "); - QChart* chart = new QChart(); - chart->setTitle("Category X , Category Y "); + 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); + } - 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); - } + 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 *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)); - 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; + return chart; } - }; DECLARE_CHART(CategoryLineChart) diff --git a/demos/chartviewer/charts/axis/valueaxis.cpp b/demos/chartviewer/charts/axis/valueaxis.cpp index 5389e6a..b72dd3e 100644 --- a/demos/chartviewer/charts/axis/valueaxis.cpp +++ b/demos/chartviewer/charts/axis/valueaxis.cpp @@ -31,30 +31,29 @@ public: QString category() { return QObject::tr("Axis"); } QString subCategory() { return QString::null; } - QChart* createChart(const DataTable& table) { - - QChart* chart = new QChart(); - chart->setTitle("Value X , Value Y"); - - 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(); - QValueAxis* axis = new QValueAxis(); - foreach (QAbstractSeries* series,chart->series()) - chart->setAxisX(axis,series); - - return chart; + QChart *createChart(const DataTable &table) + { + QChart *chart = new QChart(); + chart->setTitle("Value X , Value Y"); + + 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(); + QValueAxis *axis = new QValueAxis(); + foreach (QAbstractSeries *series, chart->series()) + chart->setAxisX(axis, series); + + return chart; } - }; DECLARE_CHART(ValueAxis); diff --git a/demos/chartviewer/charts/barseries/horizontalbarchart.cpp b/demos/chartviewer/charts/barseries/horizontalbarchart.cpp index 5ebe997..f03eb23 100644 --- a/demos/chartviewer/charts/barseries/horizontalbarchart.cpp +++ b/demos/chartviewer/charts/barseries/horizontalbarchart.cpp @@ -30,14 +30,11 @@ public: QString category() { return QObject::tr("BarSeries"); } QString subCategory() { return QObject::tr("Horizontal"); } - QChart* createChart(const DataTable& table) - { - - QChart* chart = new QChart(); - + QChart *createChart(const DataTable &table) + { + QChart *chart = new QChart(); chart->setTitle("Horizontal bar chart"); - - QHorizontalBarSeries* series = new QHorizontalBarSeries(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]) @@ -48,7 +45,6 @@ public: chart->createDefaultAxes(); return chart; } - }; DECLARE_CHART(HorizontalBarChart) diff --git a/demos/chartviewer/charts/barseries/horizontalpercentbarchart.cpp b/demos/chartviewer/charts/barseries/horizontalpercentbarchart.cpp index ce1223a..cc71920 100644 --- a/demos/chartviewer/charts/barseries/horizontalpercentbarchart.cpp +++ b/demos/chartviewer/charts/barseries/horizontalpercentbarchart.cpp @@ -30,14 +30,11 @@ public: QString category() { return QObject::tr("BarSeries"); } QString subCategory() { return QObject::tr("Horizontal"); } - QChart* createChart(const DataTable& table) + QChart *createChart(const DataTable &table) { - - QChart* chart = new QChart(); - + QChart *chart = new QChart(); chart->setTitle("Horizontal percent chart"); - - QHorizontalPercentBarSeries* series = new QHorizontalPercentBarSeries(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]) @@ -48,7 +45,6 @@ public: chart->createDefaultAxes(); return chart; } - }; DECLARE_CHART(HorizontalPercentBarChart) diff --git a/demos/chartviewer/charts/barseries/horizontalstackedbarchart.cpp b/demos/chartviewer/charts/barseries/horizontalstackedbarchart.cpp index e8ba4e3..ab2c49d 100644 --- a/demos/chartviewer/charts/barseries/horizontalstackedbarchart.cpp +++ b/demos/chartviewer/charts/barseries/horizontalstackedbarchart.cpp @@ -30,14 +30,11 @@ public: QString category() { return QObject::tr("BarSeries"); } QString subCategory() { return QObject::tr("Horizontal"); } - QChart* createChart(const DataTable& table) + QChart *createChart(const DataTable &table) { - - QChart* chart = new QChart(); - + QChart *chart = new QChart(); chart->setTitle("Horizontal stacked chart"); - - QHorizontalStackedBarSeries* series = new QHorizontalStackedBarSeries(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]) @@ -48,7 +45,6 @@ public: chart->createDefaultAxes(); return chart; } - }; DECLARE_CHART(HorizontalStackedBarChart) diff --git a/demos/chartviewer/charts/barseries/verticalbarchart.cpp b/demos/chartviewer/charts/barseries/verticalbarchart.cpp index a480b3d..6f48d7b 100644 --- a/demos/chartviewer/charts/barseries/verticalbarchart.cpp +++ b/demos/chartviewer/charts/barseries/verticalbarchart.cpp @@ -30,14 +30,11 @@ public: QString category() { return QObject::tr("BarSeries"); } QString subCategory() { return QObject::tr("Vertical"); } - QChart* createChart(const DataTable& table) + QChart *createChart(const DataTable &table) { - - QChart* chart = new QChart(); - + QChart *chart = new QChart(); chart->setTitle("Vertical bar chart"); - - QBarSeries* series = new QBarSeries(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]) @@ -48,7 +45,6 @@ public: chart->createDefaultAxes(); return chart; } - }; DECLARE_CHART(VerticalBarChart) diff --git a/demos/chartviewer/charts/barseries/verticalpercentbarchart.cpp b/demos/chartviewer/charts/barseries/verticalpercentbarchart.cpp index 5adeb38..ddb5c96 100644 --- a/demos/chartviewer/charts/barseries/verticalpercentbarchart.cpp +++ b/demos/chartviewer/charts/barseries/verticalpercentbarchart.cpp @@ -30,14 +30,11 @@ public: QString category() { return QObject::tr("BarSeries"); } QString subCategory() { return QObject::tr("Vertical"); } - QChart* createChart(const DataTable& table) + QChart *createChart(const DataTable &table) { - - QChart* chart = new QChart(); - + QChart *chart = new QChart(); chart->setTitle("Stacked bar chart"); - - QPercentBarSeries* series = new QPercentBarSeries(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]) @@ -48,7 +45,6 @@ public: chart->createDefaultAxes(); return chart; } - }; DECLARE_CHART(VerticalPercentBarChart) diff --git a/demos/chartviewer/charts/barseries/verticalstackedbarchart.cpp b/demos/chartviewer/charts/barseries/verticalstackedbarchart.cpp index c9c1a60..21160ed 100644 --- a/demos/chartviewer/charts/barseries/verticalstackedbarchart.cpp +++ b/demos/chartviewer/charts/barseries/verticalstackedbarchart.cpp @@ -30,14 +30,11 @@ public: QString category() { return QObject::tr("BarSeries"); } QString subCategory() { return QObject::tr("Vertical"); } - QChart* createChart(const DataTable& table) + QChart *createChart(const DataTable &table) { - - QChart* chart = new QChart(); - + QChart *chart = new QChart(); chart->setTitle("Stacked bar chart"); - - QStackedBarSeries* series = new QStackedBarSeries(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]) @@ -48,7 +45,6 @@ public: chart->createDefaultAxes(); return chart; } - }; DECLARE_CHART(VerticalStackedBarChart) diff --git a/demos/chartviewer/charts/font/font.cpp b/demos/chartviewer/charts/font/font.cpp index 1ec9d49..1b0626b 100644 --- a/demos/chartviewer/charts/font/font.cpp +++ b/demos/chartviewer/charts/font/font.cpp @@ -25,86 +25,90 @@ class FontChart: public Chart { public: - FontChart(int fontSize):m_fontSize(fontSize){}; + 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; + 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{ +class FontChart6: public FontChart +{ public: - FontChart6():FontChart(6){}; + FontChart6(): FontChart(6) {}; }; -class FontChart8:public FontChart{ +class FontChart8: public FontChart +{ public: - FontChart8():FontChart(8){}; + FontChart8(): FontChart(8) {}; }; -class FontChart10:public FontChart{ +class FontChart10: public FontChart +{ public: - FontChart10():FontChart(10){}; + FontChart10(): FontChart(10) {}; }; -class FontChart14:public FontChart{ +class FontChart14: public FontChart +{ public: - FontChart14():FontChart(14){}; + FontChart14(): FontChart(14) {}; }; - -class FontChart18:public FontChart{ +class FontChart18: public FontChart +{ public: - FontChart18():FontChart(18){}; + FontChart18(): FontChart(18) {}; }; -class FontChart20:public FontChart{ +class FontChart20: public FontChart +{ public: - FontChart20():FontChart(20){}; + FontChart20(): FontChart(20) {}; }; -class FontChart24:public FontChart{ +class FontChart24: public FontChart +{ public: - FontChart24():FontChart(24){}; + FontChart24(): FontChart(24) {}; }; -class FontChart28:public FontChart{ +class FontChart28: public FontChart +{ public: - FontChart28():FontChart(28){}; + FontChart28(): FontChart(28) {}; }; -class FontChart32:public FontChart{ +class FontChart32: public FontChart +{ public: - FontChart32():FontChart(32){}; + FontChart32(): FontChart(32) {}; }; DECLARE_CHART(FontChart6); diff --git a/demos/chartviewer/charts/pieseries/donutchart.cpp b/demos/chartviewer/charts/pieseries/donutchart.cpp index 8402b2f..4f35b67 100644 --- a/demos/chartviewer/charts/pieseries/donutchart.cpp +++ b/demos/chartviewer/charts/pieseries/donutchart.cpp @@ -29,28 +29,26 @@ public: QString category() { return QObject::tr("PieSeries"); } QString subCategory() { return QString::null; } - QChart* createChart(const DataTable& table) - { - QChart* chart = new QChart(); + 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--) { + 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()) { + 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->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 index 9fc2d5f..cde4183 100644 --- a/demos/chartviewer/charts/pieseries/piechart.cpp +++ b/demos/chartviewer/charts/pieseries/piechart.cpp @@ -29,11 +29,10 @@ public: QString category() { return QObject::tr("PieSeries"); } QString subCategory() { return QString::null; } - QChart* createChart(const DataTable& table) + QChart *createChart(const DataTable &table) { - QChart* chart = new QChart(); + 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); @@ -52,7 +51,6 @@ public: } return chart; } - }; DECLARE_CHART(PieChart) diff --git a/demos/chartviewer/charts/xyseries/areachart.cpp b/demos/chartviewer/charts/xyseries/areachart.cpp index 9bb4191..70c9a9c 100644 --- a/demos/chartviewer/charts/xyseries/areachart.cpp +++ b/demos/chartviewer/charts/xyseries/areachart.cpp @@ -30,9 +30,8 @@ public: QString category() { return QObject::tr("XYSeries"); } QString subCategory() { return QString::null; } - QChart* createChart(const DataTable& table) + QChart *createChart(const DataTable &table) { - QChart *chart = new QChart(); chart->setTitle("Area chart"); @@ -47,9 +46,9 @@ public: if (lowerSeries) { const QList& points = lowerSeries->points(); upperSeries->append(QPointF(j, points[i].y() + data.first.y())); - } - else + } else { upperSeries->append(QPointF(j, data.first.y())); + } } QAreaSeries *area = new QAreaSeries(upperSeries, lowerSeries); area->setName(name + QString::number(nameIndex)); @@ -58,11 +57,8 @@ public: chart->createDefaultAxes(); lowerSeries = upperSeries; } - return chart; - } - }; DECLARE_CHART(AreaChart) diff --git a/demos/chartviewer/charts/xyseries/linechart.cpp b/demos/chartviewer/charts/xyseries/linechart.cpp index 07d4311..0436ff6 100644 --- a/demos/chartviewer/charts/xyseries/linechart.cpp +++ b/demos/chartviewer/charts/xyseries/linechart.cpp @@ -29,27 +29,23 @@ public: 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; + 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 index a821962..7a88191 100644 --- a/demos/chartviewer/charts/xyseries/scatterchart.cpp +++ b/demos/chartviewer/charts/xyseries/scatterchart.cpp @@ -29,10 +29,9 @@ public: QString category() { return QObject::tr("XYSeries"); } QString subCategory() { return QString::null; } - QChart* createChart(const DataTable& table) + QChart *createChart(const DataTable &table) { - - QChart* chart = new QChart(); + QChart *chart = new QChart(); chart->setTitle("Scatter chart"); QString name("Series "); int nameIndex = 0; @@ -45,10 +44,8 @@ public: 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 index 454c1c6..bf81ff2 100644 --- a/demos/chartviewer/charts/xyseries/splinechart.cpp +++ b/demos/chartviewer/charts/xyseries/splinechart.cpp @@ -29,11 +29,9 @@ public: QString category() { return QObject::tr("XYSeries"); } QString subCategory() { return QString::null; } - QChart* createChart(const DataTable& table) + QChart *createChart(const DataTable &table) { - - QChart* chart = new QChart(); - + QChart *chart = new QChart(); chart->setTitle("Spline chart"); QString name("Series "); int nameIndex = 0; @@ -48,7 +46,6 @@ public: chart->createDefaultAxes(); return chart; } - }; DECLARE_CHART(SplineChart) diff --git a/demos/chartviewer/model.h b/demos/chartviewer/model.h index 3fb7700..c160144 100644 --- a/demos/chartviewer/model.h +++ b/demos/chartviewer/model.h @@ -35,7 +35,7 @@ typedef QList DataTable; class Model { private: - Model(){} + Model() {} public: static DataTable generateRandomData(int listCount, int valueMax, int valueCount) @@ -50,19 +50,17 @@ public: DataList dataList; qreal yValue(0); for (int j(0); j < valueCount; j++) { - yValue = yValue + (qreal) (qrand() % valueMax) / (qreal) valueCount; + yValue = yValue + (qreal)(qrand() % valueMax) / (qreal) valueCount; QPointF value( (j + (qreal) qrand() / (qreal) RAND_MAX) - * ((qreal) valueMax / (qreal) valueCount), yValue); + * ((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 index 2c119a8..e8b6aa9 100644 --- a/demos/chartviewer/view.cpp +++ b/demos/chartviewer/view.cpp @@ -23,8 +23,9 @@ #include #include -View::View(QGraphicsScene *scene, QGraphicsWidget *form , QWidget *parent):QGraphicsView(scene,parent), - m_form(form) +View::View(QGraphicsScene *scene, QGraphicsWidget *form , QWidget *parent) + : QGraphicsView(scene, parent), + m_form(form) { setDragMode(QGraphicsView::NoDrag); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); @@ -49,8 +50,7 @@ void View::mouseMoveEvent(QMouseEvent *event) void View::mouseReleaseEvent(QMouseEvent *event) { - QGraphicsView::mouseReleaseEvent(event); - //BugFix somehow view always eats the mouse release event; + //BugFix somehow view always eats the mouse release event; event->setAccepted(false); } diff --git a/demos/chartviewer/window.cpp b/demos/chartviewer/window.cpp index 9db9c0e..a969c78 100644 --- a/demos/chartviewer/window.cpp +++ b/demos/chartviewer/window.cpp @@ -40,7 +40,7 @@ #include #include -Window::Window(QWidget* parent) : +Window::Window(QWidget *parent) : QMainWindow(parent), m_listCount(3), m_valueMax(10), @@ -88,12 +88,12 @@ Window::Window(QWidget* parent) : Charts::ChartList list = Charts::chartList(); for (int i = 0; i < 9; ++i) { - QChart* chart = 0; - if(icreateChart(m_dataTable); - }else{ - chart = new QChart(); - chart->setTitle(tr("Empty")); + 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); @@ -123,7 +123,7 @@ Window::~Window() void Window::connectSignals() { - QObject::connect(m_form, SIGNAL(geometryChanged()),this ,SLOT(handleGeometryChanged())); + 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())); @@ -143,7 +143,7 @@ void Window::createProxyWidgets() m_openGLCheckBox = new QCheckBox(tr("OpenGL")); m_zoomCheckBox = new QCheckBox(tr("Zoom")); m_scrollCheckBox = new QCheckBox(tr("Scroll")); - m_templateComboBox= createTempleteBox(); + 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); @@ -159,9 +159,9 @@ void Window::createProxyWidgets() } -QComboBox* Window::createThemeBox() +QComboBox *Window::createThemeBox() { - QComboBox* themeComboBox = new ComboBox(this); + QComboBox *themeComboBox = new ComboBox(this); themeComboBox->addItem("Light", QChart::ChartThemeLight); themeComboBox->addItem("Blue Cerulean", QChart::ChartThemeBlueCerulean); themeComboBox->addItem("Dark", QChart::ChartThemeDark); @@ -172,9 +172,9 @@ QComboBox* Window::createThemeBox() return themeComboBox; } -QComboBox* Window::createAnimationBox() +QComboBox *Window::createAnimationBox() { - QComboBox* animationComboBox = new ComboBox(this); + QComboBox *animationComboBox = new ComboBox(this); animationComboBox->addItem("No Animations", QChart::NoAnimation); animationComboBox->addItem("GridAxis Animations", QChart::GridAxisAnimations); animationComboBox->addItem("Series Animations", QChart::SeriesAnimations); @@ -182,9 +182,9 @@ QComboBox* Window::createAnimationBox() return animationComboBox; } -QComboBox* Window::createLegendBox() +QComboBox *Window::createLegendBox() { - QComboBox* legendComboBox = new ComboBox(this); + QComboBox *legendComboBox = new ComboBox(this); legendComboBox->addItem("No Legend ", 0); legendComboBox->addItem("Legend Top", Qt::AlignTop); legendComboBox->addItem("Legend Bottom", Qt::AlignBottom); @@ -193,20 +193,20 @@ QComboBox* Window::createLegendBox() return legendComboBox; } -QComboBox* Window::createTempleteBox() +QComboBox *Window::createTempleteBox() { - QComboBox* templateComboBox = new ComboBox(this); + QComboBox *templateComboBox = new ComboBox(this); templateComboBox->addItem("No Template", 0); Charts::ChartList list = Charts::chartList(); - QMultiMap categoryMap; + QMultiMap categoryMap; - foreach(Chart* chart, list) { - categoryMap.insertMulti(chart->category(), chart); - } - foreach(const QString& category, categoryMap.uniqueKeys()) { + foreach (Chart *chart, list) + categoryMap.insertMulti(chart->category(), chart); + + foreach (const QString &category, categoryMap.uniqueKeys()) templateComboBox->addItem(category, category); - } + return templateComboBox; } @@ -226,11 +226,9 @@ void Window::checkLegend() Qt::Alignment alignment(m_legendComboBox->itemData(m_legendComboBox->currentIndex()).toInt()); if (!alignment) { - foreach (QChart *chart, m_chartHash.keys()) { + foreach (QChart *chart, m_chartHash.keys()) chart->legend()->hide(); - } - } - else { + } else { foreach (QChart *chart, m_chartHash.keys()) { chart->legend()->setAlignment(alignment); chart->legend()->show(); @@ -241,7 +239,7 @@ void Window::checkLegend() void Window::checkOpenGL() { bool opengl = m_openGLCheckBox->isChecked(); - bool isOpengl = qobject_cast(m_view->viewport()); + bool isOpengl = qobject_cast(m_view->viewport()); if ((isOpengl && !opengl) || (!isOpengl && opengl)) { m_view->deleteLater(); m_view = new View(m_scene, m_form); @@ -251,20 +249,21 @@ void Window::checkOpenGL() bool antialias = m_antialiasCheckBox->isChecked(); - if (opengl) - m_view->setRenderHint(QPainter::HighQualityAntialiasing, antialias); - else - m_view->setRenderHint(QPainter::Antialiasing, antialias); + 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); - } + 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() @@ -274,8 +273,7 @@ void Window::checkState() if (m_state != ScrollState && scroll) { m_state = ScrollState; m_zoomCheckBox->setChecked(false); - } - else if (!scroll && m_state == ScrollState) { + } else if (!scroll && m_state == ScrollState) { m_state = NoState; } @@ -284,8 +282,7 @@ void Window::checkState() if (m_state != ZoomState && zoom) { m_state = ZoomState; m_scrollCheckBox->setChecked(false); - } - else if (!zoom && m_state == ZoomState) { + } else if (!zoom && m_state == ZoomState) { m_state = NoState; } } @@ -302,26 +299,25 @@ void Window::checkTemplate() QString category = m_templateComboBox->itemData(index).toString(); Charts::ChartList list = Charts::chartList(); - QList qchartList = m_chartHash.keys(); + QList 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; - } - } + 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); + QChart *qchart(0); - int j=0; + int j = 0; for (int i = 0; i < list.size(); ++i) { - Chart* chart = list.at(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); @@ -341,7 +337,7 @@ void Window::checkTemplate() void Window::checkTheme() { QChart::ChartTheme theme = (QChart::ChartTheme) m_themeComboBox->itemData( - m_themeComboBox->currentIndex()).toInt(); + m_themeComboBox->currentIndex()).toInt(); foreach (QChart *chart, m_chartHash.keys()) chart->setTheme(theme); @@ -350,38 +346,30 @@ void Window::checkTheme() if (theme == QChart::ChartThemeLight) { pal.setColor(QPalette::Window, QRgb(0xf0f0f0)); pal.setColor(QPalette::WindowText, QRgb(0x404044)); - } - else if (theme == QChart::ChartThemeDark) { + } else if (theme == QChart::ChartThemeDark) { pal.setColor(QPalette::Window, QRgb(0x121218)); pal.setColor(QPalette::WindowText, QRgb(0xd6d6d6)); - } - else if (theme == QChart::ChartThemeBlueCerulean) { + } else if (theme == QChart::ChartThemeBlueCerulean) { pal.setColor(QPalette::Window, QRgb(0x40434a)); pal.setColor(QPalette::WindowText, QRgb(0xd6d6d6)); - } - else if (theme == QChart::ChartThemeBrownSand) { + } else if (theme == QChart::ChartThemeBrownSand) { pal.setColor(QPalette::Window, QRgb(0x9e8965)); pal.setColor(QPalette::WindowText, QRgb(0x404044)); - } - else if (theme == QChart::ChartThemeBlueNcs) { + } else if (theme == QChart::ChartThemeBlueNcs) { pal.setColor(QPalette::Window, QRgb(0x018bba)); pal.setColor(QPalette::WindowText, QRgb(0x404044)); - } - else if (theme == QChart::ChartThemeHighContrast) { + } else if (theme == QChart::ChartThemeHighContrast) { pal.setColor(QPalette::Window, QRgb(0xffab03)); pal.setColor(QPalette::WindowText, QRgb(0x181818)); - } - else if (theme == QChart::ChartThemeBlueIcy) { + } else if (theme == QChart::ChartThemeBlueIcy) { pal.setColor(QPalette::Window, QRgb(0xcee7f0)); pal.setColor(QPalette::WindowText, QRgb(0x404044)); - } - else { + } else { pal.setColor(QPalette::Window, QRgb(0xf0f0f0)); pal.setColor(QPalette::WindowText, QRgb(0x404044)); } - foreach(QGraphicsProxyWidget* widget , m_widgetHash) { + foreach (QGraphicsProxyWidget *widget, m_widgetHash) widget->setPalette(pal); - } m_view->setBackgroundBrush(pal.color((QPalette::Window))); m_rubberBand->setPen(pal.color((QPalette::WindowText))); } @@ -400,10 +388,8 @@ void Window::mousePressEvent(QMouseEvent *event) plotArea.translate(geometryRect.topLeft()); if (plotArea.contains(m_origin)) { m_currentState = m_state; - - if (m_currentState == NoState && m_templateComboBox->currentIndex()==0) { + if (m_currentState == NoState && m_templateComboBox->currentIndex() == 0) handleMenu(chart); - } break; } } @@ -424,7 +410,7 @@ void Window::mousePressEvent(QMouseEvent *event) void Window::mouseMoveEvent(QMouseEvent *event) { - if ( m_currentState != NoState) { + if (m_currentState != NoState) { foreach (QChart *chart, m_chartHash.keys()) { @@ -437,13 +423,13 @@ void Window::mouseMoveEvent(QMouseEvent *event) QPointF delta = m_origin - event->pos(); chart->scroll(delta.x(), -delta.y()); } - if (m_currentState == ZoomState && plotArea.contains(event->pos())) { + 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(); + if (m_currentState == ScrollState) + m_origin = event->pos(); event->accept(); } } @@ -493,32 +479,31 @@ void Window::mouseReleaseEvent(QMouseEvent *event) void Window::comboBoxFocused(QComboBox *combobox) { - foreach(QGraphicsProxyWidget* widget , m_widgetHash) { - if(widget->widget()==combobox) - widget->setZValue(2.0); - else - widget->setZValue(0.0); + foreach (QGraphicsProxyWidget *widget , m_widgetHash) { + if (widget->widget() == combobox) + widget->setZValue(2.0); + else + widget->setZValue(0.0); } } -void Window::handleMenu(QChart* qchart) +void Window::handleMenu(QChart *qchart) { QAction *chosen = m_menu->exec(QCursor::pos()); if (chosen) { - Chart* chart = (Chart *) chosen->data().value(); + Chart *chart = (Chart *) chosen->data().value(); 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){ + 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); + QChart *newChart = chart->createChart(m_dataTable); m_baseLayout->addItem(newChart, index / 3, index % 3); m_chartHash[newChart] = index; delete qchart; @@ -527,46 +512,41 @@ void Window::handleMenu(QChart* qchart) } -QMenu* Window::createMenu() +QMenu *Window::createMenu() { Charts::ChartList list = Charts::chartList(); - QMultiMap categoryMap; + QMultiMap categoryMap; - QMenu* result = new QMenu(this); + QMenu *result = new QMenu(this); - foreach(Chart* chart, list) { + foreach (Chart *chart, list) categoryMap.insertMulti(chart->category(), chart); - } - foreach(const QString& category, categoryMap.uniqueKeys()) { - QMenu* menu(0); - QMultiMap subCategoryMap; + foreach (const QString &category, categoryMap.uniqueKeys()) { + QMenu *menu(0); + QMultiMap subCategoryMap; if (category.isEmpty()) { menu = result; - } - else { + } else { menu = new QMenu(category, this); result->addMenu(menu); } - foreach(Chart* chart , categoryMap.values(category)) { + foreach (Chart *chart, categoryMap.values(category)) subCategoryMap.insert(chart->subCategory(), chart); - } - foreach(const QString& subCategory, subCategoryMap.uniqueKeys()) { - QMenu* subMenu(0); + foreach (const QString &subCategory, subCategoryMap.uniqueKeys()) { + QMenu *subMenu(0); if (subCategory.isEmpty()) { subMenu = menu; - } - else { + } else { subMenu = new QMenu(subCategory, this); menu->addMenu(subMenu); } - foreach(Chart* chart , subCategoryMap.values(subCategory)) { - + foreach(Chart *chart, subCategoryMap.values(subCategory)) { createMenuAction(subMenu, QIcon(), chart->name(), - qVariantFromValue((void *) chart)); + qVariantFromValue((void *) chart)); } } } @@ -574,8 +554,8 @@ QMenu* Window::createMenu() return result; } -QAction* Window::createMenuAction(QMenu *menu, const QIcon &icon, const QString &text, - const QVariant &data) +QAction *Window::createMenuAction(QMenu *menu, const QIcon &icon, const QString &text, + const QVariant &data) { QAction *action = menu->addAction(icon, text); action->setCheckable(false); @@ -585,7 +565,7 @@ QAction* Window::createMenuAction(QMenu *menu, const QIcon &icon, const QString void Window::handleGeometryChanged() { - QSizeF size = m_baseLayout->sizeHint(Qt::MinimumSize); - m_view->scene()->setSceneRect(0, 0, this->width(), this->height()); - m_view->setMinimumSize(size.toSize()); + QSizeF size = m_baseLayout->sizeHint(Qt::MinimumSize); + m_view->scene()->setSceneRect(0, 0, this->width(), this->height()); + m_view->setMinimumSize(size.toSize()); } diff --git a/demos/chartviewer/window.h b/demos/chartviewer/window.h index 83817d0..3e63351 100644 --- a/demos/chartviewer/window.h +++ b/demos/chartviewer/window.h @@ -44,7 +44,7 @@ QTCOMMERCIALCHART_USE_NAMESPACE class Window: public QMainWindow { Q_OBJECT - enum State{ NoState = 0, ZoomState, ScrollState}; + enum State { NoState = 0, ZoomState, ScrollState}; public: explicit Window(QWidget *parent = 0); ~Window(); @@ -53,10 +53,10 @@ private Q_SLOTS: void updateUI(); void handleGeometryChanged(); private: - QComboBox* createThemeBox(); - QComboBox* createAnimationBox(); - QComboBox* createLegendBox(); - QComboBox* createTempleteBox(); + QComboBox *createThemeBox(); + QComboBox *createAnimationBox(); + QComboBox *createLegendBox(); + QComboBox *createTempleteBox(); void connectSignals(); void createProxyWidgets(); void comboBoxFocused(QComboBox *combox); @@ -66,9 +66,9 @@ private: 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); + QMenu *createMenu(); + void handleMenu(QChart *chart); + QAction *createMenuAction(QMenu *menu, const QIcon &icon, const QString &text, const QVariant &data); protected: void mousePressEvent(QMouseEvent *event); @@ -79,10 +79,10 @@ private: int m_listCount; int m_valueMax; int m_valueCount; - QGraphicsScene* m_scene; - View* m_view; - QHash m_widgetHash; - QHash m_chartHash; + QGraphicsScene *m_scene; + View *m_view; + QHash m_widgetHash; + QHash m_chartHash; DataTable m_dataTable; QGraphicsWidget *m_form; @@ -95,9 +95,9 @@ private: QCheckBox *m_zoomCheckBox; QCheckBox *m_scrollCheckBox; QPoint m_origin; - QGraphicsRectItem* m_rubberBand; - QGraphicsGridLayout* m_baseLayout; - QMenu* m_menu; + QGraphicsRectItem *m_rubberBand; + QGraphicsGridLayout *m_baseLayout; + QMenu *m_menu; State m_state; State m_currentState; int m_template; @@ -108,17 +108,16 @@ private: class ComboBox: public QComboBox { public: - ComboBox(Window* window,QWidget *parent = 0):QComboBox(parent),m_window(window) + ComboBox(Window *window, QWidget *parent = 0): QComboBox(parent), m_window(window) {} protected: - void focusInEvent(QFocusEvent *e) - { + void focusInEvent(QFocusEvent *e) { QComboBox::focusInEvent(e); m_window->comboBoxFocused(this); } private: - Window* m_window; + Window *m_window; }; #endif diff --git a/demos/dynamicspline/chart.cpp b/demos/dynamicspline/chart.cpp index ec34224..b27b200 100644 --- a/demos/dynamicspline/chart.cpp +++ b/demos/dynamicspline/chart.cpp @@ -46,7 +46,7 @@ Chart::Chart(QGraphicsItem *parent, Qt::WindowFlags wFlags): addSeries(m_series); createDefaultAxes(); - setAxisX(m_axis,m_series); + setAxisX(m_axis, m_series); m_axis->setTickCount(5); axisX()->setRange(0, 10); axisY()->setRange(-5, 10); @@ -61,11 +61,12 @@ Chart::~Chart() void Chart::handleTimeout() { - qreal x = plotArea().width()/m_axis->tickCount(); - qreal y =(m_axis->max() - m_axis->min())/m_axis->tickCount(); + qreal x = plotArea().width() / m_axis->tickCount(); + qreal y = (m_axis->max() - m_axis->min()) / m_axis->tickCount(); m_x += y; m_y = qrand() % 5 - 2.5; m_series->append(m_x, m_y); - scroll(x,0); - if(m_x==100) m_timer.stop(); + scroll(x, 0); + if (m_x == 100) + m_timer.stop(); } diff --git a/demos/dynamicspline/chart.h b/demos/dynamicspline/chart.h index 92729ed..e828f7b 100644 --- a/demos/dynamicspline/chart.h +++ b/demos/dynamicspline/chart.h @@ -44,9 +44,9 @@ public slots: private: QTimer m_timer; - QSplineSeries* m_series; + QSplineSeries *m_series; QStringList m_titles; - QValueAxis* m_axis; + QValueAxis *m_axis; qreal m_step; qreal m_x; qreal m_y; diff --git a/demos/nesteddonuts/main.cpp b/demos/nesteddonuts/main.cpp index 036a7d6..9fe7f5c 100644 --- a/demos/nesteddonuts/main.cpp +++ b/demos/nesteddonuts/main.cpp @@ -25,6 +25,5 @@ int main(int argc, char *argv[]) QApplication a(argc, argv); Widget w; w.show(); - return a.exec(); } diff --git a/demos/nesteddonuts/widget.cpp b/demos/nesteddonuts/widget.cpp index 2dc8147..03a7a5c 100644 --- a/demos/nesteddonuts/widget.cpp +++ b/demos/nesteddonuts/widget.cpp @@ -31,14 +31,14 @@ QTCOMMERCIALCHART_USE_NAMESPACE Widget::Widget(QWidget *parent) : QWidget(parent) -{ +{ setMinimumSize(800, 600); - qsrand(QTime(0,0,0).secsTo(QTime::currentTime())); + qsrand(QTime(0, 0, 0).secsTo(QTime::currentTime())); //! [1] QChartView *chartView = new QChartView; chartView->setRenderHint(QPainter::Antialiasing); - QChart *chart = chartView->chart(); + QChart *chart = chartView->chart(); chart->legend()->setVisible(false); chart->setTitle("Nested donuts demo"); chart->setAnimationOptions(QChart::AllAnimations); @@ -72,7 +72,7 @@ Widget::Widget(QWidget *parent) // create main layout //! [4] - QGridLayout* mainLayout = new QGridLayout; + QGridLayout *mainLayout = new QGridLayout; mainLayout->addWidget(chartView, 1, 1); setLayout(mainLayout); //! [4] @@ -86,10 +86,10 @@ Widget::Widget(QWidget *parent) Widget::~Widget() { - + } - //! [6] +//! [6] void Widget::updateRotation() { for (int i = 0; i < m_donuts.count(); i++) { @@ -99,9 +99,9 @@ void Widget::updateRotation() donut->setPieEndAngle(donut->pieEndAngle() + phaseShift); } } - //! [6] +//! [6] - //! [7] +//! [7] void Widget::explodeSlice(bool exploded) { QPieSlice *slice = qobject_cast(sender()); @@ -125,4 +125,4 @@ void Widget::explodeSlice(bool exploded) } slice->setExploded(exploded); } - //! [7] +//! [7] diff --git a/demos/nesteddonuts/widget.h b/demos/nesteddonuts/widget.h index 585e28a..00a6a67 100644 --- a/demos/nesteddonuts/widget.h +++ b/demos/nesteddonuts/widget.h @@ -30,7 +30,7 @@ QTCOMMERCIALCHART_USE_NAMESPACE class Widget : public QWidget { Q_OBJECT - + public: Widget(QWidget *parent = 0); ~Widget(); diff --git a/demos/piechartcustomization/brushtool.cpp b/demos/piechartcustomization/brushtool.cpp index e2bc169..5f83ef2 100644 --- a/demos/piechartcustomization/brushtool.cpp +++ b/demos/piechartcustomization/brushtool.cpp @@ -24,7 +24,7 @@ #include BrushTool::BrushTool(QString title, QWidget *parent) - :QWidget(parent) + : QWidget(parent) { setWindowTitle(title); setWindowFlags(Qt::Tool); diff --git a/demos/piechartcustomization/customslice.cpp b/demos/piechartcustomization/customslice.cpp index 7cf2a25..b4f1e6f 100644 --- a/demos/piechartcustomization/customslice.cpp +++ b/demos/piechartcustomization/customslice.cpp @@ -23,7 +23,7 @@ QTCOMMERCIALCHART_USE_NAMESPACE CustomSlice::CustomSlice(QString label, qreal value) - :QPieSlice(label, value) + : QPieSlice(label, value) { connect(this, SIGNAL(hovered(bool)), this, SLOT(showHighlight(bool))); } diff --git a/demos/piechartcustomization/mainwidget.cpp b/demos/piechartcustomization/mainwidget.cpp index ad8375d..c2e7681 100644 --- a/demos/piechartcustomization/mainwidget.cpp +++ b/demos/piechartcustomization/mainwidget.cpp @@ -34,8 +34,8 @@ QTCOMMERCIALCHART_USE_NAMESPACE -MainWidget::MainWidget(QWidget* parent) - :QWidget(parent), +MainWidget::MainWidget(QWidget *parent) + : QWidget(parent), m_slice(0) { // create chart @@ -71,18 +71,18 @@ MainWidget::MainWidget(QWidget* parent) m_legendCheckBox = new QCheckBox(); - QFormLayout* chartSettingsLayout = new QFormLayout(); + QFormLayout *chartSettingsLayout = new QFormLayout(); chartSettingsLayout->addRow("Theme", m_themeComboBox); chartSettingsLayout->addRow("Antialiasing", m_aaCheckBox); chartSettingsLayout->addRow("Animations", m_animationsCheckBox); chartSettingsLayout->addRow("Legend", m_legendCheckBox); - QGroupBox* chartSettings = new QGroupBox("Chart"); + QGroupBox *chartSettings = new QGroupBox("Chart"); chartSettings->setLayout(chartSettingsLayout); - connect(m_themeComboBox, SIGNAL(currentIndexChanged(int)), this ,SLOT(updateChartSettings())); - connect(m_aaCheckBox, SIGNAL(toggled(bool)), this ,SLOT(updateChartSettings())); - connect(m_animationsCheckBox, SIGNAL(toggled(bool)), this ,SLOT(updateChartSettings())); - connect(m_legendCheckBox, SIGNAL(toggled(bool)), this ,SLOT(updateChartSettings())); + connect(m_themeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateChartSettings())); + connect(m_aaCheckBox, SIGNAL(toggled(bool)), this, SLOT(updateChartSettings())); + connect(m_animationsCheckBox, SIGNAL(toggled(bool)), this, SLOT(updateChartSettings())); + connect(m_legendCheckBox, SIGNAL(toggled(bool)), this, SLOT(updateChartSettings())); // series settings m_hPosition = new QDoubleSpinBox(); @@ -125,7 +125,7 @@ MainWidget::MainWidget(QWidget* parent) QPushButton *insertSlice = new QPushButton("Insert slice"); QPushButton *removeSlice = new QPushButton("Remove selected slice"); - QFormLayout* seriesSettingsLayout = new QFormLayout(); + QFormLayout *seriesSettingsLayout = new QFormLayout(); seriesSettingsLayout->addRow("Horizontal position", m_hPosition); seriesSettingsLayout->addRow("Vertical position", m_vPosition); seriesSettingsLayout->addRow("Size factor", m_sizeFactor); @@ -135,7 +135,7 @@ MainWidget::MainWidget(QWidget* parent) seriesSettingsLayout->addRow(appendSlice); seriesSettingsLayout->addRow(insertSlice); seriesSettingsLayout->addRow(removeSlice); - QGroupBox* seriesSettings = new QGroupBox("Series"); + QGroupBox *seriesSettings = new QGroupBox("Series"); seriesSettings->setLayout(seriesSettingsLayout); connect(m_vPosition, SIGNAL(valueChanged(double)), this, SLOT(updateSerieSettings())); @@ -172,7 +172,7 @@ MainWidget::MainWidget(QWidget* parent) m_labelPosition->addItem("Inside tangential", QPieSlice::LabelInsideTangential); m_labelPosition->addItem("Inside normal", QPieSlice::LabelInsideNormal); - QFormLayout* sliceSettingsLayout = new QFormLayout(); + QFormLayout *sliceSettingsLayout = new QFormLayout(); sliceSettingsLayout->addRow("Label", m_sliceName); sliceSettingsLayout->addRow("Value", m_sliceValue); sliceSettingsLayout->addRow("Pen", m_pen); @@ -184,7 +184,7 @@ MainWidget::MainWidget(QWidget* parent) sliceSettingsLayout->addRow("Label arm length", m_sliceLabelArmFactor); sliceSettingsLayout->addRow("Exploded", m_sliceExploded); sliceSettingsLayout->addRow("Explode distance", m_sliceExplodedFactor); - QGroupBox* sliceSettings = new QGroupBox("Selected slice"); + QGroupBox *sliceSettings = new QGroupBox("Selected slice"); sliceSettings->setLayout(sliceSettingsLayout); connect(m_sliceName, SIGNAL(textChanged(QString)), this, SLOT(updateSliceSettings())); @@ -213,7 +213,7 @@ MainWidget::MainWidget(QWidget* parent) settingsLayout->addWidget(sliceSettings); settingsLayout->addStretch(); - QGridLayout* baseLayout = new QGridLayout(); + QGridLayout *baseLayout = new QGridLayout(); baseLayout->addLayout(settingsLayout, 0, 0); baseLayout->addWidget(m_chartView, 0, 1); setLayout(baseLayout); @@ -272,9 +272,9 @@ void MainWidget::updateSliceSettings() m_slice->setExplodeDistanceFactor(m_sliceExplodedFactor->value()); } -void MainWidget::handleSliceClicked(QPieSlice* slice) +void MainWidget::handleSliceClicked(QPieSlice *slice) { - m_slice = static_cast(slice); + m_slice = static_cast(slice); // name m_sliceName->blockSignals(true); @@ -332,7 +332,7 @@ void MainWidget::showFontDialog() void MainWidget::appendSlice() { - *m_series << new CustomSlice("Slice " + QString::number(m_series->count()+1), 10.0); + *m_series << new CustomSlice("Slice " + QString::number(m_series->count() + 1), 10.0); } void MainWidget::insertSlice() @@ -342,7 +342,7 @@ void MainWidget::insertSlice() int i = m_series->slices().indexOf(m_slice); - m_series->insert(i, new CustomSlice("Slice " + QString::number(m_series->count()+1), 10.0)); + m_series->insert(i, new CustomSlice("Slice " + QString::number(m_series->count() + 1), 10.0)); } void MainWidget::removeSlice() diff --git a/demos/piechartcustomization/mainwidget.h b/demos/piechartcustomization/mainwidget.h index 6ac4995..6008ccb 100644 --- a/demos/piechartcustomization/mainwidget.h +++ b/demos/piechartcustomization/mainwidget.h @@ -45,13 +45,13 @@ class MainWidget : public QWidget Q_OBJECT public: - explicit MainWidget(QWidget* parent = 0); + explicit MainWidget(QWidget *parent = 0); public Q_SLOTS: void updateChartSettings(); void updateSerieSettings(); void updateSliceSettings(); - void handleSliceClicked(QPieSlice* slice); + void handleSliceClicked(QPieSlice *slice); void showFontDialog(); void appendSlice(); void insertSlice(); @@ -63,23 +63,23 @@ private: QCheckBox *m_animationsCheckBox; QCheckBox *m_legendCheckBox; - QChartView* m_chartView; - QPieSeries* m_series; - CustomSlice* m_slice; + QChartView *m_chartView; + QPieSeries *m_series; + CustomSlice *m_slice; - QDoubleSpinBox* m_hPosition; - QDoubleSpinBox* m_vPosition; - QDoubleSpinBox* m_sizeFactor; - QDoubleSpinBox* m_startAngle; - QDoubleSpinBox* m_endAngle; - QDoubleSpinBox* m_holeSize; + QDoubleSpinBox *m_hPosition; + QDoubleSpinBox *m_vPosition; + QDoubleSpinBox *m_sizeFactor; + QDoubleSpinBox *m_startAngle; + QDoubleSpinBox *m_endAngle; + QDoubleSpinBox *m_holeSize; - QLineEdit* m_sliceName; - QDoubleSpinBox* m_sliceValue; - QCheckBox* m_sliceLabelVisible; - QDoubleSpinBox* m_sliceLabelArmFactor; - QCheckBox* m_sliceExploded; - QDoubleSpinBox* m_sliceExplodedFactor; + QLineEdit *m_sliceName; + QDoubleSpinBox *m_sliceValue; + QCheckBox *m_sliceLabelVisible; + QDoubleSpinBox *m_sliceLabelArmFactor; + QCheckBox *m_sliceExploded; + QDoubleSpinBox *m_sliceExplodedFactor; QPushButton *m_brush; BrushTool *m_brushTool; QPushButton *m_pen; diff --git a/demos/piechartcustomization/pentool.cpp b/demos/piechartcustomization/pentool.cpp index d79a458..2298831 100644 --- a/demos/piechartcustomization/pentool.cpp +++ b/demos/piechartcustomization/pentool.cpp @@ -26,7 +26,7 @@ #include PenTool::PenTool(QString title, QWidget *parent) - :QWidget(parent) + : QWidget(parent) { setWindowTitle(title); setWindowFlags(Qt::Tool); diff --git a/demos/qmlcustomlegend/main.cpp b/demos/qmlcustomlegend/main.cpp old mode 100755 new mode 100644 index 6353e56..2bb44ee --- a/demos/qmlcustomlegend/main.cpp +++ b/demos/qmlcustomlegend/main.cpp @@ -1,40 +1,40 @@ -/**************************************************************************** -** -** 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 -#ifdef QT5_QUICK_1 +/**************************************************************************** +** +** 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 +#ifdef QT5_QUICK_1 #include -#else +#else #include -#endif -#include "qmlapplicationviewer.h" - -Q_DECL_EXPORT int main(int argc, char *argv[]) -{ - QScopedPointer app(createApplication(argc, argv)); - QScopedPointer viewer(QmlApplicationViewer::create()); - - //viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto); - viewer->setSource(QUrl("qrc:/qml/qmlcustomlegend/loader.qml")); - viewer->setRenderHint(QPainter::Antialiasing, true); - viewer->showExpanded(); - - return app->exec(); -} +#endif +#include "qmlapplicationviewer.h" + +Q_DECL_EXPORT int main(int argc, char *argv[]) +{ + QScopedPointer app(createApplication(argc, argv)); + QScopedPointer viewer(QmlApplicationViewer::create()); + + //viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto); + viewer->setSource(QUrl("qrc:/qml/qmlcustomlegend/loader.qml")); + viewer->setRenderHint(QPainter::Antialiasing, true); + viewer->showExpanded(); + + return app->exec(); +} diff --git a/demos/qmlcustomlegend/qmlapplicationviewer/qmlapplicationviewer.cpp b/demos/qmlcustomlegend/qmlapplicationviewer/qmlapplicationviewer.cpp old mode 100755 new mode 100644 diff --git a/demos/qmlcustomlegend/qmlapplicationviewer/qmlapplicationviewer.h b/demos/qmlcustomlegend/qmlapplicationviewer/qmlapplicationviewer.h old mode 100755 new mode 100644 diff --git a/demos/qmlcustommodel/customtablemodel.cpp b/demos/qmlcustommodel/customtablemodel.cpp index 7a99747..1e8f980 100644 --- a/demos/qmlcustommodel/customtablemodel.cpp +++ b/demos/qmlcustommodel/customtablemodel.cpp @@ -31,13 +31,13 @@ CustomTableModel::CustomTableModel(QObject *parent) : { } -int CustomTableModel::rowCount(const QModelIndex & parent) const +int CustomTableModel::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent) return m_data.count(); } -int CustomTableModel::columnCount(const QModelIndex & parent) const +int CustomTableModel::columnCount(const QModelIndex &parent) const { Q_UNUSED(parent) return m_columnCount; @@ -128,7 +128,7 @@ bool CustomTableModel::removeRows(int row, int count, const QModelIndex &parent) return removed; } -Qt::ItemFlags CustomTableModel::flags ( const QModelIndex & index ) const +Qt::ItemFlags CustomTableModel::flags(const QModelIndex &index) const { return QAbstractItemModel::flags(index) | Qt::ItemIsEditable; } diff --git a/demos/qmlcustommodel/customtablemodel.h b/demos/qmlcustommodel/customtablemodel.h index ea40d1b..497130e 100644 --- a/demos/qmlcustommodel/customtablemodel.h +++ b/demos/qmlcustommodel/customtablemodel.h @@ -33,17 +33,17 @@ class CustomTableModel : public QAbstractTableModel public: explicit CustomTableModel(QObject *parent = 0); - int rowCount ( const QModelIndex & parent = QModelIndex() ) const; - int columnCount ( const QModelIndex & parent = QModelIndex() ) const; - QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const; + int rowCount(const QModelIndex &parent = QModelIndex()) const; + int columnCount(const QModelIndex &parent = QModelIndex()) const; + QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role = Qt::EditRole); QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; - bool setData ( const QModelIndex & index, const QVariant & value, int role = Qt::EditRole ); - Qt::ItemFlags flags ( const QModelIndex & index ) const; + bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole); + Qt::ItemFlags flags(const QModelIndex &index) const; void insertColumn(int column, const QModelIndex &parent = QModelIndex()); void insertRow(int row, const QModelIndex &parent = QModelIndex()); - Q_INVOKABLE bool removeRows(int row, int count, const QModelIndex & parent = QModelIndex()); - Q_INVOKABLE bool removeRow (int row, const QModelIndex &parent = QModelIndex()); + Q_INVOKABLE bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()); + Q_INVOKABLE bool removeRow(int row, const QModelIndex &parent = QModelIndex()); Q_INVOKABLE QVariant at(int row, int column); private: diff --git a/demos/qmloscilloscope/datasource.h b/demos/qmloscilloscope/datasource.h index 0bde577..df283e2 100644 --- a/demos/qmloscilloscope/datasource.h +++ b/demos/qmloscilloscope/datasource.h @@ -33,9 +33,9 @@ class DataSource : public QObject Q_OBJECT public: explicit DataSource(QDeclarativeView *appViewer, QObject *parent = 0); - + signals: - + public slots: void generateData(int type, int rowCount, int colCount); void update(QAbstractSeries *series);