]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/qt-console/jobgraphs/jobplot.h
4297b4be4cb390bb6f614526a35616fe5052780a
[bacula/bacula] / bacula / src / qt-console / jobgraphs / jobplot.h
1 #ifndef _JOBPLOT_H_
2 #define _JOBPLOT_H_
3 /*
4    Bacula(R) - The Network Backup Solution
5
6    Copyright (C) 2000-2015 Kern Sibbald
7    Copyright (C) 2007-2014 Free Software Foundation Europe e.V.
8
9    The original author of Bacula is Kern Sibbald, with contributions
10    from many others, a complete list can be found in the file AUTHORS.
11
12    You may use this file and others of this release according to the
13    license defined in the LICENSE file, which includes the Affero General
14    Public License, v3.0 ("AGPLv3") and some additional permissions and
15    terms pursuant to its AGPLv3 Section 7.
16
17    This notice must be preserved when any source code is 
18    conveyed and/or propagated.
19
20    Bacula(R) is a registered trademark of Kern Sibbald.
21 */
22 /*
23  *   Dirk Bartley, March 2007
24  */
25
26 #include <QtGui>
27 #include "pages.h"
28 #include "ui_jobplotcontrols.h"
29 #include <qwt_data.h>
30 #include <qwt_legend.h>
31 #include <qwt_plot_curve.h>
32 #include <qwt_plot.h>
33 #include <qwt_plot_marker.h>
34 #include <qwt_plot_curve.h>
35 #include <qwt_symbol.h>
36 #include <qwt_scale_map.h>
37 #include <qwt_scale_draw.h>
38 #include <qwt_text.h>
39
40 /*
41  * Structure to hold data items of jobs when and how much.
42  * If I worked at it I could eliminate this.  It's just the way it evolved.
43  */
44 struct PlotJobData
45 {
46    double files;
47    double bytes;
48    QDateTime dt;
49 };
50
51 /*
52  * Class for the purpose of having a single object to pass data to the JobPlot
53  * Constructor.  The other option was a constructor with this many passed 
54  * values or some sort of code to parse a list.  I liked this best at the time.
55  */
56 class JobPlotPass
57 {
58 public:
59    JobPlotPass();
60    JobPlotPass& operator=(const JobPlotPass&);
61    bool use;
62    Qt::CheckState recordLimitCheck;
63    Qt::CheckState daysLimitCheck;
64    int recordLimitSpin;
65    int daysLimitSpin;
66    QString jobCombo;
67    QString clientCombo;
68    QString volumeCombo;
69    QString fileSetCombo;
70    QString purgedCombo;
71    QString levelCombo;
72    QString statusCombo;
73 };
74
75 /*
76  * Class to Change the display of the time scale to display dates.
77  */
78 class DateTimeScaleDraw : public QwtScaleDraw
79 {
80 public:
81    virtual QwtText label(double v) const
82    {
83       QDateTime dtlabel(QDateTime::fromTime_t((uint)v));
84       return dtlabel.toString("M-d-yy");
85    }
86 };
87
88 /*
89  * These are the user interface control widgets as a separate class.
90  * Separately for the purpos of having the controls in a Scroll Area.
91  */
92 class JobPlotControls : public QWidget, public Ui::JobPlotControlsForm
93 {
94    Q_OBJECT
95
96 public:
97    JobPlotControls();
98 };
99
100 /*
101  * The main class
102  */
103 class JobPlot : public Pages
104 {
105    Q_OBJECT 
106
107 public:
108    JobPlot(QTreeWidgetItem *parentTreeWidgetItem, JobPlotPass &);
109    ~JobPlot();
110    virtual void currentStackItem();
111
112 private slots:
113    void setPlotType(QString);
114    void setFileSymbolType(int);
115    void setByteSymbolType(int);
116    void fileCheckChanged(int);
117    void byteCheckChanged(int);
118    void reGraph();
119
120 private:
121    void fillSymbolCombo(QComboBox *q);
122    void setSymbolType(int, int type);
123    void addCurve();
124    void writeSettings();
125    void readSplitterSettings();
126    void readControlSettings();
127    void setupControls();
128    void runQuery();
129    bool m_drawn;
130    JobPlotPass m_pass;
131    JobPlotControls* controls;
132    QList<PlotJobData *> m_pjd;
133    QwtPlotCurve *m_fileCurve;
134    QwtPlotCurve *m_byteCurve;
135    /* from the user interface before using scroll area */
136    void setupUserInterface();
137    QGridLayout *m_gridLayout;
138    QSplitter *m_splitter;
139    QwtPlot *m_jobPlot;
140 };
141
142 #endif /* _JOBPLOT_H_ */