]> git.sur5r.net Git - bacula/bacula/commitdiff
Add new MediaView
authorEric Bollengier <eric@eb.homelinux.org>
Tue, 20 Oct 2009 09:46:24 +0000 (09:46 +0000)
committerEric Bollengier <eric@eb.homelinux.org>
Tue, 20 Oct 2009 09:46:24 +0000 (09:46 +0000)
bacula/src/qt-console/bat.pro.in
bacula/src/qt-console/medialist/mediaview.cpp [new file with mode: 0644]
bacula/src/qt-console/medialist/mediaview.h [new file with mode: 0644]
bacula/src/qt-console/medialist/mediaview.ui [new file with mode: 0644]

index 7e3b8ebacf3e017e53c420d45cd8e42585a6d13c..cd6359765e5765cbf596f1c57216f3b006ed1e01 100644 (file)
@@ -49,6 +49,7 @@ FORMS += restore/restoretree.ui
 FORMS += run/run.ui run/runcmd.ui run/estimate.ui run/prune.ui
 FORMS += select/select.ui select/textinput.ui
 FORMS += medialist/medialist.ui mediaedit/mediaedit.ui joblist/joblist.ui
+FORMS += medialist/mediaview.ui
 FORMS += clients/clients.ui storage/storage.ui fileset/fileset.ui
 FORMS += joblog/joblog.ui jobs/jobs.ui job/job.ui
 FORMS += help/help.ui mediainfo/mediainfo.ui
@@ -99,6 +100,10 @@ SOURCES += select/select.cpp select/textinput.cpp
 HEADERS += medialist/medialist.h
 SOURCES += medialist/medialist.cpp
 
+# MediaView
+HEADERS += medialist/mediaview.h
+SOURCES += medialist/mediaview.cpp
+
 ## MediaEdit
 HEADERS += mediaedit/mediaedit.h
 SOURCES += mediaedit/mediaedit.cpp
