]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/qt-console/jobgraphs/jobplot.h
kes Change Bacula trademark owner from John Walker to Kern Sibbald
[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-2007 Free Software Foundation Europe e.V.
7
8    The main author of Bacula is Kern Sibbald, with contributions from
9    many others, a complete list can be found in the file AUTHORS.
10    This program is Free Software; you can redistribute it and/or
11    modify it under the terms of version two of the GNU General Public
12    License as published by the Free Software Foundation and included
13    in the file LICENSE.
14
15    This program is distributed in the hope that it will be useful, but
16    WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18    General Public License for more details.
19
20    You should have received a copy of the GNU General Public License
21    along with this program; if not, write to the Free Software
22    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23    02110-1301, USA.
24
25    Bacula® is a registered trademark of Kern Sibbald.
26    The licensor of Bacula is the Free Software Foundation Europe
27    (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
28    Switzerland, email:ftf@fsfeurope.org.
29 */
30 /*
31  *   Version $Id$
32  *
33  *   Dirk Bartley, March 2007
34  */
35
36 #include <QtGui>
37 #include "pages.h"
38 #include "ui_jobplotcontrols.h"
39 #include <qwt_data.h>
40 #include <qwt_legend.h>
41 #include <qwt_plot_curve.h>
42 #include <qwt_plot.h>
43 #include <qwt_plot_marker.h>
44 #include <qwt_plot_curve.h>
45 #include <qwt_symbol.h>
46 #include <qwt_scale_map.h>
47 #include <qwt_scale_draw.h>
48 #include <qwt_text.h>
49
50 /*
51  * Structure to hold data items of jobs when and how much.
52  * If I worked at it I could eliminate this.  It's just the way it evolved.
53  */
54 struct PlotJobData
55 {
56    double files;
57    double bytes;
58    QDateTime dt;
59 };
60
61 /*
62  * Class for the purpose of having a single object to pass data to the JobPlot
63  * Constructor.  The other option was a constructor with this many passed 
64  * values or some sort of code to parse a list.  I liked this best at the time.
65  */
66 class JobPlotPass
67 {
68 public:
69    JobPlotPass();
70    JobPlotPass& operator=(const JobPlotPass&);
71    bool use;
72    Qt::CheckState recordLimitCheck;
73    Qt::CheckState daysLimitCheck;
74    int recordLimitSpin;
75    int daysLimitSpin;
76    QString jobCombo;
77    QString clientCombo;
78    QString volumeCombo;
79    QString fileSetCombo;
80    QString purgedCombo;
81    QString levelCombo;
82    QString statusCombo;
83 };
84
85 /*
86  * Class to Change the display of the time scale to display dates.
87  */
88 class DateTimeScaleDraw : public QwtScaleDraw
89 {
90 public:
91    virtual QwtText label(double v) const
92    {
93       QDateTime dtlabel(QDateTime::fromTime_t((uint)v));
94       return dtlabel.toString("M-d-yy");
95    }
96 };
97
98 /*
99  * These are the user interface control widgets as a separate class.
100  * Separately for the purpos of having the controls in a Scroll Area.
101  */
102 class JobPlotControls : public QWidget, public Ui::JobPlotControlsForm
103 {
104    Q_OBJECT
105
106 public:
107    JobPlotControls();
108 };
109
110 /*
111  * The main class
112  */
113 class JobPlot : public Pages
114 {
115    Q_OBJECT 
116
117 public:
118    JobPlot(QTreeWidgetItem *parentTreeWidgetItem, JobPlotPass &);
119    ~JobPlot();
120    virtual void currentStackItem();
121
122 private slots:
123    void setPlotType(QString);
124    void setFileSymbolType(int);
125    void setByteSymbolType(int);
126    void fileCheckChanged(int);
127    void byteCheckChanged(int);
128    void reGraph();
129
130 private:
131    void fillSymbolCombo(QComboBox *q);
132    void setSymbolType(int, int type);
133    void addCurve();
134    void writeSettings();
135    void readSplitterSettings();
136    void readControlSettings();
137    void setupControls();
138    void runQuery();
139    bool m_drawn;
140    JobPlotPass m_pass;
141    JobPlotControls* controls;
142    QList<PlotJobData *> m_pjd;
143    QwtPlotCurve *m_fileCurve;
144    QwtPlotCurve *m_byteCurve;
145    /* from the user interface before using scroll area */
146    void setupUserInterface();
147    QGridLayout *m_gridLayout;
148    QSplitter *m_splitter;
149    QwtPlot *m_jobPlot;
150 };
151
152 #endif /* _JOBPLOT_H_ */