]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/qt-console/mediaedit/mediaedit.cpp
Make bad Storage check in is_on_same_storage non-fatal
[bacula/bacula] / bacula / src / qt-console / mediaedit / mediaedit.cpp
index fa6429a02d29a4f6b795c4727560cdbeae6bf52a..3e3b6d03bc0a85cd73051f979e7e2264e5182ae2 100644 (file)
@@ -1,54 +1,52 @@
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2000-2007 Free Software Foundation Europe e.V.
+   Copyright (C) 2007-2009 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 plus additions
-   that are listed in the file LICENSE.
+   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 General Public License
+   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 John Walker.
+   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.
 */
 /*
- *   Version $Id: batstack.h 4230 2007-02-21 20:07:37Z kerns $
+ *   Version $Id$
  *
  *   Dirk Bartley, March 2007
  */
  
+#include "bat.h"
 #include <QAbstractEventDispatcher>
 #include <QTableWidgetItem>
 #include <QMessageBox>
-#include "bat.h"
 #include "mediaedit.h"
-#include <inttypes.h>
 
 /*
  * A constructor 
  */
-MediaEdit::MediaEdit(QTreeWidgetItem *parentWidget, QString &mediaId)
+MediaEdit::MediaEdit(QTreeWidgetItem *parentWidget, QString &mediaId) 
+  : Pages()
 {
    setupUi(this);
-   m_name = "Media Edit";
-   pgInitialize(parentWidget);
+   pgInitialize(tr("Media Edit"), parentWidget);
    QTreeWidgetItem* thisitem = mainWin->getFromHash(this);
-   thisitem->setIcon(0,QIcon(QString::fromUtf8(":images/cartridge-edit.svg")));
-   m_closeable = true;
+   thisitem->setIcon(0,QIcon(QString::fromUtf8(":images/cartridge-edit.png")));
    dockPage();
    setCurrent();
 
@@ -65,14 +63,12 @@ MediaEdit::MediaEdit(QTreeWidgetItem *parentWidget, QString &mediaId)
    m_status = "";
    m_slot = 0;
 
-   if (!m_console->preventInUseConnect())
-      return;
-
    /* The media's pool */
    poolCombo->addItems(m_console->pool_list);
 
    /* The media's Status */
-   QStringList statusList = (QStringList() << "Full" << "Used" << "Append" << "Error" << "Purged" << "Recycled");
+   QStringList statusList = (QStringList() << "Full" << "Used" << "Append" 
+       << "Error" << "Purged" << "Recycle" << "Read-Only" << "Cleaning");
    statusCombo->addItems(statusList);
 
    /* Set up the query for the default values */
@@ -95,11 +91,15 @@ MediaEdit::MediaEdit(QTreeWidgetItem *parentWidget, QString &mediaId)
       query += field + " AS " + AsList[i];
       i += 1;
    }
+
+   QString where = " WHERE Media.VolumeName = '" + mediaId + "' ";
+   if (mediaId.contains(QRegExp("^[0-9]+$"))) {
+      where = " WHERE Media.MediaId=" + mediaId;
+   }
    query += " FROM Media"
-            " LEFT OUTER JOIN Pool ON (Media.PoolId=Pool.PoolId)"
-            " LEFT OUTER JOIN Pool AS Pol ON (Media.recyclepoolid=Pol.PoolId)"
-            " WHERE Media.MediaId='" + mediaId + "'"
-            " ORDER BY Pool.Name";
+            " JOIN Pool ON (Media.PoolId=Pool.PoolId)"
+            " LEFT OUTER JOIN Pool AS Pol ON (Media.RecyclePoolId=Pol.PoolId)"
+            + where;
 
    if (mainWin->m_sqlDebug) {
       Pmsg1(000, "MediaList query cmd : %s\n",query.toUtf8().data());
@@ -184,16 +184,14 @@ MediaEdit::MediaEdit(QTreeWidgetItem *parentWidget, QString &mediaId)
       else enabledCheck->setCheckState(Qt::Unchecked);
       /* default for recycle pool */
       recyclePoolCombo->addItems(m_console->pool_list);
+      recyclePoolCombo->insertItem(0, "*None*");
       index = recyclePoolCombo->findText(m_recyclePool, Qt::MatchExactly);
       if (index == -1) {
-         recyclePoolCombo->insertItem(0, "");
-         index = recyclePoolCombo->findText(m_recyclePool, Qt::MatchExactly);
-      }
-      if (index != -1) {
-         recyclePoolCombo->setCurrentIndex(index);
+         index = 0;
       }
+      recyclePoolCombo->setCurrentIndex(index);
    } else {
-      QMessageBox::warning(this, "No Volume name", "No Volume name given",
+      QMessageBox::warning(this, tr("No Volume name"), tr("No Volume name given"),
                            QMessageBox::Ok, QMessageBox::Ok);
       return;
    }
@@ -258,7 +256,11 @@ void MediaEdit::okButtonPushed()
       docmd = true;
    }
    if (m_recyclePool != recyclePoolCombo->currentText()) {
-      scmd += " recyclepool=\"" + recyclePoolCombo->currentText() + "\"";
+      scmd += " recyclepool=\"";
+      if (recyclePoolCombo->currentText() != "*None*") {
+         scmd += recyclePoolCombo->currentText();
+      }
+      scmd += "\"";
       docmd = true;
    }
    if (docmd) {