KDChartLegend.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef KDCHARTLEGEND_H
00024 #define KDCHARTLEGEND_H
00025
00026 #include "KDChartAbstractAreaWidget.h"
00027 #include "KDChartPosition.h"
00028 #include "KDChartMarkerAttributes.h"
00029
00030 class QTextTable;
00031
00032 namespace KDChart {
00033
00034 class AbstractDiagram;
00035 typedef QList<AbstractDiagram*> DiagramList;
00036 typedef QList<const AbstractDiagram*> ConstDiagramList;
00037
00055 class KDCHART_EXPORT Legend : public AbstractAreaWidget
00056 {
00057 Q_OBJECT
00058
00059 Q_DISABLE_COPY( Legend )
00060 KDCHART_DECLARE_PRIVATE_DERIVED_QWIDGET( Legend )
00061
00062 public:
00063 explicit Legend( QWidget* parent = 0 );
00064 explicit Legend( KDChart::AbstractDiagram* diagram, QWidget* parent );
00065 virtual ~Legend();
00066
00067
00068 enum LegendStyle { MarkersOnly = 0,
00069 LinesOnly = 1,
00070 MarkersAndLines = 2 };
00071
00072
00073 void setLegendStyle( LegendStyle style );
00074 LegendStyle legendStyle() const;
00075
00076
00077 virtual Legend * clone() const;
00078
00082 bool compare( const Legend* other )const;
00083
00084
00085 virtual void resizeEvent( QResizeEvent * event );
00086
00087 virtual void paint( QPainter* painter );
00088 virtual void setVisible( bool visible );
00089
00105 void setReferenceArea( const QWidget* area );
00113 const QWidget* referenceArea() const;
00114
00121 KDChart::AbstractDiagram* diagram() const;
00122
00129 DiagramList diagrams() const;
00130
00134 ConstDiagramList constDiagrams() const;
00135
00142 void addDiagram( KDChart::AbstractDiagram* newDiagram );
00143
00149 void removeDiagram( KDChart::AbstractDiagram* oldDiagram );
00150
00156 void removeDiagrams();
00157
00172 void replaceDiagram( KDChart::AbstractDiagram* newDiagram,
00173 KDChart::AbstractDiagram* oldDiagram = 0 );
00174
00179 uint dataSetOffset( KDChart::AbstractDiagram* diagram );
00180
00189 void setDiagram( KDChart::AbstractDiagram* newDiagram );
00190
00199 void setPosition( Position position );
00200
00205 Position position() const;
00206
00215 void setAlignment( Qt::Alignment );
00216
00221 Qt::Alignment alignment() const;
00222
00228 void setTextAlignment( Qt::Alignment );
00229
00235 Qt::Alignment textAlignment() const;
00236
00281 void setFloatingPosition( const RelativePosition& relativePosition );
00282
00287 const RelativePosition floatingPosition() const;
00288
00289 void setOrientation( Qt::Orientation orientation );
00290 Qt::Orientation orientation() const;
00291
00292
00293 void setSortOrder( Qt::SortOrder order );
00294 Qt::SortOrder sortOrder() const;
00295
00296 void setShowLines( bool legendShowLines );
00297 bool showLines() const;
00298
00299 void resetTexts();
00300 void setText( uint dataset, const QString& text );
00301 QString text( uint dataset ) const;
00302 const QMap<uint,QString> texts() const;
00303
00311 void setHiddenDatasets( const QList<uint> hiddenDatasets );
00312 const QList<uint> hiddenDatasets() const;
00313 void setDatasetHidden( uint dataset, bool hidden );
00314 bool datasetIsHidden( uint dataset ) const;
00315
00316 uint datasetCount() const;
00317
00318 void setDefaultColors();
00319 void setRainbowColors();
00320 void setSubduedColors( bool ordered = false );
00321
00322 void setBrushesFromDiagram( KDChart::AbstractDiagram* diagram );
00323
00329 void setColor( uint dataset, const QColor& color );
00330
00331 void setBrush( uint dataset, const QBrush& brush );
00332 QBrush brush( uint dataset ) const;
00333 const QMap<uint,QBrush> brushes() const;
00334
00335 void setPen( uint dataset, const QPen& pen );
00336 QPen pen( uint dataset ) const;
00337 const QMap<uint,QPen> pens() const;
00338
00344 void setMarkerAttributes( uint dataset, const MarkerAttributes& );
00345 MarkerAttributes markerAttributes( uint dataset ) const;
00346 const QMap<uint, MarkerAttributes> markerAttributes() const;
00347
00355 void setUseAutomaticMarkerSize( bool useAutomaticMarkerSize );
00356 bool useAutomaticMarkerSize() const;
00357
00358 void setTextAttributes( const TextAttributes &a );
00359 TextAttributes textAttributes() const;
00360
00361 void setTitleText( const QString& text );
00362 QString titleText() const;
00363
00364 void setTitleTextAttributes( const TextAttributes &a );
00365 TextAttributes titleTextAttributes() const;
00366
00367
00368 void setSpacing( uint space );
00369 uint spacing() const;
00370
00371
00372 virtual void forceRebuild();
00373
00374 virtual QSize minimumSizeHint() const;
00375 virtual QSize sizeHint() const;
00376 virtual void needSizeHint();
00377 virtual void resizeLayout( const QSize& size );
00378
00379
00380
00381
00382 Q_SIGNALS:
00383 void destroyedLegend( Legend* );
00385 void propertiesChanged();
00386
00387 private Q_SLOTS:
00388 void emitPositionChanged();
00389 void resetDiagram( AbstractDiagram* );
00390 void activateTheLayout();
00391 void setNeedRebuild();
00392 void buildLegend();
00393 };
00394
00395 }
00396
00397
00398 #endif // KDCHARTLEGEND_H