]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/qt-console/label/label.cpp
update configure
[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
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() : Pages()
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) : Pages()
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    if (m_console) {
102       m_console->write_dir(scmd.toUtf8().data());
103       m_console->displayToPrompt(m_conn);
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 void labelPage::cancelButtonPushed()
113 {
114    this->hide();
115    if (m_console) {
116       m_console->notify(m_conn, true);
117    } else {
118       Pmsg0(000, "m_console==NULL !!!!!!\n");
119    }
120    closeStackPage();
121    mainWin->resetFocus();
122 }
123
124 /* turn automount on */
125 void labelPage::automountOnButtonPushed()
126 {
127    QString cmd("automount on");
128    consoleCommand(cmd);
129 }
130
131 /* turn automount off */
132 void labelPage::automountOffButtonPushed()
133 {
134    QString cmd("automount off");
135    consoleCommand(cmd);
136 }