Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- Bacula® is a registered trademark of John Walker.
+ 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.
#include "clients/clients.h"
#include "run/run.h"
#include "status/clientstat.h"
+#include "util/fmtwidgetitem.h"
Clients::Clients()
{
*/
void Clients::populateTable()
{
- QTableWidgetItem *tableItem;
- QBrush blackBrush(Qt::black);
-
if (!m_console->preventInUseConnect())
return;
- m_checkcurwidget = false;
- tableWidget->clear();
- m_checkcurwidget = true;
+ m_populated = true;
+
+ QBrush blackBrush(Qt::black);
QStringList headerlist = (QStringList() << tr("Client Name") << tr("File Retention")
<< tr("Job Retention") << tr("AutoPrune") << tr("ClientId") << tr("Uname") );
+ int sortcol = headerlist.indexOf(tr("Client Name"));
+ Qt::SortOrder sortord = Qt::AscendingOrder;
+ if (tableWidget->rowCount()) {
+ sortcol = tableWidget->horizontalHeader()->sortIndicatorSection();
+ sortord = tableWidget->horizontalHeader()->sortIndicatorOrder();
+ }
+
+ m_checkcurwidget = false;
+ tableWidget->clear();
+ m_checkcurwidget = true;
+
tableWidget->setColumnCount(headerlist.count());
tableWidget->setHorizontalHeaderLabels(headerlist);
+ tableWidget->horizontalHeader()->setHighlightSections(false);
tableWidget->setRowCount(m_console->client_list.count());
tableWidget->verticalHeader()->hide();
+ tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
+ tableWidget->setSelectionMode(QAbstractItemView::SingleSelection);
+ tableWidget->setSortingEnabled(false); /* rows move on insert if sorting enabled */
int row = 0;
foreach (QString clientName, m_console->client_list){
" FROM Client"
" WHERE ";
query += " Name='" + clientName + "'";
- query += " ORDER BY Name";
+ query += " ORDER BY ClientId LIMIT 1";
QStringList results;
/* This could be a log item */
}
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 column = 0;
- /* Iterate through fields in the record */
- foreach (field, fieldlist) {
- field = field.trimmed(); /* strip leading & trailing spaces */
- tableItem = new QTableWidgetItem(field, 1);
- tableItem->setFlags(Qt::ItemIsSelectable);
- tableItem->setForeground(blackBrush);
- tableItem->setData(Qt::UserRole, 1);
- tableWidget->setItem(row, column, tableItem);
- column++;
- }
- }
+ if (resultCount){
+ /* only use the last one */
+ QString resultline = results[resultCount - 1];
+ QStringList fieldlist = resultline.split("\t");
+
+ TableItemFormatter item(*tableWidget, row);
+
+ /* Iterate through fields in the record */
+ QStringListIterator fld(fieldlist);
+ int col = 0;
+
+ /* name */
+ item.setTextFld(col++, fld.next());
+
+ /* file retention */
+ item.setDurationFld(col++, fld.next());
+
+ /* job retention */
+ item.setDurationFld(col++, fld.next());
+
+ /* autoprune */
+ item.setBoolFld(col++, fld.next());
+
+ /* client id */
+ item.setNumericFld(col++, fld.next());
+
+ /* uname */
+ item.setTextFld(col++, fld.next());
+
}
}
row ++;
}
- /* Resize the columns */
- for(int cnter=0; cnter<headerlist.size(); cnter++) {
- tableWidget->resizeColumnToContents(cnter);
- }
+ /* set default sorting */
+ tableWidget->sortByColumn(sortcol, sortord);
+ tableWidget->setSortingEnabled(true);
+
+ /* Resize rows and columns */
+ tableWidget->resizeColumnsToContents();
+ tableWidget->resizeRowsToContents();
}
/*
{
if(!m_populated) {
populateTable();
- m_populated=true;
}
}
if(!m_populated) {
populateTable();
/* Create the context menu for the client table */
- m_populated=true;
}
}
void Clients::consolePurgeJobs()
{
if (QMessageBox::warning(this, "Bat",
- tr("Are you sure you want to purge ?? !!!.\n"
+ tr("Are you sure you want to purge all jobs of client \"%1\" ?\n"
"The Purge command will delete associated Catalog database records from Jobs and"
" Volumes without considering the retention period. Purge works only on the"
" Catalog database and does not affect data written to Volumes. This command can"
" you are doing.\n\n"
" Is there any way I can get you to click Cancel here? You really don't want to do"
" this\n\n"
- "Press OK to proceed with the purge operation?"),
- QMessageBox::Ok | QMessageBox::Cancel)
+ "Press OK to proceed with the purge operation?").arg(m_currentlyselected),
+ QMessageBox::Ok | QMessageBox::Cancel,
+ QMessageBox::Cancel)
== QMessageBox::Cancel) { return; }
QString cmd("purge jobs client=");
QTreeWidgetItem *parentItem = mainWin->getFromHash(this);
new ClientStat(m_currentlyselected, parentItem);
}
+