File indexing completed on 2024-05-12 04:43:20

0001 /* This file is part of the KDE project
0002  * Copyright (C) 2007-2008 by Adam Pigg (adam@piggz.co.uk)
0003  *
0004  * This library is free software; you can redistribute it and/or
0005  * modify it under the terms of the GNU Lesser General Public
0006  * License as published by the Free Software Foundation; either
0007  * version 2.1 of the License, or (at your option) any later version.
0008  *
0009  * This library is distributed in the hope that it will be useful,
0010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
0012  * Lesser General Public License for more details.
0013  *
0014  * You should have received a copy of the GNU Lesser General Public
0015  * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
0016  */
0017 
0018 #ifndef KRCHARTDATA_H
0019 #define KRCHARTDATA_H
0020 
0021 #include <KDChartWidget>
0022 
0023 #include "KReportItemBase.h"
0024 #include "KReportData.h"
0025 
0026 namespace Scripting
0027 {
0028 class Chart;
0029 }
0030 
0031 /**
0032 */
0033 class KReportItemChart : public KReportItemBase
0034 {
0035     Q_OBJECT
0036 public:
0037     KReportItemChart();
0038     explicit KReportItemChart(QDomNode *element);
0039     ~KReportItemChart();
0040 
0041     virtual QString typeName() const;
0042 
0043     virtual int renderReportData(OROPage *page, OROSection *section, const QPointF &offset, KReportData *data, KReportScriptHandler *script);
0044 
0045     KDChart::Widget *widget() {
0046         return m_chartWidget;
0047     }
0048 
0049     /**
0050     @brief Perform the query for the chart and set the charts data
0051     */
0052     void populateData();
0053     void setConnection(const KReportData *c);
0054 
0055     /**
0056     @brief Set the value of a field from the master (report) data set
0057     This data will be used when retrieving the data for the chart
0058     as the values in a 'where' clause.
0059     */
0060     void setLinkData(QString, QVariant);
0061 
0062     /**
0063     @brief Return the list of master fields
0064     The caller will use this to set the current value for each field
0065     at that stage in the report
0066     */
0067     QStringList masterFields() const;
0068 
0069     /**
0070     @brief The chart object is a complex object that uses its own data source
0071     @return true
0072     */
0073     virtual bool supportsSubQuery() const { return true; }
0074 
0075 protected:
0076     KProperty * m_font;
0077     KProperty * m_chartType;
0078     KProperty * m_chartSubType;
0079     KProperty * m_threeD;
0080     KProperty * m_colorScheme;
0081     KProperty * m_aa;
0082     KProperty * m_xTitle;
0083     KProperty * m_yTitle;
0084 
0085     KProperty *m_backgroundColor;
0086     KProperty *m_displayLegend;
0087     KProperty *m_legendPosition;
0088     KProperty *m_legendOrientation;
0089 
0090     KProperty *m_linkMaster;
0091     KProperty *m_linkChild;
0092 
0093     KDChart::Widget *m_chartWidget;
0094 
0095     void set3D(bool td);
0096     void setAA(bool aa);
0097     void setColorScheme(const QString &cs);
0098     void setAxis(const QString &xa, const QString &ya);
0099     void setBackgroundColor(const QColor&);
0100     void setLegend(bool le, const QStringList &legends = QStringList());
0101 
0102 private:
0103     virtual void createProperties();
0104     const KReportData *m_reportData;
0105 
0106     friend class Scripting::Chart;
0107 
0108     QMap<QString, QVariant> m_links; //Map of field->value for child/master links
0109 
0110 };
0111 
0112 #endif