From: Dirk H Bartley Date: Tue, 18 Mar 2008 02:10:22 +0000 (+0000) Subject: Add buttons and local timer configuration to storage window. X-Git-Tag: Release-7.0.0~4819 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=3820ecbd25bf40a23671371d279d8864cafa1e18;p=bacula%2Fbacula Add buttons and local timer configuration to storage window. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@6623 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/qt-console/status/storstat.cpp b/bacula/src/qt-console/status/storstat.cpp index f228ab1b3a..bad5b47f2c 100644 --- a/bacula/src/qt-console/status/storstat.cpp +++ b/bacula/src/qt-console/status/storstat.cpp @@ -35,6 +35,7 @@ #include #include "bat.h" #include "storstat.h" +#include "mount/mount.h" /* .status storage= @@ -64,11 +65,10 @@ StorStat::StorStat(QString &storage, QTreeWidgetItem *parentTreeWidgetItem) thisitem->setIcon(0,QIcon(QString::fromUtf8(":images/status.png"))); m_cursor = new QTextCursor(textEditHeader->document()); + m_timer = new QTimer(this); readSettings(); dockPage(); - m_timer = new QTimer(this); QWidget::connect(m_timer, SIGNAL(timeout()), this, SLOT(timerTriggered())); - m_timer->start(mainWin->m_refreshStatusDirInterval*1000); createConnections(); setCurrent(); @@ -105,7 +105,6 @@ void StorStat::populateAll() if (!m_console->preventInUseConnect()) return; populateTerminated(); - populateRunning(); populateCurrentTab(tabWidget->currentIndex()); } @@ -115,7 +114,7 @@ void StorStat::populateAll() void StorStat::timerTriggered() { bool iscurrent = mainWin->stackedWidget->currentIndex() == mainWin->stackedWidget->indexOf(this); - if (((isDocked() && iscurrent) || (!isDocked())) && mainWin->m_refreshStatusDir) { + if (((isDocked() && iscurrent) || (!isDocked())) && (checkBox->checkState() == Qt::Checked)) { if (m_console->is_ready()) populateAll(); } @@ -204,6 +203,22 @@ void StorStat::populateSpooling() } } +void StorStat::populateRunning() +{ + QString command = QString(".status storage=\"" + m_storage + "\" running"); + if (mainWin->m_commandDebug) + Pmsg1(000, "sending command : %s\n",command.toUtf8().data()); + QStringList results; + textEditRunning->clear(); + + if (m_console->dir_cmd(command, results)) { + foreach (QString line, results) { + line += "\n"; + textEditRunning->insertPlainText(line); + } + } +} + /* * Populate teminated table */ @@ -260,50 +275,6 @@ void StorStat::populateTerminated() terminatedTable->verticalHeader()->hide(); } -/* - * Populate running table - */ -void StorStat::populateRunning() -{ - QString command = QString(".status storage=\"" + m_storage + "\" running"); - if (mainWin->m_commandDebug) - Pmsg1(000, "sending command : %s\n",command.toUtf8().data()); - QStringList results; - QBrush blackBrush(Qt::black); - - runningTable->clear(); - QStringList headerlist = (QStringList() - << tr("Job Id") << tr("Job Level") << tr("Job Data") << tr("Job Info")); - - runningTable->setColumnCount(headerlist.size()); - runningTable->setHorizontalHeaderLabels(headerlist); - - if (m_console->dir_cmd(command, results)) { - int row = 0; - QTableWidgetItem* p_tableitem; - runningTable->setRowCount(results.size()); - foreach (QString line, results) { - /* Iterate through the record returned from the query */ - QStringList fieldlist = line.split("\t"); - int column = 0; - QString statusCode(""); - /* Iterate through fields in the record */ - foreach (QString field, fieldlist) { - field = field.trimmed(); /* strip leading & trailing spaces */ - p_tableitem = new QTableWidgetItem(field, 1); - p_tableitem->setForeground(blackBrush); - p_tableitem->setFlags(0); - runningTable->setItem(row, column, p_tableitem); - column += 1; - } - row += 1; - } - } - runningTable->resizeColumnsToContents(); - runningTable->resizeRowsToContents(); - runningTable->verticalHeader()->hide(); -} - /* * When the treeWidgetItem in the page selector tree is singleclicked, Make sure * The tree has been populated. @@ -336,15 +307,14 @@ void StorStat::createConnections() { connect(actionRefresh, SIGNAL(triggered()), this, SLOT(populateAll())); - connect(actionCancelRunning, SIGNAL(triggered()), this, - SLOT(consoleCancelJob())); connect(tabWidget, SIGNAL(currentChanged(int)), this, SLOT(populateCurrentTab(int))); + connect(spinBox, SIGNAL(valueChanged(int)), this, + SLOT(spinBoxValueChanged(int))); + connect(mountButton, SIGNAL(pressed()), this, SLOT(mountButtonPushed())); + connect(umountButton, SIGNAL(pressed()), this, SLOT(umountButtonPushed())); terminatedTable->setContextMenuPolicy(Qt::ActionsContextMenu); terminatedTable->addAction(actionRefresh); - runningTable->setContextMenuPolicy(Qt::ActionsContextMenu); - runningTable->addAction(actionRefresh); - runningTable->addAction(actionCancelRunning); } /* @@ -355,6 +325,8 @@ void StorStat::writeSettings() QSettings settings(m_console->m_dir->name(), "bat"); settings.beginGroup(m_groupText); settings.setValue(m_splitText, splitter->saveState()); + settings.setValue("refreshInterval", spinBox->value()); + settings.setValue("refreshCheck", checkBox->checkState()); settings.endGroup(); } @@ -368,22 +340,11 @@ void StorStat::readSettings() QSettings settings(m_console->m_dir->name(), "bat"); settings.beginGroup(m_groupText); splitter->restoreState(settings.value(m_splitText).toByteArray()); + spinBox->setValue(settings.value("refreshInterval", 28).toInt()); + checkBox->setCheckState((Qt::CheckState)settings.value("refreshCheck", Qt::Checked).toInt()); settings.endGroup(); -} -/* - * Cancel a running job - */ -void StorStat::consoleCancelJob() -{ - int currentrow = runningTable->currentRow(); - QTableWidgetItem *item = runningTable->item(currentrow, 0); - if (item) { - QString text = item->text(); - QString cmd("cancel jobid="); - cmd += text; - consoleCommand(cmd); - } + m_timer->start(spinBox->value()*1000); } /* @@ -401,4 +362,72 @@ void StorStat::populateCurrentTab(int index) populateVolumes(); if (index == 4) populateSpooling(); + if (index == 5) + populateRunning(); +} + +/* + * Set the timer when changed + */ +void StorStat::spinBoxValueChanged(int newval) +{ + m_timer->setInterval(newval*1000); +} + +/* + * execute mount in console + */ +void StorStat::mountButtonPushed() +{ + int haschanger = 3; + + /* Set up query QString and header QStringList */ + QString query("SELECT AutoChanger AS Changer" + " FROM Storage WHERE Name='" + m_storage + "'" + " ORDER BY Name" ); + + QStringList results; + /* This could be a log item */ + if (mainWin->m_sqlDebug) { + Pmsg1(000, "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 */ + haschanger = field.toInt(); + index++; + } + } + } + } + + Pmsg1(000, "haschanger is : %i\n", haschanger); + if (haschanger == 0){ + /* no autochanger, just execute the command in the console */ + QString cmd("mount storage=" + m_storage); + consoleCommand(cmd); + } else if (haschanger != 3) { + setConsoleCurrent(); + /* if this storage is an autochanger, lets ask for the slot */ + new mountDialog(m_console, m_storage); + } +} + +/* + * execute umount in console + */ +void StorStat::umountButtonPushed() +{ + QString cmd("umount storage=" + m_storage); + consoleCommand(cmd); } diff --git a/bacula/src/qt-console/status/storstat.h b/bacula/src/qt-console/status/storstat.h index dd1b41e01b..6577a9526e 100644 --- a/bacula/src/qt-console/status/storstat.h +++ b/bacula/src/qt-console/status/storstat.h @@ -60,8 +60,10 @@ public slots: private slots: void timerTriggered(); - void consoleCancelJob(); + void spinBoxValueChanged(int); void populateCurrentTab(int); + void mountButtonPushed(); + void umountButtonPushed(); private: void createConnections(); diff --git a/bacula/src/qt-console/status/storstat.ui b/bacula/src/qt-console/status/storstat.ui index b72635453d..fd1960e20c 100644 --- a/bacula/src/qt-console/status/storstat.ui +++ b/bacula/src/qt-console/status/storstat.ui @@ -5,8 +5,8 @@ 0 0 - 502 - 466 + 367 + 310 @@ -72,29 +72,89 @@ - - - - - - - Qt::LeftToRight + + + Running + + + + + + + + + + Misc + + + + + 170 + 40 + 80 + 24 + + + + Mount + + + + + + 170 + 70 + 80 + 24 + + + + UMount + + + + + + 10 + 10 + 151 + 91 + + + + Refresh Timer Top + + + + + 20 + 50 + 111 + 24 + - - <html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal; text-decoration:none;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:13pt; font-weight:600;">Running Jobs</span></p></body></html> + + 5 - - Qt::AlignCenter + + 999 - - - - - + + + + 20 + 20 + 101 + 20 + + + + Do Refresh + + + +