2 Bacula® - The Network Backup Solution
4 Copyright (C) 2007-2007 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 = "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 << "Job Id" << "Job Level" << "Job Files" << "Job Bytes" << "Job Status"
137 << "Job Time" << "Job Name");
138 QStringList flaglist = (QStringList()
139 << "R" << "L" << "R" << "R" << "LC"
142 terminatedTable->setColumnCount(headerlist.size());
143 terminatedTable->setHorizontalHeaderLabels(headerlist);
145 if (m_console->dir_cmd(command, results)) {
147 QTableWidgetItem* p_tableitem;
148 terminatedTable->setRowCount(results.size());
149 foreach (QString line, results) {
150 /* Iterate through the record returned from the query */
151 QStringList fieldlist = line.split("\t");
153 QString statusCode("");
154 /* Iterate through fields in the record */
155 foreach (QString field, fieldlist) {
156 field = field.trimmed(); /* strip leading & trailing spaces */
157 p_tableitem = new QTableWidgetItem(field, 1);
158 p_tableitem->setForeground(blackBrush);
159 p_tableitem->setFlags(0);
160 if (flaglist[column].contains("R"))
161 p_tableitem->setTextAlignment(Qt::AlignRight);
162 if (flaglist[column].contains("C"))
164 p_tableitem->setBackground(Qt::green);
166 p_tableitem->setBackground(Qt::red);
167 terminatedTable->setItem(row, column, p_tableitem);
173 terminatedTable->resizeColumnsToContents();
174 terminatedTable->resizeRowsToContents();
175 terminatedTable->verticalHeader()->hide();
179 * Populate scheduled table
181 void DirStat::populateScheduled()
183 QString command = QString(".status dir scheduled");
185 QBrush blackBrush(Qt::black);
187 scheduledTable->clear();
188 QStringList headerlist = (QStringList()
189 << "Job Level" << "Job Type" << "Priority" << "Job Time" << "Job Name" << "Volume");
190 QStringList flaglist = (QStringList()
191 << "L" << "L" << "R" << "L" << "L" << "L");
193 scheduledTable->setColumnCount(headerlist.size());
194 scheduledTable->setHorizontalHeaderLabels(headerlist);
196 if (m_console->dir_cmd(command, results)) {
198 QTableWidgetItem* p_tableitem;
199 scheduledTable->setRowCount(results.size());
200 foreach (QString line, results) {
201 /* Iterate through the record returned from the query */
202 QStringList fieldlist = line.split("\t");
204 QString statusCode("");
205 /* Iterate through fields in the record */
206 foreach (QString field, fieldlist) {
207 field = field.trimmed(); /* strip leading & trailing spaces */
208 p_tableitem = new QTableWidgetItem(field, 1);
209 p_tableitem->setForeground(blackBrush);
210 p_tableitem->setFlags(0);
211 scheduledTable->setItem(row, column, p_tableitem);
217 scheduledTable->resizeColumnsToContents();
218 scheduledTable->resizeRowsToContents();
219 scheduledTable->verticalHeader()->hide();
223 * Populate running table
225 void DirStat::populateRunning()
227 QString command = QString(".status dir running");
229 QBrush blackBrush(Qt::black);
231 runningTable->clear();
232 QStringList headerlist = (QStringList()
233 << "Job Id" << "Job Level" << "Job Data" << "Job Info");
235 runningTable->setColumnCount(headerlist.size());
236 runningTable->setHorizontalHeaderLabels(headerlist);
238 if (m_console->dir_cmd(command, results)) {
240 QTableWidgetItem* p_tableitem;
241 runningTable->setRowCount(results.size());
242 foreach (QString line, results) {
243 /* Iterate through the record returned from the query */
244 QStringList fieldlist = line.split("\t");
246 QString statusCode("");
247 /* Iterate through fields in the record */
248 foreach (QString field, fieldlist) {
249 field = field.trimmed(); /* strip leading & trailing spaces */
250 p_tableitem = new QTableWidgetItem(field, 1);
251 p_tableitem->setForeground(blackBrush);
252 p_tableitem->setFlags(0);
253 runningTable->setItem(row, column, p_tableitem);
259 runningTable->resizeColumnsToContents();
260 runningTable->resizeRowsToContents();
261 runningTable->verticalHeader()->hide();
265 * When the treeWidgetItem in the page selector tree is singleclicked, Make sure
266 * The tree has been populated.
268 void DirStat::PgSeltreeWidgetClicked()
277 * Virtual function override of pages function which is called when this page
278 * is visible on the stack
280 void DirStat::currentStackItem()
289 * Function to create connections for context sensitive menu for this and
292 void DirStat::createConnections()
297 * Save user settings associated with this page
299 void DirStat::writeSettings()
301 QSettings settings(m_console->m_dir->name(), "bat");
302 settings.beginGroup(m_groupText);
303 settings.setValue(m_splitText, splitter->saveState());
308 * Read and restore user settings associated with this page
310 void DirStat::readSettings()
312 m_groupText = "DirStatPage";
313 m_splitText = "splitterSizes_0";
314 QSettings settings(m_console->m_dir->name(), "bat");
315 settings.beginGroup(m_groupText);
316 splitter->restoreState(settings.value(m_splitText).toByteArray());