From 56d92e52ead269fabd1053492c6006a682473612 Mon Sep 17 00:00:00 2001 From: Eric Bollengier Date: Tue, 20 Oct 2009 09:46:24 +0000 Subject: [PATCH] Add new MediaView --- bacula/src/qt-console/bat.pro.in | 5 + bacula/src/qt-console/medialist/mediaview.cpp | 214 +++++++++++++++ bacula/src/qt-console/medialist/mediaview.h | 67 +++++ bacula/src/qt-console/medialist/mediaview.ui | 259 ++++++++++++++++++ 4 files changed, 545 insertions(+) create mode 100644 bacula/src/qt-console/medialist/mediaview.cpp create mode 100644 bacula/src/qt-console/medialist/mediaview.h create mode 100644 bacula/src/qt-console/medialist/mediaview.ui diff --git a/bacula/src/qt-console/bat.pro.in b/bacula/src/qt-console/bat.pro.in index 7e3b8ebacf..cd6359765e 100644 --- a/bacula/src/qt-console/bat.pro.in +++ b/bacula/src/qt-console/bat.pro.in @@ -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 index 0000000000..19d36fe8b3 --- /dev/null +++ b/bacula/src/qt-console/medialist/mediaview.cpp @@ -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 +#include +#include +#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 index 0000000000..e433510c22 --- /dev/null +++ b/bacula/src/qt-console/medialist/mediaview.h @@ -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 +#include "ui_mediaview.h" +#include "console.h" +#include + +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 index 0000000000..9b61e8cdfc --- /dev/null +++ b/bacula/src/qt-console/medialist/mediaview.ui @@ -0,0 +1,259 @@ + + MediaViewForm + + + + 0 + 0 + 949 + 638 + + + + Form + + + + + + + + Edit + + + :/images/edit.png + + + true + + + + + + + Purge + + + :/images/purge.png + + + true + + + + + + + Delete + + + :/images/purge.png + + + true + + + + + + + Prune + + + :/images/edit-cut.png + + + true + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Filter + + + + + + Media Type: + + + + + + + + + + Status: + + + + + + + + + + Limit: + + + + + + + + + + Name: + + + + + + + + 0 + 0 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Pool: + + + + + + + + + + Location: + + + + + + + + + + Expired + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Apply + + + :/images/view-refresh.png + + + + + + + + + + + Volume Name + + + + + Online + + + + + Vol Bytes + + + + + Vol Usage + + + + + Vol Status + + + + + Pool + + + + + Media Type + + + + + Last Written + + + + + When expire? + + + + + + + + + + + -- 2.39.5