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 many
7 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 Bacula® is a registered trademark of Kern Sibbald.
20 * Kern Sibbald, February MMVII
26 #include <QMessageBox>
29 * An overload of the constructor to have a default storage show in the
30 * combobox on start. Used from context sensitive in storage class.
32 relabelDialog::relabelDialog(Console *console, QString &fromVolume)
35 m_fromVolume = fromVolume;
36 m_conn = m_console->notifyOff();
38 storageCombo->addItems(console->storage_list);
39 poolCombo->addItems(console->pool_list);
40 volumeName->setText(fromVolume);
41 QString fromText(tr("From Volume : "));
42 fromText += fromVolume;
43 fromLabel->setText(fromText);
44 QStringList defFields;
45 if (getDefs(defFields) >= 1) {
46 poolCombo->setCurrentIndex(poolCombo->findText(defFields[1], Qt::MatchExactly));
47 storageCombo->setCurrentIndex(storageCombo->findText(defFields[0], Qt::MatchExactly));
53 * Use an sql statment to get some defaults
55 int relabelDialog::getDefs(QStringList &fieldlist)
57 QString job, client, fileset;
59 query = "SELECT MediaType AS MediaType, Pool.Name AS PoolName"
61 " LEFT OUTER JOIN Pool ON Media.PoolId = Pool.PoolId"
62 " WHERE VolumeName = \'" + m_fromVolume + "\'";
63 if (mainWin->m_sqlDebug) { Pmsg1(000, "query = %s\n", query.toUtf8().data()); }
65 if (m_console->sql_cmd(query, results)) {
67 /* Iterate through the lines of results, there should only be one. */
68 foreach (QString resultline, results) {
69 fieldlist = resultline.split("\t");
70 } /* foreach resultline */
71 } /* if results from query */
72 return results.count();
75 void relabelDialog::accept()
78 if (volumeName->text().toUtf8().data()[0] == 0) {
79 QMessageBox::warning(this, tr("No Volume name"), tr("No Volume name given"),
80 QMessageBox::Ok, QMessageBox::Ok);
83 if (m_fromVolume == volumeName->text().toUtf8()) {
84 QMessageBox::warning(this, tr("New name must be different"),
85 tr("New name must be different"),
86 QMessageBox::Ok, QMessageBox::Ok);
91 scmd = QString("relabel storage=\"%1\" oldvolume=\"%2\" volume=\"%3\" pool=\"%4\" slot=%5")
92 .arg(storageCombo->currentText())
94 .arg(volumeName->text())
95 .arg(poolCombo->currentText())
96 .arg(slotSpin->value());
97 if (mainWin->m_commandDebug) {
98 Pmsg1(000, "sending command : %s\n",scmd.toUtf8().data());
100 m_console->write_dir(scmd.toUtf8().data());
101 m_console->displayToPrompt(m_conn);
102 m_console->notify(m_conn, true);
104 mainWin->resetFocus();
107 void relabelDialog::reject()
110 m_console->notify(m_conn, true);
112 mainWin->resetFocus();