2 Bacula® - The Network Backup Solution
4 Copyright (C) 2007-2009 Free Software Foundation Europe e.V.
6 The main author of Bacula is Kern Sibbald, with contributions from
7 many others, a complete list can be found in the file AUTHORS.
8 This program is Free Software; you can redistribute it and/or
9 modify it under the terms of version two of the GNU General Public
10 License as published by the Free Software Foundation and included
13 This program is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23 Bacula® is a registered trademark of Kern Sibbald.
24 The licensor of Bacula is the Free Software Foundation Europe
25 (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
26 Switzerland, email:ftf@fsfeurope.org.
32 * Kern Sibbald, February MMVII
38 #include <QMessageBox>
41 * An overload of the constructor to have a default storage show in the
42 * combobox on start. Used from context sensitive in storage class.
44 relabelDialog::relabelDialog(Console *console, QString &fromVolume)
47 m_fromVolume = fromVolume;
48 m_conn = m_console->notifyOff();
50 storageCombo->addItems(console->storage_list);
51 poolCombo->addItems(console->pool_list);
52 volumeName->setText(fromVolume);
53 QString fromText(tr("From Volume : "));
54 fromText += fromVolume;
55 fromLabel->setText(fromText);
56 QStringList defFields;
57 if (getDefs(defFields) >= 1) {
58 poolCombo->setCurrentIndex(poolCombo->findText(defFields[1], Qt::MatchExactly));
59 storageCombo->setCurrentIndex(storageCombo->findText(defFields[0], Qt::MatchExactly));
65 * Use an sql statment to get some defaults
67 int relabelDialog::getDefs(QStringList &fieldlist)
69 QString job, client, fileset;
71 query = "SELECT MediaType AS MediaType, Pool.Name AS PoolName"
73 " LEFT OUTER JOIN Pool ON Media.PoolId = Pool.PoolId"
74 " WHERE VolumeName = \'" + m_fromVolume + "\'";
75 if (mainWin->m_sqlDebug) { Pmsg1(000, "query = %s\n", query.toUtf8().data()); }
77 if (m_console->sql_cmd(query, results)) {
79 /* Iterate through the lines of results, there should only be one. */
80 foreach (QString resultline, results) {
81 fieldlist = resultline.split("\t");
82 } /* foreach resultline */
83 } /* if results from query */
84 return results.count();
87 void relabelDialog::accept()
90 if (volumeName->text().toUtf8().data()[0] == 0) {
91 QMessageBox::warning(this, tr("No Volume name"), tr("No Volume name given"),
92 QMessageBox::Ok, QMessageBox::Ok);
95 if (m_fromVolume == volumeName->text().toUtf8()) {
96 QMessageBox::warning(this, tr("New name must be different"),
97 tr("New name must be different"),
98 QMessageBox::Ok, QMessageBox::Ok);
103 scmd = QString("relabel storage=\"%1\" oldvolume=\"%2\" volume=\"%3\" pool=\"%4\" slot=%5")
104 .arg(storageCombo->currentText())
106 .arg(volumeName->text())
107 .arg(poolCombo->currentText())
108 .arg(slotSpin->value());
109 if (mainWin->m_commandDebug) {
110 Pmsg1(000, "sending command : %s\n",scmd.toUtf8().data());
112 m_console->write_dir(scmd.toUtf8().data());
113 m_console->displayToPrompt(m_conn);
114 m_console->notify(m_conn, true);
116 mainWin->resetFocus();
119 void relabelDialog::reject()
122 m_console->notify(m_conn, true);
124 mainWin->resetFocus();