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.
30 * Version $Id: client.cpp 4230 2007-02-21 20:07:37Z kerns $
34 * Dirk Bartley, March 2007
38 //#include <QAbstractEventDispatcher>
41 #include "jobs/jobs.h"
48 QTreeWidgetItem* thisitem = mainWin->getFromHash(this);
49 thisitem->setIcon(0,QIcon(QString::fromUtf8(":images/emblem-system.svg")));
51 /* mp_treeWidget, Storage Tree Tree Widget inherited from ui_client.h */
53 m_checkcurwidget = true;
55 /* add context sensitive menu items specific to this classto the page
56 * selector tree. m_contextActions is QList of QActions */
57 m_contextActions.append(actionRefreshJobs);
67 * The main meat of the class!! The function that querries the director and
68 * creates the widgets with appropriate values.
70 void Jobs::populateTree()
72 QTreeWidgetItem *jobsItem, *topItem;
74 if (!m_console->preventInUseConnect())
76 m_checkcurwidget = false;
77 mp_treeWidget->clear();
78 m_checkcurwidget = true;
79 QStringList headerlist = (QStringList() << "Job Name" << "Pool" << "Messages"
80 << "Client" << "Storage" << "Where" << "Level" << "Type" << "FileSet"
81 << "Catalog" << "Enabled");
83 topItem = new QTreeWidgetItem(mp_treeWidget);
84 topItem->setText(0, "Jobs");
85 topItem->setData(0, Qt::UserRole, 0);
86 topItem->setExpanded(true);
88 mp_treeWidget->setColumnCount(headerlist.count());
89 mp_treeWidget->setHeaderLabels(headerlist);
91 foreach (QString jobName, m_console->job_list){
92 jobsItem = new QTreeWidgetItem(topItem);
93 jobsItem->setText(0, jobName);
94 //jobsItem->setExpanded(true);
96 for (int i=0; i<headerlist.count(); i++)
97 jobsItem->setData(i, Qt::UserRole, 1);
98 /*struct job_defaults {
101 QString messages_name;
107 QString fileset_name;
108 QString catalog_name;
111 job_defaults job_defs;
112 job_defs.job_name = jobName;
113 if (m_console->get_job_defaults(job_defs)) {
115 jobsItem->setText(col++, job_defs.pool_name);
116 jobsItem->setText(col++, job_defs.messages_name);
117 jobsItem->setText(col++, job_defs.client_name);
118 jobsItem->setText(col++, job_defs.store_name);
119 jobsItem->setText(col++, job_defs.where);
120 jobsItem->setText(col++, job_defs.level);
121 jobsItem->setText(col++, job_defs.type);
122 jobsItem->setText(col++, job_defs.fileset_name);
123 jobsItem->setText(col++, job_defs.catalog_name);
124 if (job_defs.enabled) {
125 jobsItem->setText(col++, "Yes");
127 jobsItem->setText(col++, "No");
132 /* Resize the columns */
133 for(int cnter=0; cnter<headerlist.size(); cnter++) {
134 mp_treeWidget->resizeColumnToContents(cnter);
139 * When the treeWidgetItem in the page selector tree is singleclicked, Make sure
140 * The tree has been populated.
142 void Jobs::PgSeltreeWidgetClicked()
151 * Added to set the context menu policy based on currently active treeWidgetItem
152 * signaled by currentItemChanged
154 void Jobs::treeItemChanged(QTreeWidgetItem *currentwidgetitem, QTreeWidgetItem *previouswidgetitem )
156 /* m_checkcurwidget checks to see if this is during a refresh, which will segfault */
157 if (m_checkcurwidget) {
158 /* The Previous item */
159 if (previouswidgetitem) { /* avoid a segfault if first time */
160 int treedepth = previouswidgetitem->data(0, Qt::UserRole).toInt();
162 //mp_treeWidget->removeAction(actionListJobsofClient);
166 int treedepth = currentwidgetitem->data(0, Qt::UserRole).toInt();
168 /* set a hold variable to the client name in case the context sensitive
170 m_currentlyselected=currentwidgetitem->text(0);
171 //mp_treeWidget->addAction(actionListJobsofClient);
177 * Setup a context menu
178 * Made separate from populate so that it would not create context menu over and
179 * over as the tree is repopulated.
181 void Jobs::createContextMenu()
183 mp_treeWidget->setContextMenuPolicy(Qt::ActionsContextMenu);
184 mp_treeWidget->addAction(actionRefreshJobs);
185 connect(mp_treeWidget, SIGNAL(
186 currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)),
187 this, SLOT(treeItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)));
188 /* connect to the action specific to this pages class */
189 connect(actionRefreshJobs, SIGNAL(triggered()), this,
190 SLOT(populateTree()));
194 * Virtual function which is called when this page is visible on the stack
196 void Jobs::currentStackItem()
200 /* Create the context menu for the client tree */