From 2a015f15bbd43521d4f7d8f78a3539ecc29e0eca 2012-02-22 15:38:16 From: sauimone Date: 2012-02-22 15:38:16 Subject: [PATCH] code cleanup after refactoring. much nicer now. --- diff --git a/src/barchart/barpresenterbase.h b/src/barchart/barpresenterbase.h index 8e47d8f..11fe9f0 100644 --- a/src/barchart/barpresenterbase.h +++ b/src/barchart/barpresenterbase.h @@ -15,7 +15,7 @@ class Separator; class BarValue; // Common implemantation of different presenters. Not to be instantiated. -// TODO: combine this with BarPresenter and derive others from it? +// TODO: combine this with BarPresenter and derive other presenters from it? class BarPresenterBase : public QObject, public ChartItem { Q_OBJECT @@ -32,12 +32,6 @@ public: // TODO: these may change with layout awarness. void setBarWidth( int w ); - void setPen(QPen pen); - QPen pen(); - - void setBrush(QBrush brush); - QBrush brush(); - // TODO: Consider the domain for layoutChanged. May be use case, may not be. If it is, then the derived classes need to implement it virtual void dataChanged(); // data of series has changed -> need to recalculate bar sizes virtual void layoutChanged() = 0; // layout has changed -> need to recalculate bar sizes @@ -68,8 +62,6 @@ protected: QList mLabels; QList mSeparators; QList mFloatingValues; - - QPen mPen; }; QTCOMMERCIALCHART_END_NAMESPACE diff --git a/src/barchart/qbarchartseries.h b/src/barchart/qbarchartseries.h index b6101b7..b93240e 100644 --- a/src/barchart/qbarchartseries.h +++ b/src/barchart/qbarchartseries.h @@ -1,8 +1,6 @@ #ifndef BARCHARTSERIES_H #define BARCHARTSERIES_H -#include -#include #include "qchartseries.h" QTCOMMERCIALCHART_BEGIN_NAMESPACE diff --git a/src/barchart/qpercentbarchartseries.cpp b/src/barchart/qpercentbarchartseries.cpp index c521bc9..eaeccec 100644 --- a/src/barchart/qpercentbarchartseries.cpp +++ b/src/barchart/qpercentbarchartseries.cpp @@ -1,77 +1,11 @@ -#include -#include #include "qpercentbarchartseries.h" -#include "qbarset.h" -#include "qbarcategory.h" -#include "barchartmodel_p.h" QTCOMMERCIALCHART_BEGIN_NAMESPACE QPercentBarChartSeries::QPercentBarChartSeries(QBarCategory *category, QObject *parent) : QBarChartSeries(category, parent) -// ,mModel(new BarChartModel(category, this)) { } -/* -void QPercentBarChartSeries::addBarSet(QBarSet *set) -{ - connect(this,SIGNAL(floatingValuesEnabled(bool)),set,SLOT(enableFloatingValues(bool))); - connect(this,SIGNAL(hoverNamesEnabled(bool)),set,SLOT(enableHoverNames(bool))); - mModel->addBarSet(set); -} - -void QPercentBarChartSeries::removeBarSet(QBarSet *set) -{ - disconnect(set,SLOT(enableFloatingValues(bool))); - disconnect(set,SLOT(enableHoverNames(bool))); - mModel->removeBarSet(set); -} - -int QPercentBarChartSeries::countSets() -{ - return mModel->countSets(); -} - -QBarSet* QPercentBarChartSeries::nextSet(bool getFirst) -{ - return mModel->nextSet(getFirst); -} - -QList QPercentBarChartSeries::legend() -{ - return mModel->legend(); -} - -int QPercentBarChartSeries::countCategories() -{ - return mModel->countCategories(); -} - -qreal QPercentBarChartSeries::min() -{ - return mModel->min(); -} - -qreal QPercentBarChartSeries::max() -{ - return mModel->max(); -} - -qreal QPercentBarChartSeries::valueAt(int set, int category) -{ - return mModel->valueAt(set,category); -} - -qreal QPercentBarChartSeries::maxCategorySum() -{ - return mModel->maxCategorySum(); -} - -BarChartModel& QPercentBarChartSeries::model() -{ - return *mModel; -} -*/ #include "moc_qpercentbarchartseries.cpp" diff --git a/src/barchart/qpercentbarchartseries.h b/src/barchart/qpercentbarchartseries.h index 7eaff04..44f3cf1 100644 --- a/src/barchart/qpercentbarchartseries.h +++ b/src/barchart/qpercentbarchartseries.h @@ -1,56 +1,17 @@ #ifndef PERCENTBARCHARTSERIES_H #define PERCENTBARCHARTSERIES_H -#include -#include #include "qbarchartseries.h" QTCOMMERCIALCHART_BEGIN_NAMESPACE -class QBarCategory; -class QBarSet; -class BarChartModel; - -//class QTCOMMERCIALCHART_EXPORT QPercentBarChartSeries : public QChartSeries class QTCOMMERCIALCHART_EXPORT QPercentBarChartSeries : public QBarChartSeries { Q_OBJECT public: QPercentBarChartSeries(QBarCategory *category, QObject* parent=0); - // from BarChartSeriesBase virtual QChartSeriesType type() const { return QChartSeries::SeriesTypePercentBar; } -/* - void addBarSet(QBarSet *set); // Takes ownership - void removeBarSet(QBarSet *set); // Releases ownership, doesn't delete set - int countSets(); - QBarSet* nextSet(bool first=false); // Returns first set, if called with true - - QList legend(); // Returns legend of series (ie. names of all sets in series) - - // Disabled by default. Call these to change behavior. - void enableFloatingValues(bool enabled=true); - void enableHoverNames(bool enabled=true); - - // TODO: Functions below this are not part of api and will be moved - // to private implementation, when we start using it (not part of api) - int countCategories(); - qreal min(); - qreal max(); - qreal valueAt(int set, int category); - qreal maxCategorySum(); - - BarChartModel& model(); - -signals: - void changed(int index); - -public Q_SLOTS: - - -private: - BarChartModel* mModel; -*/ }; QTCOMMERCIALCHART_END_NAMESPACE diff --git a/src/barchart/qstackedbarchartseries.cpp b/src/barchart/qstackedbarchartseries.cpp index d01b983..71d1196 100644 --- a/src/barchart/qstackedbarchartseries.cpp +++ b/src/barchart/qstackedbarchartseries.cpp @@ -1,77 +1,11 @@ -#include -#include #include "qstackedbarchartseries.h" -#include "qbarcategory.h" -#include "qbarset.h" -#include "barchartmodel_p.h" QTCOMMERCIALCHART_BEGIN_NAMESPACE QStackedBarChartSeries::QStackedBarChartSeries(QBarCategory *category, QObject *parent) : QBarChartSeries(category, parent) -// ,mModel(new BarChartModel(category, this)) { } -/* -void QStackedBarChartSeries::addBarSet(QBarSet *set) -{ - connect(this,SIGNAL(floatingValuesEnabled(bool)),set,SLOT(enableFloatingValues(bool))); - connect(this,SIGNAL(hoverNamesEnabled(bool)),set,SLOT(enableHoverNames(bool))); - mModel->addBarSet(set); -} - -void QStackedBarChartSeries::removeBarSet(QBarSet *set) -{ - disconnect(set,SLOT(enableFloatingValues(bool))); - disconnect(set,SLOT(enableHoverNames(bool))); - mModel->removeBarSet(set); -} - -int QStackedBarChartSeries::countSets() -{ - return mModel->countSets(); -} - -QBarSet* QStackedBarChartSeries::nextSet(bool getFirst) -{ - return mModel->nextSet(getFirst); -} - -QList QStackedBarChartSeries::legend() -{ - return mModel->legend(); -} - -int QStackedBarChartSeries::countCategories() -{ - return mModel->countCategories(); -} - -qreal QStackedBarChartSeries::min() -{ - return mModel->min(); -} - -qreal QStackedBarChartSeries::max() -{ - return mModel->max(); -} - -qreal QStackedBarChartSeries::valueAt(int set, int category) -{ - return mModel->valueAt(set,category); -} - -qreal QStackedBarChartSeries::maxCategorySum() -{ - return mModel->maxCategorySum(); -} - -BarChartModel& QStackedBarChartSeries::model() -{ - return *mModel; -} -*/ #include "moc_qstackedbarchartseries.cpp" diff --git a/src/barchart/qstackedbarchartseries.h b/src/barchart/qstackedbarchartseries.h index 9ef680d..d2f3726 100644 --- a/src/barchart/qstackedbarchartseries.h +++ b/src/barchart/qstackedbarchartseries.h @@ -1,56 +1,19 @@ #ifndef STACKEDBARCHARTSERIES_H #define STACKEDBARCHARTSERIES_H -#include -#include #include "qbarchartseries.h" QTCOMMERCIALCHART_BEGIN_NAMESPACE class QBarCategory; -class QBarSet; -class BarChartModel; -//class QTCOMMERCIALCHART_EXPORT QStackedBarChartSeries : public QChartSeries class QTCOMMERCIALCHART_EXPORT QStackedBarChartSeries : public QBarChartSeries { Q_OBJECT public: QStackedBarChartSeries(QBarCategory *category, QObject* parent=0); - // from QChartSeries virtual QChartSeriesType type() const { return QChartSeries::SeriesTypeStackedBar; } -/* - // Set handling - void addBarSet(QBarSet *set); // Takes ownership - void removeBarSet(QBarSet *set); // Releases ownership, doesn't delete set - int countSets(); - QBarSet* nextSet(bool first=false); // Returns first set, if called with true - - QList legend(); // Returns legend of series (ie. names of all sets in series) - - // Disabled by default. Call these to change behavior. - void enableFloatingValues(bool enabled=true); - void enableHoverNames(bool enabled=true); - - // TODO: Functions below this are not part of api and will be moved - // to private implementation, when we start using it (not part of api) - int countCategories(); - qreal min(); - qreal max(); - qreal valueAt(int set, int category); - qreal maxCategorySum(); - - BarChartModel& model(); - -signals: - void changed(int index); - -public Q_SLOTS: - -private: - BarChartModel* mModel; -*/ }; QTCOMMERCIALCHART_END_NAMESPACE diff --git a/src/barchart/separator.cpp b/src/barchart/separator.cpp index d280d55..56bacf1 100644 --- a/src/barchart/separator.cpp +++ b/src/barchart/separator.cpp @@ -28,7 +28,7 @@ void Separator::setSize(const QSizeF &size) void Separator::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { -// qDebug() << "separator::paint" << boundingRect(); + // TODO: real pen QPen pen(mColor); painter->setPen(pen); painter->drawLine(mXpos,mYpos,mXpos,mHeight);