/*
Bacula® - The Network Backup Solution
- Copyright (C) 2007-2009 Free Software Foundation Europe e.V.
+ Copyright (C) 2007-2010 Free Software Foundation Europe e.V.
- The main author of Bacula is Kern Sibbald, with contributions from
- many others, a complete list can be found in the file AUTHORS.
- This program is Free Software; you can redistribute it and/or
- modify it under the terms of version two of the GNU General Public
- License as published by the Free Software Foundation and included
- in the file LICENSE.
+ The main author of Bacula is Kern Sibbald, with contributions from many
+ others, a complete list can be found in the file AUTHORS.
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301, USA.
+ You may use this file and others of this release according to the
+ license defined in the LICENSE file, which includes the Affero General
+ Public License, v3.0 ("AGPLv3") and some additional permissions and
+ terms pursuant to its AGPLv3 Section 7.
Bacula® is a registered trademark of Kern Sibbald.
- The licensor of Bacula is the Free Software Foundation Europe
- (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
- Switzerland, email:ftf@fsfeurope.org.
*/
-
+
#include "bat.h"
#include <QAbstractEventDispatcher>
#include <QMenu>
#include "run/run.h"
#include "util/fmtwidgetitem.h"
-MediaView::MediaView()
+MediaView::MediaView() : Pages()
{
setupUi(this);
m_name = tr("Media");
connect(m_pbPurge, SIGNAL(pressed()), this, SLOT(purgePushed()));
connect(m_pbDelete, SIGNAL(pressed()), this, SLOT(deletePushed()));
connect(m_pbPrune, SIGNAL(pressed()), this, SLOT(prunePushed()));
- connect(m_tableMedia, SIGNAL(itemDoubleClicked(QTableWidgetItem*)),
+ connect(m_tableMedia, SIGNAL(itemDoubleClicked(QTableWidgetItem*)),
this, SLOT(showInfoForMedia(QTableWidgetItem *)));
/* mp_treeWidget, Storage Tree Tree Widget inherited from ui_medialist.h */
QStringList sel;
QString cmd;
getSelection(sel);
-
+
for(int i=0; i<sel.count(); i++) {
cmd = sel.at(i);
new MediaEdit(mainWin->getFromHash(this), cmd);
bool MediaView::getSelection(QStringList &list)
{
- QList<QTableWidgetItem*> items = m_tableMedia->selectedItems();
+ int i, nb, nr_rows, row;
+ bool *tab;
QTableWidgetItem *it;
- int row;
- int *tab;
- int nb = items.count();
+ QList<QTableWidgetItem*> items = m_tableMedia->selectedItems();
+
+ /*
+ * See if anything is selected.
+ */
+ nb = items.count();
if (!nb) {
return false;
}
- tab = (int *) malloc (nb * sizeof(int));
- memset(tab, 0, sizeof(int)*nb);
- for (int i = 0; i < nb; ++i) {
+
+ /*
+ * Create a nibble map for each row so we can see if its
+ * selected or not.
+ */
+ nr_rows = m_tableMedia->rowCount();
+ tab = (bool *)malloc (nr_rows * sizeof(bool));
+ memset(tab, 0, sizeof(bool) * nr_rows);
+
+ for (i = 0; i < nb; ++i) {
row = items[i]->row();
if (!tab[row]) {
- tab[row]=1;
+ tab[row] = true;
it = m_tableMedia->item(row, 0);
list.append(it->text());
}
}
free(tab);
+
return list.count() > 0;
}
m_cbLocation->addItems(m_console->location_list);
}
-/*
+/*
* If chkExpired button is checked, we can remove all non Expired
* entries
*/
}
/*
- * The main meat of the class!! The function that querries the director and
+ * The main meat of the class!! The function that querries the director and
* creates the widgets with appropriate values.
*/
void MediaView::populateTable()
if (m_cbPool->currentText() != "") {
cmd = " Pool.Name = '" + m_cbPool->currentText() + "'";
where.append(cmd);
- }
+ }
if (m_cbStatus->currentText() != "") {
cmd = " Media.VolStatus = '" + m_cbStatus->currentText() + "'";
"WHERE VolStatus IN ('Full', 'Used') "
"GROUP BY MediaType";
+ if (mainWin->m_sqlDebug) {
+ Pmsg1(000, "MediaView query cmd : %s\n",query.toUtf8().data());
+ }
if (m_console->sql_cmd(query, results)) {
foreach (resultline, results) {
fieldlist = resultline.split("\t");
- if (fieldlist.at(1).toInt() >= 1) {
+ if (fieldlist.at(1).toInt() >= 1) {
// MediaType
- hash_size[fieldlist.at(2)]
- = fieldlist.at(0).toFloat();
+ hash_size[fieldlist.at(2)]
+ = fieldlist.at(0).toFloat();
}
}
- }
-
+ }
+
m_tableMedia->clearContents();
- query =
+ query =
"SELECT VolumeName, InChanger, "
"Slot, MediaType, VolStatus, VolBytes, Pool.Name, "
"LastWritten, Media.VolRetention "
"FROM Media JOIN Pool USING (PoolId) "
"LEFT JOIN Location ON (Media.LocationId=Location.LocationId) "
- + cmd +
+ + cmd +
" ORDER BY VolumeName LIMIT " + m_sbLimit->cleanText();
-// Pmsg1(000, "MediaView query cmd : %s\n",query.toUtf8().data());
+ m_tableMedia->sortByColumn(0, Qt::AscendingOrder);
m_tableMedia->setSortingEnabled(false); /* Don't sort during insert */
results.clear();
+ if (mainWin->m_sqlDebug) {
+ Pmsg1(000, "MediaView query cmd : %s\n",query.toUtf8().data());
+ }
if (m_console->sql_cmd(query, results)) {
int row=0;
filterExipired(results);
m_tableMedia->setRowCount(results.size());
foreach (resultline, results) { // should have only one result
+ int index = 0;
QString VolBytes, MediaType, LastWritten, VolStatus;
fieldlist = resultline.split("\t");
if (fieldlist.size() != 10) {
continue;
}
QStringListIterator fld(fieldlist);
- int index=0;
TableItemFormatter mediaitem(*m_tableMedia, row);
/* VolumeName */
- mediaitem.setTextFld(index++, fld.next());
-
+ mediaitem.setTextFld(index++, fld.next());
+
/* Online */
mediaitem.setInChanger(index++, fld.next());
- fld.next(); // Slot
+
+ /* Slot */
+ mediaitem.setNumericFld(index++, fld.next());
MediaType = fld.next();
VolStatus = fld.next();
/* Usage */
usage = 0;
if (hash_size.contains(MediaType) &&
- hash_size[MediaType] != 0)
- {
+ hash_size[MediaType] != 0) {
usage = VolBytes.toLongLong() * 100 / hash_size[MediaType];
}
mediaitem.setPercent(index++, usage);
t = str_to_utime(LastWritten.toAscii().data());
t = t + stat.toULongLong();
ttime = t;
- localtime_r(&ttime, &tm);
+ localtime_r(&ttime, &tm);
strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", &tm);
}
-
+
/* LastWritten */
mediaitem.setTextFld(index++, LastWritten);
// setConsoleCurrent();
// new relabelDialog(m_console, m_currentVolumeName);
// }
-//
+//
// /*
// * Called from the signal of the context sensitive menu to purge!
// */
// consoleCommand(cmd);
// populateTable();
// }
-//
+//
// void MediaView::allVolumes()
// {
// QString cmd = "update volume allfrompools";
// consoleCommand(cmd);
// populateTable();
// }
-//
+//
// /*
// * Called from the signal of the context sensitive menu to purge!
// */
// consoleCommand(cmd);
// populateTable();
// }
-//
+//