qbarset.cpp
191 lines
| 3.5 KiB
| text/x-c
|
CppLexer
sauimone
|
r169 | #include "qbarset.h" | ||
sauimone
|
r239 | #include <QDebug> | ||
sauimone
|
r283 | #include <QToolTip> | ||
sauimone
|
r169 | |||
QTCOMMERCIALCHART_BEGIN_NAMESPACE | ||||
sauimone
|
r313 | /*! | ||
\class QBarSet | ||||
\brief part of QtCommercial chart API. | ||||
QBarSet represents one set of bars. Set of bars contains one data value for each category. | ||||
First value of set is assumed to belong to first category, second to second category and so on. | ||||
If set has fewer values than there are categories, then the missing values are assumed to be | ||||
at the end of set. For missing values in middle of a set, numerical value of zero is used. | ||||
sauimone
|
r325 | \mainclass | ||
sauimone
|
r377 | \sa QBarSeries, QStackedBarSeries, QPercentBarSeries | ||
sauimone
|
r313 | */ | ||
/*! | ||||
sauimone
|
r425 | \fn void QBarSet::clicked(QString category) | ||
sauimone
|
r313 | \brief signals that set has been clicked | ||
sauimone
|
r425 | Parameter \a category describes on which category was clicked | ||
sauimone
|
r313 | */ | ||
sauimone
|
r425 | |||
/*! | ||||
\fn void QBarSet::rightClicked(QString category) | ||||
\brief signals that set has been clicked with right mouse button | ||||
Parameter \a category describes on which category was clicked | ||||
*/ | ||||
sauimone
|
r313 | /*! | ||
\fn void QBarSet::hoverEnter(QPoint pos) | ||||
\brief signals that mouse has entered over the set at position \a pos. | ||||
*/ | ||||
sauimone
|
r425 | |||
sauimone
|
r313 | /*! | ||
\fn void QBarSet::hoverLeave() | ||||
\brief signals that mouse has left from the set. | ||||
*/ | ||||
sauimone
|
r425 | |||
sauimone
|
r313 | /*! | ||
\fn void QBarSet::toggleFloatingValues() | ||||
sauimone
|
r319 | \brief \internal | ||
sauimone
|
r313 | */ | ||
sauimone
|
r425 | |||
sauimone
|
r313 | /*! | ||
\fn void QBarSet::showToolTip(QPoint pos, QString tip) | ||||
sauimone
|
r319 | \brief \internal \a pos \a tip | ||
sauimone
|
r313 | */ | ||
/*! | ||||
Constructs QBarSet with a name of \a name and with parent of \a parent | ||||
*/ | ||||
sauimone
|
r280 | QBarSet::QBarSet(QString name, QObject *parent) | ||
sauimone
|
r276 | : QObject(parent) | ||
sauimone
|
r280 | ,mName(name) | ||
sauimone
|
r169 | { | ||
} | ||||
sauimone
|
r313 | /*! | ||
Sets new \a name for set. | ||||
*/ | ||||
sauimone
|
r169 | void QBarSet::setName(QString name) | ||
{ | ||||
mName = name; | ||||
} | ||||
sauimone
|
r313 | |||
/*! | ||||
Returns name of the set. | ||||
*/ | ||||
sauimone
|
r171 | QString QBarSet::name() | ||
{ | ||||
return mName; | ||||
} | ||||
sauimone
|
r169 | |||
sauimone
|
r313 | /*! | ||
Appends new value \a value to the end of set. | ||||
*/ | ||||
sauimone
|
r169 | QBarSet& QBarSet::operator << (const qreal &value) | ||
{ | ||||
mValues.append(value); | ||||
return *this; | ||||
} | ||||
sauimone
|
r313 | /*! | ||
Returns count of values in set. | ||||
*/ | ||||
sauimone
|
r171 | int QBarSet::count() | ||
{ | ||||
return mValues.count(); | ||||
} | ||||
sauimone
|
r313 | /*! | ||
Returns value of set indexed by \a index | ||||
*/ | ||||
sauimone
|
r171 | qreal QBarSet::valueAt(int index) | ||
{ | ||||
return mValues.at(index); | ||||
} | ||||
sauimone
|
r313 | /*! | ||
Sets a new value \a value to set, indexed by \a index | ||||
*/ | ||||
sauimone
|
r183 | void QBarSet::setValue(int index, qreal value) | ||
{ | ||||
mValues.replace(index,value); | ||||
} | ||||
sauimone
|
r492 | /*! | ||
Returns total sum of all values in barset. | ||||
*/ | ||||
sauimone
|
r438 | qreal QBarSet::total() | ||
{ | ||||
qreal total(0); | ||||
for (int i=0; i<mValues.count(); i++) { | ||||
total += mValues.at(i); | ||||
} | ||||
return total; | ||||
} | ||||
sauimone
|
r313 | /*! | ||
Sets pen for set. Bars of this set are drawn using \a pen | ||||
*/ | ||||
sauimone
|
r473 | void QBarSet::setPen(const QPen pen) | ||
sauimone
|
r214 | { | ||
mPen = pen; | ||||
} | ||||
sauimone
|
r313 | /*! | ||
Returns pen of the set. | ||||
*/ | ||||
sauimone
|
r473 | QPen QBarSet::pen() const | ||
sauimone
|
r214 | { | ||
return mPen; | ||||
} | ||||
sauimone
|
r313 | /*! | ||
Sets brush for the set. Bars of this set are drawn using \a brush | ||||
*/ | ||||
sauimone
|
r473 | void QBarSet::setBrush(const QBrush brush) | ||
sauimone
|
r214 | { | ||
mBrush = brush; | ||||
} | ||||
sauimone
|
r313 | /*! | ||
Returns brush of the set. | ||||
*/ | ||||
sauimone
|
r473 | QBrush QBarSet::brush() const | ||
sauimone
|
r214 | { | ||
return mBrush; | ||||
} | ||||
sauimone
|
r512 | /*! | ||
Sets the pen for floating values that are drawn on top of this set | ||||
*/ | ||||
void QBarSet::setFloatingValuePen(const QPen pen) | ||||
{ | ||||
mFloatingValuePen = pen; | ||||
} | ||||
/*! | ||||
Returns the pen for floating values that are drawn on top of this set | ||||
*/ | ||||
QPen QBarSet::floatingValuePen() const | ||||
{ | ||||
return mFloatingValuePen; | ||||
} | ||||
sauimone
|
r313 | /*! | ||
sauimone
|
r319 | \internal \a pos | ||
sauimone
|
r313 | */ | ||
sauimone
|
r412 | void QBarSet::barHoverEnterEvent(QPoint pos) | ||
sauimone
|
r276 | { | ||
sauimone
|
r296 | emit showToolTip(pos, mName); | ||
sauimone
|
r288 | emit hoverEnter(pos); | ||
sauimone
|
r276 | } | ||
sauimone
|
r313 | /*! | ||
sauimone
|
r319 | \internal | ||
sauimone
|
r313 | */ | ||
sauimone
|
r412 | void QBarSet::barHoverLeaveEvent() | ||
sauimone
|
r276 | { | ||
sauimone
|
r288 | // Emit signal to user of charts | ||
emit hoverLeave(); | ||||
sauimone
|
r276 | } | ||
sauimone
|
r239 | #include "moc_qbarset.cpp" | ||
sauimone
|
r169 | QTCOMMERCIALCHART_END_NAMESPACE | ||