]> git.sur5r.net Git - bacula/bacula/commitdiff
Add a relabel dialog box. It is in context from medialist defaulting in the
authorDirk H Bartley <dbartley@schupan.com>
Sun, 29 Apr 2007 18:34:23 +0000 (18:34 +0000)
committerDirk H Bartley <dbartley@schupan.com>
Sun, 29 Apr 2007 18:34:23 +0000 (18:34 +0000)
media name.  The user must correctly select storage, slot and pool.

git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@4661 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/src/qt-console/TODO
bacula/src/qt-console/bat.pro.in
bacula/src/qt-console/medialist/medialist.cpp
bacula/src/qt-console/medialist/medialist.h
bacula/src/qt-console/medialist/medialist.ui
bacula/src/qt-console/relabel/relabel.cpp [new file with mode: 0644]
bacula/src/qt-console/relabel/relabel.h [new file with mode: 0644]
bacula/src/qt-console/relabel/relabel.ui [new file with mode: 0644]

index 422082cf78901d4fefc8bd28a1b283930f8d1aea..8b67ec8993be1a3f1f1c7a24fe7a51049d3646ca 100644 (file)
@@ -6,9 +6,6 @@ Add context sensitive options for most commands
 status dir on page select director item
 All items with jobid= that I thought could work from joblist are done.
 
-relabel storage=DDS3 oldvolume=ddsvol003 volume=dds3vol003 slot=3 pool=dds3_hope
-in label slot spinner, limit the upper to the value of slots for that storage.
-
 Create list of what does not work.
 
 Ask Kern about bRestore and what to do with it in terms of priorities.  Should
@@ -52,6 +49,9 @@ global one defined in the mainWin class (if I remember right).
 ============================================================
 DONE:
 ============================================================
+relabel storage=DDS3 oldvolume=ddsvol003 volume=dds3vol003 slot=3 pool=dds3_hope
+in label slot spinner, limit the upper to the value of slots for that storage.
+
 Fix bug in myth box not working with .sql query="" command.
 This was a fix in mysql
 
index 64a1e937953d9b63c571d1b1187db09d764fc0e4..93a4a0d5bdfda48694128aeceb064929e0f849e0 100644 (file)
@@ -30,6 +30,7 @@ UI_DIR = ui
 # Main window
 FORMS += main.ui
 FORMS += label/label.ui 
+FORMS += relabel/relabel.ui 
 FORMS += mount/mount.ui
 FORMS += console/console.ui
 FORMS += restore/restore.ui restore/prerestore.ui restore/brestore.ui
@@ -53,6 +54,10 @@ SOURCES += restore/prerestore.cpp restore/restore.cpp restore/brestore.cpp
 HEADERS += label/label.h
 SOURCES += label/label.cpp
 
+# Relabel dialog
+HEADERS += relabel/relabel.h
+SOURCES += relabel/relabel.cpp
+
 # Mount dialog
 HEADERS += mount/mount.h
 SOURCES += mount/mount.cpp
index 53025ac4491e9704efabaa5e095597e1419abb11..06b9d625e714b5ec98b1b60fb909c1e00572dcad 100644 (file)
@@ -41,6 +41,7 @@
 #include "medialist.h"
 #include "mediaedit/mediaedit.h"
 #include "joblist/joblist.h"
+#include "relabel/relabel.h"
 
 MediaList::MediaList()
 {
@@ -182,6 +183,7 @@ void MediaList::treeItemChanged(QTreeWidgetItem *currentwidgetitem, QTreeWidgetI
             mp_treeWidget->removeAction(actionListJobsOnVolume);
             mp_treeWidget->removeAction(actionDeleteVolume);
             mp_treeWidget->removeAction(actionPurgeVolume);
+            mp_treeWidget->removeAction(actionRelabelVolume);
          }
       }
 
