/*
Bacula® - The Network Backup Solution
- Copyright (C) 2007-2008 Free Software Foundation Europe e.V.
+ 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
+ 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.
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
+ 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.
#include <QAbstractEventDispatcher>
#include <QMenu>
#include "storage.h"
+#include "content.h"
#include "label/label.h"
#include "mount/mount.h"
#include "status/storstat.h"
#include "util/fmtwidgetitem.h"
-Storage::Storage()
+Storage::Storage() : Pages()
{
setupUi(this);
pgInitialize(tr("Storage"));
/* mp_treeWidget, Storage Tree Tree Widget inherited from ui_storage.h */
m_populated = false;
+ m_firstpopulation = true;
m_checkcurwidget = true;
m_closeable = false;
m_currentStorage = "";
/* add context sensitive menu items specific to this classto the page
* selector tree. m_contextActions is QList of QActions */
m_contextActions.append(actionRefreshStorage);
- dockPage();
}
Storage::~Storage()
if (m_console->sql_cmd(query, results)) {
QStringList fieldlist;
- int cnter = 1;
foreach (QString resultline, results) {
fieldlist = resultline.split("\t");
storageName = fieldlist.takeFirst();
+ if (m_firstpopulation) {
+ settingsOpenStatus(storageName);
+ }
TreeItemFormatter storageItem(*m_topItem, 1);
storageItem.setTextFld(0, storageName);
if(settings.contains(storageName))
for(int cnter=0; cnter<headerlist.size(); cnter++) {
mp_treeWidget->resizeColumnToContents(cnter);
}
+ m_firstpopulation = false;
}
/*
populateTree();
createContextMenu();
}
+ if (!isOnceDocked()) {
+ dockPage();
+ }
}
/*
SLOT(consoleRelease()));
connect(actionStatusStorageWindow, SIGNAL(triggered()), this,
SLOT(statusStorageWindow()));
+ connect(mp_treeWidget, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)),
+ this, SLOT(contentWindow()));
+
+}
+
+void Storage::contentWindow()
+{
+ if (m_currentStorage != "" && m_currentAutoChanger) {
+ QTreeWidgetItem *parentItem = mainWin->getFromHash(this);
+ new Content(m_currentStorage, parentItem);
+ }
}
/*
*/
void Storage::statusStorageWindow()
{
- QTreeWidgetItem *parentItem = mainWin->getFromHash(this);
- new StorStat(m_currentStorage, parentItem);
+ /* if one exists, then just set it current */
+ bool found = false;
+ foreach(Pages *page, mainWin->m_pagehash) {
+ if (mainWin->currentConsole() == page->console()) {
+ if (page->name() == tr("Storage Status %1").arg(m_currentStorage)) {
+ found = true;
+ page->setCurrent();
+ }
+ }
+ }
+ if (!found) {
+ QTreeWidgetItem *parentItem = mainWin->getFromHash(this);
+ new StorStat(m_currentStorage, parentItem);
+ }
}
/*
}
settings.endGroup();
}
+
+/*
+ * If first time, then check to see if there were status pages open the last time closed
+ * if so open
+ */
+void Storage::settingsOpenStatus(QString &storage)
+{
+ QSettings settings(m_console->m_dir->name(), "bat");
+
+ settings.beginGroup("OpenOnExit");
+ QString toRead = "StorageStatus_" + storage;
+ if (settings.value(toRead) == 1) {
+ if (mainWin->m_sqlDebug) {
+ Pmsg1(000, "Do open Storage Status window for : %s\n", storage.toUtf8().data());
+ }
+ new StorStat(storage, mainWin->getFromHash(this));
+ setCurrent();
+ mainWin->getFromHash(this)->setExpanded(true);
+ } else {
+ if (mainWin->m_sqlDebug) {
+ Pmsg1(000, "Do NOT open Storage Status window for : %s\n", storage.toUtf8().data());
+ }
+ }
+ settings.endGroup();
+}