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