From de3daf83749b7197ab7a3c9e4e60023ea9e9232e Mon Sep 17 00:00:00 2001 From: Dirk H Bartley Date: Sun, 29 Apr 2007 14:27:46 +0000 Subject: [PATCH] Added delete and purge options in medialist. Shorten headings to get more to show up. Now I am testing with my companies old DDS3 autochangers. Added mount dialog so that if a mount is requested on an autochanger, a dialog asks the user which slot. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@4654 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/qt-console/TODO | 8 +- bacula/src/qt-console/bat.pro.in | 6 +- bacula/src/qt-console/joblist/joblist.cpp | 2 +- bacula/src/qt-console/label/label.cpp | 2 + bacula/src/qt-console/mediaedit/mediaedit.cpp | 2 +- bacula/src/qt-console/medialist/medialist.cpp | 40 +++- bacula/src/qt-console/medialist/medialist.h | 7 +- bacula/src/qt-console/medialist/medialist.ui | 16 ++ bacula/src/qt-console/mount/mount.cpp | 89 ++++++++ bacula/src/qt-console/mount/mount.h | 55 +++++ bacula/src/qt-console/mount/mount.ui | 199 ++++++++++++++++++ bacula/src/qt-console/pages.cpp | 10 +- bacula/src/qt-console/pages.h | 1 + bacula/src/qt-console/storage/storage.cpp | 27 ++- bacula/src/qt-console/storage/storage.h | 1 + 15 files changed, 440 insertions(+), 25 deletions(-) create mode 100644 bacula/src/qt-console/mount/mount.cpp create mode 100644 bacula/src/qt-console/mount/mount.h create mode 100644 bacula/src/qt-console/mount/mount.ui diff --git a/bacula/src/qt-console/TODO b/bacula/src/qt-console/TODO index a728b08163..422082cf78 100644 --- a/bacula/src/qt-console/TODO +++ b/bacula/src/qt-console/TODO @@ -6,13 +6,14 @@ 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 that be working before an initial release. -Fix bug in myth box not working with .sql query="" command. - Create documentation for any other developers interested in creating new classes to add more pages. Explain how to use the pages class and about not populating until the tree widget is clicked etc... @@ -51,6 +52,9 @@ global one defined in the mainWin class (if I remember right). ============================================================ DONE: ============================================================ +Fix bug in myth box not working with .sql query="" command. +This was a fix in mysql + Figure out how to get tables like Joblist to do the equivalent of double clicking on the separating lines between each of the headings. Tried the hard way first. Oops. diff --git a/bacula/src/qt-console/bat.pro.in b/bacula/src/qt-console/bat.pro.in index 6371b5d86d..a7ee540f28 100644 --- a/bacula/src/qt-console/bat.pro.in +++ b/bacula/src/qt-console/bat.pro.in @@ -29,7 +29,7 @@ UI_DIR = ui # Main window FORMS += main.ui -FORMS += label/label.ui +FORMS += label/label.ui mount/mount.ui FORMS += console/console.ui FORMS += restore/restore.ui restore/prerestore.ui restore/brestore.ui FORMS += run/run.ui run/runcmd.ui @@ -52,6 +52,10 @@ SOURCES += restore/prerestore.cpp restore/restore.cpp restore/brestore.cpp HEADERS += label/label.h SOURCES += label/label.cpp +# Mount dialog +HEADERS += mount/mount.h +SOURCES += mount/mount.cpp + # Run dialog HEADERS += run/run.h SOURCES += run/run.cpp run/runcmd.cpp diff --git a/bacula/src/qt-console/joblist/joblist.cpp b/bacula/src/qt-console/joblist/joblist.cpp index 2298d0e562..fc3eabe327 100644 --- a/bacula/src/qt-console/joblist/joblist.cpp +++ b/bacula/src/qt-console/joblist/joblist.cpp @@ -70,7 +70,7 @@ void JobList::populateTable() /* Set up query QString and header QStringList */ QString query(""); - query += "SELECT Job.Jobid AS Id, Job.Name AS JobName, Client.Name AS Client," + query += "SELECT DISTINCT Job.Jobid AS Id, Job.Name AS JobName, Client.Name AS Client," " Job.Starttime AS JobStart, Job.Type AS JobType," " Job.Level AS BackupLevel, Job.Jobfiles AS FileCount," " Job.JobBytes AS Bytes, Job.JobStatus AS Status" diff --git a/bacula/src/qt-console/label/label.cpp b/bacula/src/qt-console/label/label.cpp index f9566f7e73..9f5556c8c7 100644 --- a/bacula/src/qt-console/label/label.cpp +++ b/bacula/src/qt-console/label/label.cpp @@ -84,6 +84,8 @@ void labelDialog::accept() .arg(poolCombo->currentText()) .arg(storageCombo->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); diff --git a/bacula/src/qt-console/mediaedit/mediaedit.cpp b/bacula/src/qt-console/mediaedit/mediaedit.cpp index 851051d482..ecd9b6df51 100644 --- a/bacula/src/qt-console/mediaedit/mediaedit.cpp +++ b/bacula/src/qt-console/mediaedit/mediaedit.cpp @@ -55,7 +55,7 @@ MediaEdit::MediaEdit(Console *console, QString &mediaId) poolCombo->addItems(console->pool_list); /* The media's Status */ - QStringList statusList = (QStringList() << "Full" << "Append" << "Error"); + QStringList statusList = (QStringList() << "Full" << "Append" << "Error" << "Purged" << "Recycled"); statusCombo->addItems(statusList); /* Set up the query for the default values */ diff --git a/bacula/src/qt-console/medialist/medialist.cpp b/bacula/src/qt-console/medialist/medialist.cpp index 0e3d7d52ce..53025ac449 100644 --- a/bacula/src/qt-console/medialist/medialist.cpp +++ b/bacula/src/qt-console/medialist/medialist.cpp @@ -68,8 +68,8 @@ void MediaList::populateTree() QTreeWidgetItem *mediatreeitem, *pooltreeitem, *topItem; QStringList headerlist = (QStringList() - << "Volume Name" << "Media Id" << "Volume Status" << "Enabled" - << "Volume Bytes" << "Volume Files" << "Volume Jobs" << "Volume Retention" + << "Volume Name" << "Id" << "Status" << "Enabled" + << "Bytes" << "Files" << "Jobs" << "Retention" << "Media Type" << "Slot" << "Last Written"); m_checkcurwidget = false; @@ -137,9 +137,9 @@ void MediaList::populateTree() /* * Called from the signal of the context sensitive menu! */ -void MediaList::editMedia() +void MediaList::editVolume() { - MediaEdit* edit = new MediaEdit(m_console, m_currentlyselected); + MediaEdit* edit = new MediaEdit(m_console, m_currentVolumeId); connect(edit, SIGNAL(destroyed()), this, SLOT(populateTree())); } @@ -150,7 +150,7 @@ void MediaList::showJobs() { QString emptyclient(""); QTreeWidgetItem *parentItem = mainWin->getFromHash(this); - mainWin->createPageJobList(m_currentlyselected, emptyclient, parentItem); + mainWin->createPageJobList(m_currentVolumeName, emptyclient, parentItem); } /* @@ -180,14 +180,19 @@ void MediaList::treeItemChanged(QTreeWidgetItem *currentwidgetitem, QTreeWidgetI if (treedepth == 2){ mp_treeWidget->removeAction(actionEditVolume); mp_treeWidget->removeAction(actionListJobsOnVolume); + mp_treeWidget->removeAction(actionDeleteVolume); + mp_treeWidget->removeAction(actionPurgeVolume); } } int treedepth = currentwidgetitem->data(0, Qt::UserRole).toInt(); if (treedepth == 2){ - m_currentlyselected=currentwidgetitem->text(1); + m_currentVolumeName=currentwidgetitem->text(0); + m_currentVolumeId=currentwidgetitem->text(1); mp_treeWidget->addAction(actionEditVolume); mp_treeWidget->addAction(actionListJobsOnVolume); + mp_treeWidget->addAction(actionDeleteVolume); + mp_treeWidget->addAction(actionPurgeVolume); } } } @@ -201,8 +206,10 @@ void MediaList::createContextMenu() { mp_treeWidget->setContextMenuPolicy(Qt::ActionsContextMenu); mp_treeWidget->addAction(actionRefreshMediaList); - connect(actionEditVolume, SIGNAL(triggered()), this, SLOT(editMedia())); + connect(actionEditVolume, SIGNAL(triggered()), this, SLOT(editVolume())); connect(actionListJobsOnVolume, SIGNAL(triggered()), this, SLOT(showJobs())); + connect(actionDeleteVolume, SIGNAL(triggered()), this, SLOT(deleteVolume())); + connect(actionPurgeVolume, SIGNAL(triggered()), this, SLOT(purgeVolume())); connect(mp_treeWidget, SIGNAL( currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), this, SLOT(treeItemChanged(QTreeWidgetItem *, QTreeWidgetItem *))); @@ -227,3 +234,22 @@ void MediaList::currentStackItem() m_populated=true; } } + +/* + * Called from the signal of the context sensitive menu! + */ +void MediaList::deleteVolume() +{ + QString cmd("delete volume="); + cmd += m_currentVolumeName; + consoleCommand(cmd); +} +/* + * Called from the signal of the context sensitive menu! + */ +void MediaList::purgeVolume() +{ + QString cmd("purge volume="); + cmd += m_currentVolumeName; + consoleCommand(cmd); +} diff --git a/bacula/src/qt-console/medialist/medialist.h b/bacula/src/qt-console/medialist/medialist.h index a86d22b555..e484d6752a 100644 --- a/bacula/src/qt-console/medialist/medialist.h +++ b/bacula/src/qt-console/medialist/medialist.h @@ -54,11 +54,14 @@ public slots: private slots: void populateTree(); void showJobs(); - void editMedia(); + void editVolume(); + void deleteVolume(); + void purgeVolume(); private: void createContextMenu(); - QString m_currentlyselected; + QString m_currentVolumeName; + QString m_currentVolumeId; bool m_populated; bool m_checkcurwidget; }; diff --git a/bacula/src/qt-console/medialist/medialist.ui b/bacula/src/qt-console/medialist/medialist.ui index 4531d2939d..df0b106bd9 100644 --- a/bacula/src/qt-console/medialist/medialist.ui +++ b/bacula/src/qt-console/medialist/medialist.ui @@ -50,6 +50,22 @@ List Jobs On Volume + + + ../images/unmark.png + + + Delete Volume + + + + + ../images/unmark.png + + + Purge Volume + + diff --git a/bacula/src/qt-console/mount/mount.cpp b/bacula/src/qt-console/mount/mount.cpp new file mode 100644 index 0000000000..53dc9a919e --- /dev/null +++ b/bacula/src/qt-console/mount/mount.cpp @@ -0,0 +1,89 @@ +/* + 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 "mount/mount.h" +#include + +/* + * A constructor + */ +mountDialog::mountDialog(Console *console, QString &storageName) +{ + m_console = console; + m_storageName = storageName; + m_console->notify(false); + setupUi(this); + this->show(); + + QString labelText("Storage : "); + labelText += storageName; + storageLabel->setText(labelText); +} + +void mountDialog::accept() +{ + QString scmd; + if (m_storageName == "") { + QMessageBox::warning(this, "No Storage name", "No Storage name given", + QMessageBox::Ok, QMessageBox::Ok); + return; + } + this->hide(); + scmd = QString("mount storage=\"%1\" slot=%2") + .arg(m_storageName) + .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->display_text("Context sensitive command :\n\n"); + m_console->display_text("**** "); + m_console->display_text(scmd + " ****\n"); + m_console->display_text("Director Response :\n\n"); + + m_console->write_dir(scmd.toUtf8().data()); + m_console->displayToPrompt(); + m_console->notify(true); + delete this; + mainWin->resetFocus(); +} + +void mountDialog::reject() +{ + this->hide(); + m_console->notify(true); + delete this; + mainWin->resetFocus(); +} diff --git a/bacula/src/qt-console/mount/mount.h b/bacula/src/qt-console/mount/mount.h new file mode 100644 index 0000000000..4919291c6f --- /dev/null +++ b/bacula/src/qt-console/mount/mount.h @@ -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 _MOUNT_H_ +#define _MOUNT_H_ + +#include +#include "ui_mount.h" +#include "console.h" + +class mountDialog : public QDialog, public Ui::mountForm +{ + Q_OBJECT + +public: + mountDialog(Console *console, QString &storage); + +private slots: + void accept(); + void reject(); + +private: + Console *m_console; + QString m_storageName; +}; + +#endif /* _MOUNT_H_ */ diff --git a/bacula/src/qt-console/mount/mount.ui b/bacula/src/qt-console/mount/mount.ui new file mode 100644 index 0000000000..fbd2c51e5c --- /dev/null +++ b/bacula/src/qt-console/mount/mount.ui @@ -0,0 +1,199 @@ + + mountForm + + + Qt::WindowModal + + + + 0 + 0 + 400 + 300 + + + + Label + + + + 9 + + + 6 + + + + + + 16777215 + 20 + + + + TextLabel + + + Qt::AlignCenter + + + + + + + 0 + + + 6 + + + + + Slot: + + + slotSpin + + + + + + + 10000 + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok + + + + + + + Qt::Vertical + + + QSizePolicy::Maximum + + + + 21 + 16 + + + + + + + + 0 + + + 6 + + + + + Qt::Horizontal + + + + 71 + 21 + + + + + + + + + 16777215 + 30 + + + + <html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal; text-decoration:none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:12pt; font-weight:600;">Mount a Slot</span></p></body></html> + + + + + + + Qt::Horizontal + + + + 81 + 20 + + + + + + + + + + Qt::Vertical + + + QSizePolicy::Maximum + + + + 382 + 16 + + + + + + + + + + buttonBox + accepted() + mountForm + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + mountForm + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/bacula/src/qt-console/pages.cpp b/bacula/src/qt-console/pages.cpp index 4076171dea..3bb4dc7999 100644 --- a/bacula/src/qt-console/pages.cpp +++ b/bacula/src/qt-console/pages.cpp @@ -216,7 +216,7 @@ void Pages::consoleCommand(QString &command) if (!m_console->is_connectedGui()) return; /* Bring this directors console to the front of the stack */ - mainWin->treeWidget->setCurrentItem(mainWin->getFromHash(m_console)); + placeConsoleOnTop(); m_console->display_text("Context sensitive command :\n\n"); m_console->display_text("**** "); m_console->display_text(command + " ****\n"); @@ -251,3 +251,11 @@ void Pages::setTitle() title += director; setWindowTitle(title); } + +/* + * Bring the current directors console window to the top of the stack. + */ +void Pages::placeConsoleOnTop() +{ + mainWin->treeWidget->setCurrentItem(mainWin->getFromHash(m_console)); +} diff --git a/bacula/src/qt-console/pages.h b/bacula/src/qt-console/pages.h index 17718f7ea1..2294af580c 100644 --- a/bacula/src/qt-console/pages.h +++ b/bacula/src/qt-console/pages.h @@ -77,6 +77,7 @@ protected: void consoleCommand(QString &); virtual void treeWidgetName(QString &); virtual void changeEvent(QEvent *event); + void placeConsoleOnTop(); void setTitle(); bool m_closeable; bool m_docked; diff --git a/bacula/src/qt-console/storage/storage.cpp b/bacula/src/qt-console/storage/storage.cpp index bab484261a..b08b53db56 100644 --- a/bacula/src/qt-console/storage/storage.cpp +++ b/bacula/src/qt-console/storage/storage.cpp @@ -39,6 +39,7 @@ #include #include "bat.h" #include "storage/storage.h" +#include "mount/mount.h" Storage::Storage() { @@ -90,12 +91,10 @@ void Storage::populateTree() storageItem->setExpanded(true); /* Set up query QString and header QStringList */ - QString query(""); - query += "SELECT Name AS StorageName, StorageId AS ID, AutoChanger" - " FROM Storage" - " WHERE "; - query += " Name='" + storageName + "'"; - query += " ORDER BY Name"; + QString query("SELECT StorageId AS ID, AutoChanger AS Changer" + " FROM Storage WHERE"); + query += " Name='" + storageName + "'" + " ORDER BY Name"; QStringList results; /* This could be a log item */ @@ -165,7 +164,8 @@ void Storage::treeItemChanged(QTreeWidgetItem *currentwidgetitem, QTreeWidgetIte if (treedepth == 1){ /* set a hold variable to the storage name in case the context sensitive * menu is used */ - m_currentStorage=currentwidgetitem->text(0); + m_currentStorage = currentwidgetitem->text(0); + m_currentAutoChanger = currentwidgetitem->text(2).toInt(); mp_treeWidget->addAction(actionStatusStorageInConsole); mp_treeWidget->addAction(actionLabelStorage); mp_treeWidget->addAction(actionMountStorage); @@ -241,9 +241,16 @@ void Storage::consoleLabelStorage() } void Storage::consoleMountStorage() { - QString cmd("mount storage="); - cmd += m_currentStorage; - consoleCommand(cmd); + if (m_currentAutoChanger == 0){ + /* no autochanger, just execute the command in the console */ + QString cmd("mount storage="); + cmd += m_currentStorage; + consoleCommand(cmd); + } else { + placeConsoleOnTop(); + /* if this storage is an autochanger, lets ask for the slot */ + new mountDialog(m_console, m_currentStorage); + } } void Storage::consoleUnMountStorage() { diff --git a/bacula/src/qt-console/storage/storage.h b/bacula/src/qt-console/storage/storage.h index 2079a9b109..b22f196daa 100644 --- a/bacula/src/qt-console/storage/storage.h +++ b/bacula/src/qt-console/storage/storage.h @@ -62,6 +62,7 @@ private slots: private: void createContextMenu(); QString m_currentStorage; + int m_currentAutoChanger; bool m_populated; bool m_checkcurwidget; }; -- 2.39.5