From 61b5634b05d8a6e23327604ecb0df1672b7385d9 Mon Sep 17 00:00:00 2001 From: Dirk H Bartley Date: Tue, 3 Mar 2009 00:41:24 +0000 Subject: [PATCH] Use an sql statement to get defaults. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@8497 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/qt-console/relabel/relabel.cpp | 27 +++++++++++++++++++++++ bacula/src/qt-console/relabel/relabel.h | 3 +++ 2 files changed, 30 insertions(+) diff --git a/bacula/src/qt-console/relabel/relabel.cpp b/bacula/src/qt-console/relabel/relabel.cpp index 342ab22c13..1aadbd7d81 100644 --- a/bacula/src/qt-console/relabel/relabel.cpp +++ b/bacula/src/qt-console/relabel/relabel.cpp @@ -53,9 +53,36 @@ relabelDialog::relabelDialog(Console *console, QString &fromVolume) QString fromText(tr("From Volume : ")); fromText += fromVolume; fromLabel->setText(fromText); + QStringList defFields; + if (getDefs(defFields) >= 1) { + poolCombo->setCurrentIndex(poolCombo->findText(defFields[1], Qt::MatchExactly)); + storageCombo->setCurrentIndex(storageCombo->findText(defFields[0], Qt::MatchExactly)); + } this->show(); } +/* + * Use an sql statment to get some defaults + */ +int relabelDialog::getDefs(QStringList &fieldlist) +{ + QString job, client, fileset; + QString query(""); + query = "SELECT mediatype AS MediaType, pool.name AS PoolName" + " FROM media" + " LEFT OUTER JOIN pool ON media.poolid = pool.poolid" + " WHERE volumename = \'" + m_fromVolume + "\'"; + if (mainWin->m_sqlDebug) { Pmsg1(000, "query = %s\n", query.toUtf8().data()); } + QStringList results; + if (m_console->sql_cmd(query, results)) { + QString field; + /* Iterate through the lines of results, there should only be one. */ + foreach (QString resultline, results) { + fieldlist = resultline.split("\t"); + } /* foreach resultline */ + } /* if results from query */ + return results.count(); +} void relabelDialog::accept() { diff --git a/bacula/src/qt-console/relabel/relabel.h b/bacula/src/qt-console/relabel/relabel.h index d314235c4b..28dbe421ba 100644 --- a/bacula/src/qt-console/relabel/relabel.h +++ b/bacula/src/qt-console/relabel/relabel.h @@ -43,6 +43,9 @@ class relabelDialog : public QDialog, public Ui::relabelForm public: relabelDialog(Console *console, QString &fromVolume); +private: + int getDefs(QStringList &fieldlist); + private slots: void accept(); void reject(); -- 2.39.5