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
HEADERS += mainwin.h bat.h bat_conf.h qstd.h
SOURCES += main.cpp bat_conf.cpp mainwin.cpp qstd.cpp
## JobList
HEADERS += joblist/joblist.h
SOURCES += joblist/joblist.cpp
+
+## Clients
+HEADERS += clients/clients.h
+SOURCES += clients/clients.cpp
--- /dev/null
+/*
+ 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: client.cpp 4230 2007-02-21 20:07:37Z kerns $
+ *
+ * Clients Class
+ *
+ * Dirk Bartley, March 2007
+ *
+ */
+
+#include <QAbstractEventDispatcher>
+#include <QMenu>
+#include "bat.h"
+#include "clients/clients.h"
+
+Clients::Clients(QStackedWidget *parent, Console *console)
+{
+ setupUi(this);
+
+ /* mp_treeWidget, Storage Tree Tree Widget inherited from ui_client.h */
+ mp_console = console;
+ m_parent = parent;
+ m_populated = false;
+ m_checkcurwidget = true;
+ m_closeable = false;
+}
+
+Clients::~Clients()
+{
+}
+
+/*
+ * The main meat of the class!! The function that querries the director and
+ * creates the widgets with appropriate values.
+ */
+void Clients::populateTree()
+{
+ QTreeWidgetItem *clientItem, *topItem;
+
+ m_checkcurwidget = false;
+ mp_treeWidget->clear();
+ m_checkcurwidget = true;
+
+ QStringList headerlist = (QStringList() << "Client Name" << "File Retention"
+ << "Job Retention" << "AutoPrune" << "ClientId" << "Uname" );
+
+ topItem = new QTreeWidgetItem(mp_treeWidget);
+ topItem->setText(0, "Clients");
+ 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 Clients::populateTree()\n");
+
+ foreach(QString clientName, mp_console->client_list){
+ clientItem = new QTreeWidgetItem(topItem);
+ clientItem->setText(0, clientName);
+ clientItem->setData(0, Qt::UserRole, 1);
+ clientItem->setExpanded(true);
+
+ /* Set up query QString and header QStringList */
+ QString query("");
+ query += "SELECT FileRetention, JobRetention, AutoPrune, ClientId, Uname"
+ " FROM client"
+ " WHERE ";
+ query += " Name='" + clientName + "'";
+ query += " ORDER BY Name";
+
+ QStringList results;
+ /* This could be a log item */
+ //printf("Clients query cmd : %s\n",query.toUtf8().data());
+ if (mp_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 */
+ clientItem->setData(index+1, Qt::UserRole, 1);
+ /* Put media fields under the pool tree item */
+ clientItem->setData(index+1, Qt::UserRole, 1);
+ clientItem->setText(index+1, field);
+ index++;
+ }
+ }
+ }
+ }
+ }
+}
+
+/*
+ * When the treeWidgetItem in the page selector tree is singleclicked, Make sure
+ * The tree has been populated.
+ */
+void Clients::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 Clients::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(actionEditVolume);
+ }
+ }
+
+ int treedepth = currentwidgetitem->data(0, Qt::UserRole).toInt();
+ if (treedepth == 1){
+ /* set a hold variable to the client name in case the context sensitive
+ * menu is used */
+ m_currentlyselected=currentwidgetitem->text(1);
+// mp_treeWidget->addAction(actionEditVolume);
+ }
+ }
+}
+
+/*
+ * 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 Clients::createContextMenu()
+{
+ mp_treeWidget->setContextMenuPolicy(Qt::ActionsContextMenu);
+ mp_treeWidget->addAction(actionRefreshClients);
+ connect(mp_treeWidget, SIGNAL(
+ currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)),
+ this, SLOT(treeItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)));
+ /* connect to the action specific to this pages class */
+ connect(actionRefreshClients, SIGNAL(triggered()), this,
+ SLOT(populateTree()));
+}
+
+/*
+ * Virtual function which is called when this page is visible on the stack
+ */
+void Clients::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(actionRefreshClients);
+ /* Create the context menu for the client tree */
+ createContextMenu();
+ m_populated=true;
+ }
+}
--- /dev/null
+#ifndef _CLIENTS_H_g
+#define _CLIENTS_H_g
+/*
+ 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 <QtGui>
+#include "ui_clients.h"
+#include "console.h"
+#include "pages.h"
+//#include <qstringlist.h>
+
+class Clients : public Pages, public Ui::ClientForm
+{
+ Q_OBJECT
+
+public:
+ Clients(QStackedWidget *parent, Console *console);
+ ~Clients();
+ virtual void PgSeltreeWidgetClicked();
+ virtual void currentStackItem();
+
+public slots:
+ void treeItemChanged(QTreeWidgetItem *, QTreeWidgetItem *);
+
+private slots:
+ void populateTree();
+
+private:
+ void createContextMenu();
+
+private:
+ Console *mp_console;
+ QString m_currentlyselected;
+ bool m_populated;
+ bool m_checkcurwidget;
+};
+
+#endif /* _CLIENTS_H_g */
--- /dev/null
+<ui version="4.0" >
+ <class>ClientForm</class>
+ <widget class="QWidget" name="ClientForm" >
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>763</width>
+ <height>650</height>
+ </rect>
+ </property>
+ <property name="windowTitle" >
+ <string>Client Tree</string>
+ </property>
+ <layout class="QGridLayout" >
+ <property name="margin" >
+ <number>9</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item row="0" column="0" >
+ <widget class="QTreeWidget" name="mp_treeWidget" />
+ </item>
+ </layout>
+ <action name="actionRefreshClients" >
+ <property name="icon" >
+ <iconset>../images/run.png</iconset>
+ </property>
+ <property name="text" >
+ <string>Refresh Client List</string>
+ </property>
+ <property name="statusTip" >
+ <string>Requery the director for the list of clients.</string>
+ </property>
+ </action>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
m_populated = false;
m_closeable = false;
/* connect to the action specific to this pages class */
- connect(actionRepopulateJobList, SIGNAL(triggered()), this,
+ connect(actionRefreshJobList, SIGNAL(triggered()), this,
SLOT(populateTable()));
}
{
if (!m_populated) {
populateTable();
- m_contextActions.append(actionRepopulateJobList);
+ m_contextActions.append(actionRefreshJobList);
m_populated=true;
}
}
<widget class="QTableWidget" name="mp_tableWidget" />
</item>
</layout>
- <action name="actionRepopulateJobList" >
+ <action name="actionRefreshJobList" >
<property name="icon" >
<iconset>../images/run.png</iconset>
</property>
<property name="text" >
- <string>Repopulate Job List</string>
+ <string>Refresh Job List</string>
</property>
<property name="statusTip" >
<string>Requery the director for the list of jobs.</string>
/* create instances of the rest of the classes that will by default exist
* under each director */
- createPagebrestore();
- createPagemedialist();
+ createPagebRestore();
+ createPageMediaList();
QString emptymedia("");
- createPagejoblist(emptymedia);
+ createPageJobList(emptymedia);
+ createPageClients();
treeWidget->expandItem(m_topItem);
stackedWidget->setCurrentWidget(m_console);
/*
* create an instance of the the brestore class on the stack
*/
-void MainWin::createPagebrestore()
+void MainWin::createPagebRestore()
{
QTreeWidgetItem *item=createPage("brestore", m_topItem);
bRestore* brestore = new bRestore(stackedWidget);
/*
* create an instance of the the medialist class on the stack
*/
-void MainWin::createPagemedialist()
+void MainWin::createPageMediaList()
{
QTreeWidgetItem *item=createPage("Media", m_topItem);
MediaList* medialist = new MediaList(stackedWidget, m_console);
/*
* create an instance of the the joblist class on the stack
*/
-void MainWin::createPagejoblist(QString &media)
+void MainWin::createPageJobList(QString &media)
{
QTreeWidgetItem *item, *holdItem;
/* save current tree widget item in case query produces no results */
}
}
+/*
+ * create an instance of the the Clients class on the stack
+ */
+void MainWin::createPageClients()
+{
+ QTreeWidgetItem *item=createPage("Clients", m_topItem);
+ Clients* clients = new Clients(stackedWidget, m_console);
+ hashInsert(item, clients);
+ clients->dockPage();
+}
+
+
/* Create a root Tree Widget */
QTreeWidgetItem *MainWin::createTopPage(char *name)
{
#include "restore/restore.h"
#include "medialist/medialist.h"
#include "joblist/joblist.h"
+#include "clients/clients.h"
class Console;
QHash<QTreeWidgetItem*,Pages*> m_pagehash;
/* This hash is to get the page selector widget when the page is known */
QHash<Pages*,QTreeWidgetItem*> m_widgethash;
- void createPagejoblist(QString &);
+ void createPageJobList(QString &);
public slots:
void input_line();
void createPages();
QTreeWidgetItem *createTopPage(char *name );
QTreeWidgetItem *createPage(char *name, QTreeWidgetItem *parent );
- void createPagebrestore();
- void createPagemedialist();
+ void createPagebRestore();
+ void createPageMediaList();
+ void createPageClients();
/* Temporarily putting this here until we figure out how to handle
* multiple directors. */
QTreeWidgetItem *m_topItem;
*/
void MediaList::showJobs()
{
- mainWin->createPagejoblist(m_currentlyselected);
+ mainWin->createPageJobList(m_currentlyselected);
}
/*
/*
* Version $Id: medialist.h 4230 2007-02-21 20:07:37Z kerns $
*
- * Dirk Bentley, March 2007
+ * Dirk Bartley, March 2007
*/
#include <QtGui>