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