2 Bacula(R) - The Network Backup Solution
4 Copyright (C) 2000-2016 Kern Sibbald
6 The original author of Bacula is Kern Sibbald, with contributions
7 from many others, a complete list can be found in the file AUTHORS.
9 You may use this file and others of this release according to the
10 license defined in the LICENSE file, which includes the Affero General
11 Public License, v3.0 ("AGPLv3") and some additional permissions and
12 terms pursuant to its AGPLv3 Section 7.
14 This notice must be preserved when any source code is
15 conveyed and/or propagated.
17 Bacula(R) is a registered trademark of Kern Sibbald.
23 * Kern Sibbald, February MMVII
29 #include <QMessageBox>
32 * An overload of the constructor to have a default storage show in the
33 * combobox on start. Used from context sensitive in storage class.
35 relabelDialog::relabelDialog(Console *console, QString &fromVolume)
38 m_fromVolume = fromVolume;
39 m_conn = m_console->notifyOff();
41 storageCombo->addItems(console->storage_list);
42 poolCombo->addItems(console->pool_list);
43 volumeName->setText(fromVolume);
44 QString fromText(tr("From Volume : "));
45 fromText += fromVolume;
46 fromLabel->setText(fromText);
47 QStringList defFields;
48 if (getDefs(defFields) >= 1) {
49 poolCombo->setCurrentIndex(poolCombo->findText(defFields[1], Qt::MatchExactly));
50 storageCombo->setCurrentIndex(storageCombo->findText(defFields[0], Qt::MatchExactly));
56 * Use an sql statment to get some defaults
58 int relabelDialog::getDefs(QStringList &fieldlist)
60 QString job, client, fileset;
62 query = "SELECT MediaType AS MediaType, Pool.Name AS PoolName"
64 " LEFT OUTER JOIN Pool ON Media.PoolId = Pool.PoolId"
65 " WHERE VolumeName = \'" + m_fromVolume + "\'";
66 if (mainWin->m_sqlDebug) { Pmsg1(000, "query = %s\n", query.toUtf8().data()); }
68 if (m_console->sql_cmd(query, results)) {
70 /* Iterate through the lines of results, there should only be one. */
71 foreach (QString resultline, results) {
72 fieldlist = resultline.split("\t");
73 } /* foreach resultline */
74 } /* if results from query */
75 return results.count();
78 void relabelDialog::accept()
81 if (volumeName->text().toUtf8().data()[0] == 0) {
82 QMessageBox::warning(this, tr("No Volume name"), tr("No Volume name given"),
83 QMessageBox::Ok, QMessageBox::Ok);
86 if (m_fromVolume == volumeName->text().toUtf8()) {
87 QMessageBox::warning(this, tr("New name must be different"),
88 tr("New name must be different"),
89 QMessageBox::Ok, QMessageBox::Ok);
94 scmd = QString("relabel storage=\"%1\" oldvolume=\"%2\" volume=\"%3\" pool=\"%4\" slot=%5")
95 .arg(storageCombo->currentText())
97 .arg(volumeName->text())
98 .arg(poolCombo->currentText())
99 .arg(slotSpin->value());
100 if (mainWin->m_commandDebug) {
101 Pmsg1(000, "sending command : %s\n",scmd.toUtf8().data());
103 m_console->write_dir(scmd.toUtf8().data());
104 m_console->displayToPrompt(m_conn);
105 m_console->notify(m_conn, true);
107 mainWin->resetFocus();
110 void relabelDialog::reject()
113 m_console->notify(m_conn, true);
115 mainWin->resetFocus();