]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/qt-console/label/label.cpp
Fix typo in buffer sizes off by factor of 10
[bacula/bacula] / bacula / src / qt-console / label / label.cpp
1 /*
2    Bacula® - The Network Backup Solution
3
4    Copyright (C) 2007-2007 Free Software Foundation Europe e.V.
5
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 three of the GNU Affero General Public
10    License as published by the Free Software Foundation and included
11    in the file LICENSE.
12
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.
17
18    You should have received a copy of the GNU Affero 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
21    02110-1301, USA.
22
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.
27 */
28  
29 /*
30  *  Label Page class
31  *
32  *   Kern Sibbald, February MMVII
33  *
34  */ 
35
36 #include "bat.h"
37 #include "label.h"
38 #include <QMessageBox>
39
40 labelPage::labelPage()
41 {
42    QString deflt("");
43    m_closeable = false;
44    showPage(deflt);
45 }
46
47 /*
48  * An overload of the constructor to have a default storage show in the
49  * combobox on start.  Used from context sensitive in storage class.
50  */
51 labelPage::labelPage(QString &defString)
52 {
53    showPage(defString);
54 }
55
56 /*
57  * moved the constructor code here for the overload.
58  */
59 void labelPage::showPage(QString &defString)
60 {
61    m_name = "Label";
62    pgInitialize();
63    setupUi(this);
64    m_conn = m_console->notifyOff();
65    QTreeWidgetItem* thisitem = mainWin->getFromHash(this);
66    thisitem->setIcon(0,QIcon(QString::fromUtf8(":images/label.png")));
67
68    storageCombo->addItems(m_console->storage_list);
69    int index = storageCombo->findText(defString, Qt::MatchExactly);
70    if (index != -1) {
71       storageCombo->setCurrentIndex(index);
72    }
73    poolCombo->addItems(m_console->pool_list);
74    connect(okButton, SIGNAL(pressed()), this, SLOT(okButtonPushed()));
75    connect(cancelButton, SIGNAL(pressed()), this, SLOT(cancelButtonPushed()));
76    connect(automountOnButton, SIGNAL(pressed()), this, SLOT(automountOnButtonPushed()));
77    connect(automountOffButton, SIGNAL(pressed()), this, SLOT(automountOffButtonPushed()));
78    dockPage();
79    setCurrent();
80    this->show();
81 }
82
83
84 void labelPage::okButtonPushed()
85 {
86    QString scmd;
87    if (volumeName->text().toUtf8().data()[0] == 0) {
88       QMessageBox::warning(this, "No Volume name", "No Volume name given",
89                            QMessageBox::Ok, QMessageBox::Ok);
90       return;
91    }
92    this->hide();
93    scmd = QString("label volume=\"%1\" pool=\"%2\" storage=\"%3\" slot=%4\n")
94                   .arg(volumeName->text())
95                   .arg(poolCombo->currentText())
96                   .arg(storageCombo->currentText()) 
97                   .arg(slotSpin->value());
98    if (mainWin->m_commandDebug) {
99       Pmsg1(000, "sending command : %s\n",scmd.toUtf8().data());
100    }
101    m_console->write_dir(scmd.toUtf8().data());
102    m_console->displayToPrompt(m_conn);
103    m_console->notify(m_conn, true);
104    closeStackPage();
105    mainWin->resetFocus();
106 }
107
108 void labelPage::cancelButtonPushed()
109 {
110    this->hide();
111    m_console->notify(m_conn, true);
112    closeStackPage();
113    mainWin->resetFocus();
114 }
115
116 /* turn automount on */
117 void labelPage::automountOnButtonPushed()
118 {
119    QString cmd("automount on");
120    consoleCommand(cmd);
121 }
122
123 /* turn automount off */
124 void labelPage::automountOffButtonPushed()
125 {
126    QString cmd("automount off");
127    consoleCommand(cmd);
128 }