From 7d15b2a5d2521a059b7c885011f9e6e5d58c706f 2012-10-17 07:46:27 From: sauimone Date: 2012-10-17 07:46:27 Subject: [PATCH] code inspection round 1 fixes --- diff --git a/examples/newlegend/main.cpp b/examples/newlegend/main.cpp index 61d5fa3..9dec87f 100644 --- a/examples/newlegend/main.cpp +++ b/examples/newlegend/main.cpp @@ -23,8 +23,6 @@ #include #include -QTCOMMERCIALCHART_USE_NAMESPACE - int main(int argc, char *argv[]) { QApplication a(argc, argv); diff --git a/examples/newlegend/mainwidget.h b/examples/newlegend/mainwidget.h index a66c55c..a0ac67e 100644 --- a/examples/newlegend/mainwidget.h +++ b/examples/newlegend/mainwidget.h @@ -44,8 +44,6 @@ public: void showLegendSpinbox(); void hideLegendSpinbox(); -signals: - public slots: void toggleAttached(); void addSlice(); @@ -61,10 +59,8 @@ public slots: void fontSizeChanged(); void updateLegendLayout(); - void handleMarkerClicked(); - private: QChart *m_chart; diff --git a/src/areachart/qareaseries.cpp b/src/areachart/qareaseries.cpp index 41bcff1..9d82664 100644 --- a/src/areachart/qareaseries.cpp +++ b/src/areachart/qareaseries.cpp @@ -26,7 +26,6 @@ #include "chartdataset_p.h" #include "charttheme_p.h" #include "qvalueaxis.h" - #include "qarealegendmarker.h" QTCOMMERCIALCHART_BEGIN_NAMESPACE diff --git a/src/barchart/qabstractbarseries.cpp b/src/barchart/qabstractbarseries.cpp index ccf60cc..518c2e2 100644 --- a/src/barchart/qabstractbarseries.cpp +++ b/src/barchart/qabstractbarseries.cpp @@ -27,7 +27,6 @@ #include "charttheme_p.h" #include "qvalueaxis.h" #include "qbarcategoryaxis.h" - #include "qbarlegendmarker.h" QTCOMMERCIALCHART_BEGIN_NAMESPACE diff --git a/src/legend/legendlayout.cpp b/src/legend/legendlayout.cpp index eeaf343..53f0815 100644 --- a/src/legend/legendlayout.cpp +++ b/src/legend/legendlayout.cpp @@ -117,7 +117,7 @@ void LegendLayout::setAttachedGeometry(const QRectF &rect) QSizeF size(0, 0); - if (m_legend->d_ptr->legendMarkers().isEmpty()) { + if (m_legend->d_ptr->markers().isEmpty()) { return; } @@ -133,7 +133,7 @@ void LegendLayout::setAttachedGeometry(const QRectF &rect) case Qt::AlignTop: case Qt::AlignBottom: { QPointF point(0,0); - foreach (QLegendMarker* marker, m_legend->d_ptr->legendMarkers()) { + foreach (QLegendMarker* marker, m_legend->d_ptr->markers()) { LegendMarkerItem* item = marker->d_ptr->item(); if (item->isVisible()) { item->setGeometry(geometry); @@ -155,7 +155,7 @@ void LegendLayout::setAttachedGeometry(const QRectF &rect) case Qt::AlignLeft: case Qt::AlignRight: { QPointF point(0,0); - foreach (QLegendMarker* marker, m_legend->d_ptr->legendMarkers()) { + foreach (QLegendMarker* marker, m_legend->d_ptr->markers()) { LegendMarkerItem* item = marker->d_ptr->item(); if (item->isVisible()) { item->setGeometry(geometry); @@ -202,7 +202,7 @@ void LegendLayout::setDettachedGeometry(const QRectF &rect) QSizeF size(0, 0); - QList markers = m_legend->d_ptr->legendMarkers(); + QList markers = m_legend->d_ptr->markers(); if (markers.isEmpty()) return; @@ -359,7 +359,7 @@ QSizeF LegendLayout::sizeHint(Qt::SizeHint which, const QSizeF &constraint) cons getContentsMargins(&left, &top, &right, &bottom); if(constraint.isValid()) { - foreach(QLegendMarker* marker, m_legend->d_ptr->legendMarkers()) { + foreach(QLegendMarker* marker, m_legend->d_ptr->markers()) { LegendMarkerItem *item = marker->d_ptr->item(); size = size.expandedTo(item->effectiveSizeHint(which)); } @@ -368,7 +368,7 @@ QSizeF LegendLayout::sizeHint(Qt::SizeHint which, const QSizeF &constraint) cons else if (constraint.width() >= 0) { qreal width = 0; qreal height = 0; - foreach(QLegendMarker* marker, m_legend->d_ptr->legendMarkers()) { + foreach(QLegendMarker* marker, m_legend->d_ptr->markers()) { LegendMarkerItem *item = marker->d_ptr->item(); width+=item->effectiveSizeHint(which).width(); height=qMax(height,item->effectiveSizeHint(which).height()); @@ -379,7 +379,7 @@ QSizeF LegendLayout::sizeHint(Qt::SizeHint which, const QSizeF &constraint) cons else if (constraint.height() >= 0) { qreal width = 0; qreal height = 0; - foreach(QLegendMarker* marker, m_legend->d_ptr->legendMarkers()) { + foreach(QLegendMarker* marker, m_legend->d_ptr->markers()) { LegendMarkerItem *item = marker->d_ptr->item(); width=qMax(width,item->effectiveSizeHint(which).width()); height+=height,item->effectiveSizeHint(which).height(); @@ -387,7 +387,7 @@ QSizeF LegendLayout::sizeHint(Qt::SizeHint which, const QSizeF &constraint) cons size = QSizeF(width,qMin(constraint.height(),height)); } else { - foreach(QLegendMarker* marker, m_legend->d_ptr->legendMarkers()) { + foreach(QLegendMarker* marker, m_legend->d_ptr->markers()) { LegendMarkerItem *item = marker->d_ptr->item(); size = size.expandedTo(item->effectiveSizeHint(which)); } diff --git a/src/legend/qarealegendmarker.cpp b/src/legend/qarealegendmarker.cpp index c19d7d3..7bf94e4 100644 --- a/src/legend/qarealegendmarker.cpp +++ b/src/legend/qarealegendmarker.cpp @@ -63,8 +63,6 @@ QAreaLegendMarkerPrivate::QAreaLegendMarkerPrivate(QAreaLegendMarker *q, QAreaSe QAreaLegendMarkerPrivate::~QAreaLegendMarkerPrivate() { - QObject::disconnect(m_series->d_func(),SIGNAL(updated()), this, SLOT(updated())); - QObject::disconnect(m_series, SIGNAL(nameChanged()), this, SLOT(updated())); } QAreaSeries* QAreaLegendMarkerPrivate::series() diff --git a/src/legend/qbarlegendmarker.cpp b/src/legend/qbarlegendmarker.cpp index 66fc2fd..dd9abac 100644 --- a/src/legend/qbarlegendmarker.cpp +++ b/src/legend/qbarlegendmarker.cpp @@ -71,9 +71,6 @@ QBarLegendMarkerPrivate::QBarLegendMarkerPrivate(QBarLegendMarker *q, QAbstractB QBarLegendMarkerPrivate::~QBarLegendMarkerPrivate() { - QObject::disconnect(m_barset, SIGNAL(labelChanged()), this, SLOT(updated())); - QObject::disconnect(m_barset, SIGNAL(brushChanged()), this, SLOT(updated())); - QObject::disconnect(m_barset, SIGNAL(penChanged()), this, SLOT(updated())); } QAbstractBarSeries* QBarLegendMarkerPrivate::series() diff --git a/src/legend/qbarlegendmarker_p.h b/src/legend/qbarlegendmarker_p.h index 27a27c6..9c15b31 100644 --- a/src/legend/qbarlegendmarker_p.h +++ b/src/legend/qbarlegendmarker_p.h @@ -61,7 +61,7 @@ private: QAbstractBarSeries* m_series; QBarSet* m_barset; - friend class QLegendPrivate; // TODO: Is this needed? + friend class QLegendPrivate; Q_DECLARE_PUBLIC(QBarLegendMarker) }; diff --git a/src/legend/qlegend.cpp b/src/legend/qlegend.cpp index fd188a1..4c797c4 100644 --- a/src/legend/qlegend.cpp +++ b/src/legend/qlegend.cpp @@ -268,11 +268,11 @@ void QLegend::setFont(const QFont &font) if (d_ptr->m_font != font) d_ptr->m_font = font; - foreach (QLegendMarker *marker, d_ptr->legendMarkers()) { + foreach (QLegendMarker *marker, d_ptr->markers()) { marker->setFont(d_ptr->m_font); - layout()->invalidate(); - emit fontChanged(font); } + layout()->invalidate(); + emit fontChanged(font); } QFont QLegend::font() const @@ -301,7 +301,7 @@ void QLegend::setLabelBrush(const QBrush &brush) { if (d_ptr->m_labelBrush != brush) { d_ptr->m_labelBrush = brush; - foreach (QLegendMarker *marker, d_ptr->legendMarkers()) { + foreach (QLegendMarker *marker, d_ptr->markers()) { marker->setLabelBrush(d_ptr->m_labelBrush); // Note: The pen of the marker rectangle could be exposed in the public QLegend API // instead of mapping it from label brush color @@ -397,16 +397,14 @@ bool QLegend::isBackgroundVisible() const return d_ptr->m_backgroundVisible; } - QList QLegend::markers() const { - // TODO: name of PIMPL method will change. - return d_ptr->legendMarkers(); + return d_ptr->markers(); } -void QLegend::appendSeries(QAbstractSeries* series) +void QLegend::addSeries(QAbstractSeries* series) { - d_ptr->appendSeries(series); + d_ptr->addSeries(series); } void QLegend::removeSeries(QAbstractSeries* series) @@ -475,7 +473,7 @@ int QLegendPrivate::roundness(qreal size) return 100 * m_diameter / int(size); } -void QLegendPrivate::appendSeries(QAbstractSeries* series) +void QLegendPrivate::addSeries(QAbstractSeries* series) { // Only allow one instance of series if (m_series.contains(series)) { @@ -532,7 +530,7 @@ void QLegendPrivate::removeSeries(QAbstractSeries* series) // Find out, which markers to remove QList removed; - foreach (QLegendMarker *m, m_legendMarkers) { + foreach (QLegendMarker *m, m_markers) { if (m->series() == series) { removed << m; } @@ -577,7 +575,7 @@ void QLegendPrivate::handleSeriesAdded(QAbstractSeries *series) { // Moved to appendSeries // This slot is just to make old code work for now. - appendSeries(series); + addSeries(series); } void QLegendPrivate::handleSeriesRemoved(QAbstractSeries *series) @@ -592,7 +590,7 @@ void QLegendPrivate::handleSeriesVisibleChanged() QAbstractSeries *series = qobject_cast (sender()); Q_ASSERT(series); - foreach (QLegendMarker* marker, m_legendMarkers) { + foreach (QLegendMarker* marker, m_markers) { if (marker->series() == series) { marker->setVisible(series->isVisible()); } @@ -610,7 +608,7 @@ void QLegendPrivate::handleCountChanged() // Find out removed markers and created markers QList removedMarkers; - foreach (QLegendMarker *oldMarker, m_legendMarkers) { + foreach (QLegendMarker *oldMarker, m_markers) { // we have marker, which is related to sender. if (oldMarker->series() == series) { bool found = false; @@ -642,7 +640,7 @@ void QLegendPrivate::addMarkers(QList markers) { foreach (QLegendMarker* marker, markers) { m_items->addToGroup(marker->d_ptr.data()->item()); - m_legendMarkers << marker; + m_markers << marker; } } @@ -652,7 +650,7 @@ void QLegendPrivate::removeMarkers(QList markers) marker->d_ptr->item()->setVisible(false); m_items->removeFromGroup(marker->d_ptr->item()); delete marker; - m_legendMarkers.removeOne(marker); + m_markers.removeOne(marker); } } diff --git a/src/legend/qlegend.h b/src/legend/qlegend.h index 5364fc4..1dc45db 100644 --- a/src/legend/qlegend.h +++ b/src/legend/qlegend.h @@ -81,7 +81,7 @@ public: // New stuff: QList markers() const; - void appendSeries(QAbstractSeries* series); + void addSeries(QAbstractSeries* series); void removeSeries(QAbstractSeries* series); protected: diff --git a/src/legend/qlegend_p.h b/src/legend/qlegend_p.h index 66dabc4..da0eed9 100644 --- a/src/legend/qlegend_p.h +++ b/src/legend/qlegend_p.h @@ -55,8 +55,8 @@ public: QGraphicsItemGroup* items() { return m_items; } // New stuff: - QList legendMarkers() { return m_legendMarkers; } - void appendSeries(QAbstractSeries* series); + QList markers() { return m_markers; } + void addSeries(QAbstractSeries* series); void removeSeries(QAbstractSeries* series); public Q_SLOTS: @@ -89,7 +89,7 @@ private: friend class QLegend; friend class LegendLayout; - QList m_legendMarkers; // TODO: rename to m_markers eventually. + QList m_markers; QList m_series; friend class QLegend; diff --git a/src/legend/qpielegendmarker.cpp b/src/legend/qpielegendmarker.cpp index 44946fb..0b99e69 100644 --- a/src/legend/qpielegendmarker.cpp +++ b/src/legend/qpielegendmarker.cpp @@ -71,9 +71,6 @@ QPieLegendMarkerPrivate::QPieLegendMarkerPrivate(QPieLegendMarker *q, QPieSeries QPieLegendMarkerPrivate::~QPieLegendMarkerPrivate() { - QObject::disconnect(m_slice, SIGNAL(labelChanged()), this, SLOT(updated())); - QObject::disconnect(m_slice, SIGNAL(brushChanged()), this, SLOT(updated())); - QObject::disconnect(m_slice, SIGNAL(penChanged()), this, SLOT(updated())); } QPieSeries* QPieLegendMarkerPrivate::series() diff --git a/src/legend/qxylegendmarker.cpp b/src/legend/qxylegendmarker.cpp index ad7c34d..acfb6a0 100644 --- a/src/legend/qxylegendmarker.cpp +++ b/src/legend/qxylegendmarker.cpp @@ -63,8 +63,6 @@ QXYLegendMarkerPrivate::QXYLegendMarkerPrivate(QXYLegendMarker *q, QXYSeries *se QXYLegendMarkerPrivate::~QXYLegendMarkerPrivate() { - QObject::disconnect(m_series->d_func(), SIGNAL(updated()), this, SLOT(updated())); - QObject::disconnect(m_series, SIGNAL(nameChanged()), this, SLOT(updated())); } QAbstractSeries* QXYLegendMarkerPrivate::series()