]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/qt-console/label/label.cpp
fae53a770a1cc58c7301df96100742bdd3bb6a39
[bacula/bacula] / bacula / src / qt-console / label / label.cpp
1 /*
2    Bacula(R) - The Network Backup Solution
3
4    Copyright (C) 2000-2015 Kern Sibbald
5    Copyright (C) 2007-2011 Free Software Foundation Europe e.V.
6
7    The original author of Bacula is Kern Sibbald, with contributions
8    from many others, a complete list can be found in the file AUTHORS.
9
10    You may use this file and others of this release according to the
11    license defined in the LICENSE file, which includes the Affero General
12    Public License, v3.0 ("AGPLv3") and some additional permissions and
13    terms pursuant to its AGPLv3 Section 7.
14
15    This notice must be preserved when any source code is 
16    conveyed and/or propagated.
17
18    Bacula(R) is a registered trademark of Kern Sibbald.
19 */
20  
21 /*
22  *  Label Page class
23  *
24  *   Kern Sibbald, February MMVII
25  *
26  */ 
27
28 #include "bat.h"
29 #include "label.h"
30 #include <QMessageBox>
31
32 labelPage::labelPage() : Pages()
33 {
34    QString deflt("");
35    m_closeable = false;
36    showPage(deflt);
37 }
38
39 /*
40  * An overload of the constructor to have a default storage show in the
41  * combobox on start.  Used from context sensitive in storage class.
42  */
43 labelPage::labelPage(QString &defString) : Pages()
44 {
45    showPage(defString);
46 }
47
48 /*
49  * moved the constructor code here for the overload.
50  */
51 void labelPage::showPage(QString &defString)
52 {
53    m_name = "Label";
54    pgInitialize();
55    setupUi(this);
56    m_conn = m_console->notifyOff();
57    QTreeWidgetItem* thisitem = mainWin->getFromHash(this);
58    thisitem->setIcon(0,QIcon(QString::fromUtf8(":images/label.png")));
59
60    storageCombo->addItems(m_console->storage_list);
61    int index = storageCombo->findText(defString, Qt::MatchExactly);
62    if (index != -1) {
63       storageCombo->setCurrentIndex(index);
64    }
65    poolCombo->addItems(m_console->pool_list);
66    connect(okButton, SIGNAL(pressed()), this, SLOT(okButtonPushed()));
67    connect(cancelButton, SIGNAL(pressed()), this, SLOT(cancelButtonPushed()));
68    connect(automountOnButton, SIGNAL(pressed()), this, SLOT(automountOnButtonPushed()));
69    connect(automountOffButton, SIGNAL(pressed()), this, SLOT(automountOffButtonPushed()));
70    dockPage();
71    setCurrent();
72    this->show();
73 }
74
75
76 void labelPage::okButtonPushed()
77 {
78    QString scmd;
79    if (volumeName->text().toUtf8().data()[0] == 0) {
80       QMessageBox::warning(this, "No Volume name", "No Volume name given",
81                            QMessageBox::Ok, QMessageBox::Ok);
82       return;
83    }
84    this->hide();
85    scmd = QString("label volume=\"%1\" pool=\"%2\" storage=\"%3\" slot=%4\n")
86                   .arg(volumeName->text())
87                   .arg(poolCombo->currentText())
88                   .arg(storageCombo->currentText()) 
89                   .arg(slotSpin->value());
90    if (mainWin->m_commandDebug) {
91       Pmsg1(000, "sending command : %s\n", scmd.toUtf8().data());
92    }
93    if (m_console) {
94       m_console->write_dir(scmd.toUtf8().data());
95       m_console->displayToPrompt(m_conn);
96       m_console->notify(m_conn, true);
97    } else {
98       Pmsg0(000, "m_console==NULL !!!!!!\n");
99    }
100    closeStackPage();
101    mainWin->resetFocus();
102 }
103
104 void labelPage::cancelButtonPushed()
105 {
106    this->hide();
107    if (m_console) {
108       m_console->notify(m_conn, true);
109    } else {
110       Pmsg0(000, "m_console==NULL !!!!!!\n");
111    }
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 }