Copyright (C) 2007-2010 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 three of the GNU Affero 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 Affero 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.
+ The main author of Bacula is Kern Sibbald, with contributions from many
+ others, a complete list can be found in the file AUTHORS.
+
+ You may use this file and others of this release according to the
+ license defined in the LICENSE file, which includes the Affero General
+ Public License, v3.0 ("AGPLv3") and some additional permissions and
+ terms pursuant to its AGPLv3 Section 7.
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.
*/
/*
*
* Kern Sibbald, January MMVII
*
- */
+ */
#include "bat.h"
#include "version.h"
#include "status/dirstat.h"
#include "util/fmtwidgetitem.h"
-/*
+/*
* Daemon message callback
*/
void message_callback(int /* type */, char *msg)
treeWidget->setColumnCount(1);
treeWidget->setHeaderLabel( tr("Select Page") );
treeWidget->setContextMenuPolicy(Qt::ActionsContextMenu);
- // tabWidget->setTabsClosable(true); /* wait for QT 4.5 */
+ tabWidget->setTabsClosable(true); /* wait for QT 4.5 */
createPages();
resetFocus(); /* lineEdit->setFocus() */
foreach(Console *console, m_consoleHash) {
console->connect_dir();
}
- /*
+ /*
* Note, the notifier is now a global flag, although each notifier
* can be individually turned on and off at a socket level. Once
* the notifier is turned off, we don't accept anything from anyone
item->setForeground(0, redBrush);
/*
- * Create instances in alphabetic order of the rest
- * of the classes that will by default exist under each Director.
+ * Create instances in alphabetic order of the rest
+ * of the classes that will by default exist under each Director.
*/
new bRestore();
new Clients();
new MediaList();
new MediaView();
new Storage();
- if (m_openBrowser) {
- new restoreTree();
- }
+// if (m_openBrowser) {
+// new restoreTree();
+// }
if (m_openDirStat) {
new DirStat();
}
connect(treeWidget, SIGNAL(itemClicked(QTreeWidgetItem *, int)), this, SLOT(treeItemClicked(QTreeWidgetItem *, int)));
connect(treeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), this, SLOT(treeItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)));
connect(tabWidget, SIGNAL(currentChanged(int)), this, SLOT(stackItemChanged(int)));
+ connect(tabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(closePage(int)));
connect(actionQuit, SIGNAL(triggered()), app, SLOT(closeAllWindows()));
connect(actionLabel, SIGNAL(triggered()), this, SLOT(labelButtonClicked()));
connect(actionRun, SIGNAL(triggered()), this, SLOT(runButtonClicked()));
connect(actionRestore, SIGNAL(triggered()), this, SLOT(restoreButtonClicked()));
connect(actionUndock, SIGNAL(triggered()), this, SLOT(undockWindowButton()));
connect(actionToggleDock, SIGNAL(triggered()), this, SLOT(toggleDockContextWindow()));
- connect(actionClosePage, SIGNAL(triggered()), this, SLOT(closePage()));
+ connect(actionClosePage, SIGNAL(triggered()), this, SLOT(closeCurrentPage()));
connect(actionPreferences, SIGNAL(triggered()), this, SLOT(setPreferences()));
connect(actionRepopLists, SIGNAL(triggered()), this, SLOT(repopLists()));
connect(actionReloadRepop, SIGNAL(triggered()), this, SLOT(reloadRepopLists()));
disconnect(treeWidget, SIGNAL(itemClicked(QTreeWidgetItem *, int)), this, SLOT(treeItemClicked(QTreeWidgetItem *, int)));
disconnect(treeWidget, SIGNAL( currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), this, SLOT(treeItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)));
disconnect(tabWidget, SIGNAL(currentChanged(int)), this, SLOT(stackItemChanged(int)));
+ disconnect(tabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(closePage(int)));
disconnect(actionQuit, SIGNAL(triggered()), app, SLOT(closeAllWindows()));
disconnect(actionLabel, SIGNAL(triggered()), this, SLOT(labelButtonClicked()));
disconnect(actionRun, SIGNAL(triggered()), this, SLOT(runButtonClicked()));
disconnect(actionRestore, SIGNAL(triggered()), this, SLOT(restoreButtonClicked()));
disconnect(actionUndock, SIGNAL(triggered()), this, SLOT(undockWindowButton()));
disconnect(actionToggleDock, SIGNAL(triggered()), this, SLOT(toggleDockContextWindow()));
- disconnect(actionClosePage, SIGNAL(triggered()), this, SLOT(closePage()));
+ disconnect(actionClosePage, SIGNAL(triggered()), this, SLOT(closeCurrentPage()));
disconnect(actionPreferences, SIGNAL(triggered()), this, SLOT(setPreferences()));
disconnect(actionRepopLists, SIGNAL(triggered()), this, SLOT(repopLists()));
disconnect(actionReloadRepop, SIGNAL(triggered()), this, SLOT(reloadRepopLists()));
*/
void MainWin::waitEnter()
{
- if (m_waitState || m_isClosing) {
+ if (m_waitState || m_isClosing) {
return;
}
m_waitState = true;
}
-/*
+/*
* Two functions to respond to menu items to repop lists and execute reload and repopulate
* the lists for jobs, clients, filesets .. ..
*/
m_currentConsole->populateLists(false);
}
-/*
- * Reimplementation of QWidget closeEvent virtual function
+/*
+ * Reimplementation of QWidget closeEvent virtual function
*/
void MainWin::closeEvent(QCloseEvent *event)
{
}
void MainWin::readSettings()
-{
+{
QSettings settings("bacula.org", "bat");
settings.beginGroup("MainWin");
/*
* This subroutine is called with an item in the Page Selection window
- * is clicked
+ * is clicked
*/
void MainWin::treeItemClicked(QTreeWidgetItem *item, int /*column*/)
{
/* Is this a page that has been inserted into the hash */
- if (getFromHash(item)) {
- Pages* page = getFromHash(item);
- int stackindex=tabWidget->indexOf(page);
+ Pages* page = getFromHash(item);
+ if (page) {
+ int stackindex = tabWidget->indexOf(page);
if (stackindex >= 0) {
tabWidget->setCurrentWidget(page);
}
+ page->dockPage();
/* run the virtual function in case this class overrides it */
page->PgSeltreeWidgetClicked();
+ } else {
+ Dmsg0(000, "Page not in hash");
}
}
nextPage = NULL;
nextConsole = NULL;
}
-
+
/* The Previous item */
/* this condition prevents a segfault. The first time there is no previousitem*/
}
/* process the current (next) item */
-
+
if ((nextPage) || (nextConsole)) {
if (nextConsole != previousConsole) {
/* make connections to the current console */
/* set the value for the currently active console */
int stackindex = tabWidget->indexOf(nextPage);
nextPage->firstUseDock();
-
+
/* Is this page currently on the stack or is it undocked */
if (stackindex >= 0) {
/* put this page on the top of the stack */
}
}
-void MainWin::labelButtonClicked()
+void MainWin::labelButtonClicked()
{
new labelPage();
}
-void MainWin::runButtonClicked()
+void MainWin::runButtonClicked()
{
new runPage("");
}
-void MainWin::estimateButtonClicked()
+void MainWin::estimateButtonClicked()
{
new estimatePage();
}
-void MainWin::browseButtonClicked()
+void MainWin::browseButtonClicked()
{
- new restoreTree();
+// new restoreTree();
}
void MainWin::statusPageButtonClicked()
}
}
-void MainWin::restoreButtonClicked()
+void MainWin::restoreButtonClicked()
{
new prerestorePage();
if (mainWin->m_miscDebug) Pmsg0(000, "in restoreButtonClicked after prerestorePage\n");
void MainWin::about()
{
QMessageBox::about(this, tr("About bat"),
- tr("<br><h2>bat %1 (%2), by Dirk H Bartley and Kern Sibbald</h2>"
+ tr("<br><h2>Bat %1 (%2), by Dirk H Bartley and Kern Sibbald</h2>"
"<p>Copyright © 2007-%3 Free Software Foundation Europe e.V."
+ "<p>Improved by Bacula Systems SA."
"<p>The <b>bat</b> is an administrative console"
" interface to the Director.").arg(VERSION).arg(BDATE).arg(BYEAR));
}
{
va_list arg_ptr;
char buf[1000];
- int len;
va_start(arg_ptr, fmt);
- len = bvsnprintf(buf, sizeof(buf), fmt, arg_ptr);
+ bvsnprintf(buf, sizeof(buf), fmt, arg_ptr);
va_end(arg_ptr);
set_status(buf);
}
void MainWin::undockWindowButton()
{
Pages* page = (Pages*)tabWidget->currentWidget();
- page->togglePageDocking();
+ if (page) {
+ page->togglePageDocking();
+ }
}
/*
- * Function to respond to action on page selector context menu to toggle the
+ * Function to respond to action on page selector context menu to toggle the
* dock status of the window associated with the page selectors current
* tree widget item.
*/
void MainWin::toggleDockContextWindow()
{
QTreeWidgetItem *currentitem = treeWidget->currentItem();
-
+
/* Is this a page that has been inserted into the hash */
if (getFromHash(currentitem)) {
Pages* page = getFromHash(currentitem);
- page->togglePageDocking();
+ if (page) {
+ page->togglePageDocking();
+ }
}
}
if (m_isClosing) return; /* if closing the application, do nothing here */
Pages* page = (Pages*)tabWidget->currentWidget();
/* run the virtual function in case this class overrides it */
- page->currentStackItem();
+ if (page) {
+ page->currentStackItem();
+ }
if (!m_waitState) {
disconnect(treeWidget, SIGNAL(itemClicked(QTreeWidgetItem *, int)), this, SLOT(treeItemClicked(QTreeWidgetItem *, int)));
disconnect(treeWidget, SIGNAL( currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), this, SLOT(treeItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)));
return m_widgethash.value(page);
}
+void MainWin::closeCurrentPage()
+{
+ closePage(-1);
+}
+
/*
* Function to respond to action on page selector context menu to close the
* current window.
*/
-void MainWin::closePage()
+void MainWin::closePage(int item)
{
- QTreeWidgetItem *currentitem = treeWidget->currentItem();
-
- /* Is this a page that has been inserted into the hash */
- if (getFromHash(currentitem)) {
- Pages* page = getFromHash(currentitem);
+ QTreeWidgetItem *currentitem;
+ Pages *page = NULL;
+
+ if (item >= 0) {
+ page = (Pages *)tabWidget->widget(item);
+ } else {
+ currentitem = treeWidget->currentItem();
+ /* Is this a page that has been inserted into the hash */
+ if (getFromHash(currentitem)) {
+ page = getFromHash(currentitem);
+ }
+ }
+
+ if (page) {
if (page->isCloseable()) {
page->closeStackPage();
+ } else {
+ page->hidePage();
}
}
}
}
/* Preferences dialog */
-prefsDialog::prefsDialog()
+prefsDialog::prefsDialog() : QDialog()
{
setupUi(this);
}
settings.beginGroup("Misc");
m_longList = settings.value("longList", false).toBool();
ItemFormatterBase::setBytesConversion(
- (ItemFormatterBase::BYTES_CONVERSION) settings.value("byteConvert",
+ (ItemFormatterBase::BYTES_CONVERSION) settings.value("byteConvert",
ItemFormatterBase::BYTES_CONVERSION_IEC).toInt());
m_openPlot = settings.value("openplot", false).toBool();
m_openBrowser = settings.value("openbrowser", false).toBool();