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