qbarset.cpp
177 lines
| 3.2 KiB
| text/x-c
|
CppLexer
|
r169 | #include "qbarset.h" | ||
|
r239 | #include <QDebug> | ||
|
r283 | #include <QToolTip> | ||
|
r169 | |||
QTCOMMERCIALCHART_BEGIN_NAMESPACE | ||||
|
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. | ||||
|
r325 | \mainclass | ||
|
r377 | \sa QBarSeries, QStackedBarSeries, QPercentBarSeries | ||
|
r313 | */ | ||
/*! | ||||
|
r425 | \fn void QBarSet::clicked(QString category) | ||
|
r313 | \brief signals that set has been clicked | ||
|
r425 | Parameter \a category describes on which category was clicked | ||
|
r313 | */ | ||
|
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 | ||||
*/ | ||||
|
r313 | /*! | ||
\fn void QBarSet::hoverEnter(QPoint pos) | ||||
\brief signals that mouse has entered over the set at position \a pos. | ||||
*/ | ||||
|
r425 | |||
|
r313 | /*! | ||
\fn void QBarSet::hoverLeave() | ||||
\brief signals that mouse has left from the set. | ||||
*/ | ||||
|
r425 | |||
|
r313 | /*! | ||
\fn void QBarSet::toggleFloatingValues() | ||||
|
r319 | \brief \internal | ||
|
r313 | */ | ||
|
r425 | |||
|
r313 | /*! | ||
\fn void QBarSet::showToolTip(QPoint pos, QString tip) | ||||
|
r319 | \brief \internal \a pos \a tip | ||
|
r313 | */ | ||
/*! | ||||
Constructs QBarSet with a name of \a name and with parent of \a parent | ||||
*/ | ||||
|
r280 | QBarSet::QBarSet(QString name, QObject *parent) | ||
|
r276 | : QObject(parent) | ||
|
r280 | ,mName(name) | ||
|
r169 | { | ||
} | ||||
|
r313 | /*! | ||
Sets new \a name for set. | ||||
*/ | ||||
|
r169 | void QBarSet::setName(QString name) | ||
{ | ||||
mName = name; | ||||
} | ||||
|
r313 | |||
/*! | ||||
Returns name of the set. | ||||
*/ | ||||
|
r171 | QString QBarSet::name() | ||
{ | ||||
return mName; | ||||
} | ||||
|
r169 | |||
|
r313 | /*! | ||
Appends new value \a value to the end of set. | ||||
*/ | ||||
|
r169 | QBarSet& QBarSet::operator << (const qreal &value) | ||
{ | ||||
mValues.append(value); | ||||
return *this; | ||||
} | ||||
|
r313 | /*! | ||
Returns count of values in set. | ||||
*/ | ||||
|
r171 | int QBarSet::count() | ||
{ | ||||
return mValues.count(); | ||||
} | ||||
|
r313 | /*! | ||
Returns value of set indexed by \a index | ||||
*/ | ||||
|
r171 | qreal QBarSet::valueAt(int index) | ||
{ | ||||
return mValues.at(index); | ||||
} | ||||
|
r313 | /*! | ||
Sets a new value \a value to set, indexed by \a index | ||||
*/ | ||||
|
r183 | void QBarSet::setValue(int index, qreal value) | ||
{ | ||||
mValues.replace(index,value); | ||||
} | ||||
|
r313 | /*! | ||
Sets pen for set. Bars of this set are drawn using \a pen | ||||
*/ | ||||
|
r357 | void QBarSet::setPen(QPen pen) | ||
|
r214 | { | ||
mPen = pen; | ||||
} | ||||
|
r313 | /*! | ||
Returns pen of the set. | ||||
*/ | ||||
|
r357 | QPen QBarSet::pen() | ||
|
r214 | { | ||
return mPen; | ||||
} | ||||
|
r313 | /*! | ||
Sets brush for the set. Bars of this set are drawn using \a brush | ||||
*/ | ||||
|
r357 | void QBarSet::setBrush(QBrush brush) | ||
|
r214 | { | ||
mBrush = brush; | ||||
} | ||||
|
r313 | /*! | ||
Returns brush of the set. | ||||
*/ | ||||
|
r357 | QBrush QBarSet::brush() | ||
|
r214 | { | ||
return mBrush; | ||||
} | ||||
|
r425 | /* | ||
void QBarSet::barClickedEvent(QString category) | ||||
|
r239 | { | ||
// Some bar of this set has been clicked | ||||
// TODO: What happens then? | ||||
|
r425 | emit clicked(category); // Notify that set has been clicked | ||
|
r239 | } | ||
|
r214 | |||
|
r425 | void QBarSet::barRightClickedEvent(QString category) | ||
{ | ||||
emit rightClicked(category); | ||||
} | ||||
*/ | ||||
|
r313 | /*! | ||
|
r319 | \internal \a pos | ||
|
r313 | */ | ||
|
r412 | void QBarSet::barHoverEnterEvent(QPoint pos) | ||
|
r276 | { | ||
|
r296 | emit showToolTip(pos, mName); | ||
|
r288 | emit hoverEnter(pos); | ||
|
r276 | } | ||
|
r313 | /*! | ||
|
r319 | \internal | ||
|
r313 | */ | ||
|
r412 | void QBarSet::barHoverLeaveEvent() | ||
|
r276 | { | ||
|
r288 | // Emit signal to user of charts | ||
emit hoverLeave(); | ||||
|
r276 | } | ||
|
r239 | #include "moc_qbarset.cpp" | ||
|
r169 | QTCOMMERCIALCHART_END_NAMESPACE | ||