From 44c0895776ca572b63c7cc01f5551bc3c2a2c77e Mon Sep 17 00:00:00 2001 From: Dirk H Bartley Date: Sat, 28 Apr 2007 15:33:36 +0000 Subject: [PATCH] Iterate throught m_console->pool_list in medialist so that pools without media will be included on the page. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@4646 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/qt-console/clients/clients.cpp | 2 +- bacula/src/qt-console/medialist/medialist.cpp | 91 ++++++++++--------- 2 files changed, 47 insertions(+), 46 deletions(-) diff --git a/bacula/src/qt-console/clients/clients.cpp b/bacula/src/qt-console/clients/clients.cpp index 0c646e9f06..4f18299e14 100644 --- a/bacula/src/qt-console/clients/clients.cpp +++ b/bacula/src/qt-console/clients/clients.cpp @@ -82,7 +82,7 @@ void Clients::populateTree() /* This could be a log item */ //printf("In Clients::populateTree()\n"); - foreach(QString clientName, m_console->client_list){ + foreach (QString clientName, m_console->client_list){ clientItem = new QTreeWidgetItem(topItem); clientItem->setText(0, clientName); clientItem->setData(0, Qt::UserRole, 1); diff --git a/bacula/src/qt-console/medialist/medialist.cpp b/bacula/src/qt-console/medialist/medialist.cpp index 701c8c2e86..e0d3805e45 100644 --- a/bacula/src/qt-console/medialist/medialist.cpp +++ b/bacula/src/qt-console/medialist/medialist.cpp @@ -66,18 +66,9 @@ MediaList::~MediaList() void MediaList::populateTree() { QTreeWidgetItem *mediatreeitem, *pooltreeitem, *topItem; - QString currentpool(""); - QString resultline; - QStringList results; - const char *query = - "SELECT Pool.Name AS Pool, Media.VolumeName AS Media, Media.MediaId AS Id, Media.VolStatus AS VolStatus," - " Media.Enabled AS Enabled, Media.VolBytes AS Bytes, Media.VolFiles AS FileCount, Media.VolJobs AS JobCount," - " Media.VolRetention AS VolumeRetention, Media.MediaType AS MediaType, Media.LastWritten AS LastWritten" - " FROM Media, Pool" - " WHERE Media.PoolId=Pool.PoolId" - " ORDER BY Pool"; + QStringList headerlist = (QStringList() - << "Pool Name" << "Volume Name" << "Media Id" << "Volume Status" << "Enabled" + << "Volume Name" << "Media Id" << "Volume Status" << "Enabled" << "Volume Bytes" << "Volume Files" << "Volume Jobs" << "Volume Retention" << "Media Type" << "Last Written"); @@ -89,44 +80,54 @@ void MediaList::populateTree() topItem->setText(0, "Pools"); topItem->setData(0, Qt::UserRole, 0); topItem->setExpanded(true); - - mp_treeWidget->setHeaderLabels(headerlist); - - /* FIXME Make this a user configurable loggin action and dont use printf */ - //printf("MediaList query cmd : %s\n",query); - if (m_console->sql_cmd(query, results)) { - QString field; - QStringList fieldlist; - - 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 */ - if (field != "") { - /* The first field is the pool name */ - if (index == 0) { - /* If new pool name, create new Pool item */ - if (currentpool != field) { - currentpool = field; - pooltreeitem = new QTreeWidgetItem(topItem); - pooltreeitem->setText(0, field); - pooltreeitem->setData(0, Qt::UserRole, 1); - pooltreeitem->setExpanded(true); - } - mediatreeitem = new QTreeWidgetItem(pooltreeitem); + + mp_treeWidget->setHeaderLabels(headerlist); + + QString query; + + foreach (QString pool_listItem, m_console->pool_list) { + pooltreeitem = new QTreeWidgetItem(topItem); + pooltreeitem->setText(0, pool_listItem); + pooltreeitem->setData(0, Qt::UserRole, 1); + pooltreeitem->setExpanded(true); + + query = "SELECT Media.VolumeName AS Media, " + " Media.MediaId AS Id, Media.VolStatus AS VolStatus," + " Media.Enabled AS Enabled, Media.VolBytes AS Bytes," + " Media.VolFiles AS FileCount, Media.VolJobs AS JobCount," + " Media.VolRetention AS VolumeRetention, Media.MediaType AS MediaType," + " Media.LastWritten AS LastWritten" + " FROM Media, Pool" + " WHERE Media.PoolId=Pool.PoolId"; + query += " AND Pool.Name='" + pool_listItem + "'"; + query += " ORDER BY Pool.Name"; + + /* FIXME Make this a user configurable loggin action and dont use printf */ + //printf("MediaList query cmd : %s\n",query.toUtf8().data()); + QStringList results; + if (m_console->sql_cmd(query, results)) { + QString field; + QStringList fieldlist; + + /* Iterate through the lines of results. */ + foreach (QString resultline, results) { + fieldlist = resultline.split("\t"); + int index = 0; + mediatreeitem = new QTreeWidgetItem(pooltreeitem); + + /* Iterate through fields in the record */ + foreach (field, fieldlist) { + field = field.trimmed(); /* strip leading & trailing spaces */ + if (field != "") { mediatreeitem->setData(index, Qt::UserRole, 2); - } else { - /* Put media fields under the pool tree item */ mediatreeitem->setData(index, Qt::UserRole, 2); mediatreeitem->setText(index, field); } - } - index++; - } - } - } + index++; + } /* foreach field */ + } /* foreach resultline */ + } /* if results from query */ + } /* foreach pool_listItem */ /* Resize the columns */ for(int cnter=0; cnterresizeColumnToContents(cnter); -- 2.39.5