1 | #ifndef CHARTFORM_H
|
---|
2 | #define CHARTFORM_H
|
---|
3 |
|
---|
4 | #include "element.h"
|
---|
5 |
|
---|
6 | #include <qmainwindow.h>
|
---|
7 | #include <qstringlist.h>
|
---|
8 |
|
---|
9 |
|
---|
10 | class CanvasView;
|
---|
11 |
|
---|
12 | class QAction;
|
---|
13 | class QCanvas;
|
---|
14 | class QFont;
|
---|
15 | class QPrinter;
|
---|
16 | class QString;
|
---|
17 |
|
---|
18 |
|
---|
19 | class ChartForm: public QMainWindow
|
---|
20 | {
|
---|
21 | Q_OBJECT
|
---|
22 | public:
|
---|
23 | enum { MAX_ELEMENTS = 100 };
|
---|
24 | enum { MAX_RECENTFILES = 9 }; // Must not exceed 9
|
---|
25 | enum ChartType { PIE, VERTICAL_BAR, HORIZONTAL_BAR };
|
---|
26 | enum AddValuesType { NO, YES, AS_PERCENTAGE };
|
---|
27 |
|
---|
28 | ChartForm( const QString& filename );
|
---|
29 | ~ChartForm();
|
---|
30 |
|
---|
31 | int chartType() { return m_chartType; }
|
---|
32 | void setChanged( bool changed = TRUE ) { m_changed = changed; }
|
---|
33 | void drawElements();
|
---|
34 |
|
---|
35 | QPopupMenu *optionsMenu; // Why public? See canvasview.cpp
|
---|
36 |
|
---|
37 | protected:
|
---|
38 | virtual void closeEvent( QCloseEvent * );
|
---|
39 |
|
---|
40 | private slots:
|
---|
41 | void fileNew();
|
---|
42 | void fileOpen();
|
---|
43 | void fileOpenRecent( int index );
|
---|
44 | void fileSave();
|
---|
45 | void fileSaveAs();
|
---|
46 | void fileSaveAsPixmap();
|
---|
47 | void filePrint();
|
---|
48 | void fileQuit();
|
---|
49 | void optionsSetData();
|
---|
50 | void updateChartType( QAction *action );
|
---|
51 | void optionsSetFont();
|
---|
52 | void optionsSetOptions();
|
---|
53 | void helpHelp();
|
---|
54 | void helpAbout();
|
---|
55 | void helpAboutQt();
|
---|
56 | void saveOptions();
|
---|
57 |
|
---|
58 | private:
|
---|
59 | void init();
|
---|
60 | void load( const QString& filename );
|
---|
61 | bool okToClear();
|
---|
62 | void drawPieChart( const double scales[], double total, int count );
|
---|
63 | void drawVerticalBarChart( const double scales[], double total, int count );
|
---|
64 | void drawHorizontalBarChart( const double scales[], double total, int count );
|
---|
65 |
|
---|
66 | QString valueLabel( const QString& label, double value, double total );
|
---|
67 | void updateRecentFiles( const QString& filename );
|
---|
68 | void updateRecentFilesMenu();
|
---|
69 | void setChartType( ChartType chartType );
|
---|
70 |
|
---|
71 | QPopupMenu *fileMenu;
|
---|
72 | QAction *optionsPieChartAction;
|
---|
73 | QAction *optionsHorizontalBarChartAction;
|
---|
74 | QAction *optionsVerticalBarChartAction;
|
---|
75 |
|
---|
76 |
|
---|
77 | QString m_filename;
|
---|
78 | QStringList m_recentFiles;
|
---|
79 | QCanvas *m_canvas;
|
---|
80 | CanvasView *m_canvasView;
|
---|
81 | bool m_changed;
|
---|
82 | ElementVector m_elements;
|
---|
83 | QPrinter *m_printer;
|
---|
84 | ChartType m_chartType;
|
---|
85 | AddValuesType m_addValues;
|
---|
86 | int m_decimalPlaces;
|
---|
87 | QFont m_font;
|
---|
88 | };
|
---|
89 |
|
---|
90 | #endif
|
---|