00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef __KDCHARTWIDGET_H__
00030 #define __KDCHARTWIDGET_H__
00031
00032 #include "KDChartGlobal.h"
00033
00034 #include <QWidget>
00035
00036 #include "KDChartEnums.h"
00037 #include "KDChartHeaderFooter.h"
00038
00039 template <typename T> class QVector;
00040 template <typename T1, typename T2> struct QPair;
00041
00042 namespace KDChart {
00043
00044
00045 class AbstractDiagram;
00046 class Chart;
00047 class AbstractCoordinatePlane;
00048 class TableModel;
00049 class BarDiagram;
00050 class LineDiagram;
00051 class PieDiagram;
00052 class RingDiagram;
00053 class PolarDiagram;
00054 class Legend;
00055 class Position;
00056
00063 class KDCHART_EXPORT Widget : public QWidget
00064 {
00065 Q_OBJECT
00066
00067 Q_DISABLE_COPY( Widget )
00068 KDCHART_DECLARE_PRIVATE_BASE_POLYMORPHIC_QWIDGET( Widget )
00069
00070 public:
00078 explicit Widget( QWidget* parent = 0 );
00079
00081 ~Widget();
00083 void setDataset( int column, const QVector< double > & data, const QString& title = QString() );
00086 void setDataset( int column, const QVector< QPair< double, double > > & data, const QString& title = QString() );
00088 void setDataCell( int row, int column, double data );
00090 void setDataCell( int row, int column, QPair< double, double > data );
00092 void resetData();
00093
00094 public Q_SLOTS:
00096 void setGlobalLeading( int left, int top, int right, int bottom );
00098 void setGlobalLeadingLeft( int leading );
00100 void setGlobalLeadingTop( int leading );
00102 void setGlobalLeadingRight( int leading );
00104 void setGlobalLeadingBottom( int leading );
00105
00106 public:
00108 int globalLeadingLeft() const;
00110 int globalLeadingTop() const;
00112 int globalLeadingRight() const;
00114 int globalLeadingBottom() const;
00115
00117 HeaderFooter* firstHeaderFooter();
00119 QList<HeaderFooter*> allHeadersFooters();
00120
00122 void addHeaderFooter( const QString& text,
00123 HeaderFooter::HeaderFooterType type,
00124 Position position );
00125
00130 void addHeaderFooter( HeaderFooter* header );
00131
00149 void replaceHeaderFooter( HeaderFooter* header,
00150 HeaderFooter* oldHeader = 0 );
00151
00159 void takeHeaderFooter( HeaderFooter* header );
00160
00162 Legend* legend();
00164 QList<Legend*> allLegends();
00165
00167 void addLegend( Position position );
00169 void addLegend (Legend* legend );
00170
00171 void replaceLegend( Legend* legend, Legend* oldLegend = 0 );
00172 void takeLegend( Legend* legend );
00173
00174
00176 AbstractDiagram* diagram();
00177
00181 BarDiagram* barDiagram();
00185 LineDiagram* lineDiagram();
00189 PieDiagram* pieDiagram();
00193 RingDiagram* ringDiagram();
00197 PolarDiagram* polarDiagram();
00198
00200 AbstractCoordinatePlane* coordinatePlane();
00201
00202
00203 enum ChartType { NoType, Bar, Line, Pie, Ring, Polar };
00204
00206 ChartType type() const;
00207
00209 enum SubType { Normal, Stacked, Percent, Rows };
00210
00212 SubType subType() const;
00213
00214 public Q_SLOTS:
00216 void setType( ChartType chartType, SubType subType=Normal );
00227 void setSubType( SubType subType );
00228
00229 private:
00231 void justifyModelSize( int rows, int columns );
00233 bool checkDatasetWidth( int width );
00234 };
00235 }
00236
00237 #endif // KDChartWidget_H