From: Dirk H Bartley Date: Sat, 28 Mar 2009 15:30:41 +0000 (+0000) Subject: Move two sql performing functions getVolumeList and getStatusList from X-Git-Tag: Release-7.0.0~3230 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=8b93b92b3d66b5968a6093768c497090d5ed9111;p=bacula%2Fbacula Move two sql performing functions getVolumeList and getStatusList from the console class to the pages class. Looking at the function and progressionof the three classes: dircomm, console and pages, these two seem to be more sense in the pages class, they have nothing to do with connecting or managing multiple connections. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@8625 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/qt-console/console/console.cpp b/bacula/src/qt-console/console/console.cpp index 2d2bab9db2..0efe905447 100644 --- a/bacula/src/qt-console/console/console.cpp +++ b/bacula/src/qt-console/console/console.cpp @@ -644,44 +644,6 @@ void Console::consoleReload() consoleCommand(cmd); } -/* Function to get a list of volumes */ -void Console::getVolumeList(QStringList &volumeList) -{ - QString query("SELECT VolumeName AS Media FROM Media ORDER BY Media"); - if (mainWin->m_sqlDebug) { - Pmsg1(000, "Query cmd : %s\n",query.toUtf8().data()); - } - QStringList results; - if (sql_cmd(query, results)) { - QString field; - QStringList fieldlist; - /* Iterate through the lines of results. */ - foreach (QString resultline, results) { - fieldlist = resultline.split("\t"); - volumeList.append(fieldlist[0]); - } /* foreach resultline */ - } /* if results from query */ -} - -/* Function to get a list of volumes */ -void Console::getStatusList(QStringList &statusLongList) -{ - QString statusQuery("SELECT JobStatusLong FROM Status"); - if (mainWin->m_sqlDebug) { - Pmsg1(000, "Query cmd : %s\n",statusQuery.toUtf8().data()); - } - QStringList statusResults; - if (sql_cmd(statusQuery, statusResults)) { - QString field; - QStringList fieldlist; - /* Iterate through the lines of results. */ - foreach (QString resultline, statusResults) { - fieldlist = resultline.split("\t"); - statusLongList.append(fieldlist[0]); - } /* foreach resultline */ - } /* if results from statusquery */ -} - /* For suppressing .messages * This may be rendered not needed if the multiple connections feature gets working */ bool Console::hasFocus() diff --git a/bacula/src/qt-console/console/console.h b/bacula/src/qt-console/console/console.h index 5c2b35e9d2..5d86d86c84 100644 --- a/bacula/src/qt-console/console/console.h +++ b/bacula/src/qt-console/console/console.h @@ -111,8 +111,6 @@ public: bool get_job_defaults(int &conn, struct job_defaults &); const QFont get_font(); void beginNewCommand(int conn); - void getVolumeList(QStringList &); - void getStatusList(QStringList &); private: bool get_job_defaults(int &conn, struct job_defaults &, bool donotify); diff --git a/bacula/src/qt-console/jobgraphs/jobplot.cpp b/bacula/src/qt-console/jobgraphs/jobplot.cpp index 10c6a07f06..92a2f1a8af 100644 --- a/bacula/src/qt-console/jobgraphs/jobplot.cpp +++ b/bacula/src/qt-console/jobgraphs/jobplot.cpp @@ -156,7 +156,7 @@ void JobPlot::setupControls() controls->clientComboBox->addItems(m_console->client_list); QStringList volumeList; - m_console->getVolumeList(volumeList); + getVolumeList(volumeList); controls->volumeComboBox->addItem(tr("Any")); controls->volumeComboBox->addItems(volumeList); controls->jobComboBox->addItem(tr("Any")); @@ -169,7 +169,7 @@ void JobPlot::setupControls() controls->fileSetComboBox->addItem(tr("Any")); controls->fileSetComboBox->addItems(m_console->fileset_list); QStringList statusLongList; - m_console->getStatusList(statusLongList); + getStatusList(statusLongList); controls->statusComboBox->addItem(tr("Any")); controls->statusComboBox->addItems(statusLongList); diff --git a/bacula/src/qt-console/joblist/joblist.cpp b/bacula/src/qt-console/joblist/joblist.cpp index 0c9d330250..b523744caa 100644 --- a/bacula/src/qt-console/joblist/joblist.cpp +++ b/bacula/src/qt-console/joblist/joblist.cpp @@ -238,7 +238,7 @@ void JobList::prepareFilterWidgets() comboSel(clientComboBox, m_clientName); QStringList volumeList; - m_console->getVolumeList(volumeList); + getVolumeList(volumeList); volumeComboBox->addItem(tr("Any")); volumeComboBox->addItems(volumeList); comboSel(volumeComboBox, m_mediaName); diff --git a/bacula/src/qt-console/pages.cpp b/bacula/src/qt-console/pages.cpp index 56d237be54..f938eabbb3 100644 --- a/bacula/src/qt-console/pages.cpp +++ b/bacula/src/qt-console/pages.cpp @@ -332,3 +332,41 @@ void Pages::setTreeWidgetItemDockColor() } } } + +/* Function to get a list of volumes */ +void Pages::getVolumeList(QStringList &volumeList) +{ + QString query("SELECT VolumeName AS Media FROM Media ORDER BY Media"); + if (mainWin->m_sqlDebug) { + Pmsg1(000, "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"); + volumeList.append(fieldlist[0]); + } /* foreach resultline */ + } /* if results from query */ +} + +/* Function to get a list of volumes */ +void Pages::getStatusList(QStringList &statusLongList) +{ + QString statusQuery("SELECT JobStatusLong FROM Status"); + if (mainWin->m_sqlDebug) { + Pmsg1(000, "Query cmd : %s\n",statusQuery.toUtf8().data()); + } + QStringList statusResults; + if (m_console->sql_cmd(statusQuery, statusResults)) { + QString field; + QStringList fieldlist; + /* Iterate through the lines of results. */ + foreach (QString resultline, statusResults) { + fieldlist = resultline.split("\t"); + statusLongList.append(fieldlist[0]); + } /* foreach resultline */ + } /* if results from statusquery */ +} diff --git a/bacula/src/qt-console/pages.h b/bacula/src/qt-console/pages.h index feefa046b3..14a409270c 100644 --- a/bacula/src/qt-console/pages.h +++ b/bacula/src/qt-console/pages.h @@ -72,6 +72,8 @@ public: void consoleCommand(QString &); void consoleInput(QString &); QString &name() { return m_name; }; + void getVolumeList(QStringList &); + void getStatusList(QStringList &); public slots: /* closeEvent is a virtual function inherited from QWidget */