]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/qt-console/util/fmtwidgetitem.h
This is the patch as sent to me by Ricardo.
[bacula/bacula] / bacula / src / qt-console / util / fmtwidgetitem.h
1 #ifndef _FMTWIDGETITEM_H_
2 #define _FMTWIDGETITEM_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 John Walker.
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  *   TreeView formatting helpers - Riccardo Ghetta, May 2008 
34  */
35
36 class QTreeWidgetItem;
37 class QString;
38
39 /*
40  * This class can be used instead of QTreeWidgetItem (it allocates one internally,
41  * to format data fields.
42  * All setXXXFld routines receive a column index and the unformatted string value.
43  */
44 class ItemFormatter
45 {
46 public:
47
48    ItemFormatter(QTreeWidgetItem &parent, int indent_level);
49
50    /* Prints Yes if fld is != 0, No otherwise. Centers field if center true*/
51    void setBoolFld(int index, const QString &fld, bool center = true);
52    void setBoolFld(int index, int fld, bool center = true);
53
54    /* Normal text field. Centers field if center true*/
55    void setTextFld(int index, const QString &fld, bool center = false);
56
57    /* Right-aligned text field.*/
58    void setNumericFld(int index, const QString &fld);
59
60    /* fld value interpreted as bytes and formatted with size suffixes */
61    void setBytesFld(int index, const QString &fld);
62
63    /* fld value interpreted as seconds and formatted with y,m,w,h suffixes */
64    void setDurationFld(int index, const QString &fld);
65
66    /* fld value interpreted as volume status. Colored accordingly */
67    void setVolStatusFld(int index, const QString &fld, bool center = true);
68
69    /* access internal widget */
70    QTreeWidgetItem *widget() { return wdg; }
71    const QTreeWidgetItem *widget() const { return wdg; }
72
73 private:
74    QTreeWidgetItem *wdg;
75    int level;
76 };
77
78 #endif /* _FMTWIDGETITEM_H_ */
79 #ifndef _FMTWIDGETITEM_H_
80 #define _FMTWIDGETITEM_H_
81 /*
82    Bacula® - The Network Backup Solution
83
84    Copyright (C) 2007-2007 Free Software Foundation Europe e.V.
85
86    The main author of Bacula is Kern Sibbald, with contributions from
87    many others, a complete list can be found in the file AUTHORS.
88    This program is Free Software; you can redistribute it and/or
89    modify it under the terms of version two of the GNU General Public
90    License as published by the Free Software Foundation and included
91    in the file LICENSE.
92
93    This program is distributed in the hope that it will be useful, but
94    WITHOUT ANY WARRANTY; without even the implied warranty of
95    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
96    General Public License for more details.
97
98    You should have received a copy of the GNU General Public License
99    along with this program; if not, write to the Free Software
100    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
101    02110-1301, USA.
102
103    Bacula® is a registered trademark of John Walker.
104    The licensor of Bacula is the Free Software Foundation Europe
105    (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
106    Switzerland, email:ftf@fsfeurope.org.
107 */
108 /*
109  *   Version $Id$
110  *
111  *   TreeView formatting helpers - Riccardo Ghetta, May 2008 
112  */
113
114 class QTreeWidgetItem;
115 class QString;
116
117 /*
118  * This class can be used instead of QTreeWidgetItem (it allocates one internally,
119  * to format data fields.
120  * All setXXXFld routines receive a column index and the unformatted string value.
121  */
122 class ItemFormatter
123 {
124 public:
125
126    ItemFormatter(QTreeWidgetItem &parent, int indent_level);
127
128    /* Prints Yes if fld is != 0, No otherwise. Centers field if center true*/
129    void setBoolFld(int index, const QString &fld, bool center = true);
130
131    /* Normal text field. Centers field if center true*/
132    void setTextFld(int index, const QString &fld, bool center = false);
133
134    /* Right-aligned text field.*/
135    void setNumericFld(int index, const QString &fld);
136
137    /* fld value interpreted as bytes and formatted with size suffixes */
138    void setBytesFld(int index, const QString &fld);
139
140    /* fld value interpreted as seconds and formatted with y,m,w,h suffixes */
141    void setDurationFld(int index, const QString &fld);
142
143    /* fld value interpreted as volume status. Colored accordingly */
144    void setVolStatusFld(int index, const QString &fld, bool center = true);
145
146    /* access internal widget */
147    QTreeWidgetItem *widget() { return wdg; }
148    const QTreeWidgetItem *widget() const { return wdg; }
149
150 private:
151    QTreeWidgetItem *wdg;
152    int level;
153 };
154
155 #endif /* _FMTWIDGETITEM_H_ */