2 Bacula® - The Network Backup Solution
4 Copyright (C) 2007-2008 Free Software Foundation Europe e.V.
6 The main author of Bacula is Kern Sibbald, with contributions from
7 many others, a complete list can be found in the file AUTHORS.
8 This program is Free Software; you can redistribute it and/or
9 modify it under the terms of version two of the GNU General Public
10 License as published by the Free Software Foundation and included
13 This program is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23 Bacula® is a registered trademark of John Walker.
24 The licensor of Bacula is the Free Software Foundation Europe
25 (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
26 Switzerland, email:ftf@fsfeurope.org.
29 * Version $Id: dirstat.cpp 5880 2007-11-09 01:20:40Z bartleyd2 $
31 * Dirk Bartley, March 2007
34 #include <QAbstractEventDispatcher>
35 #include <QTableWidgetItem>
40 * Constructor for the class
45 m_name = tr("Director Status");
48 QTreeWidgetItem* thisitem = mainWin->getFromHash(this);
49 thisitem->setIcon(0,QIcon(QString::fromUtf8(":images/joblog.png")));
50 m_cursor = new QTextCursor(textEdit->document());
54 m_timer = new QTimer(this);
55 QWidget::connect(m_timer, SIGNAL(timeout()), this, SLOT(timerTriggered()));
56 //m_timer->start(mainWin->m_checkMessagesInterval*1000);
57 m_timer->start(10*1000);
60 void DirStat::getFont()
62 QFont font = textEdit->font();
65 m_console->getDirResName(dirname);
66 QSettings settings(dirname, "bat");
67 settings.beginGroup("Console");
68 font.setFamily(settings.value("consoleFont", "Courier").value<QString>());
69 font.setPointSize(settings.value("consolePointSize", 10).toInt());
70 font.setFixedPitch(settings.value("consoleFixedPitch", true).toBool());
72 textEdit->setFont(font);
76 * Write the m_splitter settings in the destructor
84 * Populate all tables and header widgets
86 void DirStat::populateAll()
88 if (!m_console->preventInUseConnect())
97 * Timer is triggered, see if is current and repopulate.
99 void DirStat::timerTriggered()
101 bool iscurrent = mainWin->stackedWidget->currentIndex() == mainWin->stackedWidget->indexOf(this);
102 if ((isDocked() && iscurrent) || (!isDocked())) {
103 if (m_console->is_ready())
109 * Populate header text widget
111 void DirStat::populateHeader()
113 QString command = QString(".status dir header");
117 if (m_console->dir_cmd(command, results)) {
118 foreach (QString line, results) {
120 textEdit->insertPlainText(line);
126 * Populate teminated table
128 void DirStat::populateTerminated()
130 QString command = QString(".status dir terminated");
132 QBrush blackBrush(Qt::black);
134 terminatedTable->clear();
135 QStringList headerlist = (QStringList()
136 << tr("Job Id") << tr("Job Level") << tr("Job Files")
137 << tr("Job Bytes") << tr("Job Status") << tr("Job Time")
139 QStringList flaglist = (QStringList()
140 << "R" << "L" << "R" << "R" << "LC"
143 terminatedTable->setColumnCount(headerlist.size());
144 terminatedTable->setHorizontalHeaderLabels(headerlist);
146 if (m_console->dir_cmd(command, results)) {
148 QTableWidgetItem* p_tableitem;
149 terminatedTable->setRowCount(results.size());
150 foreach (QString line, results) {
151 /* Iterate through the record returned from the query */
152 QStringList fieldlist = line.split("\t");
154 QString statusCode("");
155 /* Iterate through fields in the record */
156 foreach (QString field, fieldlist) {
157 field = field.trimmed(); /* strip leading & trailing spaces */
158 p_tableitem = new QTableWidgetItem(field, 1);
159 p_tableitem->setForeground(blackBrush);
160 p_tableitem->setFlags(0);
161 if (flaglist[column].contains("R"))
162 p_tableitem->setTextAlignment(Qt::AlignRight);
163 if (flaglist[column].contains("C"))
165 p_tableitem->setBackground(Qt::green);
167 p_tableitem->setBackground(Qt::red);
168 terminatedTable->setItem(row, column, p_tableitem);
174 terminatedTable->resizeColumnsToContents();
175 terminatedTable->resizeRowsToContents();
176 terminatedTable->verticalHeader()->hide();
180 * Populate scheduled table
182 void DirStat::populateScheduled()
184 QString command = QString(".status dir scheduled");
186 QBrush blackBrush(Qt::black);
188 scheduledTable->clear();
189 QStringList headerlist = (QStringList()
190 << tr("Job Level") << tr("Job Type") << tr("Priority") << tr("Job Time")
191 << tr("Job Name") << tr("Volume"));
192 QStringList flaglist = (QStringList()
193 << "L" << "L" << "R" << "L" << "L" << "L");
195 scheduledTable->setColumnCount(headerlist.size());
196 scheduledTable->setHorizontalHeaderLabels(headerlist);
198 if (m_console->dir_cmd(command, results)) {
200 QTableWidgetItem* p_tableitem;
201 scheduledTable->setRowCount(results.size());
202 foreach (QString line, results) {
203 /* Iterate through the record returned from the query */
204 QStringList fieldlist = line.split("\t");
206 QString statusCode("");
207 /* Iterate through fields in the record */
208 foreach (QString field, fieldlist) {
209 field = field.trimmed(); /* strip leading & trailing spaces */
210 p_tableitem = new QTableWidgetItem(field, 1);
211 p_tableitem->setForeground(blackBrush);
212 p_tableitem->setFlags(0);
213 scheduledTable->setItem(row, column, p_tableitem);
219 scheduledTable->resizeColumnsToContents();
220 scheduledTable->resizeRowsToContents();
221 scheduledTable->verticalHeader()->hide();
225 * Populate running table
227 void DirStat::populateRunning()
229 QString command = QString(".status dir running");
231 QBrush blackBrush(Qt::black);
233 runningTable->clear();
234 QStringList headerlist = (QStringList()
235 << tr("Job Id") << tr("Job Level") << tr("Job Data") << tr("Job Info"));
237 runningTable->setColumnCount(headerlist.size());
238 runningTable->setHorizontalHeaderLabels(headerlist);
240 if (m_console->dir_cmd(command, results)) {
242 QTableWidgetItem* p_tableitem;
243 runningTable->setRowCount(results.size());
244 foreach (QString line, results) {
245 /* Iterate through the record returned from the query */
246 QStringList fieldlist = line.split("\t");
248 QString statusCode("");
249 /* Iterate through fields in the record */
250 foreach (QString field, fieldlist) {
251 field = field.trimmed(); /* strip leading & trailing spaces */
252 p_tableitem = new QTableWidgetItem(field, 1);
253 p_tableitem->setForeground(blackBrush);
254 p_tableitem->setFlags(0);
255 runningTable->setItem(row, column, p_tableitem);
261 runningTable->resizeColumnsToContents();
262 runningTable->resizeRowsToContents();
263 runningTable->verticalHeader()->hide();
267 * When the treeWidgetItem in the page selector tree is singleclicked, Make sure
268 * The tree has been populated.
270 void DirStat::PgSeltreeWidgetClicked()
279 * Virtual function override of pages function which is called when this page
280 * is visible on the stack
282 void DirStat::currentStackItem()
291 * Function to create connections for context sensitive menu for this and
294 void DirStat::createConnections()
299 * Save user settings associated with this page
301 void DirStat::writeSettings()
303 QSettings settings(m_console->m_dir->name(), "bat");
304 settings.beginGroup(m_groupText);
305 settings.setValue(m_splitText, splitter->saveState());
310 * Read and restore user settings associated with this page
312 void DirStat::readSettings()
314 m_groupText = "DirStatPage";
315 m_splitText = "splitterSizes_0";
316 QSettings settings(m_console->m_dir->name(), "bat");
317 settings.beginGroup(m_groupText);
318 splitter->restoreState(settings.value(m_splitText).toByteArray());