2 Bacula® - The Network Backup Solution
4 Copyright (C) 2007-2009 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 Kern Sibbald.
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 #include <QAbstractEventDispatcher>
33 #include "label/label.h"
34 #include "mount/mount.h"
35 #include "util/fmtwidgetitem.h"
36 #include "status/storstat.h"
38 Content::Content(QString storage)
41 pgInitialize(tr("Storage Content"));
42 QTreeWidgetItem* thisitem = mainWin->getFromHash(this);
43 thisitem->setIcon(0,QIcon(QString::fromUtf8(":images/package-x-generic.png")));
46 m_firstpopulation = true;
47 m_checkcurwidget = true;
49 m_currentStorage = storage;
58 * The main meat of the class!! The function that querries the director and
59 * creates the widgets with appropriate values.
61 void Content::populate()
64 m_firstpopulation = false;
65 Freeze frz(*tableContent); /* disable updating*/
68 QString cmd("status slots drive=0 storage=\"" + m_currentStorage + "\"");
69 m_console->dir_cmd(cmd, results);
70 foreach (QString resultline, results){
71 Pmsg1(0, "s=%s\n", resultline.toUtf8().data());
72 QStringList fieldlist = resultline.split("|");
73 QStringListIterator fld(fieldlist);
74 if (fieldlist.size() < 9)
75 continue; /* some fields missing, ignore row */
76 Pmsg1(0, "s=%s\n", resultline.toUtf8().data());
77 TableItemFormatter jobitem(*tableContent, row);
79 jobitem.setNumericFld(col++, fld.next());
81 jobitem.setTextFld(col++, fld.next());
82 jobitem.setNumericFld(col++, fld.next());
83 jobitem.setVolStatusFld(col++, fld.next());
84 jobitem.setTextFld(col++, fld.next());
85 jobitem.setTextFld(col++, fld.next());
86 jobitem.setTextFld(col++, fld.next());
87 jobitem.setTextFld(col++, fld.next());
94 * Virtual function which is called when this page is visible on the stack
96 void Content::currentStackItem()
104 * Functions to respond to local context sensitive menu sending console
105 * commands If I could figure out how to make these one function passing a
108 void Content::consoleStatusStorage()
110 QString cmd("status storage=");
111 cmd += m_currentStorage;
115 /* Label Media populating current storage by default */
116 void Content::consoleLabelStorage()
118 new labelPage(m_currentStorage);
121 void Content::treeItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)
126 /* Mount currently selected storage */
127 void Content::consoleMountStorage()
129 if (m_currentAutoChanger == 0){
130 /* no autochanger, just execute the command in the console */
131 QString cmd("mount storage=");
132 cmd += m_currentStorage;
136 /* if this storage is an autochanger, lets ask for the slot */
137 new mountDialog(m_console, m_currentStorage);
141 /* Unmount Currently selected storage */
142 void Content::consoleUnMountStorage()
144 QString cmd("umount storage=");
145 cmd += m_currentStorage;
150 void Content::consoleUpdateSlots()
152 QString cmd("update slots storage=");
153 cmd += m_currentStorage;
157 /* Update Slots Scan*/
158 void Content::consoleUpdateSlotsScan()
160 QString cmd("update slots scan storage=");
161 cmd += m_currentStorage;
165 /* Release a tape in the drive */
166 void Content::consoleRelease()
168 QString cmd("release storage=");
169 cmd += m_currentStorage;
174 * Open a status storage window
176 void Content::statusStorageWindow()
178 /* if one exists, then just set it current */
180 foreach(Pages *page, mainWin->m_pagehash) {
181 if (mainWin->currentConsole() == page->console()) {
182 if (page->name() == tr("Storage Status %1").arg(m_currentStorage)) {
189 QTreeWidgetItem *parentItem = mainWin->getFromHash(this);
190 new StorStat(m_currentStorage, parentItem);