From 0265ee4755a1ce79a50e99aabf3f022788ccbac8 Mon Sep 17 00:00:00 2001 From: Dirk H Bartley Date: Mon, 26 Mar 2007 01:19:57 +0000 Subject: [PATCH] dhb Cleaned up populatetree in medialist with foreaches. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@4421 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/qt-console/console/console.cpp | 6 ++--- bacula/src/qt-console/console/console.h | 2 +- bacula/src/qt-console/medialist/medialist.cpp | 24 ++++++++++++------- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/bacula/src/qt-console/console/console.cpp b/bacula/src/qt-console/console/console.cpp index d6d8a8e723..ea29925880 100644 --- a/bacula/src/qt-console/console/console.cpp +++ b/bacula/src/qt-console/console/console.cpp @@ -584,12 +584,11 @@ void Console::setDirRes(DIRRES *dir) m_dir = dir; } -QStringList* Console::dosql(QString* sqlcmd) +void Console::dosql(QString* sqlcmd, QStringList& strlstret) { int stat; /* don't effect the string coming in */ QString cmd(*sqlcmd); - QStringList* strlstret = new QStringList; cmd = ".sql \"" + cmd + "\""; @@ -598,8 +597,7 @@ QStringList* Console::dosql(QString* sqlcmd) QString line = msg(); QRegExp regex("^Using Catalog"); if ( regex.indexIn(line) < 0 ){ - strlstret->append(line); + strlstret.append(line); } } - return strlstret; } diff --git a/bacula/src/qt-console/console/console.h b/bacula/src/qt-console/console/console.h index 1620f12662..1d76d5b40a 100644 --- a/bacula/src/qt-console/console/console.h +++ b/bacula/src/qt-console/console/console.h @@ -91,7 +91,7 @@ public: void discardToPrompt(); void setTreeItem(QTreeWidgetItem *item); void setDirRes(DIRRES *dir); - QStringList* dosql(QString* sqlcmd); + void dosql(QString* sqlcmd, QStringList& strlstret); QStringList job_list; QStringList client_list; diff --git a/bacula/src/qt-console/medialist/medialist.cpp b/bacula/src/qt-console/medialist/medialist.cpp index a4dddadd20..1e3e453730 100644 --- a/bacula/src/qt-console/medialist/medialist.cpp +++ b/bacula/src/qt-console/medialist/medialist.cpp @@ -41,7 +41,6 @@ #include "mediaedit/mediaedit.h" #include "joblist/joblist.h" #include -//#include MediaList::MediaList(QStackedWidget *parent, Console *console, QTreeWidgetItem *treeItem) { @@ -77,23 +76,32 @@ void MediaList::populateTree() topItem->setText(0, "Pools"); topItem->setData(0, Qt::UserRole, 0); topItem->setExpanded( true ); - //topItem->setSizeHint(0,QSize(1050,50)); +#ifdef xxx +#include +***** FIXME ***** +//how to get the size of a column to be larger +//topItem->setSizeHint(0,QSize(1050,50)); +#endif /* Start with a list of pools */ m_poollist->clear(); - QStringList *results=m_console->dosql(m_cmd); - int recordcounter=0; m_headerlist->append("Volume Name"); m_headerlist->append("Media Id"); m_headerlist->append("Type"); m_treeWidget->setHeaderLabels(*m_headerlist); + QString currentpool(""); - for ( QStringList::Iterator resultline = results->begin(); resultline != results->end(); ++resultline ) { - QStringList recorditemlist = resultline->split("\t"); + QString resultline; + QStringList results; + m_console->dosql(m_cmd,results); + int recordcounter=0; + foreach( resultline, results ){ + QStringList recorditemlist = resultline.split("\t"); int recorditemcnter=0; /* Iterate through items in the record */ - for ( QStringList::Iterator mediarecorditem = recorditemlist.begin(); mediarecorditem != recorditemlist.end(); ++mediarecorditem ) { - QString trimmeditem = mediarecorditem->trimmed(); + QString mediarecorditem; + foreach( mediarecorditem, recorditemlist ){ + QString trimmeditem = mediarecorditem.trimmed(); if( trimmeditem != "" ){ if ( recorditemcnter == 0 ){ if ( currentpool != trimmeditem.toUtf8().data() ){ -- 2.39.5