From: Dirk H Bartley Date: Thu, 29 Mar 2007 00:59:27 +0000 (+0000) Subject: dhb Implement dir_cmd in medialist remove dosql from console X-Git-Tag: Release-7.0.0~6679 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=b864ef0509e00bdcb78cef21478bf61bceed1f20;p=bacula%2Fbacula dhb Implement dir_cmd in medialist remove dosql from console git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@4446 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/qt-console/console/console.cpp b/bacula/src/qt-console/console/console.cpp index 90d5fe1469..c7032d0014 100644 --- a/bacula/src/qt-console/console/console.cpp +++ b/bacula/src/qt-console/console/console.cpp @@ -577,7 +577,8 @@ void Console::setDirRes(DIRRES *dir) { m_dir = dir; } - +#ifndef xxx +******FIXME****** Just Delete me void Console::dosql(QString* sqlcmd, QStringList& strlstret) { int stat; @@ -595,3 +596,4 @@ void Console::dosql(QString* sqlcmd, QStringList& strlstret) } } } +#endif diff --git a/bacula/src/qt-console/console/console.h b/bacula/src/qt-console/console/console.h index 9faaba4d79..721ed38538 100644 --- a/bacula/src/qt-console/console/console.h +++ b/bacula/src/qt-console/console/console.h @@ -92,7 +92,6 @@ public: void displayToPrompt(); void discardToPrompt(); void setDirRes(DIRRES *dir); - 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 592da0525d..452d90f81f 100644 --- a/bacula/src/qt-console/medialist/medialist.cpp +++ b/bacula/src/qt-console/medialist/medialist.cpp @@ -54,7 +54,6 @@ MediaList::MediaList(QStackedWidget *parent, Console *console, QTreeWidgetItem * m_headerlist = new QStringList(); m_popupmedia = new QString(""); m_poollist = new QStringList(); - m_cmd = new QString("select p.name, m.volumename, m.mediaid, m.mediatype from media m, pool p ORDER BY p.name"); } MediaList::~MediaList() @@ -62,7 +61,6 @@ MediaList::~MediaList() delete m_headerlist; delete m_popupmedia; delete m_poollist; - delete m_cmd; } void MediaList::populateTree() @@ -93,33 +91,38 @@ void MediaList::populateTree() QString currentpool(""); 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 */ - QString mediarecorditem; - foreach( mediarecorditem, recorditemlist ){ - QString trimmeditem = mediarecorditem.trimmed(); - if( trimmeditem != "" ){ - if ( recorditemcnter == 0 ){ - if ( currentpool != trimmeditem.toUtf8().data() ){ - currentpool = trimmeditem.toUtf8().data(); - pooltreeitem = new QTreeWidgetItem(topItem); - pooltreeitem->setText(0, trimmeditem.toUtf8().data()); - pooltreeitem->setData(0, Qt::UserRole, 1); - pooltreeitem->setExpanded( true ); + const char* m_cmd = ".sql \"select p.name, m.volumename, m.mediaid, m.mediatype from media m, pool p ORDER BY p.name\""; + if ( m_console->dir_cmd(m_cmd,results)){ + int recordcounter=0; + foreach( resultline, results ){ + QRegExp regex("^Using Catalog"); + if ( regex.indexIn(resultline) < 0 ){ + QStringList recorditemlist = resultline.split("\t"); + int recorditemcnter=0; + /* Iterate through items in the record */ + QString mediarecorditem; + foreach( mediarecorditem, recorditemlist ){ + QString trimmeditem = mediarecorditem.trimmed(); + if( trimmeditem != "" ){ + if ( recorditemcnter == 0 ){ + if ( currentpool != trimmeditem.toUtf8().data() ){ + currentpool = trimmeditem.toUtf8().data(); + pooltreeitem = new QTreeWidgetItem(topItem); + pooltreeitem->setText(0, trimmeditem.toUtf8().data()); + pooltreeitem->setData(0, Qt::UserRole, 1); + pooltreeitem->setExpanded( true ); + } + mediatreeitem = new QTreeWidgetItem(pooltreeitem); + } else { + mediatreeitem->setData(recorditemcnter-1, Qt::UserRole, 2); + mediatreeitem->setText(recorditemcnter-1, trimmeditem.toUtf8().data()); + } + recorditemcnter+=1; } - mediatreeitem = new QTreeWidgetItem(pooltreeitem); - } else { - mediatreeitem->setData(recorditemcnter-1, Qt::UserRole, 2); - mediatreeitem->setText(recorditemcnter-1, trimmeditem.toUtf8().data()); } - recorditemcnter+=1; } + recordcounter+=1; } - recordcounter+=1; } }