@@ -193,6 +195,7 @@ void MediaList::treeItemChanged(QTreeWidgetItem *currentwidgetitem, QTreeWidgetI
          mp_treeWidget->addAction(actionListJobsOnVolume);
          mp_treeWidget->addAction(actionDeleteVolume);
          mp_treeWidget->addAction(actionPurgeVolume);
+         mp_treeWidget->addAction(actionRelabelVolume);
       }
    }
 }
@@ -210,6 +213,7 @@ void MediaList::createContextMenu()
    connect(actionListJobsOnVolume, SIGNAL(triggered()), this, SLOT(showJobs()));
    connect(actionDeleteVolume, SIGNAL(triggered()), this, SLOT(deleteVolume()));
    connect(actionPurgeVolume, SIGNAL(triggered()), this, SLOT(purgeVolume()));
+   connect(actionRelabelVolume, SIGNAL(triggered()), this, SLOT(relabelVolume()));
    connect(mp_treeWidget, SIGNAL(
            currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)),
            this, SLOT(treeItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)));
@@ -252,4 +256,13 @@ void MediaList::purgeVolume()
    QString cmd("purge volume=");
    cmd += m_currentVolumeName;
    consoleCommand(cmd);
+   populateTree();
+}
+/*
+ * Called from the signal of the context sensitive menu!
+ */
+void MediaList::relabelVolume()
+{
+   placeConsoleOnTop();
+   new relabelDialog(m_console, m_currentVolumeName);
 }
index e484d6752a01923d5a300f5023e361f8cfd020d6..35f575821df5d7ec9ea06927afab7aefa423fbef 100644 (file)
@@ -57,6 +57,7 @@ private slots:
    void editVolume();
    void deleteVolume();
    void purgeVolume();
+   void relabelVolume();
 
 private:
    void createContextMenu();
index 77ff35c27a364ec9bb4be0e6da7aa7b9f7f85eb5..69e45d0e481a02a045c962925c23fb7bb5c249e9 100644 (file)
     <string>Purge Volume</string>
    </property>
   </action>
+  <action name="actionRelabelVolume" >
+   <property name="icon" >
+    <iconset>../images/unmark.png</iconset>
+   </property>
+   <property name="text" >
+    <string>Relabel Volume</string>
+   </property>
+  </action>
  </widget>
  <resources/>
  <connections/>
