qbarset.cpp
170 lines
| 3.1 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 | ||
Example on how to create sets of data: | ||||
\snippet ../example/barchart/main.cpp 2 | ||||
|
r338 | \sa QBarCategory, QBarSeries, QStackedBarSeries, QPercentBarSeries | ||
|
r313 | */ | ||
/*! | ||||
\fn void QBarSet::clicked() | ||||
\brief signals that set has been clicked | ||||
*/ | ||||
/*! | ||||
\fn void QBarSet::hoverEnter(QPoint pos) | ||||
\brief signals that mouse has entered over the set at position \a pos. | ||||
*/ | ||||
/*! | ||||
\fn void QBarSet::hoverLeave() | ||||
\brief signals that mouse has left from the set. | ||||
*/ | ||||
/*! | ||||
\fn void QBarSet::toggleFloatingValues() | ||||
|
r319 | \brief \internal | ||
|
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 | ||||
*/ | ||||
|
r214 | void QBarSet::setPen(const QPen& pen) | ||
{ | ||||
mPen = pen; | ||||
} | ||||
|
r313 | /*! | ||
Returns pen of the set. | ||||
*/ | ||||
|
r214 | const QPen& QBarSet::pen() const | ||
{ | ||||
return mPen; | ||||
} | ||||
|
r313 | /*! | ||
Sets brush for the set. Bars of this set are drawn using \a brush | ||||
*/ | ||||
|
r214 | void QBarSet::setBrush(const QBrush& brush) | ||
{ | ||||
mBrush = brush; | ||||
} | ||||
|
r313 | /*! | ||
Returns brush of the set. | ||||
*/ | ||||
|
r214 | const QBrush& QBarSet::brush() const | ||
{ | ||||
return mBrush; | ||||
} | ||||
|
r313 | /*! | ||
|
r319 | \internal | ||
|
r313 | */ | ||
|
r239 | void QBarSet::barClicked() | ||
{ | ||||
|
r288 | // qDebug() << "QBarset::barClicked" << this; | ||
|
r239 | // Some bar of this set has been clicked | ||
// TODO: What happens then? | ||||
|
r263 | emit clicked(); // Notify that set has been clicked | ||
|
r239 | } | ||
|
r214 | |||
|
r313 | /*! | ||
|
r319 | \internal \a pos | ||
|
r313 | */ | ||
|
r283 | void QBarSet::barHoverEntered(QPoint pos) | ||
|
r276 | { | ||
|
r296 | emit showToolTip(pos, mName); | ||
|
r288 | emit hoverEnter(pos); | ||
|
r276 | } | ||
|
r313 | /*! | ||
|
r319 | \internal | ||
|
r313 | */ | ||
|
r276 | void QBarSet::barHoverLeaved() | ||
{ | ||||
|
r288 | // qDebug() << "QBarset::barHoverLeaved" << this; | ||
// if (mToolTipEnabled) { | ||||
// TODO: do what? | ||||
// } | ||||
// Emit signal to user of charts | ||||
emit hoverLeave(); | ||||
|
r276 | } | ||
|
r239 | #include "moc_qbarset.cpp" | ||
|
r169 | QTCOMMERCIALCHART_END_NAMESPACE | ||