qaxiscategories.cpp
127 lines
| 2.7 KiB
| text/x-c
|
CppLexer
Jani Honkonen
|
r794 | /**************************************************************************** | ||
** | ||||
** Copyright (C) 2012 Digia Plc | ||||
** All rights reserved. | ||||
** For any questions to Digia, please use contact form at http://qt.digia.com | ||||
** | ||||
** This file is part of the Qt Commercial Charts Add-on. | ||||
** | ||||
** $QT_BEGIN_LICENSE$ | ||||
** Licensees holding valid Qt Commercial licenses may use this file in | ||||
** accordance with the Qt Commercial License Agreement provided with the | ||||
** Software or, alternatively, in accordance with the terms contained in | ||||
** a written agreement between you and Digia. | ||||
** | ||||
** If you have questions regarding the use of this file, please use | ||||
** contact form at http://qt.digia.com | ||||
** $QT_END_LICENSE$ | ||||
** | ||||
****************************************************************************/ | ||||
Michal Klocek
|
r1032 | #include "qaxiscategories.h" | ||
#include "qaxiscategories_p.h" | ||||
Michal Klocek
|
r445 | |||
QTCOMMERCIALCHART_BEGIN_NAMESPACE | ||||
Michal Klocek
|
r1038 | /*! | ||
\class QAxisCategories | ||||
\brief The QAxisCategoriess class is used for manipulating axis's categories. | ||||
\mainclass | ||||
Each axis can have categories instead of numerical representation. The typical use case | ||||
is bar chart, where categories are always show on X axis. | ||||
*/ | ||||
Michal Klocek
|
r1032 | QAxisCategories::QAxisCategories(): | ||
d_ptr(new QAxisCategoriesPrivate(this)) | ||||
Michal Klocek
|
r445 | { | ||
} | ||||
Michal Klocek
|
r1032 | QAxisCategories::~QAxisCategories() | ||
Michal Klocek
|
r445 | { | ||
Michal Klocek
|
r963 | |||
Michal Klocek
|
r445 | } | ||
Michal Klocek
|
r1038 | /*! | ||
Inserts bar \a categories. | ||||
*/ | ||||
Michal Klocek
|
r1032 | void QAxisCategories::insert(const QBarCategories &categories) | ||
Michal Klocek
|
r701 | { | ||
int i=1; | ||||
Michal Klocek
|
r974 | foreach (const QString& string , categories) { | ||
Michal Klocek
|
r963 | d_ptr->m_map.insert(i,string); | ||
Michal Klocek
|
r701 | i++; | ||
} | ||||
Michal Klocek
|
r963 | emit d_ptr->updated(); | ||
Michal Klocek
|
r701 | } | ||
Michal Klocek
|
r1038 | /*! | ||
Inserts category, instead of \a value on axis a \a label will be shown. | ||||
*/ | ||||
Michal Klocek
|
r1032 | void QAxisCategories::insert(qreal value,QString label) | ||
Michal Klocek
|
r445 | { | ||
Michal Klocek
|
r963 | d_ptr->m_map.insert(value,label); | ||
emit d_ptr->updated(); | ||||
Michal Klocek
|
r445 | } | ||
Michal Klocek
|
r706 | |||
Michal Klocek
|
r1038 | /*! | ||
Removes category for \a value. | ||||
*/ | ||||
Michal Klocek
|
r1032 | void QAxisCategories::remove(qreal value) | ||
Michal Klocek
|
r445 | { | ||
Michal Klocek
|
r963 | d_ptr->m_map.remove(value); | ||
emit d_ptr->updated(); | ||||
Michal Klocek
|
r445 | } | ||
Michal Klocek
|
r706 | |||
Michal Klocek
|
r1038 | /*! | ||
Removes all categories. | ||||
*/ | ||||
Michal Klocek
|
r1032 | void QAxisCategories::clear() | ||
Michal Klocek
|
r445 | { | ||
Michal Klocek
|
r963 | d_ptr->m_map.clear(); | ||
emit d_ptr->updated(); | ||||
Michal Klocek
|
r445 | } | ||
Michal Klocek
|
r706 | |||
Michal Klocek
|
r1038 | /*! | ||
Returns number of categories. | ||||
*/ | ||||
Michal Klocek
|
r1032 | int QAxisCategories::count() | ||
Michal Klocek
|
r445 | { | ||
Michal Klocek
|
r963 | return d_ptr->m_map.count(); | ||
Michal Klocek
|
r445 | } | ||
Michal Klocek
|
r1038 | /*! | ||
Returns all values of categories. | ||||
*/ | ||||
Michal Klocek
|
r1032 | QList<qreal> QAxisCategories::values() const | ||
Michal Klocek
|
r706 | { | ||
Michal Klocek
|
r963 | return d_ptr->m_map.keys(); | ||
Michal Klocek
|
r706 | } | ||
Michal Klocek
|
r1038 | /*! | ||
Returns label for given \a value. | ||||
*/ | ||||
Michal Klocek
|
r1032 | QString QAxisCategories::label(qreal value) const | ||
Michal Klocek
|
r497 | { | ||
Michal Klocek
|
r963 | return d_ptr->m_map.value(value); | ||
} | ||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||||
Michal Klocek
|
r1032 | QAxisCategoriesPrivate::QAxisCategoriesPrivate(QAxisCategories *q): | ||
Michal Klocek
|
r963 | q_ptr(q) | ||
{ | ||||
} | ||||
Michal Klocek
|
r1032 | QAxisCategoriesPrivate::~QAxisCategoriesPrivate() | ||
Michal Klocek
|
r963 | { | ||
Michal Klocek
|
r497 | } | ||
Michal Klocek
|
r1032 | #include "moc_qaxiscategories.cpp" | ||
#include "moc_qaxiscategories_p.cpp" | ||||
Michal Klocek
|
r445 | |||
QTCOMMERCIALCHART_END_NAMESPACE | ||||