]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/qt-console/medialist/mediaview.cpp
Backport from Bacula Enterprise
[bacula/bacula] / bacula / src / qt-console / medialist / mediaview.cpp
index 6f8f28240daa53e563e28743dbd5dbd40d59fa08..5650a264a973e48105ef45783edffc631b873015 100644 (file)
@@ -1,29 +1,21 @@
 /*
-   Bacula® - The Network Backup Solution
+   Bacula(R) - The Network Backup Solution
 
+   Copyright (C) 2000-2015 Kern Sibbald
    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 three of the GNU Affero General Public
-   License as published by the Free Software Foundation and included
-   in the file LICENSE.
-
-   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 Affero 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.
-
-   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.
+   The original author of Bacula is Kern Sibbald, with contributions
+   from many others, a complete list can be found in the file AUTHORS.
+
+   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.
+
+   This notice must be preserved when any source code is 
+   conveyed and/or propagated.
+
+   Bacula(R) is a registered trademark of Kern Sibbald.
 */
  
 #include "bat.h"
@@ -115,28 +107,19 @@ void MediaView::purgePushed()
 
 bool MediaView::getSelection(QStringList &list)
 {
-   int i, nb, nr_rows, row;
-   bool *tab;
    QTableWidgetItem *it;
    QList<QTableWidgetItem*> items = m_tableMedia->selectedItems();
-
-   /*
-    * See if anything is selected.
-    */
-   nb = items.count();
+   int row;
+   int nrows;                      /* number of rows */
+   bool *tab;
+   int nb = items.count();
    if (!nb) {
       return false;
    }
-
-   /*
-    * 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) {
+   nrows = m_tableMedia->rowCount();
+   tab = (bool *) malloc (nrows * sizeof(bool));
+   memset(tab, 0, sizeof(bool)*nrows);
+   for (int i = 0; i < nb; ++i) {
       row = items[i]->row();
       if (!tab[row]) {
          tab[row] = true;
@@ -145,7 +128,6 @@ bool MediaView::getSelection(QStringList &list)
       }
    }
    free(tab);
-
    return list.count() > 0;
 }
 
@@ -305,6 +287,10 @@ void MediaView::populateTable()
    if (m_console->sql_cmd(query, results)) {
       foreach (resultline, results) {
          fieldlist = resultline.split("\t");
+         if (fieldlist.size() != 3) {
+            Pmsg1(000, "Unexpected line %s", resultline.toUtf8().data());
+            continue;
+         }
          if (fieldlist.at(1).toInt() >= 1) { 
             //           MediaType
             hash_size[fieldlist.at(2)] 
@@ -333,12 +319,12 @@ void MediaView::populateTable()
       int row=0;
       filterExipired(results);
       m_tableMedia->setRowCount(results.size());
-
       foreach (resultline, results) { // should have only one result
          int index = 0;
          QString Slot, VolBytes, MediaType, LastWritten, VolStatus;
          fieldlist = resultline.split("\t");
-         if (fieldlist.size() != 10) {
+         if (fieldlist.size() != 9) {
+            Pmsg1(000, "Unexpected line %s", resultline.toUtf8().data());
             continue;
          }
          QStringListIterator fld(fieldlist);
@@ -351,7 +337,7 @@ void MediaView::populateTable()
          mediaitem.setInChanger(index++, fld.next());
 
          Slot = fld.next();            // Slot
-         mediaitem.setTextFld(index++, Slot);
+         mediaitem.setNumericFld(index++, Slot);
 
          MediaType = fld.next();
          VolStatus = fld.next();