summaryrefslogtreecommitdiffstats
path: root/examples/charts/piechartcustomization
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@qt.io>2017-08-01 16:45:50 +0300
committerMiikka Heikkinen <miikka.heikkinen@qt.io>2017-08-03 07:54:28 +0000
commitebc5bc3d8b2d7ea135a430d5cbc77f9f97cb78b0 (patch)
tree3b872b582ddeab668e0cc4b809640a53b114c282 /examples/charts/piechartcustomization
parenteedb1c76538cac3c11e7ac57eaa571d6ce07a632 (diff)
Minor coding style fixes to examples
Task-number: QTBUG-60662 Change-Id: I0edd88328b403d09faa27d30b89ac91c802121dc Reviewed-by: André Hartmann <aha_1980@gmx.de> Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io> Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Diffstat (limited to 'examples/charts/piechartcustomization')
-rw-r--r--examples/charts/piechartcustomization/brushtool.cpp5
-rw-r--r--examples/charts/piechartcustomization/customslice.cpp2
-rw-r--r--examples/charts/piechartcustomization/mainwidget.cpp88
-rw-r--r--examples/charts/piechartcustomization/pentool.cpp19
4 files changed, 74 insertions, 40 deletions
diff --git a/examples/charts/piechartcustomization/brushtool.cpp b/examples/charts/piechartcustomization/brushtool.cpp
index 6f46fe26..d4c1785b 100644
--- a/examples/charts/piechartcustomization/brushtool.cpp
+++ b/examples/charts/piechartcustomization/brushtool.cpp
@@ -61,8 +61,9 @@ BrushTool::BrushTool(QString title, QWidget *parent)
layout->addRow("Style", m_styleCombo);
setLayout(layout);
- connect(m_colorButton, SIGNAL(clicked()), this, SLOT(showColorDialog()));
- connect(m_styleCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(updateStyle()));
+ connect(m_colorButton, &QPushButton::clicked, this, &BrushTool::showColorDialog);
+ connect(m_styleCombo, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
+ this, &BrushTool::updateStyle);
}
void BrushTool::setBrush(QBrush brush)
diff --git a/examples/charts/piechartcustomization/customslice.cpp b/examples/charts/piechartcustomization/customslice.cpp
index ac46410b..12402d60 100644
--- a/examples/charts/piechartcustomization/customslice.cpp
+++ b/examples/charts/piechartcustomization/customslice.cpp
@@ -34,7 +34,7 @@ QT_CHARTS_USE_NAMESPACE
CustomSlice::CustomSlice(QString label, qreal value)
: QPieSlice(label, value)
{
- connect(this, SIGNAL(hovered(bool)), this, SLOT(showHighlight(bool)));
+ connect(this, &CustomSlice::hovered, this, &CustomSlice::showHighlight);
}
QBrush CustomSlice::originalBrush()
diff --git a/examples/charts/piechartcustomization/mainwidget.cpp b/examples/charts/piechartcustomization/mainwidget.cpp
index 71de08d9..7c3648a2 100644
--- a/examples/charts/piechartcustomization/mainwidget.cpp
+++ b/examples/charts/piechartcustomization/mainwidget.cpp
@@ -62,7 +62,7 @@ MainWidget::MainWidget(QWidget *parent)
m_series->setLabelsVisible();
chart->addSeries(m_series);
- connect(m_series, SIGNAL(clicked(QPieSlice*)), this, SLOT(handleSliceClicked(QPieSlice*)));
+ connect(m_series, &QPieSeries::clicked, this, &MainWidget::handleSliceClicked);
// chart settings
m_themeComboBox = new QComboBox();
@@ -89,10 +89,11 @@ MainWidget::MainWidget(QWidget *parent)
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, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
+ this, &MainWidget::updateChartSettings);
+ connect(m_aaCheckBox, &QCheckBox::toggled, this, &MainWidget::updateChartSettings);
+ connect(m_animationsCheckBox, &QCheckBox::toggled, this, &MainWidget::updateChartSettings);
+ connect(m_legendCheckBox, &QCheckBox::toggled, this, &MainWidget::updateChartSettings);
// series settings
m_hPosition = new QDoubleSpinBox();
@@ -148,15 +149,27 @@ MainWidget::MainWidget(QWidget *parent)
QGroupBox *seriesSettings = new QGroupBox("Series");
seriesSettings->setLayout(seriesSettingsLayout);
- connect(m_vPosition, SIGNAL(valueChanged(double)), this, SLOT(updateSerieSettings()));
- connect(m_hPosition, SIGNAL(valueChanged(double)), this, SLOT(updateSerieSettings()));
- connect(m_sizeFactor, SIGNAL(valueChanged(double)), this, SLOT(updateSerieSettings()));
- connect(m_startAngle, SIGNAL(valueChanged(double)), this, SLOT(updateSerieSettings()));
- connect(m_endAngle, SIGNAL(valueChanged(double)), this, SLOT(updateSerieSettings()));
- connect(m_holeSize, SIGNAL(valueChanged(double)), this, SLOT(updateSerieSettings()));
- connect(appendSlice, SIGNAL(clicked()), this, SLOT(appendSlice()));
- connect(insertSlice, SIGNAL(clicked()), this, SLOT(insertSlice()));
- connect(removeSlice, SIGNAL(clicked()), this, SLOT(removeSlice()));
+ connect(m_vPosition,
+ static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
+ this, &MainWidget::updateSerieSettings);
+ connect(m_hPosition,
+ static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
+ this, &MainWidget::updateSerieSettings);
+ connect(m_sizeFactor,
+ static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
+ this, &MainWidget::updateSerieSettings);
+ connect(m_startAngle,
+ static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
+ this, &MainWidget::updateSerieSettings);
+ connect(m_endAngle,
+ static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
+ this, &MainWidget::updateSerieSettings);
+ connect(m_holeSize,
+ static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
+ this, &MainWidget::updateSerieSettings);
+ connect(appendSlice, &QPushButton::clicked, this, &MainWidget::appendSlice);
+ connect(insertSlice, &QPushButton::clicked, this, &MainWidget::insertSlice);
+ connect(removeSlice, &QPushButton::clicked, this, &MainWidget::removeSlice);
// slice settings
m_sliceName = new QLineEdit("<click a slice>");
@@ -197,21 +210,29 @@ MainWidget::MainWidget(QWidget *parent)
QGroupBox *sliceSettings = new QGroupBox("Selected slice");
sliceSettings->setLayout(sliceSettingsLayout);
- connect(m_sliceName, SIGNAL(textChanged(QString)), this, SLOT(updateSliceSettings()));
- connect(m_sliceValue, SIGNAL(valueChanged(double)), this, SLOT(updateSliceSettings()));
- connect(m_pen, SIGNAL(clicked()), m_penTool, SLOT(show()));
- connect(m_penTool, SIGNAL(changed()), this, SLOT(updateSliceSettings()));
- connect(m_brush, SIGNAL(clicked()), m_brushTool, SLOT(show()));
- connect(m_brushTool, SIGNAL(changed()), this, SLOT(updateSliceSettings()));
- connect(m_font, SIGNAL(clicked()), this, SLOT(showFontDialog()));
- connect(m_labelBrush, SIGNAL(clicked()), m_labelBrushTool, SLOT(show()));
- connect(m_labelBrushTool, SIGNAL(changed()), this, SLOT(updateSliceSettings()));
- connect(m_sliceLabelVisible, SIGNAL(toggled(bool)), this, SLOT(updateSliceSettings()));
- connect(m_sliceLabelVisible, SIGNAL(toggled(bool)), this, SLOT(updateSliceSettings()));
- connect(m_sliceLabelArmFactor, SIGNAL(valueChanged(double)), this, SLOT(updateSliceSettings()));
- connect(m_sliceExploded, SIGNAL(toggled(bool)), this, SLOT(updateSliceSettings()));
- connect(m_sliceExplodedFactor, SIGNAL(valueChanged(double)), this, SLOT(updateSliceSettings()));
- connect(m_labelPosition, SIGNAL(currentIndexChanged(int)), this, SLOT(updateSliceSettings()));
+ connect(m_sliceName, &QLineEdit::textChanged, this, &MainWidget::updateSliceSettings);
+ connect(m_sliceValue,
+ static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
+ this, &MainWidget::updateSliceSettings);
+ connect(m_pen, &QPushButton::clicked, m_penTool, &PenTool::show);
+ connect(m_penTool, &PenTool::changed, this, &MainWidget::updateSliceSettings);
+ connect(m_brush, &QPushButton::clicked, m_brushTool, &BrushTool::show);
+ connect(m_brushTool, &BrushTool::changed, this, &MainWidget::updateSliceSettings);
+ connect(m_font, &QPushButton::clicked, this, &MainWidget::showFontDialog);
+ connect(m_labelBrush, &QPushButton::clicked, m_labelBrushTool, &BrushTool::show);
+ connect(m_labelBrushTool, &BrushTool::changed, this, &MainWidget::updateSliceSettings);
+ connect(m_sliceLabelVisible, &QCheckBox::toggled, this, &MainWidget::updateSliceSettings);
+ connect(m_sliceLabelVisible, &QCheckBox::toggled, this, &MainWidget::updateSliceSettings);
+ connect(m_sliceLabelArmFactor,
+ static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
+ this, &MainWidget::updateSliceSettings);
+ connect(m_sliceExploded, &QCheckBox::toggled, this, &MainWidget::updateSliceSettings);
+ connect(m_sliceExplodedFactor,
+ static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
+ this, &MainWidget::updateSliceSettings);
+ connect(m_labelPosition,
+ static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
+ this, &MainWidget::updateSliceSettings);
// create chart view
m_chartView = new QChartView(chart);
@@ -235,7 +256,8 @@ MainWidget::MainWidget(QWidget *parent)
void MainWidget::updateChartSettings()
{
- QChart::ChartTheme theme = (QChart::ChartTheme) m_themeComboBox->itemData(m_themeComboBox->currentIndex()).toInt();
+ QChart::ChartTheme theme = static_cast<QChart::ChartTheme>(m_themeComboBox->itemData(
+ m_themeComboBox->currentIndex()).toInt());
m_chartView->chart()->setTheme(theme);
m_chartView->setRenderHint(QPainter::Antialiasing, m_aaCheckBox->isChecked());
@@ -276,7 +298,8 @@ void MainWidget::updateSliceSettings()
m_slice->setLabelBrush(m_labelBrushTool->brush());
m_slice->setLabelVisible(m_sliceLabelVisible->isChecked());
m_slice->setLabelArmLengthFactor(m_sliceLabelArmFactor->value());
- m_slice->setLabelPosition((QPieSlice::LabelPosition)m_labelPosition->currentIndex()); // assumes that index is in sync with the enum
+ // We assume that label position index is in sync with the enum
+ m_slice->setLabelPosition((QPieSlice::LabelPosition)m_labelPosition->currentIndex());
m_slice->setExploded(m_sliceExploded->isChecked());
m_slice->setExplodeDistanceFactor(m_sliceExplodedFactor->value());
@@ -315,7 +338,8 @@ void MainWidget::handleSliceClicked(QPieSlice *slice)
m_sliceLabelArmFactor->setValue(slice->labelArmLengthFactor());
m_sliceLabelArmFactor->blockSignals(false);
m_labelPosition->blockSignals(true);
- m_labelPosition->setCurrentIndex(slice->labelPosition()); // assumes that index is in sync with the enum
+ // We assume that label position index is in sync with the enum
+ m_labelPosition->setCurrentIndex(slice->labelPosition());
m_labelPosition->blockSignals(false);
// exploded
diff --git a/examples/charts/piechartcustomization/pentool.cpp b/examples/charts/piechartcustomization/pentool.cpp
index f39d8661..3b160859 100644
--- a/examples/charts/piechartcustomization/pentool.cpp
+++ b/examples/charts/piechartcustomization/pentool.cpp
@@ -71,11 +71,20 @@ PenTool::PenTool(QString title, QWidget *parent)
layout->addRow("Join style", m_joinStyleCombo);
setLayout(layout);
- connect(m_colorButton, SIGNAL(clicked()), this, SLOT(showColorDialog()));
- connect(m_widthSpinBox, SIGNAL(valueChanged(double)), this, SLOT(updateWidth(double)));
- connect(m_styleCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(updateStyle(int)));
- connect(m_capStyleCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(updateCapStyle(int)));
- connect(m_joinStyleCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(updateJoinStyle(int)));
+ // Use old style connect on some signals because the signal is overloaded
+ connect(m_colorButton, &QPushButton::clicked, this, &PenTool::showColorDialog);
+ connect(m_widthSpinBox,
+ static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
+ this, &PenTool::updateWidth);
+ connect(m_styleCombo,
+ static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
+ this, &PenTool::updateStyle);
+ connect(m_capStyleCombo,
+ static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
+ this, &PenTool::updateCapStyle);
+ connect(m_joinStyleCombo,
+ static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
+ this, &PenTool::updateJoinStyle);
}
void PenTool::setPen(const QPen &pen)