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::populateContent()
64 m_firstpopulation = false;
65 // Freeze frz(*tableContent); /* disable updating*/
66 tableContent->clear();
69 QStringList results_all;
70 QString cmd("status slots drive=0 storage=\"" + m_currentStorage + "\"");
72 m_console->dir_cmd(cmd, results_all);
73 // skip non list messages
74 QStringList results = results_all.filter(QRegExp("[0-9]+\\|"));
75 Pmsg1(0, "count=%i\n", results.size());
76 tableContent->setRowCount(results.size());
78 foreach (QString resultline, results){
80 QStringList fieldlist = resultline.split("|");
81 QStringListIterator fld(fieldlist);
83 if (fieldlist.size() < 9)
84 continue; /* some fields missing, ignore row */
86 Pmsg1(0, "s=%s\n", resultline.toUtf8().data());
88 TableItemFormatter slotitem(*tableContent, row);
90 slotitem.setNumericFld(col++, fld.next()); // Slot
91 Pmsg1(0, "s=%s\n", fld.next().toUtf8().data()); // Real Slot
93 // if (fld.next() != "") { // skip "Real Slot"
94 slotitem.setTextFld(col++, fld.next()); // Volume
95 slotitem.setNumericFld(col++, fld.next()); // Bytes
96 slotitem.setVolStatusFld(col++, fld.next()); // Status
97 slotitem.setTextFld(col++, fld.next()); // MediaType
98 slotitem.setTextFld(col++, fld.next()); // Pool
99 slotitem.setTextFld(col++, fld.next()); // LastWritten
100 slotitem.setTextFld(col++, fld.next()); // Expire
105 tableContent->resizeColumnsToContents();
106 tableContent->verticalHeader()->hide();
108 tableContent->sortByColumn(0, Qt::AscendingOrder);
109 tableContent->setSortingEnabled(true);
111 int rcnt = tableContent->rowCount();
112 int ccnt = tableContent->columnCount();
113 for(int r=0; r < rcnt; r++) {
114 for(int c=0; c < ccnt; c++) {
115 QTableWidgetItem* item = tableContent->item(r, c);
117 item->setFlags(Qt::ItemFlags(item->flags() & (~Qt::ItemIsEditable)));
122 tableContent->update();
124 tableDrive->verticalHeader()->hide();
128 * Virtual function which is called when this page is visible on the stack
130 void Content::currentStackItem()
138 * Functions to respond to local context sensitive menu sending console
139 * commands If I could figure out how to make these one function passing a
142 void Content::consoleStatusStorage()
144 QString cmd("status storage=");
145 cmd += m_currentStorage;
149 /* Label Media populating current storage by default */
150 void Content::consoleLabelStorage()
152 new labelPage(m_currentStorage);
155 void Content::treeItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)
160 /* Mount currently selected storage */
161 void Content::consoleMountStorage()
163 if (m_currentAutoChanger == 0){
164 /* no autochanger, just execute the command in the console */
165 QString cmd("mount storage=");
166 cmd += m_currentStorage;
170 /* if this storage is an autochanger, lets ask for the slot */
171 new mountDialog(m_console, m_currentStorage);
175 /* Unmount Currently selected storage */
176 void Content::consoleUnMountStorage()
178 QString cmd("umount storage=");
179 cmd += m_currentStorage;
184 void Content::consoleUpdateSlots()
186 QString cmd("update slots storage=");
187 cmd += m_currentStorage;
191 /* Update Slots Scan*/
192 void Content::consoleUpdateSlotsScan()
194 QString cmd("update slots scan storage=");
195 cmd += m_currentStorage;
199 /* Release a tape in the drive */
200 void Content::consoleRelease()
202 QString cmd("release storage=");
203 cmd += m_currentStorage;
208 * Open a status storage window
210 void Content::statusStorageWindow()
212 /* if one exists, then just set it current */
214 foreach(Pages *page, mainWin->m_pagehash) {
215 if (mainWin->currentConsole() == page->console()) {
216 if (page->name() == tr("Storage Status %1").arg(m_currentStorage)) {
223 QTreeWidgetItem *parentItem = mainWin->getFromHash(this);
224 new StorStat(m_currentStorage, parentItem);