X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=bacula%2Fsrc%2Fqt-console%2Fmainwin.cpp;h=0465ac3cd9f88afed8c9ced0e9651daedc4cb3fb;hb=ff963fce22ab64308beeaae594c3c872a40bf31f;hp=566c702653c198767e5d24f442632ae8daf20ae6;hpb=ae34d2c3046a602ccaf22d1dbd0153fad3076284;p=bacula%2Fbacula
diff --git a/bacula/src/qt-console/mainwin.cpp b/bacula/src/qt-console/mainwin.cpp
index 566c702653..0465ac3cd9 100644
--- a/bacula/src/qt-console/mainwin.cpp
+++ b/bacula/src/qt-console/mainwin.cpp
@@ -1,7 +1,7 @@
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2007-2007 Free Software Foundation Europe e.V.
+ Copyright (C) 2007-2008 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.
@@ -50,6 +50,7 @@
#include "help/help.h"
#include "jobs/jobs.h"
#include "jobgraphs/jobplot.h"
+#include "status/dirstat.h"
/*
* Daemon message callback
@@ -122,7 +123,7 @@ void MainWin::createPages()
item = new QTreeWidgetItem(topItem);
item->setText(0, "Console");
if (!m_firstItem){ m_firstItem = item; }
- item->setIcon(0,QIcon(QString::fromUtf8(":images/utilities-terminal.svg")));
+ item->setIcon(0,QIcon(QString::fromUtf8(":images/utilities-terminal.png")));
/* insert the cosole and tree widget item into the hashes */
hashInsert(item, m_currentConsole);
@@ -143,12 +144,16 @@ void MainWin::createPages()
new FileSet();
new Jobs();
createPageJobList("", "", "", "", NULL);
- new MediaList();
- new Storage();
- new restoreTree();
JobPlotPass pass;
pass.use = false;
- new JobPlot(NULL, pass);
+ if (m_openPlot)
+ new JobPlot(NULL, pass);
+ new MediaList();
+ new Storage();
+ if (m_openBrowser)
+ new restoreTree();
+ if (m_openDirStat)
+ new DirStat();
treeWidget->expandItem(topItem);
stackedWidget->setCurrentWidget(m_currentConsole);
@@ -232,6 +237,7 @@ void MainWin::createConnections()
connect(actionRun, SIGNAL(triggered()), this, SLOT(runButtonClicked()));
connect(actionEstimate, SIGNAL(triggered()), this, SLOT(estimateButtonClicked()));
connect(actionBrowse, SIGNAL(triggered()), this, SLOT(browseButtonClicked()));
+ connect(actionStatusDirPage, SIGNAL(triggered()), this, SLOT(statusPageButtonClicked()));
connect(actionJobPlot, SIGNAL(triggered()), this, SLOT(jobPlotButtonClicked()));
connect(actionRestore, SIGNAL(triggered()), this, SLOT(restoreButtonClicked()));
connect(actionUndock, SIGNAL(triggered()), this, SLOT(undockWindowButton()));
@@ -248,10 +254,15 @@ void MainWin::closeEvent(QCloseEvent *event)
m_isClosing = true;
writeSettings();
/* close all non console pages, this will call settings in destructors */
- foreach(Pages *page, m_pagehash) {
- if (page != page->console()) {
- page->console()->setCurrent();
- page->closeStackPage();
+ while (m_consoleHash.count() < m_pagehash.count()) {
+ foreach(Pages *page, m_pagehash) {
+ if (page != page->console()) {
+ QTreeWidgetItem* pageSelectorTreeWidgetItem = mainWin->getFromHash(page);
+ if (pageSelectorTreeWidgetItem->childCount() == 0) {
+ page->console()->setCurrent();
+ page->closeStackPage();
+ }
+ }
}
}
/* close the console pages and terminate connection */
@@ -424,6 +435,22 @@ void MainWin::browseButtonClicked()
new restoreTree();
}
+void MainWin::statusPageButtonClicked()
+{
+ /* if one exists, then just set it current */
+ bool found = false;
+ foreach(Pages *page, m_pagehash) {
+ if (m_currentConsole == page->console()) {
+ if (page->name() == "Director Status") {
+ found = true;
+ page->setCurrent();
+ }
+ }
+ }
+ if (!found)
+ new DirStat();
+}
+
void MainWin::restoreButtonClicked()
{
new prerestorePage();
@@ -447,7 +474,7 @@ void MainWin::input_line()
/* Use consoleInput to allow typing anything */
m_currentConsole->consoleInput(cmdStr);
} else {
- set_status("Director not connected. Click on connect button.");
+ set_status(tr("Director not connected. Click on connect button."));
}
m_cmd_history.append(cmdStr);
m_cmd_last = -1;
@@ -460,7 +487,7 @@ void MainWin::about()
{
QMessageBox::about(this, tr("About bat"),
tr("
Copyright © " BYEAR " Free Software Foundation Europe e.V." + "
Copyright © 2007-" BYEAR " Free Software Foundation Europe e.V." "
The bat is an administrative console"
" interface to the Director."));
}
@@ -483,7 +510,12 @@ void MainWin::set_statusf(const char *fmt, ...)
void MainWin::set_status_ready()
{
- set_status(" Ready");
+ set_status(tr(" Ready"));
+}
+
+void MainWin::set_status(const QString &str)
+{
+ statusBar()->showMessage(str);
}
void MainWin::set_status(const char *buf)
@@ -614,6 +646,8 @@ void MainWin::setPreferences()
prefs.daysSpinBox->setValue(m_daysLimitVal);
prefs.checkMessages->setCheckState(m_checkMessages ? Qt::Checked : Qt::Unchecked);
prefs.checkMessagesSpin->setValue(m_checkMessagesInterval);
+ prefs.refreshStatusDir->setCheckState(m_refreshStatusDir ? Qt::Checked : Qt::Unchecked);
+ prefs.refreshStatusDirSpin->setValue(m_refreshStatusDirInterval);
prefs.executeLongCheckBox->setCheckState(m_longList ? Qt::Checked : Qt::Unchecked);
prefs.rtPopDirCheckBox->setCheckState(m_rtPopDirDebug ? Qt::Checked : Qt::Unchecked);
prefs.rtDirCurICCheckBox->setCheckState(m_rtDirCurICDebug ? Qt::Checked : Qt::Unchecked);
@@ -627,6 +661,17 @@ void MainWin::setPreferences()
prefs.rtRestore1CheckBox->setCheckState(m_rtRestore1Debug ? Qt::Checked : Qt::Unchecked);
prefs.rtRestore2CheckBox->setCheckState(m_rtRestore2Debug ? Qt::Checked : Qt::Unchecked);
prefs.rtRestore3CheckBox->setCheckState(m_rtRestore3Debug ? Qt::Checked : Qt::Unchecked);
+ if (m_radioConvert == 0) {
+ prefs.radioConvertOff->setChecked(Qt::Checked);
+ } else if (m_radioConvert == 1){
+ prefs.radioConvertIEC->setChecked(Qt::Checked);
+ } else {
+ m_radioConvert = 2;
+ prefs.radioConvertStandard->setChecked(Qt::Checked);
+ }
+ prefs.openPlotCheckBox->setCheckState(m_openPlot ? Qt::Checked : Qt::Unchecked);
+ prefs.openBrowserCheckBox->setCheckState(m_openBrowser ? Qt::Checked : Qt::Unchecked);
+ prefs.openDirStatCheckBox->setCheckState(m_openDirStat ? Qt::Checked : Qt::Unchecked);
prefs.exec();
}
@@ -650,6 +695,8 @@ void prefsDialog::accept()
mainWin->m_daysLimitVal = this->daysSpinBox->value();
mainWin->m_checkMessages = this->checkMessages->checkState() == Qt::Checked;
mainWin->m_checkMessagesInterval = this->checkMessagesSpin->value();
+ mainWin->m_refreshStatusDir = this->refreshStatusDir->checkState() == Qt::Checked;
+ mainWin->m_refreshStatusDirInterval = this->refreshStatusDirSpin->value();
mainWin->m_longList = this->executeLongCheckBox->checkState() == Qt::Checked;
mainWin->m_rtPopDirDebug = this->rtPopDirCheckBox->checkState() == Qt::Checked;
@@ -664,6 +711,16 @@ void prefsDialog::accept()
mainWin->m_rtRestore1Debug = this->rtRestore1CheckBox->checkState() == Qt::Checked;
mainWin->m_rtRestore2Debug = this->rtRestore2CheckBox->checkState() == Qt::Checked;
mainWin->m_rtRestore3Debug = this->rtRestore3CheckBox->checkState() == Qt::Checked;
+ if (this->radioConvertOff->isChecked()) {
+ mainWin->m_radioConvert = 0;
+ } else if (this->radioConvertIEC->isChecked()){
+ mainWin->m_radioConvert = 1;
+ } else {
+ mainWin->m_radioConvert = 2;
+ }
+ mainWin->m_openPlot = this->openPlotCheckBox->checkState() == Qt::Checked;
+ mainWin->m_openBrowser = this->openBrowserCheckBox->checkState() == Qt::Checked;
+ mainWin->m_openDirStat = this->openDirStatCheckBox->checkState() == Qt::Checked;
QSettings settings("www.bacula.org", "bat");
settings.beginGroup("Debug");
@@ -679,12 +736,18 @@ void prefsDialog::accept()
settings.setValue("daysLimitCheck", mainWin->m_daysLimitCheck);
settings.setValue("daysLimitVal", mainWin->m_daysLimitVal);
settings.endGroup();
- settings.beginGroup("Messages");
+ settings.beginGroup("Timers");
settings.setValue("checkMessages", mainWin->m_checkMessages);
settings.setValue("checkMessagesInterval", mainWin->m_checkMessagesInterval);
+ settings.setValue("refreshStatusDir", mainWin->m_refreshStatusDir);
+ settings.setValue("refreshStatusDirInterval", mainWin->m_refreshStatusDirInterval);
settings.endGroup();
settings.beginGroup("Misc");
settings.setValue("longList", mainWin->m_longList);
+ settings.setValue("byteConvert", mainWin->m_radioConvert);
+ settings.setValue("openplot", mainWin->m_openPlot);
+ settings.setValue("openbrowser", mainWin->m_openBrowser);
+ settings.setValue("opendirstat", mainWin->m_openDirStat);
settings.endGroup();
settings.beginGroup("RestoreTree");
settings.setValue("rtPopDirDebug", mainWin->m_rtPopDirDebug);
@@ -708,7 +771,7 @@ void prefsDialog::accept()
void prefsDialog::reject()
{
this->hide();
- mainWin->set_status("Canceled");
+ mainWin->set_status(tr("Canceled"));
}
/* read preferences for the prefences dialog box */
@@ -728,12 +791,18 @@ void MainWin::readPreferences()
m_daysLimitCheck = settings.value("daysLimitCheck", false).toBool();
m_daysLimitVal = settings.value("daysLimitVal", 28).toInt();
settings.endGroup();
- settings.beginGroup("Messages");
+ settings.beginGroup("Timers");
m_checkMessages = settings.value("checkMessages", false).toBool();
m_checkMessagesInterval = settings.value("checkMessagesInterval", 28).toInt();
+ m_refreshStatusDir = settings.value("refreshStatusDir", false).toBool();
+ m_refreshStatusDirInterval = settings.value("refreshStatusDirInterval", 28).toInt();
settings.endGroup();
settings.beginGroup("Misc");
m_longList = settings.value("longList", false).toBool();
+ m_radioConvert = settings.value("byteConvert", false).toInt();
+ m_openPlot = settings.value("openplot", false).toBool();
+ m_openBrowser = settings.value("openbrowser", false).toBool();
+ m_openDirStat = settings.value("opendirstat", false).toBool();
settings.endGroup();
settings.beginGroup("RestoreTree");
m_rtPopDirDebug = settings.value("rtPopDirDebug", false).toBool();
@@ -750,3 +819,71 @@ void MainWin::readPreferences()
m_rtRestore3Debug = settings.value("rtRestore3Debug", false).toBool();
settings.endGroup();
}
+
+void MainWin::hrConvert(QString &ret, qlonglong &inval)
+{
+ double net = 0;
+ qlonglong base;
+ QStringList suflist;
+
+ if (m_radioConvert == 0) {
+ ret = QString("%1").arg(inval);
+ return;
+ } else if (m_radioConvert == 1){
+ base = 1000;
+ suflist = (QStringList() << "B" << "KiB" << "MiB" << "GiB" << "TiB" << "PiB" << "EiB" << "ZiB");
+ } else {
+ base = 1024;
+ suflist = (QStringList() << "B" << "KB" << "MB" << "GB" << "TB" << "PB" << "EB" << "ZB");
+ }
+ qlonglong running = base;
+ bool done = false;
+ int count = 1;
+ while (done == false) {
+ QString test1 = QString("%1").arg(inval);
+ QString test2 = QString("%1").arg(running);
+ if (float(inval) < (float)(running)) {
+ done = true;
+ ret = suflist[count - 1];
+ net = (float)inval / (float)(running/base);
+ }
+ count += 1;
+ if (count > suflist.count()) done = true;
+ running *= base;
+ }
+ char format = 'f';
+ if (net != 0)
+ ret = QString("%1 %2")
+ .arg(net, 0, format, 2, QLatin1Char(' '))
+ .arg(ret);
+ else ret = "0 B";
+}
+
+void MainWin::hrConvertSeconds(QString &ret, qlonglong &inval)
+{
+ double net = 0;
+ QList