diff --git a/bacula/src/qt-console/medialist/mediaview.cpp b/bacula/src/qt-console/medialist/mediaview.cpp
new file mode 100644 (file)
index 0000000..19d36fe
--- /dev/null
@@ -0,0 +1,214 @@
+/*
+   Bacula® - The Network Backup Solution
+
+   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 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
+   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.
+*/
+#include "bat.h"
+#include <QAbstractEventDispatcher>
+#include <QMenu>
+#include <math.h>
+#include "mediaview.h"
+#include "mediaedit/mediaedit.h"
+#include "mediainfo/mediainfo.h"
+#include "joblist/joblist.h"
+#include "relabel/relabel.h"
+#include "run/run.h"
+#include "util/fmtwidgetitem.h"
+
+MediaView::MediaView()
+{
+   setupUi(this);
+   m_name = tr("Media");
+   pgInitialize();
+   QTreeWidgetItem* thisitem = mainWin->getFromHash(this);
+   thisitem->setIcon(0,QIcon(QString::fromUtf8(":images/cartridge.png")));
+
+   /* mp_treeWidget, Storage Tree Tree Widget inherited from ui_medialist.h */
+   m_populated = false;
+   m_checkcurwidget = true;
+   m_closeable = false;
+}
+
+MediaView::~MediaView()
+{
+}
+
+/*
+ * The main meat of the class!!  The function that querries the director and 
+ * creates the widgets with appropriate values.
+ */
+void MediaView::populateTable()
+{
+   m_populated = true;
+
+   Freeze frz(*m_tableMedia); /* disable updating*/
+
+}
+
+/*
+ * Called from the signal of the context sensitive menu!
+ */
+void MediaView::editVolume()
+{
+   MediaEdit* edit = new MediaEdit(mainWin->getFromHash(this), m_currentVolumeId);
+   connect(edit, SIGNAL(destroyed()), this, SLOT(populateTable()));
+}
+
+/*
+ * Called from the signal of the context sensitive menu!
+ */
+void MediaView::showJobs()
+{
+   QTreeWidgetItem *parentItem = mainWin->getFromHash(this);
+   mainWin->createPageJobList(m_currentVolumeName, "", "", "", parentItem);
+}
+
+/*
+ * Called from the signal of the context sensitive menu!
+ */
+void MediaView::viewVolume()
+{
+   QTreeWidgetItem *parentItem = mainWin->getFromHash(this);
+   MediaInfo* view = new MediaInfo(parentItem, m_currentVolumeName);
+   connect(view, SIGNAL(destroyed()), this, SLOT(populateTable()));
+
+}
+
+/*
+ * When the treeWidgetItem in the page selector tree is singleclicked, Make sure
+ * The tree has been populated.
+ */
+void MediaView::PgSeltreeWidgetClicked()
+{
+   if (!m_populated) {
+      populateTable();
+   }
+   dockPage();
+}
+
+/*
+ * Virtual function which is called when this page is visible on the stack
+ */
+void MediaView::currentStackItem()
+{
+   if(!m_populated) {
+      populateTable();
+   }
+}
+
+/*
+ * Called from the signal of the context sensitive menu to delete a volume!
+ */
+void MediaView::deleteVolume()
+{
+   if (QMessageBox::warning(this, "Bat",
+      tr("Are you sure you want to delete??  !!!.\n"
+"This delete command is used to delete a Volume record and all associated catalog"
+" records that were created. This command operates only on the Catalog"
+" database and has no effect on the actual data written to a Volume. This"
+" command can be dangerous and we strongly recommend that you do not use"
+" it unless you know what you are doing.  All Jobs and all associated"
+" records (File and JobMedia) will be deleted from the catalog."
+      "Press OK to proceed with delete operation.?"),
+      QMessageBox::Ok | QMessageBox::Cancel)
+      == QMessageBox::Cancel) { return; }
+
+   QString cmd("delete volume=");
+   cmd += m_currentVolumeName;
+   consoleCommand(cmd);
+}
+
+/*
+ * Called from the signal of the context sensitive menu to purge!
+ */
+void MediaView::purgeVolume()
+{
+   if (QMessageBox::warning(this, "Bat",
+      tr("Are you sure you want to purge ??  !!!.\n"
+"The Purge command will delete associated Catalog database records from Jobs and"
+" Volumes without considering the retention period. Purge  works only on the"
+" Catalog database and does not affect data written to Volumes. This command can"
+" be dangerous because you can delete catalog records associated with current"
+" backups of files, and we recommend that you do not use it unless you know what"
+" you are doing.\n"
+      "Press OK to proceed with the purge operation?"),
+      QMessageBox::Ok | QMessageBox::Cancel)
+      == QMessageBox::Cancel) { return; }
+
+   QString cmd("purge volume=");
+   cmd += m_currentVolumeName;
+   consoleCommand(cmd);
+   populateTable();
+}
+
+/*
+ * Called from the signal of the context sensitive menu to prune!
+ */
+void MediaView::pruneVolume()
+{
+   new prunePage(m_currentVolumeName, "");
+}
+
+// /*
+//  * Called from the signal of the context sensitive menu to relabel!
+//  */
+// void MediaView::relabelVolume()
+// {
+//    setConsoleCurrent();
+//    new relabelDialog(m_console, m_currentVolumeName);
+// }
+// 
+// /*
+//  * Called from the signal of the context sensitive menu to purge!
+//  */
+// void MediaView::allVolumesFromPool()
+// {
+//    QString cmd = "update volume AllFromPool=" + m_currentVolumeName;
+//    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!
+//   */
+//  void MediaView::volumeFromPool()
+//  {
+//     QTreeWidgetItem *currentItem = mp_treeWidget->currentItem();
+//     QTreeWidgetItem *parent = currentItem->parent();
+//     QString pool = parent->text(0);
+//     QString cmd;
+//     cmd = "update volume=" + m_currentVolumeName + " frompool=" + pool;
+//     consoleCommand(cmd);
+//     populateTable();
+//  }
+//  
diff --git a/bacula/src/qt-console/medialist/mediaview.h b/bacula/src/qt-console/medialist/mediaview.h
new file mode 100644 (file)
index 0000000..e433510
--- /dev/null
@@ -0,0 +1,67 @@
+#ifndef _MEDIAVIEW_H_
+#define _MEDIAVIEW_H_
+/*
+   Bacula® - The Network Backup Solution
+
+   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 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
+   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.
+*/
+
+#include <QtGui>
+#include "ui_mediaview.h"
+#include "console.h"
+#include <qstringlist.h>
+
+class MediaView : public Pages, public Ui::MediaViewForm
+{
+   Q_OBJECT 
+
+public:
+   MediaView();
+   ~MediaView();
+
+private slots:
+   void populateTable();
+   void viewVolume();
+   void editVolume();
+   void deleteVolume();
+   void purgeVolume();
+   void pruneVolume();
+   void showJobs();
+   void PgSeltreeWidgetClicked();
+   void currentStackItem();
+//   void relabelVolume();
+//   void allVolumesFromPool();
+//   void allVolumes();
+//   void volumeFromPool();
+
+private:
+   QString m_currentVolumeName;
+   QString m_currentVolumeId;
+   bool m_populated;
+   bool m_checkcurwidget;
+   QTreeWidgetItem *m_topItem;
+};
+
+#endif /* _MEDIAVIEW_H_ */
diff --git a/bacula/src/qt-console/medialist/mediaview.ui b/bacula/src/qt-console/medialist/mediaview.ui
new file mode 100644 (file)
index 0000000..9b61e8c
--- /dev/null
@@ -0,0 +1,259 @@
+<ui version="4.0" >
+ <class>MediaViewForm</class>
+ <widget class="QWidget" name="MediaViewForm" >
+  <property name="geometry" >
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>949</width>
+    <height>638</height>
+   </rect>
+  </property>
+  <property name="windowTitle" >
+   <string>Form</string>
+  </property>
+  <layout class="QVBoxLayout" >
+   <item>
+    <layout class="QHBoxLayout" >
+     <item>
+      <widget class="QPushButton" name="m_pbEdit" >
+       <property name="text" >
+        <string>Edit</string>
+       </property>
+       <property name="icon" >
+        <iconset resource="../main.qrc" >:/images/edit.png</iconset>
+       </property>
+       <property name="flat" >
+        <bool>true</bool>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QPushButton" name="m_pbPurge" >
+       <property name="text" >
+        <string>Purge</string>
+       </property>
+       <property name="icon" >
+        <iconset resource="../main.qrc" >:/images/purge.png</iconset>
+       </property>
+       <property name="flat" >
+        <bool>true</bool>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QPushButton" name="m_pbDelete" >
+       <property name="text" >
+        <string>Delete</string>
+       </property>
+       <property name="icon" >
+        <iconset resource="../main.qrc" >:/images/purge.png</iconset>
+       </property>
+       <property name="flat" >
+        <bool>true</bool>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QPushButton" name="m_pbPrune" >
+       <property name="text" >
+        <string>Prune</string>
+       </property>
+       <property name="icon" >
+        <iconset resource="../main.qrc" >:/images/edit-cut.png</iconset>
+       </property>
+       <property name="flat" >
+        <bool>true</bool>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <spacer>
+       <property name="orientation" >
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="sizeHint" >
+        <size>
+         <width>40</width>
+         <height>20</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+    </layout>
+   </item>
+   <item>
+    <widget class="QGroupBox" name="groupBox" >
+     <property name="title" >
+      <string>Filter</string>
+     </property>
+     <layout class="QGridLayout" >
+      <item row="0" column="0" >
+       <widget class="QLabel" name="label_2" >
+        <property name="text" >
+         <string>Media Type:</string>
+        </property>
+       </widget>
+      </item>
+      <item row="0" column="1" >
+       <widget class="QComboBox" name="m_cbMediaType" />
+      </item>
+      <item row="0" column="2" >
+       <widget class="QLabel" name="label_4" >
+        <property name="text" >
+         <string>Status:</string>
+        </property>
+       </widget>
+      </item>
+      <item row="0" column="3" >
+       <widget class="QComboBox" name="m_cbStatus" />
+      </item>
+      <item row="0" column="4" >
+       <widget class="QLabel" name="label_6" >
+        <property name="text" >
+         <string>Limit:</string>
+        </property>
+       </widget>
+      </item>
+      <item row="0" column="5" >
+       <widget class="QSpinBox" name="m_sbLimit" />
+      </item>
+      <item row="0" column="6" >
+       <widget class="QLabel" name="label_3" >
+        <property name="text" >
+         <string>Name:</string>
+        </property>
+       </widget>
+      </item>
+      <item row="0" column="7" >
+       <widget class="QLineEdit" name="m_textName" >
+        <property name="sizePolicy" >
+         <sizepolicy vsizetype="Fixed" hsizetype="Maximum" >
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+       </widget>
+      </item>
+      <item row="0" column="8" colspan="2" >
+       <spacer>
+        <property name="orientation" >
+         <enum>Qt::Horizontal</enum>
+        </property>
+        <property name="sizeHint" >
+         <size>
+          <width>40</width>
+          <height>20</height>
+         </size>
+        </property>
+       </spacer>
+      </item>
+      <item row="1" column="0" >
+       <widget class="QLabel" name="label" >
+        <property name="text" >
+         <string>Pool:</string>
+        </property>
+       </widget>
+      </item>
+      <item row="1" column="1" >
+       <widget class="QComboBox" name="m_cbPool" />
+      </item>
+      <item row="1" column="2" >
+       <widget class="QLabel" name="label_5" >
+        <property name="text" >
+         <string>Location:</string>
+        </property>
+       </widget>
+      </item>
+      <item row="1" column="3" >
+       <widget class="QComboBox" name="m_cbLocation" />
+      </item>
+      <item row="1" column="4" colspan="2" >
+       <widget class="QCheckBox" name="m_chkExpired" >
+        <property name="text" >
+         <string>Expired</string>
+        </property>
+       </widget>
+      </item>
+      <item row="1" column="7" colspan="2" >
+       <spacer>
+        <property name="orientation" >
+         <enum>Qt::Horizontal</enum>
+        </property>
+        <property name="sizeHint" >
+         <size>
+          <width>40</width>
+          <height>20</height>
+         </size>
+        </property>
+       </spacer>
+      </item>
+      <item row="1" column="9" >
+       <widget class="QPushButton" name="pushButton" >
+        <property name="text" >
+         <string>Apply</string>
+        </property>
+        <property name="icon" >
+         <iconset resource="../main.qrc" >:/images/view-refresh.png</iconset>
+        </property>
+       </widget>
+      </item>
+     </layout>
+    </widget>
+   </item>
+   <item>
+    <widget class="QTableWidget" name="m_tableMedia" >
+     <column>
+      <property name="text" >
+       <string>Volume Name</string>
+      </property>
+     </column>
+     <column>
+      <property name="text" >
+       <string>Online</string>
+      </property>
+     </column>
+     <column>
+      <property name="text" >
+       <string>Vol Bytes</string>
+      </property>
+     </column>
+     <column>
+      <property name="text" >
+       <string>Vol Usage</string>
+      </property>
+     </column>
+     <column>
+      <property name="text" >
+       <string>Vol Status</string>
+      </property>
+     </column>
+     <column>
+      <property name="text" >
+       <string>Pool</string>
+      </property>
+     </column>
+     <column>
+      <property name="text" >
+       <string>Media Type</string>
+      </property>
+     </column>
+     <column>
+      <property name="text" >
+       <string>Last Written</string>
+      </property>
+     </column>
+     <column>
+      <property name="text" >
+       <string>When expire?</string>
+      </property>
+     </column>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <resources>
+  <include location="../main.qrc" />
+ </resources>
+ <connections/>
+</ui>