2 Bacula® - The Network Backup Solution
4 Copyright (C) 2000-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 plus additions
11 that are listed in the file LICENSE.
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: joblist.h 4230 2007-02-21 20:07:37Z kerns $
31 * Dirk Bartley, March 2007
34 #include <QAbstractEventDispatcher>
35 #include <QTableWidgetItem>
41 * Constructor for the class
43 JobList::JobList(Console *console, QString &medianame)
46 /* Store passed variables in member variables */
48 m_medianame = medianame;
54 * The Meat of the class.
55 * This function will populate the QTableWidget, mp_tablewidget, with
56 * QTableWidgetItems representing the results of a query for what jobs exist on
57 * the media name passed from the constructor stored in m_medianame.
59 void JobList::populateTable()
64 /* Set up query QString and header QStringList */
66 query += "SELECT j.jobid,j.name,j.starttime,j.type,j.level,j.jobfiles,"
68 " FROM job j, jobmedia jm, media m"
69 " WHERE jm.jobid=j.jobid and jm.mediaid=m.mediaid and m.VolumeName='";
70 query += m_medianame + "' ORDER BY j.starttime";
71 QStringList headerlist = (QStringList()
72 << "Job Id" << "Job Name" << "Job Starttime" << "Job Type" << "Job Level"
73 << "Job Files" << "Job Status");
75 /* Initialize the QTableWidget */
76 mp_tableWidget->clear();
77 mp_tableWidget->setColumnCount(headerlist.size());
78 mp_tableWidget->setHorizontalHeaderLabels(headerlist);
80 if (mp_console->sql_cmd(query, results)) {
81 QTableWidgetItem* p_tableitem;
83 QStringList fieldlist;
84 mp_tableWidget->setRowCount(results.size());
87 /* Iterate through the record returned from the query */
88 foreach (resultline, results) {
89 fieldlist = resultline.split("\t");
91 /* Iterate through fields in the record */
92 foreach (field, fieldlist) {
93 field = field.trimmed(); /* strip leading & trailing spaces */
94 p_tableitem = new QTableWidgetItem(field,1);
95 p_tableitem->setFlags(0);
96 mp_tableWidget->setItem(row, column, p_tableitem);