From: Dirk H Bartley Date: Sun, 22 Apr 2007 01:50:10 +0000 (+0000) Subject: Add a consoleCommand to Pages class X-Git-Tag: Release-7.0.0~6540 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=6190fb0275477e2b791cdc0f3dd8d537b3024768;p=bacula%2Fbacula Add a consoleCommand to Pages class Added Storage class and a FileSet class Added a context sensitive menu option for status client from client page Added a context sensitive menu option for status storage from storage page Added a context sensitive menu option for status fileset from fileset page git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@4588 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/qt-console/TODO b/bacula/src/qt-console/TODO index 9f937d4186..06d6eec025 100644 --- a/bacula/src/qt-console/TODO +++ b/bacula/src/qt-console/TODO @@ -3,18 +3,11 @@ dhb Must:: get page selector to follow undocked windows. Otherwise current console won't be current. -Low priority item: -move behavior of: - MainWin::setContextMenuDockText - MainWin::setTreeWidgetItemDockColor -to the pages class +Figure out how to get tables like Joblist to do the equivalent of double clicking +on the separating lines between each of the headings. Add context sensitive options for most commands - -Re-add class for storage, I accidentally reverted because I left -it on my laptop. This is why I like committing often. - -Add class for FileSets +status dir on page select director item Create list of what does not work. @@ -27,15 +20,20 @@ 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... -A Tree widget context sensitive from anywhere a job is listed for -the ability to surf what's on the job. +A Tree widget context sensitive menu option and class to jump from known job +to surf the filestructure on the job. -Think about good ways to clean up the Console creation part of the -loop creating pages. +LOW priority items: -Font is being set on a per console basis, should it be. -Tried to get the settings to write for a second, but not coming up next time +Get rid of "Warning: name layoutWidget is already used" when make uic's resture.ui +move behavior of: + MainWin::setContextMenuDockText + MainWin::setTreeWidgetItemDockColor +to the pages class + +Think about good ways to clean up the Console creation part of the +loop creating pages. ======================================================== Things to do: @@ -56,6 +54,13 @@ global one defined in the mainWin class (if I remember right). ============================================================ DONE: ============================================================ + +Re-add class for storage, I accidentally reverted because I left +it on my laptop. This is why I like committing often. + +Add class for FileSets + + Another idea for what you have implemented: - I think that the dynamic pages that you create on the fly should be nested under the item that creates them more like a diff --git a/bacula/src/qt-console/bat.pro b/bacula/src/qt-console/bat.pro index e91810d71b..d5de17896c 100644 --- a/bacula/src/qt-console/bat.pro +++ b/bacula/src/qt-console/bat.pro @@ -24,7 +24,7 @@ FORMS += restore/restore.ui restore/prerestore.ui restore/brestore.ui FORMS += run/run.ui run/runcmd.ui FORMS += select/select.ui FORMS += medialist/medialist.ui mediaedit/mediaedit.ui joblist/joblist.ui -FORMS += clients/clients.ui +FORMS += clients/clients.ui storage/storage.ui fileset/fileset.ui HEADERS += mainwin.h bat.h bat_conf.h qstd.h SOURCES += main.cpp bat_conf.cpp mainwin.cpp qstd.cpp @@ -68,3 +68,11 @@ SOURCES += joblist/joblist.cpp ## Clients HEADERS += clients/clients.h SOURCES += clients/clients.cpp + +## Storage +HEADERS += storage/storage.h +SOURCES += storage/storage.cpp + +## Fileset +HEADERS += fileset/fileset.h +SOURCES += fileset/fileset.cpp diff --git a/bacula/src/qt-console/clients/clients.cpp b/bacula/src/qt-console/clients/clients.cpp index c10e7d9a91..290d8d2319 100644 --- a/bacula/src/qt-console/clients/clients.cpp +++ b/bacula/src/qt-console/clients/clients.cpp @@ -148,6 +148,7 @@ void Clients::treeItemChanged(QTreeWidgetItem *currentwidgetitem, QTreeWidgetIte int treedepth = previouswidgetitem->data(0, Qt::UserRole).toInt(); if (treedepth == 1){ mp_treeWidget->removeAction(actionListJobsofClient); + mp_treeWidget->removeAction(actionStatusClientInConsole); } } @@ -157,6 +158,7 @@ void Clients::treeItemChanged(QTreeWidgetItem *currentwidgetitem, QTreeWidgetIte * menu is used */ m_currentlyselected=currentwidgetitem->text(0); mp_treeWidget->addAction(actionListJobsofClient); + mp_treeWidget->addAction(actionStatusClientInConsole); } } } @@ -178,6 +180,8 @@ void Clients::createContextMenu() SLOT(populateTree())); connect(actionListJobsofClient, SIGNAL(triggered()), this, SLOT(showJobs())); + connect(actionStatusClientInConsole, SIGNAL(triggered()), this, + SLOT(consoleStatusClient())); } /* @@ -191,6 +195,17 @@ void Clients::showJobs() mainWin->createPageJobList(emptymedia, m_currentlyselected, parentItem); } +/* + * Function responding to actionListJobsofClient which calls mainwin function + * to create a window of a list of jobs of this client. + */ +void Clients::consoleStatusClient() +{ + QString cmd("status client="); + cmd += m_currentlyselected += "\n"; + consoleCommand(cmd); +} + /* * Virtual function which is called when this page is visible on the stack */ diff --git a/bacula/src/qt-console/clients/clients.h b/bacula/src/qt-console/clients/clients.h index 12fa98b675..4d39ef31a4 100644 --- a/bacula/src/qt-console/clients/clients.h +++ b/bacula/src/qt-console/clients/clients.h @@ -56,6 +56,7 @@ public slots: private slots: void populateTree(); void showJobs(); + void consoleStatusClient(); private: void createContextMenu(); diff --git a/bacula/src/qt-console/clients/clients.ui b/bacula/src/qt-console/clients/clients.ui index 7df98614bd..bb08890e65 100644 --- a/bacula/src/qt-console/clients/clients.ui +++ b/bacula/src/qt-console/clients/clients.ui @@ -42,6 +42,14 @@ List Jobs of Client + + + ../images/status.png + + + Status Client In Console + + diff --git a/bacula/src/qt-console/fileset/fileset.cpp b/bacula/src/qt-console/fileset/fileset.cpp new file mode 100644 index 0000000000..da232bfc55 --- /dev/null +++ b/bacula/src/qt-console/fileset/fileset.cpp @@ -0,0 +1,222 @@ +/* + Bacula® - The Network Backup Solution + + Copyright (C) 2000-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. +*/ + +/* + * Version $Id: fileset.cpp 4230 2007-02-21 20:07:37Z kerns $ + * + * FileSet Class + * + * Dirk Bartley, March 2007 + * + */ + +#include +#include +#include "bat.h" +#include "fileset/fileset.h" + +FileSet::FileSet() +{ + setupUi(this); + pgInitialize(); + + /* mp_treeWidget, FileSet Tree Tree Widget inherited from ui_fileset.h */ + m_populated = false; + m_checkcurwidget = true; + m_closeable = false; +} + +FileSet::~FileSet() +{ +} + +/* + * The main meat of the class!! The function that querries the director and + * creates the widgets with appropriate values. + */ +void FileSet::populateTree() +{ + QTreeWidgetItem *filesetItem, *topItem; + + m_checkcurwidget = false; + mp_treeWidget->clear(); + m_checkcurwidget = true; + + QStringList headerlist = (QStringList() << "FileSet Name" << "FileSet Id" + << "Create Time"); + + topItem = new QTreeWidgetItem(mp_treeWidget); + topItem->setText(0, "FileSet"); + topItem->setData(0, Qt::UserRole, 0); + topItem->setExpanded(true); + + mp_treeWidget->setColumnCount(headerlist.count()); + mp_treeWidget->setHeaderLabels(headerlist); + /* This could be a log item */ + //printf("In FileSet::populateTree()\n"); + + foreach(QString filesetName, m_console->fileset_list){ + filesetItem = new QTreeWidgetItem(topItem); + filesetItem->setText(0, filesetName); + filesetItem->setData(0, Qt::UserRole, 1); + filesetItem->setExpanded(true); + + /* Set up query QString and header QStringList */ + QString query(""); + query += "SELECT FileSet AS Name, FileSetId AS Id, CreateTime" + " FROM FileSet" + " WHERE "; + query += " FileSet='" + filesetName + "'"; + query += " ORDER BY FileSet"; + + QStringList results; + /* This could be a log item */ + //printf("FileSet query cmd : %s\n",query.toUtf8().data()); + if (m_console->sql_cmd(query, results)) { + int resultCount = results.count(); + if (resultCount == 1){ + QString resultline; + QString field; + QStringList fieldlist; + /* there will only be one of these */ + foreach (resultline, results) { + fieldlist = resultline.split("\t"); + int index = 0; + /* Iterate through fields in the record */ + foreach (field, fieldlist) { + field = field.trimmed(); /* strip leading & trailing spaces */ + filesetItem->setData(index+1, Qt::UserRole, 1); + /* Put media fields under the pool tree item */ + filesetItem->setData(index+1, Qt::UserRole, 1); + filesetItem->setText(index+1, field); + index++; + } + } + } + } + } +} + +/* + * When the treeWidgetItem in the page selector tree is singleclicked, Make sure + * The tree has been populated. + */ +void FileSet::PgSeltreeWidgetClicked() +{ + if(!m_populated) { + populateTree(); + createContextMenu(); + m_populated=true; + } +} + +/* + * Added to set the context menu policy based on currently active treeWidgetItem + * signaled by currentItemChanged + */ +void FileSet::treeItemChanged(QTreeWidgetItem *currentwidgetitem, QTreeWidgetItem *previouswidgetitem ) +{ + /* m_checkcurwidget checks to see if this is during a refresh, which will segfault */ + if (m_checkcurwidget) { + /* The Previous item */ + if (previouswidgetitem) { /* avoid a segfault if first time */ + int treedepth = previouswidgetitem->data(0, Qt::UserRole).toInt(); + if (treedepth == 1){ + mp_treeWidget->removeAction(actionStatusFileSetInConsole); + } + } + + int treedepth = currentwidgetitem->data(0, Qt::UserRole).toInt(); + if (treedepth == 1){ + /* set a hold variable to the fileset name in case the context sensitive + * menu is used */ + m_currentlyselected=currentwidgetitem->text(0); + mp_treeWidget->addAction(actionStatusFileSetInConsole); + } + } +} + +/* + * Setup a context menu + * Made separate from populate so that it would not create context menu over and + * over as the tree is repopulated. + */ +void FileSet::createContextMenu() +{ + mp_treeWidget->setContextMenuPolicy(Qt::ActionsContextMenu); + mp_treeWidget->addAction(actionRefreshFileSet); + connect(mp_treeWidget, SIGNAL( + currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), + this, SLOT(treeItemChanged(QTreeWidgetItem *, QTreeWidgetItem *))); + /* connect to the action specific to this pages class */ + connect(actionRefreshFileSet, SIGNAL(triggered()), this, + SLOT(populateTree())); + connect(actionStatusFileSetInConsole, SIGNAL(triggered()), this, + SLOT(consoleStatusFileSet())); +} + +/* + * Function responding to actionListJobsofFileSet which calls mainwin function + * to create a window of a list of jobs of this fileset. + */ +void FileSet::consoleStatusFileSet() +{ + QString cmd("status fileset="); + cmd += m_currentlyselected += "\n"; + consoleCommand(cmd); +// m_console->write_dir(cmd.toUtf8().data()); +// m_console->displayToPrompt(); + /* Bring this directors console to the front of the stack */ +// mainWin->treeWidget->setCurrentItem(mainWin->getFromHash(m_console)); +} + +/* + * Virtual function which is called when this page is visible on the stack + */ +void FileSet::currentStackItem() +{ + if(!m_populated) { + populateTree(); + /* add context sensitive menu items specific to this classto the page + * selector tree. m_m_contextActions is QList of QActions, so this is + * only done once with the first population. */ + m_contextActions.append(actionRefreshFileSet); + /* Create the context menu for the fileset tree */ + createContextMenu(); + m_populated=true; + } +} + +/* + * Virtual Function to return the name for the medialist tree widget + */ +void FileSet::treeWidgetName(QString &name) +{ + name = "FileSet"; +} + diff --git a/bacula/src/qt-console/fileset/fileset.h b/bacula/src/qt-console/fileset/fileset.h new file mode 100644 index 0000000000..285b64579b --- /dev/null +++ b/bacula/src/qt-console/fileset/fileset.h @@ -0,0 +1,66 @@ +#ifndef _FILESET_H_ +#define _FILESET_H_ +/* + Bacula® - The Network Backup Solution + + Copyright (C) 2000-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. +*/ +/* + * Version $Id: clients.h 4230 2007-02-21 20:07:37Z kerns $ + * + * Dirk Bartley, March 2007 + */ + +#include +#include "ui_fileset.h" +#include "console.h" +#include "pages.h" + +class FileSet : public Pages, public Ui::FileSetForm +{ + Q_OBJECT + +public: + FileSet(); + ~FileSet(); + virtual void PgSeltreeWidgetClicked(); + virtual void currentStackItem(); + void treeWidgetName(QString &); + +public slots: + void treeItemChanged(QTreeWidgetItem *, QTreeWidgetItem *); + +private slots: + void populateTree(); + void consoleStatusFileSet(); + +private: + void createContextMenu(); + QString m_currentlyselected; + bool m_populated; + bool m_checkcurwidget; +}; + +#endif /* _FILESET_H_ */ diff --git a/bacula/src/qt-console/fileset/fileset.ui b/bacula/src/qt-console/fileset/fileset.ui new file mode 100644 index 0000000000..863a370533 --- /dev/null +++ b/bacula/src/qt-console/fileset/fileset.ui @@ -0,0 +1,48 @@ + + FileSetForm + + + + 0 + 0 + 763 + 650 + + + + FileSet Tree + + + + 9 + + + 6 + + + + + + + + ../images/run.png + + + Refresh FileSet List + + + Requery the director for the list of storage objects. + + + + + ../images/status.png + + + Status FileSet In Console + + + + + + diff --git a/bacula/src/qt-console/mainwin.cpp b/bacula/src/qt-console/mainwin.cpp index 1939461777..ba8b8fe7ab 100644 --- a/bacula/src/qt-console/mainwin.cpp +++ b/bacula/src/qt-console/mainwin.cpp @@ -37,6 +37,8 @@ #include "bat.h" #include "joblist/joblist.h" +#include "storage/storage.h" +#include "fileset/fileset.h" MainWin::MainWin(QWidget *parent) : QMainWindow(parent) { @@ -114,6 +116,8 @@ void MainWin::createPages() QString emptymedia(""), emptyclient(""); createPageJobList(emptymedia, emptyclient, NULL); createPageClients(); + createPageStorage(); + createPageFileSet(); treeWidget->expandItem(topItem); stackedWidget->setCurrentWidget(m_currentConsole); @@ -172,6 +176,23 @@ void MainWin::createPageClients() clients->dockPage(); } +/* + * create an instance of the the storage class on the stack + */ +void MainWin::createPageStorage() +{ + Storage* storage = new Storage(); + storage->dockPage(); +} + +/* + * create an instance of the the fileset class on the stack + */ +void MainWin::createPageFileSet() +{ + FileSet* fileset = new FileSet(); + fileset->dockPage(); +} /* Create a root Tree Widget */ QTreeWidgetItem *MainWin::createTopPage(char *name) diff --git a/bacula/src/qt-console/mainwin.h b/bacula/src/qt-console/mainwin.h index 109ae59846..b568711c4d 100644 --- a/bacula/src/qt-console/mainwin.h +++ b/bacula/src/qt-console/mainwin.h @@ -105,6 +105,8 @@ private: void createPagebRestore(); void createPageMediaList(); void createPageClients(); + void createPageStorage(); + void createPageFileSet(); private: Console *m_currentConsole; diff --git a/bacula/src/qt-console/pages.cpp b/bacula/src/qt-console/pages.cpp index 74cebde6cb..e1cfec9d5d 100644 --- a/bacula/src/qt-console/pages.cpp +++ b/bacula/src/qt-console/pages.cpp @@ -206,3 +206,15 @@ void Pages::treeWidgetName(QString &name) { name = "Default Page Name"; } + +/* + * Function to simplify executing a console command and bringing the + * console to the front of the stack + */ +void Pages::consoleCommand(QString &command) +{ + m_console->write_dir(command.toUtf8().data()); + m_console->displayToPrompt(); + /* Bring this directors console to the front of the stack */ + mainWin->treeWidget->setCurrentItem(mainWin->getFromHash(m_console)); +} diff --git a/bacula/src/qt-console/pages.h b/bacula/src/qt-console/pages.h index aec0d6a0b3..85b99b5f7f 100644 --- a/bacula/src/qt-console/pages.h +++ b/bacula/src/qt-console/pages.h @@ -74,6 +74,7 @@ public slots: protected: void pgInitialize(); void pgInitialize(QTreeWidgetItem *); + void consoleCommand(QString &); bool m_closeable; bool m_docked; virtual void treeWidgetName(QString &); diff --git a/bacula/src/qt-console/storage/storage.cpp b/bacula/src/qt-console/storage/storage.cpp new file mode 100644 index 0000000000..8efd845d78 --- /dev/null +++ b/bacula/src/qt-console/storage/storage.cpp @@ -0,0 +1,222 @@ +/* + Bacula® - The Network Backup Solution + + Copyright (C) 2000-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. +*/ + +/* + * Version $Id: storage.cpp 4230 2007-02-21 20:07:37Z kerns $ + * + * Storage Class + * + * Dirk Bartley, March 2007 + * + */ + +#include +#include +#include "bat.h" +#include "storage/storage.h" + +Storage::Storage() +{ + setupUi(this); + pgInitialize(); + + /* mp_treeWidget, Storage Tree Tree Widget inherited from ui_storage.h */ + m_populated = false; + m_checkcurwidget = true; + m_closeable = false; +} + +Storage::~Storage() +{ +} + +/* + * The main meat of the class!! The function that querries the director and + * creates the widgets with appropriate values. + */ +void Storage::populateTree() +{ + QTreeWidgetItem *storageItem, *topItem; + + m_checkcurwidget = false; + mp_treeWidget->clear(); + m_checkcurwidget = true; + + QStringList headerlist = (QStringList() << "Storage Name" << "Storage Id" + << "Auto Changer"); + + topItem = new QTreeWidgetItem(mp_treeWidget); + topItem->setText(0, "Storage"); + topItem->setData(0, Qt::UserRole, 0); + topItem->setExpanded(true); + + mp_treeWidget->setColumnCount(headerlist.count()); + mp_treeWidget->setHeaderLabels(headerlist); + /* This could be a log item */ + //printf("In Storage::populateTree()\n"); + + foreach(QString storageName, m_console->storage_list){ + storageItem = new QTreeWidgetItem(topItem); + storageItem->setText(0, storageName); + storageItem->setData(0, Qt::UserRole, 1); + 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"; + + QStringList results; + /* This could be a log item */ + //printf("Storage query cmd : %s\n",query.toUtf8().data()); + if (m_console->sql_cmd(query, results)) { + int resultCount = results.count(); + if (resultCount == 1){ + QString resultline; + QString field; + QStringList fieldlist; + /* there will only be one of these */ + foreach (resultline, results) { + fieldlist = resultline.split("\t"); + int index = 0; + /* Iterate through fields in the record */ + foreach (field, fieldlist) { + field = field.trimmed(); /* strip leading & trailing spaces */ + storageItem->setData(index+1, Qt::UserRole, 1); + /* Put media fields under the pool tree item */ + storageItem->setData(index+1, Qt::UserRole, 1); + storageItem->setText(index+1, field); + index++; + } + } + } + } + } +} + +/* + * When the treeWidgetItem in the page selector tree is singleclicked, Make sure + * The tree has been populated. + */ +void Storage::PgSeltreeWidgetClicked() +{ + if(!m_populated) { + populateTree(); + createContextMenu(); + m_populated=true; + } +} + +/* + * Added to set the context menu policy based on currently active treeWidgetItem + * signaled by currentItemChanged + */ +void Storage::treeItemChanged(QTreeWidgetItem *currentwidgetitem, QTreeWidgetItem *previouswidgetitem ) +{ + /* m_checkcurwidget checks to see if this is during a refresh, which will segfault */ + if (m_checkcurwidget) { + /* The Previous item */ + if (previouswidgetitem) { /* avoid a segfault if first time */ + int treedepth = previouswidgetitem->data(0, Qt::UserRole).toInt(); + if (treedepth == 1){ + mp_treeWidget->removeAction(actionStatusStorageInConsole); + } + } + + int treedepth = currentwidgetitem->data(0, Qt::UserRole).toInt(); + if (treedepth == 1){ + /* set a hold variable to the storage name in case the context sensitive + * menu is used */ + m_currentlyselected=currentwidgetitem->text(0); + mp_treeWidget->addAction(actionStatusStorageInConsole); + } + } +} + +/* + * Setup a context menu + * Made separate from populate so that it would not create context menu over and + * over as the tree is repopulated. + */ +void Storage::createContextMenu() +{ + mp_treeWidget->setContextMenuPolicy(Qt::ActionsContextMenu); + mp_treeWidget->addAction(actionRefreshStorage); + connect(mp_treeWidget, SIGNAL( + currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), + this, SLOT(treeItemChanged(QTreeWidgetItem *, QTreeWidgetItem *))); + /* connect to the action specific to this pages class */ + connect(actionRefreshStorage, SIGNAL(triggered()), this, + SLOT(populateTree())); + connect(actionStatusStorageInConsole, SIGNAL(triggered()), this, + SLOT(consoleStatusStorage())); +} + +/* + * Function responding to actionListJobsofStorage which calls mainwin function + * to create a window of a list of jobs of this storage. + */ +void Storage::consoleStatusStorage() +{ + QString cmd("status storage="); + cmd += m_currentlyselected += "\n"; + consoleCommand(cmd); +// m_console->write_dir(cmd.toUtf8().data()); +// m_console->displayToPrompt(); + /* Bring this directors console to the front of the stack */ +// mainWin->treeWidget->setCurrentItem(mainWin->getFromHash(m_console)); +} + +/* + * Virtual function which is called when this page is visible on the stack + */ +void Storage::currentStackItem() +{ + if(!m_populated) { + populateTree(); + /* add context sensitive menu items specific to this classto the page + * selector tree. m_m_contextActions is QList of QActions, so this is + * only done once with the first population. */ + m_contextActions.append(actionRefreshStorage); + /* Create the context menu for the storage tree */ + createContextMenu(); + m_populated=true; + } +} + +/* + * Virtual Function to return the name for the medialist tree widget + */ +void Storage::treeWidgetName(QString &name) +{ + name = "Storage"; +} + diff --git a/bacula/src/qt-console/storage/storage.h b/bacula/src/qt-console/storage/storage.h new file mode 100644 index 0000000000..8b788953d0 --- /dev/null +++ b/bacula/src/qt-console/storage/storage.h @@ -0,0 +1,67 @@ +#ifndef _STORAGE_H_ +#define _STORAGE_H_ +/* + Bacula® - The Network Backup Solution + + Copyright (C) 2000-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. +*/ +/* + * Version $Id: clients.h 4230 2007-02-21 20:07:37Z kerns $ + * + * Dirk Bartley, March 2007 + */ + +#include +#include "ui_storage.h" +#include "console.h" +#include "pages.h" + +class Storage : public Pages, public Ui::StorageForm +{ + Q_OBJECT + +public: + Storage(); + ~Storage(); + virtual void PgSeltreeWidgetClicked(); + virtual void currentStackItem(); + void treeWidgetName(QString &); + +public slots: + void treeItemChanged(QTreeWidgetItem *, QTreeWidgetItem *); + +private slots: + void populateTree(); +// void showJobs(); + void consoleStatusStorage(); + +private: + void createContextMenu(); + QString m_currentlyselected; + bool m_populated; + bool m_checkcurwidget; +}; + +#endif /* _STORAGE_H_ */ diff --git a/bacula/src/qt-console/storage/storage.ui b/bacula/src/qt-console/storage/storage.ui new file mode 100644 index 0000000000..1c1d1eb683 --- /dev/null +++ b/bacula/src/qt-console/storage/storage.ui @@ -0,0 +1,48 @@ + + StorageForm + + + + 0 + 0 + 763 + 650 + + + + Storage Tree + + + + 9 + + + 6 + + + + + + + + ../images/run.png + + + Refresh Storage List + + + Requery the director for the list of storage objects. + + + + + ../images/status.png + + + Status Storage In Console + + + + + +