diff --git a/bacula/src/qt-console/relabel/relabel.cpp b/bacula/src/qt-console/relabel/relabel.cpp
new file mode 100644 (file)
index 0000000..27d1e3b
--- /dev/null
@@ -0,0 +1,96 @@
+/*
+   Bacula® - The Network Backup Solution
+
+   Copyright (C) 2007-2007 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.
+
+   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.
+
+   Bacula® is a registered trademark of John Walker.
+   The licensor of Bacula is the Free Software Foundation Europe
+   (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
+   Switzerland, email:ftf@fsfeurope.org.
+*/
+/*
+ *  Label Dialog class
+ *
+ *   Kern Sibbald, February MMVII
+ *
+ */ 
+
+#include "bat.h"
+#include "relabel.h"
+#include <QMessageBox>
+
+/*
+ * An overload of the constructor to have a default storage show in the
+ * combobox on start.  Used from context sensitive in storage class.
+ */
+relabelDialog::relabelDialog(Console *console, QString &fromVolume)
+{
+   m_console = console;
+   m_fromVolume = fromVolume;
+   m_console->notify(false);
+   setupUi(this);
+   storageCombo->addItems(console->storage_list);
+   poolCombo->addItems(console->pool_list);
+   volumeName->setText(fromVolume);
+   QString fromText("From Volume : ");
+   fromText += fromVolume;
+   fromLabel->setText(fromText);
+   this->show();
+}
+
+
+void relabelDialog::accept()
+{
+   QString scmd;
+   if (volumeName->text().toUtf8().data()[0] == 0) {
+      QMessageBox::warning(this, "No Volume name", "No Volume name given",
+                           QMessageBox::Ok, QMessageBox::Ok);
+      return;
+   }
+   if (m_fromVolume == volumeName->text().toUtf8()) {
+      QMessageBox::warning(this, "New name must be different", "New name must be different",
+                           QMessageBox::Ok, QMessageBox::Ok);
+      return;
+   }
+
+   this->hide();
+   scmd = QString("relabel storage=\"%1\" oldvolume=\"%2\" volume=\"%3\" pool=\"%4\" slot=%5")
+                  .arg(storageCombo->currentText())
+                  .arg(m_fromVolume)
+                  .arg(volumeName->text())
+                  .arg(poolCombo->currentText())
+                  .arg(slotSpin->value());
+   /* FIXME Make this a user configurable logging action and dont use printf */
+   //printf("sending command : %s\n",scmd.toUtf8().data());
+   m_console->write_dir(scmd.toUtf8().data());
+   m_console->displayToPrompt();
+   m_console->notify(true);
+   delete this;
+   mainWin->resetFocus();
+}
+
+void relabelDialog::reject()
+{
+   this->hide();
+   m_console->notify(true);
+   delete this;
+   mainWin->resetFocus();
+}
diff --git a/bacula/src/qt-console/relabel/relabel.h b/bacula/src/qt-console/relabel/relabel.h
new file mode 100644 (file)
index 0000000..f870b73
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+   Bacula® - The Network Backup Solution
+
+   Copyright (C) 2007-2007 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.
+
+   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.
+
+   Bacula® is a registered trademark of John Walker.
+   The licensor of Bacula is the Free Software Foundation Europe
+   (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
+   Switzerland, email:ftf@fsfeurope.org.
+*/
+/* 
+ * Kern Sibbald, February MMVII
+ */
+
+#ifndef _RELABEL_H_
+#define _RELABEL_H_
+
+#include <QtGui>
+#include "ui_relabel.h"
+#include "console.h"
+
+class relabelDialog : public QDialog, public Ui::relabelForm
+{
+   Q_OBJECT 
+
+public:
+   relabelDialog(Console *console, QString &fromVolume);
+
+private slots:
+   void accept();
+   void reject();
+
+private:
+   Console *m_console;
+   QString m_fromVolume;
+};
+
+#endif /* _RELABEL_H_ */
diff --git a/bacula/src/qt-console/relabel/relabel.ui b/bacula/src/qt-console/relabel/relabel.ui
new file mode 100644 (file)
index 0000000..4a8b20e
--- /dev/null
@@ -0,0 +1,245 @@
+<ui version="4.0" >
+ <class>relabelForm</class>
+ <widget class="QDialog" name="relabelForm" >
+  <property name="windowModality" >
+   <enum>Qt::WindowModal</enum>
+  </property>
+  <property name="geometry" >
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>400</width>
+    <height>212</height>
+   </rect>
+  </property>
+  <property name="windowTitle" >
+   <string>Label</string>
+  </property>
+  <layout class="QGridLayout" >
+   <property name="margin" >
+    <number>9</number>
+   </property>
+   <property name="spacing" >
+    <number>6</number>
+   </property>
+   <item row="1" column="0" >
+    <widget class="QLabel" name="fromLabel" >
+     <property name="maximumSize" >
+      <size>
+       <width>16777215</width>
+       <height>20</height>
+      </size>
+     </property>
+     <property name="text" >
+      <string>From Volume :</string>
+     </property>
+     <property name="alignment" >
+      <set>Qt::AlignCenter</set>
+     </property>
+    </widget>
+   </item>
+   <item row="2" column="0" >
+    <spacer>
+     <property name="orientation" >
+      <enum>Qt::Vertical</enum>
+     </property>
+     <property name="sizeType" >
+      <enum>QSizePolicy::Maximum</enum>
+     </property>
+     <property name="sizeHint" >
+      <size>
+       <width>382</width>
+       <height>16</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
+   <item row="4" column="0" >
+    <spacer>
+     <property name="orientation" >
+      <enum>Qt::Vertical</enum>
+     </property>
+     <property name="sizeType" >
+      <enum>QSizePolicy::Maximum</enum>
+     </property>
+     <property name="sizeHint" >
+      <size>
+       <width>21</width>
+       <height>16</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
+   <item row="5" column="0" >
+    <widget class="QDialogButtonBox" name="buttonBox" >
+     <property name="orientation" >
+      <enum>Qt::Horizontal</enum>
+     </property>
+     <property name="standardButtons" >
+      <set>QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set>
+     </property>
+    </widget>
+   </item>
+   <item row="3" column="0" >
+    <layout class="QGridLayout" >
+     <property name="margin" >
+      <number>0</number>
+     </property>
+     <property name="spacing" >
+      <number>6</number>
+     </property>
+     <item row="3" column="1" >
+      <widget class="QSpinBox" name="slotSpin" >
+       <property name="maximum" >
+        <number>10000</number>
+       </property>
+      </widget>
+     </item>
+     <item row="1" column="0" >
+      <widget class="QLabel" name="label_3" >
+       <property name="text" >
+        <string>Pool:</string>
+       </property>
+       <property name="buddy" >
+        <cstring>poolCombo</cstring>
+       </property>
+      </widget>
+     </item>
+     <item row="0" column="0" >
+      <widget class="QLabel" name="label_2" >
+       <property name="text" >
+        <string>Storage:</string>
+       </property>
+       <property name="buddy" >
+        <cstring>storageCombo</cstring>
+       </property>
+      </widget>
+     </item>
+     <item row="2" column="1" >
+      <widget class="QLineEdit" name="volumeName" >
+       <property name="minimumSize" >
+        <size>
+         <width>200</width>
+         <height>0</height>
+        </size>
+       </property>
+      </widget>
+     </item>
+     <item row="1" column="1" >
+      <widget class="QComboBox" name="poolCombo" />
+     </item>
+     <item row="2" column="0" >
+      <widget class="QLabel" name="label_5" >
+       <property name="text" >
+        <string>New Volume Name:</string>
+       </property>
+       <property name="buddy" >
+        <cstring>volumeName</cstring>
+       </property>
+      </widget>
+     </item>
+     <item row="0" column="1" >
+      <widget class="QComboBox" name="storageCombo" />
+     </item>
+     <item row="3" column="0" >
+      <widget class="QLabel" name="label_4" >
+       <property name="text" >
+        <string>Slot:</string>
+       </property>
+       <property name="buddy" >
+        <cstring>slotSpin</cstring>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+   <item row="0" column="0" >
+    <layout class="QHBoxLayout" >
+     <property name="margin" >
+      <number>0</number>
+     </property>
+     <property name="spacing" >
+      <number>6</number>
+     </property>
+     <item>
+      <spacer>
+       <property name="orientation" >
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="sizeHint" >
+        <size>
+         <width>71</width>
+         <height>21</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+     <item>
+      <widget class="QLabel" name="label" >
+       <property name="maximumSize" >
+        <size>
+         <width>16777215</width>
+         <height>30</height>
+        </size>
+       </property>
+       <property name="text" >
+        <string>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;style type="text/css">
+p, li { white-space: pre-wrap; }
+&lt;/style>&lt;/head>&lt;body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal; text-decoration:none;">
+&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">&lt;span style=" font-size:12pt; font-weight:600;">Relabel a Volume&lt;/span>&lt;/p>&lt;/body>&lt;/html></string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <spacer>
+       <property name="orientation" >
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="sizeHint" >
+        <size>
+         <width>81</width>
+         <height>20</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+    </layout>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>accepted()</signal>
+   <receiver>relabelForm</receiver>
+   <slot>accept()</slot>
+   <hints>
+    <hint type="sourcelabel" >
+     <x>248</x>
+     <y>254</y>
+    </hint>
+    <hint type="destinationlabel" >
+     <x>157</x>
+     <y>274</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>rejected()</signal>
+   <receiver>relabelForm</receiver>
+   <slot>reject()</slot>
+   <hints>
+    <hint type="sourcelabel" >
+     <x>316</x>
+     <y>260</y>
+    </hint>
+    <hint type="destinationlabel" >
+     <x>286</x>
+     <y>274</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
+</ui>